mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
[WIP] Allow modules to register *framework* params
I'm not yet convinced about this solution. The name *framework parameter* isn't always correct. (i.e. page) Then there's also an alternative available by using the `rel` attribute of anchors with a custom value. If it's set our JS preserves (or doesn't) the `_dashlet` param. It cannot do that for every url that's loaded into the same container. (e.g. stat badges in the footer of lists)
This commit is contained in:
parent
fae7531879
commit
efcd14ce0a
@ -207,6 +207,9 @@ class Module
|
||||
*/
|
||||
protected $routes = array();
|
||||
|
||||
/** @var string[] Framework parameters of this module */
|
||||
protected $frameworkParams = [];
|
||||
|
||||
/**
|
||||
* A set of menu elements
|
||||
*
|
||||
@ -283,6 +286,18 @@ class Module
|
||||
$this->translationDomain = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this module's framework parameters
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFrameworkParams(): array
|
||||
{
|
||||
$this->launchConfigScript();
|
||||
|
||||
return $this->frameworkParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a search URL
|
||||
*
|
||||
@ -1461,4 +1476,18 @@ class Module
|
||||
$this->routes[$name] = $route;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register URL parameters which should be ignored by various URL handlers
|
||||
*
|
||||
* @param string ...$params
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function addFrameworkParams(string ...$params): self
|
||||
{
|
||||
$this->frameworkParams = array_merge($this->frameworkParams, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,33 @@ class Web extends EmbeddedWeb
|
||||
return array_combine($themes, $themes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default framework parameters and those of the current module
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFrameworkParams(): array
|
||||
{
|
||||
$defaultParams = [
|
||||
'isIframe',
|
||||
'showFullscreen',
|
||||
'showCompact',
|
||||
'renderLayout',
|
||||
'_disableLayout',
|
||||
'_dashlet',
|
||||
'_dev',
|
||||
// TODO: is this really a "framework" param? or should the all be called differently, widgetyUrlFlags perhaps?
|
||||
'page'
|
||||
];
|
||||
|
||||
$moduleParams = [];
|
||||
if (($moduleName = $this->getRequest()->getModuleName()) !== 'default') {
|
||||
$moduleParams = $this->getModuleManager()->getModule($moduleName)->getFrameworkParams();
|
||||
}
|
||||
|
||||
return array_merge($defaultParams, $moduleParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare routing
|
||||
*
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Data\Filterable;
|
||||
use Icinga\Data\Sortable;
|
||||
use Icinga\Data\QueryInterface;
|
||||
@ -234,16 +235,17 @@ class Controller extends ModuleActionController
|
||||
'limit', // setupPaginationControl()
|
||||
'sort', // setupSortControl()
|
||||
'dir', // setupSortControl()
|
||||
'backend', // Framework
|
||||
'showCompact', // Framework
|
||||
'_dev' // Framework
|
||||
);
|
||||
|
||||
$editor = Widget::create('filterEditor');
|
||||
/** @var \Icinga\Web\Widget\FilterEditor $editor */
|
||||
call_user_func_array(
|
||||
array($editor, 'preserveParams'),
|
||||
array_merge($defaultPreservedParams, $preserveParams ?: array())
|
||||
array_merge(
|
||||
Icinga::app()->getFrameworkParams(),
|
||||
$defaultPreservedParams,
|
||||
$preserveParams ?: array()
|
||||
)
|
||||
);
|
||||
|
||||
$editor
|
||||
|
@ -729,7 +729,6 @@ class ListController extends Controller
|
||||
protected function filterQuery(DataView $dataView)
|
||||
{
|
||||
$this->setupFilterControl($dataView, null, null, array(
|
||||
'format', // handleFormatRequest()
|
||||
'stateType', // hostsAction() and servicesAction()
|
||||
'addColumns', // addColumns()
|
||||
'problems', // servicegridAction()
|
||||
|
@ -120,6 +120,8 @@ $this->provideSearchUrl($this->translate('Services'), 'monitoring/list/services?
|
||||
$this->provideSearchUrl($this->translate('Hostgroups'), 'monitoring/list/hostgroups?limit=10', 97);
|
||||
$this->provideSearchUrl($this->translate('Servicegroups'), 'monitoring/list/servicegroups?limit=10', 96);
|
||||
|
||||
$this->addFrameworkParams('backend', 'format');
|
||||
|
||||
/*
|
||||
* Available navigation items
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user