Add javascript autoloading
the js/modules/%modulename%/%file% is now mapped to the module path (if existing). To prevent name clashing, the modules folder has been renamed to components.
This commit is contained in:
parent
04511121b1
commit
6881c8d074
|
@ -9,6 +9,7 @@ use Icinga\Web\ActionController;
|
|||
use Icinga\Application\Icinga;
|
||||
use Zend_Controller_Action_Exception as ActionException;
|
||||
|
||||
use Icinga\Application\Benchmark;
|
||||
/**
|
||||
* Class StaticController
|
||||
* @package Icinga\Web\Form
|
||||
|
@ -69,7 +70,7 @@ class StaticController extends ActionController
|
|||
*/
|
||||
public function javascriptAction()
|
||||
{
|
||||
$module = $this->_getParam('moduleName');
|
||||
$module = $this->_getParam('module_name');
|
||||
$file = $this->_getParam('file');
|
||||
$basedir = Icinga::app()->getModule($module)->getBaseDir();
|
||||
|
||||
|
@ -96,15 +97,16 @@ class StaticController extends ActionController
|
|||
) . ' GMT'
|
||||
);
|
||||
|
||||
$hash = md5_file($filePath);
|
||||
|
||||
if ($hash === $this->getRequest()->getHeader('If-None-Match')) {
|
||||
$response->setHttpResponseCode(304);
|
||||
return;
|
||||
} else {
|
||||
readfile($filePath);
|
||||
}
|
||||
// TODO: get rid of exit:
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -60,6 +60,17 @@ class Web extends ApplicationBootstrap
|
|||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->frontController->getRouter()->addRoute(
|
||||
'module_javascript',
|
||||
new Route(
|
||||
'js/modules/:module_name/:file',
|
||||
array(
|
||||
'controller' => 'static',
|
||||
'action' => 'javascript'
|
||||
)
|
||||
)
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -173,6 +184,7 @@ class Web extends ApplicationBootstrap
|
|||
*/
|
||||
protected function configurePagination()
|
||||
{
|
||||
|
||||
Paginator::addScrollingStylePrefixPath(
|
||||
'Icinga_Web_Paginator_ScrollingStyle',
|
||||
'Icinga/Web/Paginator/ScrollingStyle'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
var containerMgrInstance = null;
|
||||
var async;
|
||||
|
||||
var ContainerMgr = function($,log,Widgets,SubTable,holder) {
|
||||
var ContainerMgr = function($,log,Widgets,SubTable) {
|
||||
|
||||
|
||||
var enhanceDetachLinks = function() {
|
||||
|
@ -34,14 +34,12 @@
|
|||
}
|
||||
target.focus();
|
||||
this.initializeContainers(target);
|
||||
holder.run();
|
||||
};
|
||||
|
||||
this.updateControlTargets = function(ctrl, req) {
|
||||
$('a',ctrl).each(function() {
|
||||
$(this).attr("href",req.url);
|
||||
});
|
||||
holder.run();
|
||||
};
|
||||
|
||||
this.initControlBehaviour = function(root) {
|
||||
|
@ -86,7 +84,6 @@
|
|||
this.initExpandables(root);
|
||||
this.drawImplicitWidgets(root);
|
||||
this.loadAsyncContainers(root);
|
||||
holder.run();
|
||||
};
|
||||
|
||||
this.createPopupContainer = function(content,req) {
|
||||
|
@ -96,7 +93,6 @@
|
|||
.append($("<div>").addClass('modal-body').html(content)).appendTo(document.body);
|
||||
|
||||
closeButton.on("click",function() {container.remove();});
|
||||
holder.run();
|
||||
};
|
||||
|
||||
this.getContainer = function(id) {
|
||||
|
@ -107,9 +103,9 @@
|
|||
};
|
||||
|
||||
};
|
||||
define(['jquery','logging','icinga/widgets/checkIcons','icinga/widgets/subTable','Holder'],function($,log,widgets,subTable,holder) {
|
||||
define(['jquery','logging','icinga/widgets/checkIcons','icinga/widgets/subTable'],function($,log,widgets,subTable) {
|
||||
if (containerMgrInstance === null) {
|
||||
containerMgrInstance = new ContainerMgr($,log,widgets,subTable,holder);
|
||||
containerMgrInstance = new ContainerMgr($,log,widgets,subTable);
|
||||
}
|
||||
return containerMgrInstance;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ define([
|
|||
* Icinga prototype
|
||||
*/
|
||||
var Icinga = function() {
|
||||
var internalModules = ['icinga/modules/actionTable','icinga/modules/mainDetail'];
|
||||
var internalModules = ['icinga/components/actionTable','icinga/components/mainDetail'];
|
||||
|
||||
this.modules = {};
|
||||
var failedModules = [];
|
||||
|
@ -37,7 +37,7 @@ define([
|
|||
};
|
||||
|
||||
var loadModuleScript = function(name) {
|
||||
moduleMgr.enableModule("modules/"+name, function(error) {
|
||||
moduleMgr.enableModule("modules/"+name+"/"+name, function(error) {
|
||||
failedModules.push({
|
||||
name: name,
|
||||
errorMessage: error
|
||||
|
|
Loading…
Reference in New Issue