Revert "Fixes unaccepted behavior in module configuration"
This reverts commit 236d384bab
.
This commit is contained in:
parent
a47c376fb3
commit
bb0e1dc105
|
@ -177,7 +177,6 @@ class Module
|
|||
/**
|
||||
* Add a pane to dashboard
|
||||
*
|
||||
* @param $id
|
||||
* @param $name
|
||||
* @return Pane
|
||||
*/
|
||||
|
@ -201,21 +200,19 @@ class Module
|
|||
/**
|
||||
* Add a menu Section to the Sidebar menu
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $name
|
||||
* @param $name
|
||||
* @param array $properties
|
||||
* @return mixed
|
||||
*/
|
||||
protected function menuSection($id, $name, array $properties = array())
|
||||
protected function menuSection($name, array $properties = array())
|
||||
{
|
||||
if (array_key_exists($id, $this->menuItems)) {
|
||||
$this->menuItems[$id]->setProperties($properties);
|
||||
if (array_key_exists($name, $this->menuItems)) {
|
||||
$this->menuItems[$name]->setProperties($properties);
|
||||
} else {
|
||||
$this->menuItems[$id] = new Menu($id, new Zend_Config($properties));
|
||||
$this->menuItems[$id]->setTitle($name);
|
||||
$this->menuItems[$name] = new Menu($name, new Zend_Config($properties));
|
||||
}
|
||||
|
||||
return $this->menuItems[$id];
|
||||
return $this->menuItems[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
namespace Icinga\Web;
|
||||
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Logger\Logger;
|
||||
use Zend_Config;
|
||||
use RecursiveIterator;
|
||||
use Icinga\Application\Config;
|
||||
|
@ -173,34 +172,34 @@ class Menu implements RecursiveIterator
|
|||
*/
|
||||
protected function addMainMenuItems()
|
||||
{
|
||||
$this->add('dashboard', t('Dashboard'), array(
|
||||
$this->add(t('Dashboard'), array(
|
||||
'url' => 'dashboard',
|
||||
'icon' => 'img/icons/dashboard.png',
|
||||
'priority' => 10
|
||||
));
|
||||
|
||||
$section = $this->add('system', t('System'), array(
|
||||
$section = $this->add(t('System'), array(
|
||||
'icon' => 'img/icons/configuration.png',
|
||||
'priority' => 200
|
||||
));
|
||||
$section->add('preferences', t('Preferences'), array(
|
||||
$section->add(t('Preferences'), array(
|
||||
'url' => 'preference',
|
||||
'priority' => 200
|
||||
));
|
||||
$section->add('configuration', t('Configuration'), array(
|
||||
$section->add(t('Configuration'), array(
|
||||
'url' => 'config',
|
||||
'priority' => 300
|
||||
));
|
||||
$section->add('modules', t('Modules'), array(
|
||||
$section->add(t('Modules'), array(
|
||||
'url' => 'config/modules',
|
||||
'priority' => 400
|
||||
));
|
||||
$section->add('applicationlog', t('ApplicationLog'), array(
|
||||
$section->add(t('ApplicationLog'), array(
|
||||
'url' => 'list/applicationlog',
|
||||
'priority' => 500
|
||||
));
|
||||
|
||||
$this->add('logout', t('Logout'), array(
|
||||
$this->add(t('Logout'), array(
|
||||
'url' => 'authentication/logout',
|
||||
'icon' => 'img/icons/logout.png',
|
||||
'priority' => 300
|
||||
|
@ -428,10 +427,9 @@ class Menu implements RecursiveIterator
|
|||
* @param array $config
|
||||
* @return Menu
|
||||
*/
|
||||
public function add($id, $name, $config = array())
|
||||
public function add($name, $config = array())
|
||||
{
|
||||
$config['title'] = $name;
|
||||
return $this->addSubMenu($id, new Zend_Config($config));
|
||||
return $this->addSubMenu($name, new Zend_Config($config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,13 +30,6 @@ class Component extends AbstractWidget
|
|||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* The id of this Component
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* The title being displayed on top of the component
|
||||
* @var
|
||||
|
@ -67,14 +60,12 @@ EOD;
|
|||
/**
|
||||
* Create a new component displaying the given url in the provided pane
|
||||
*
|
||||
* @param string $id The id to use for this component
|
||||
* @param string $title The title to use for this component
|
||||
* @param Url|string $url The url this component uses for displaying information
|
||||
* @param Pane $pane The pane this Component will be added to
|
||||
*/
|
||||
public function __construct($id, $title, $url, Pane $pane)
|
||||
public function __construct($title, $url, Pane $pane)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->title = $title;
|
||||
$this->pane = $pane;
|
||||
if ($url instanceof Url) {
|
||||
|
@ -195,14 +186,14 @@ EOD;
|
|||
|
||||
/**
|
||||
* Create a @see Component instance from the given Zend config, using the provided title
|
||||
* @param $id The id for this component
|
||||
*
|
||||
* @param $title The title for this component
|
||||
* @param Zend_Config $config The configuration defining url, parameters, height, width, etc.
|
||||
* @param Pane $pane The pane this component belongs to
|
||||
*
|
||||
* @return Component A newly created Component for use in the Dashboard
|
||||
*/
|
||||
public static function fromIni($id, $title, Zend_Config $config, Pane $pane)
|
||||
public static function fromIni($title, Zend_Config $config, Pane $pane)
|
||||
{
|
||||
$height = null;
|
||||
$width = null;
|
||||
|
@ -210,27 +201,7 @@ EOD;
|
|||
$parameters = $config->toArray();
|
||||
unset($parameters['url']); // otherwise there's an url = parameter in the Url
|
||||
|
||||
$cmp = new Component($id, $title, Url::fromPath($url, $parameters), $pane);
|
||||
$cmp = new Component($title, Url::fromPath($url, $parameters), $pane);
|
||||
return $cmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the components id
|
||||
*
|
||||
* @param $id string
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the components id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,44 +83,44 @@ class Pane extends AbstractWidget
|
|||
/**
|
||||
* Return true if a component with the given title exists in this pane
|
||||
*
|
||||
* @param string $id The id of the component to check for existence
|
||||
* @param string $title The title of the component to check for existence
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasComponent($id)
|
||||
public function hasComponent($title)
|
||||
{
|
||||
return array_key_exists($id, $this->components);
|
||||
return array_key_exists($title, $this->components);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a component with the given name if existing
|
||||
*
|
||||
* @param string $id The id of the component to return
|
||||
* @param string $title The title of the component to return
|
||||
*
|
||||
* @return Component The component with the given title
|
||||
* @throws ProgrammingError If the component doesn't exist
|
||||
*/
|
||||
public function getComponent($id)
|
||||
public function getComponent($title)
|
||||
{
|
||||
if ($this->hasComponent($id)) {
|
||||
return $this->components[$id];
|
||||
if ($this->hasComponent($title)) {
|
||||
return $this->components[$title];
|
||||
}
|
||||
throw new ProgrammingError(
|
||||
'Trying to access invalid component: %s',
|
||||
$id
|
||||
$title
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the component with the given id if it exists in this pane
|
||||
* Removes the component with the given title if it exists in this pane
|
||||
*
|
||||
* @param string $id The pane
|
||||
* @param string $title The pane
|
||||
* @return Pane $this
|
||||
*/
|
||||
public function removeComponent($id)
|
||||
public function removeComponent($title)
|
||||
{
|
||||
if ($this->hasComponent($id)) {
|
||||
unset($this->components[$id]);
|
||||
if ($this->hasComponent($title)) {
|
||||
unset($this->components[$title]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
@ -146,7 +146,6 @@ class Pane extends AbstractWidget
|
|||
/**
|
||||
* Add a component to this pane, optionally creating it if $component is a string
|
||||
*
|
||||
* @param string $id An unique Identifier
|
||||
* @param string|Component $component The component object or title
|
||||
* (if a new component will be created)
|
||||
* @param string|null $url An Url to be used when component is a string
|
||||
|
@ -154,12 +153,12 @@ class Pane extends AbstractWidget
|
|||
* @return self
|
||||
* @throws \Icinga\Exception\ConfigurationError
|
||||
*/
|
||||
public function addComponent($id, $component, $url = null)
|
||||
public function addComponent($component, $url = null)
|
||||
{
|
||||
if ($component instanceof Component) {
|
||||
$this->components[$component->getId()] = $component;
|
||||
} elseif (is_string($id) && is_string($component) && $url !== null) {
|
||||
$this->components[$id] = new Component($id, $component, $url, $this);
|
||||
$this->components[$component->getTitle()] = $component;
|
||||
} elseif (is_string($component) && $url !== null) {
|
||||
$this->components[$component] = new Component($component, $url, $this);
|
||||
} else {
|
||||
throw new ConfigurationError('Invalid component added: %s', $component);
|
||||
}
|
||||
|
@ -176,15 +175,15 @@ class Pane extends AbstractWidget
|
|||
{
|
||||
/* @var $component Component */
|
||||
foreach ($components as $component) {
|
||||
if (array_key_exists($component->getId(), $this->components)) {
|
||||
if (preg_match('/-(\d+)$/', $component->getId(), $m)) {
|
||||
$name = preg_replace('/-\d+$/', $m[1]++, $component->getId());
|
||||
if (array_key_exists($component->getTitle(), $this->components)) {
|
||||
if (preg_match('/_(\d+)$/', $component->getTitle(), $m)) {
|
||||
$name = preg_replace('/_\d+$/', $m[1]++, $component->getTitle());
|
||||
} else {
|
||||
$name = $component->getId() . '-2';
|
||||
$name = $component->getTitle() . '_2';
|
||||
}
|
||||
$this->components[$name] = $component;
|
||||
} else {
|
||||
$this->components[$component->getId()] = $component;
|
||||
$this->components[$component->getTitle()] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,18 +193,17 @@ class Pane extends AbstractWidget
|
|||
/**
|
||||
* Add a component to the current pane
|
||||
*
|
||||
* @param $id
|
||||
* @param $title
|
||||
* @param null $url
|
||||
* @return mixed
|
||||
* @param $url
|
||||
* @return Component
|
||||
*
|
||||
* @see addComponent()
|
||||
*/
|
||||
public function add($id, $title, $url = null)
|
||||
public function add($title, $url = null)
|
||||
{
|
||||
$this->addComponent($id, $title, $url);
|
||||
$this->addComponent($title, $url);
|
||||
|
||||
return $this->components[$id];
|
||||
return $this->components[$title];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
/* @var $this \Icinga\Application\Modules\Module */
|
||||
|
||||
$section = $this->menuSection('documentation', $this->translate('Documentation'), array(
|
||||
$section = $this->menuSection($this->translate('Documentation'), array(
|
||||
'title' => 'Documentation',
|
||||
'icon' => 'img/icons/comment.png',
|
||||
'url' => 'doc',
|
||||
'priority' => 80
|
||||
|
|
|
@ -22,73 +22,72 @@ $this->provideConfigTab('security', array(
|
|||
/*
|
||||
* Problems Section
|
||||
*/
|
||||
$section = $this->menuSection('problems', $this->translate('Problems'), array(
|
||||
$section = $this->menuSection($this->translate('Problems'), array(
|
||||
'icon' => 'img/icons/error.png',
|
||||
'priority' => 20
|
||||
));
|
||||
$section->add('unhandled hosts', $this->translate('Unhandled Hosts'), array(
|
||||
$section->add($this->translate('Unhandled Hosts'), array(
|
||||
'url' => 'monitoring/list/hosts?host_problem=1&host_handled=0',
|
||||
'priority' => 40
|
||||
));
|
||||
$section->add('unhandled services', $this->translate('Unhandled Services'), array(
|
||||
$section->add($this->translate('Unhandled Services'), array(
|
||||
'url' => 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity',
|
||||
'priority' => 40
|
||||
));
|
||||
$section->add('host problems', $this->translate('Host Problems'), array(
|
||||
$section->add($this->translate('Host Problems'), array(
|
||||
'url' => 'monitoring/list/hosts?host_problem=1&sort=host_severity',
|
||||
'priority' => 50
|
||||
));
|
||||
$section->add('service prolems', $this->translate('Service Problems'), array(
|
||||
$section->add($this->translate('Service Problems'), array(
|
||||
'url' => 'monitoring/list/services?service_problem=1&sort=service_severity&dir=desc',
|
||||
'priority' => 50
|
||||
));
|
||||
$section->add('current downtimes', $this->translate('Current Downtimes'))
|
||||
->setUrl('monitoring/list/downtimes?downtime_is_in_effect=1');
|
||||
$section->add($this->translate('Current Downtimes'))->setUrl('monitoring/list/downtimes?downtime_is_in_effect=1');
|
||||
|
||||
/*
|
||||
* Overview Section
|
||||
*/
|
||||
$section = $this->menuSection('overview', $this->translate('Overview'), array(
|
||||
$section = $this->menuSection($this->translate('Overview'), array(
|
||||
'icon' => 'img/icons/hostgroup.png',
|
||||
'priority' => 30
|
||||
));
|
||||
$section->add('tactical overview', $this->translate('Tactical Overview'), array(
|
||||
$section->add($this->translate('Tactical Overview'), array(
|
||||
'url' => 'monitoring/tactical',
|
||||
'priority' => 40
|
||||
));
|
||||
$section->add('hosts', $this->translate('Hosts'), array(
|
||||
$section->add($this->translate('Hosts'), array(
|
||||
'url' => 'monitoring/list/hosts',
|
||||
'priority' => 50
|
||||
));
|
||||
$section->add('services', $this->translate('Services'), array(
|
||||
$section->add($this->translate('Services'), array(
|
||||
'url' => 'monitoring/list/services',
|
||||
'priority' => 50
|
||||
));
|
||||
$section->add('servicematrix', $this->translate('Servicematrix'), array(
|
||||
$section->add($this->translate('Servicematrix'), array(
|
||||
'url' => 'monitoring/list/servicematrix?service_problem=1',
|
||||
'priority' => 51
|
||||
));
|
||||
$section->add('servicegroups', $this->translate('Servicegroups'), array(
|
||||
$section->add($this->translate('Servicegroups'), array(
|
||||
'url' => 'monitoring/list/servicegroups',
|
||||
'priority' => 60
|
||||
));
|
||||
$section->add('hostgroups', $this->translate('Hostgroups'), array(
|
||||
$section->add($this->translate('Hostgroups'), array(
|
||||
'url' => 'monitoring/list/hostgroups',
|
||||
'priority' => 60
|
||||
));
|
||||
$section->add('contactgroups', $this->translate('Contactgroups'), array(
|
||||
$section->add($this->translate('Contactgroups'), array(
|
||||
'url' => 'monitoring/list/contactgroups',
|
||||
'priority' => 61
|
||||
));
|
||||
$section->add('downtimes', $this->translate('Downtimes'), array(
|
||||
$section->add($this->translate('Downtimes'), array(
|
||||
'url' => 'monitoring/list/downtimes',
|
||||
'priority' => 71
|
||||
));
|
||||
$section->add('comments', $this->translate('Comments'), array(
|
||||
$section->add($this->translate('Comments'), array(
|
||||
'url' => 'monitoring/list/comments?comment_type=(comment|ack)',
|
||||
'priority' => 70
|
||||
));
|
||||
$section->add('contacts', $this->translate('Contacts'), array(
|
||||
$section->add($this->translate('Contacts'), array(
|
||||
'url' => 'monitoring/list/contacts',
|
||||
'priority' => 70
|
||||
));
|
||||
|
@ -96,33 +95,31 @@ $section->add('contacts', $this->translate('Contacts'), array(
|
|||
/*
|
||||
* History Section
|
||||
*/
|
||||
$section = $this->menuSection('history', $this->translate('History'), array(
|
||||
'title' => $this->translate('History'),
|
||||
$section = $this->menuSection($this->translate('History'), array(
|
||||
'icon' => 'img/icons/history.png'
|
||||
));
|
||||
$section->add('critical events', $this->translate('Critical Events'), array(
|
||||
'title' => $this->translate('Critical Events'),
|
||||
$section->add($this->translate('Critical Events'), array(
|
||||
'url' => 'monitoring/list/statehistorysummary',
|
||||
'priority' => 50
|
||||
));
|
||||
$section->add('notifications', $this->translate('Notifications'), array(
|
||||
$section->add($this->translate('Notifications'), array(
|
||||
'url' => 'monitoring/list/notifications'
|
||||
));
|
||||
$section->add('events', $this->translate('Events'), array(
|
||||
$section->add($this->translate('Events'), array(
|
||||
'title' => $this->translate('All Events'),
|
||||
'url' => 'monitoring/list/eventhistory?timestamp>=-7%20days'
|
||||
));
|
||||
$section->add('timeline', $this->translate('Timeline'))->setUrl('monitoring/timeline');
|
||||
$section->add($this->translate('Timeline'))->setUrl('monitoring/timeline');
|
||||
|
||||
/*
|
||||
* System Section
|
||||
*/
|
||||
$section = $this->menuSection('system', $this->translate('System'));
|
||||
$section->add('process info', $this->translate('Process Info'), array(
|
||||
$section = $this->menuSection($this->translate('System'));
|
||||
$section->add($this->translate('Process Info'), array(
|
||||
'url' => 'monitoring/process/info',
|
||||
'priority' => 120
|
||||
));
|
||||
$section->add('performance info', $this->translate('Performance Info'), array(
|
||||
$section->add($this->translate('Performance Info'), array(
|
||||
'url' => 'monitoring/process/performance',
|
||||
'priority' => 130
|
||||
));
|
||||
|
@ -130,19 +127,16 @@ $section->add('performance info', $this->translate('Performance Info'), array(
|
|||
/*
|
||||
* Dashboard
|
||||
*/
|
||||
$dashboard = $this->dashboard('current-incidents', $this->translate('Current Incidents'));
|
||||
$dashboard = $this->dashboard($this->translate('Current Incidents'));
|
||||
$dashboard->add(
|
||||
'service problems',
|
||||
$this->translate('Service Problems'),
|
||||
'monitoring/list/services?service_problem=1&limit=10&sort=service_severity'
|
||||
);
|
||||
$dashboard->add(
|
||||
'recently recovered services',
|
||||
$this->translate('Recently Recovered Services'),
|
||||
'monitoring/list/services?service_state=0&limit=10&sort=service_last_state_change&dir=desc'
|
||||
);
|
||||
$dashboard->add(
|
||||
'host problems',
|
||||
$this->translate('Host Problems'),
|
||||
'monitoring/list/hosts?host_problem=1&sort=host_severity'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue