Skip to content

Commit

Permalink
Finally an update to the app manager
Browse files Browse the repository at this point in the history
  • Loading branch information
tschallacka committed Aug 19, 2019
1 parent 1523714 commit 6d31557
Show file tree
Hide file tree
Showing 20 changed files with 1,199 additions and 454 deletions.
265 changes: 225 additions & 40 deletions applications/ApplicationBase.php

Large diffs are not rendered by default.

87 changes: 47 additions & 40 deletions applications/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private function getAppContainer($app) {
$app->render().
'</div>';
}

private function addApplication($appClass,$name) {
$app = new $appClass($this);
if($app instanceof ApplicationBase) {
Expand All @@ -33,28 +34,48 @@ private function addApplication($appClass,$name) {
dd($this);
}
$app->bindToController();
$app->preInit();
return $app->getApplicationID();
}
}
public function getApplication($appId) {
if(array_key_exists($appId, $this->applications)) {
return $this->applications[$appId];
}
return null;
}

public function renderApp($appId) {
if($app = $this->getApplication($appId)) {
return $this->getAppContainer($app);
}
return '';
}

public function getRegisteredAppsList() {
return collect(array_keys($this->applications));
}

public function registerApplication($appName,$name=null) {
if(is_null($name)) {
$name = $appName;
}
if(class_exists($appName)) {
$this->addApplication($appName,$name);
return $this->addApplication($appName,$name);
}
else {
$appSpace = 'Applications';
$app = implode('\\',['', $appSpace,$appName,$appName]);
if(class_exists($app)) {
$this->addApplication($app,$name);
return $this->addApplication($app,$name);
}
else {
$reflector = new ReflectionClass(get_class($this)); // class Foo of namespace A
$namespace = $reflector->getNamespaceName();
$pluginspace = substr($namespace,0,strpos($namespace,'\\Controller') );
$app = implode('\\',['',$pluginspace,$appSpace,$appName,$appName]);
if(class_exists($app)) {
$this->addApplication($app,$name);
return $this->addApplication($app,$name);
}
else {
throw new ApplicationException('Cannot find application '.$appName . '
Expand All @@ -73,40 +94,25 @@ public function renderApps() {

return $str;
}

/**
* Creates a form and binds it to the controller
* @param $config
* @return \Backend\Widgets\Form
*/
public function createApplicationForm($config) {

/*
* Form Widget with extensibility
*/
$this->formWidget = $this->makeWidget('Backend\Widgets\Form', $config);

$this->formWidget->bindEvent('form.extendFieldsBefore', function () {
$this->controller->formExtendFieldsBefore($this->formWidget);
});

$this->formWidget->bindEvent('form.extendFields', function ($fields) {
$this->controller->formExtendFields($this->formWidget, $fields);
});

$this->formWidget->bindEvent('form.beforeRefresh', function ($saveData) {
return $this->controller->formExtendRefreshData($this->formWidget, $saveData);
});

$this->formWidget->bindEvent('form.refreshFields', function ($fields) {
return $this->controller->formExtendRefreshFields($this->formWidget, $fields);
});

$this->formWidget->bindEvent('form.refresh', function ($result) {
return $this->controller->formExtendRefreshResults($this->formWidget, $result);
});

$this->formWidget->bindToController();
$formWidget = $this->makeWidget('Backend\Widgets\Form', $config);


$formWidget->bindToController();
/*
* Detected Relation controller behavior
*/
if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController')) {
$this->controller->initRelation($config->model);
}

return $formWidget;
}

public function loadApplicationAssets() {
Expand All @@ -133,16 +139,17 @@ public function getUrlBase($url='') {

public function loadAssets()
{
$this->addCss($this->getUrlBase('assets/css/metro.css'), 'ExitControl.Desktop');
$this->addCss($this->getUrlBase('assets/css/metro-icons.css'), 'ExitControl.Desktop');
$this->addCss($this->getUrlBase('assets/css/application.css'), 'ExitControl.Desktop');

$this->addJs($this->getUrlBase('assets/js/metro.js'), 'ExitControl.Desktop');
$this->addJs($this->getUrlBase('assets/js/application.js'), 'ExitControl.Desktop');
$this->addJs($this->getUrlBase('assets/js/listsearchelement.js'), 'ExitControl.Desktop');
$this->addJs($this->getUrlBase('assets/js/linkopenclick.js'), 'ExitControl.Desktop');
$this->addJs($this->getUrlBase('assets/js/apppopup.js'), 'ExitControl.Desktop');
$this->addJs($this->getUrlBase('assets/js/draggable.js'), 'ExitControl.Desktop');
$this->addCss($this->getUrlBase('assets/css/metro.css'), 'Util.Desktop');
$this->addCss($this->getUrlBase('assets/css/metro-icons.css'), 'Util.Desktop');
$this->addCss($this->getUrlBase('assets/css/application.css'), 'Util.Desktop');

$this->addJs($this->getUrlBase('assets/js/metro.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/application.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/listsearchelement.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/linkopenclick.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/apppopup.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/draggable.js'), 'Util.Desktop');
$this->addJs($this->getUrlBase('assets/js/panelopenclick.js'), 'Util.Desktop');

}

Expand Down
26 changes: 20 additions & 6 deletions applications/assets/css/application.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.logcontainer .logcontents{
position:relative;
overflow:hidden;
Expand Down Expand Up @@ -40,20 +41,33 @@
}
[data-drag-handle] {
cursor: default;
}
}
.size-widthsixhundered {
width: 600px;
}
@media (min-width: 768px) {

.modal-dialog.dragging {
width: 600px;
/*width: 600px;*/
margin: 0px 0px 0px 0px;
}
}

.metro-popup-content {
pointer-events: all;
pointer-events: auto;
border : 2px outset #eee;
background-color:white;
}

.no-pointer-events {
pointer-events:none;
}
.metro-control {
pointer-events: none !important;
}
/*pointer-events: none !important;*/
}
.control-popup.modal.metro-control {
background:none;
}
.control-popup.modal.metro-control > .modal-dialog {
background: none;

}
2 changes: 1 addition & 1 deletion applications/assets/css/metro.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ html,
body {
padding: 0;
margin: 0;
height: 100%;

}
html,
body,
Expand Down
159 changes: 133 additions & 26 deletions applications/assets/js/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
(function($){
var timeouts = [];

var latency = 300;
var scrollActive = false;

var clearTimeouts = function() {
for(var c=0;c<timeouts.length;c++) {
window.clearTimeout(timeouts[c]);
}
timeouts = [];
}

var scrollEnd = function($elem) {
if(scrollActive) {
clearTimeouts();
scrollActive = false;
$elem.trigger('scroll:end');
}
}
$(window).on('shown.bs.modal',function() {
$fixed = $('.modal').filter(function() {
var $this = $(this);
return $this.css("position") === 'fixed' && $this.data('scroll-trigger-activated') !== true;
});

$fixed.each(function(index,elem) {
var $elem = $(elem);
$elem.data('scroll-trigger-activated',true);
$elem.on('scroll',function(e) {
$(window).trigger(e);
})
});
});

$(window).scroll(function(e) {
clearTimeouts();
var $elem = $(e.target);
timeouts.push(window.setTimeout(
function() {
scrollEnd($elem);
},
latency));
if(!scrollActive) {
scrollActive = true;
$elem.trigger('scroll:start');
}
});

})(jQuery);

(function($) {

$(window).on('mousemove',function(e) {
var $elem = $(document.elementFromPoint(e.clientX,e.clientY));
if($elem.closest('.modal-content').length == 0 && e.clientX < window.innerWidth-100) {
$('.modal').addClass('no-pointer-events');
}
else {
var $modal = $elem.closest('.modal');
if($modal.hasClass('no-pointer-events')) {
$modal.removeClass('no-pointer-events');
}
}

});
})(jQuery);

/**
* Manages the Z index ordering of application windows.
* @param $
*/
(function($){

var Z = 1050;

var $document = $(document);

$document.off('focusin.bs.modal');
$document.on('shown.bs.modal',function(e) {
$(e.target).trigger('click');
});
$document.on('click','.modal',function(e) {
var $target = $(e.currentTarget);
$document.off('focusin.bs.modal')
if($target.data('current-z-index') != Z) {
Z++;

if(Z > 1080) {
/**
* Resetting order to 1050 to prevent other css issues.
* Gather all te modals, sort them to current order
* set Z index starting from 1050 on each of em.
*/
Z=1050;
$result = $('.modal').sort(function(a,b) {
var $a = $(a).data('current-z-index');
var $b = $(b).data('current-z-index');
if($a == $b) {
return 0;
}
return $a - $b;
});
$result.each(function(i,e) {

var $mod = $(e);
$mod.data('current-z-index', Z);
$mod.css({'z-index': Z});
Z++;

});

}
$target.data('current-z-index', Z);
$target.css({'z-index': Z});
}

})
}(jQuery))

+function ($) { "use strict";
var appName = 'MasterApplicationControl';

Expand Down Expand Up @@ -25,7 +145,9 @@
* Find the closest originating event caster(in case event originated from child element
*/
var $this = $(e.target).closest('[data-apprequest]');

if($this.length == 0) {
return;
}
/**
* Prepare data object
*/
Expand All @@ -50,12 +172,14 @@
}

var success = $this.data('apprequest-success');

if(success) {
eval('data.success = function(data,status,xhr){'+success+'}');
}
else {
data.success = function(data) {console.log(data);};
data.success = new Function('data', 'status', 'xhr', success);
//eval('data.success = function(data,status,xhr){'+success+'}');
}
//else {
//data.success = function(data) {console.log(data);};
//}

var update = $this.data('apprequest-update');
if(update) {
Expand Down Expand Up @@ -84,7 +208,8 @@

var complete = $this.data('apprequest-complete');
if(complete) {
eval('data.complete = function(context,textStatus,xhr){'+complete+'}');
data.complete = new Function('context','textStatus', 'xhr', complete);
//eval('data.complete = function(context,textStatus,xhr){'+complete+'}');
}

/**
Expand Down Expand Up @@ -148,25 +273,7 @@
$.request('onAppRequest', sendobject);
}

/**
* Open a popup model with an app :-)
*/
$.fn.appPopup = $.appPopup = function(appid,request,data) {

var sendobject = {
handler:'onAppRequest',
extraData:{
appid:appid,
request:request,
}
};

sendobject.extraData.data = data;

$.popup(sendobject);

}



$.getAppId = $.fn.getAppId = function() {
return this.closest('[data-appid]').data('appid');
Expand Down Expand Up @@ -212,4 +319,4 @@

})

}(window.jQuery);
}(window.jQuery);
Loading

0 comments on commit 6d31557

Please sign in to comment.