diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp
index 282803a83..13d54bf9f 100644
--- a/.vagrant-puppet/manifests/default.pp
+++ b/.vagrant-puppet/manifests/default.pp
@@ -740,18 +740,6 @@ file { '/etc/icingaweb/modules/monitoring/instances.ini':
group => 'apache',
}
-file { '/etc/icingaweb/dashboard':
- ensure => 'directory',
- owner => 'apache',
- group => 'apache',
-}
-
-file { '/etc/icingaweb/dashboard/dashboard.ini':
- source => 'puppet:////vagrant/config/dashboard/dashboard.ini',
- owner => 'apache',
- group => 'apache',
-}
-
# pear::package { 'deepend/Mockery':
# channel => 'pear.survivethedeepend.com'
# }
diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php
index 1f45eacde..108117959 100644
--- a/application/controllers/DashboardController.php
+++ b/application/controllers/DashboardController.php
@@ -111,19 +111,23 @@ class DashboardController extends ActionController
*/
public function indexAction()
{
- $dashboard = $this->getDashboard();
- if ($this->_getParam('pane')) {
- $pane = $this->_getParam('pane');
- $dashboard->activate($pane);
- }
+ $dashboard = Dashboard::load();
- $this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
-
- if ($dashboard === null) {
+ if (! $dashboard->hasPanes()) {
$this->view->title = 'Dashboard';
} else {
- $this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
- $this->view->tabs = $dashboard->getTabs();
+ if ($this->_getParam('pane')) {
+ $pane = $this->_getParam('pane');
+ $dashboard->activate($pane);
+ }
+
+ $this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
+
+ if ($dashboard === null) {
+ $this->view->title = 'Dashboard';
+ } else {
+ $this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
+ $this->view->tabs = $dashboard->getTabs();
/* Temporarily removed
$this->view->tabs->add(
@@ -135,8 +139,8 @@ class DashboardController extends ActionController
);
*/
- $this->view->dashboard = $dashboard;
-
+ $this->view->dashboard = $dashboard;
+ }
}
}
diff --git a/application/views/scripts/dashboard/addurl.phtml b/application/views/scripts/dashboard/addurl.phtml
index 27ea46f56..c2d3f7e6c 100644
--- a/application/views/scripts/dashboard/addurl.phtml
+++ b/application/views/scripts/dashboard/addurl.phtml
@@ -2,6 +2,11 @@
= $this->tabs ?>
-
+
= $this->escape($this->translate('This feature is deactivated at the moment.')); ?>
+
+ =
+ $this->escape($this->translate('Please have a little patience, we are hard working on it, take a look at icingaweb2 issues.'));
+ ?>
+
+
\ No newline at end of file
diff --git a/application/views/scripts/dashboard/index.phtml b/application/views/scripts/dashboard/index.phtml
index 3e721dc68..4adad7b66 100644
--- a/application/views/scripts/dashboard/index.phtml
+++ b/application/views/scripts/dashboard/index.phtml
@@ -7,16 +7,10 @@
-
No dashboard configuration found!
-
- =
- $this->translate('We tried to load a dashboard configuration with no success.'
- . ' Please have look that the configuration does exist:');
- ?>
-
-
- = $this->escape($this->configPath) ?>.ini
-
-
+
= $this->escape($this->translate('Welcome to Icinga Web!')) ?>
+
= sprintf(
+ $this->escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')),
+ $this->qlink($this->translate('modules'), 'config/modules')
+ ) ?>
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/config/dashboard/dashboard.ini b/config/dashboard/dashboard.ini
deleted file mode 100644
index 022b34be5..000000000
--- a/config/dashboard/dashboard.ini
+++ /dev/null
@@ -1,39 +0,0 @@
-[Incidents]
-title = "Current incidents"
-
-[Incidents.Service Problems]
-url = "monitoring/list/services"
-service_problem = 1
-limit = 10
-sort = service_severity
-
-[Incidents.Recently Recovered Services]
-url = "monitoring/list/services"
-sort = "service_last_state_change"
-service_state = 0
-limit = 10
-dir = "desc"
-
-[Incidents.Host Problems]
-url = "monitoring/list/hosts"
-host_problem = 1
-sort = host_severity
-
-[Landing]
-title = "Landing page"
-
-[Landing.Hostgroups]
-url = "monitoring/chart/hostgroup"
-
-[Landing.Servicegroups]
-url = "monitoring/chart/servicegroup"
-
-[Landing.Unhandled Problem Services]
-url = "monitoring/list/services"
-service_handled = 0
-service_problem = 1
-
-[Landing.Unhandled Problem Hosts]
-url = "monitoring/list/hosts"
-host_handled = 0
-host_problem = 1
diff --git a/doc/dashboard.md b/doc/dashboard.md
index 89ff52ee1..1b1e7a983 100644
--- a/doc/dashboard.md
+++ b/doc/dashboard.md
@@ -14,30 +14,4 @@ the objects you're interested in and can add and remove elements.
* The dashboard itself is just the view containing the panes
-## Configuration files
-
-By default, the config/dashboard/dashboard.ini is used for storing dashboards in the following format:
-
- [PaneName] ; Define a new Pane
- title = "PaneTitle" ; The title of the pane as displayed in the tabls
-
- [PaneName.Component1] ; Define a new component 'Component 1' underneat the pane
- url = "/url/for/component1" ; the url that will be displayed, with view=compact as URL parameter appended
- height = "500px" ; optional height setting
- width = "400px" ; optional width setting
-
- [test.My hosts] ; Another component, here with host
- url = "monitoring/list/hosts" ; the url of the component
- ; Notice the missing height/width definition
-
- [test.My services] ; And another pane
- url = "monitoring/list/services" ; With service url
-
- [test2] ; Define a second pane
- title = "test2" ; with the title
-
- [test2.test] ; Add a component to the second pane
- url = "/monitoring/show/host/host1" ; ...and define it's url
-
-
[dashboards1]: res/Dashboard.png
diff --git a/icingaweb2.spec b/icingaweb2.spec
index d7cc53ed9..270e18fff 100644
--- a/icingaweb2.spec
+++ b/icingaweb2.spec
@@ -185,8 +185,6 @@ install -D -m0644 packages/rpm/etc/httpd/conf.d/icingaweb.conf %{buildroot}/%{ap
install -D -m0644 packages/rpm/etc/icingaweb/authentication.ini %{buildroot}/%{_sysconfdir}/icingaweb/authentication.ini
# custom resource paths
install -D -m0644 packages/rpm/etc/icingaweb/resources.ini %{buildroot}/%{_sysconfdir}/icingaweb/resources.ini
-# dashboard
-install -D -m0644 config/dashboard/dashboard.ini %{buildroot}/%{_sysconfdir}/icingaweb/dashboard/dashboard.ini
# monitoring module (icinga2)
install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/backends.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/backends.ini
install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/instances.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/instances.ini
diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php
index a4b87be08..a325dfef0 100644
--- a/library/Icinga/Application/Modules/Module.php
+++ b/library/Icinga/Application/Modules/Module.php
@@ -16,6 +16,7 @@ use Icinga\Util\Translator;
use Icinga\Web\Hook;
use Icinga\Web\Menu;
use Icinga\Web\Widget;
+use Icinga\Web\Widget\Dashboard\Pane;
use Icinga\Util\File;
use Icinga\Exception\ProgrammingError;
@@ -154,6 +155,36 @@ class Module
*/
protected $menuItems = array();
+ /**
+ * A set of Pane elements
+ *
+ * @var array
+ */
+ protected $paneItems = array();
+
+ /**
+ * Get all Menu Items
+ *
+ * @return array
+ */
+ public function getPaneItems()
+ {
+ $this->launchConfigScript();
+ return $this->paneItems;
+ }
+
+ /**
+ * Add a pane to dashboard
+ *
+ * @param $name
+ * @return Pane
+ */
+ protected function dashboard($name)
+ {
+ $this->paneItems[$name] = new Pane($name);
+ return $this->paneItems[$name];
+ }
+
/**
* Get all Menu Items
*
diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php
index c87afa1ab..f565c0fca 100644
--- a/library/Icinga/Web/Widget/Dashboard.php
+++ b/library/Icinga/Web/Widget/Dashboard.php
@@ -63,6 +63,46 @@ class Dashboard extends AbstractWidget
$this->getTabs()->activate($name);
}
+ /**
+ * Load Pane items provided by all enabled modules
+ *
+ * @return self
+ */
+ public static function load()
+ {
+ /** @var $dashboard Dashboard */
+ $dashboard = new static('dashboard');
+ $manager = Icinga::app()->getModuleManager();
+ foreach ($manager->getLoadedModules() as $module) {
+ /** @var $module \Icinga\Application\Modules\Module */
+ $dashboard->mergePanes($module->getPaneItems());
+
+ }
+ return $dashboard;
+ }
+
+ /**
+ * Merge panes with existing panes
+ *
+ * @param array $panes
+ * @return $this
+ */
+ public function mergePanes(array $panes)
+ {
+ /** @var $pane Pane */
+ foreach ($panes as $pane) {
+ if (array_key_exists($pane->getName(), $this->panes)) {
+ /** @var $current Pane */
+ $current = $this->panes[$pane->getName()];
+ $current->addComponents($pane->getComponents());
+ } else {
+ $this->panes = array_filter(array_merge($this->panes, $panes));
+ }
+ }
+
+ return $this;
+ }
+
/**
* Return the tab object used to navigate through this dashboard
*
@@ -147,6 +187,16 @@ class Dashboard extends AbstractWidget
return $this;
}
+ /**
+ * Checks if the current dashboard has any panes
+ *
+ * @return bool
+ */
+ public function hasPanes()
+ {
+ return ! empty($this->panes);
+ }
+
/**
* Return true if a pane doesn't exist or doesn't have any components in it
*
diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php
index 5e3e8ffea..15cf56524 100644
--- a/library/Icinga/Web/Widget/Dashboard/Pane.php
+++ b/library/Icinga/Web/Widget/Dashboard/Pane.php
@@ -162,6 +162,47 @@ class Pane extends AbstractWidget
return $this;
}
+ /**
+ * Add new components to existing components
+ *
+ * @param array $components
+ * @return $this
+ */
+ public function addComponents(array $components)
+ {
+ /* @var $component Component */
+ foreach ($components as $component) {
+ 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->getTitle() . '_2';
+ }
+ $this->components[$name] = $component;
+ } else {
+ $this->components[$component->getTitle()] = $component;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add a component to the current pane
+ *
+ * @param $title
+ * @param $url
+ * @return Component
+ *
+ * @see addComponent()
+ */
+ public function add($title, $url = null)
+ {
+ $this->addComponent($title, $url);
+
+ return $this->components[$title];
+ }
+
/**
* Return the this pane's structure as array
*
diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php
index d4431e6e1..412581d24 100644
--- a/modules/monitoring/configuration.php
+++ b/modules/monitoring/configuration.php
@@ -125,10 +125,18 @@ $section->add($this->translate('Performance Info'), array(
));
/*
-
-$dashboard = $this->dashboard('Current Incidents'); // Web\Widget\Dashboard\Pane
-$dashboard->add('Service Problems', array(
-
-));
-
-*/
+ * Dashboard
+ */
+$dashboard = $this->dashboard($this->translate('Current Incidents'));
+$dashboard->add(
+ $this->translate('Service Problems'),
+ 'monitoring/list/services?service_problem=1&limit=10&sort=service_severity'
+);
+$dashboard->add(
+ $this->translate('Recently Recovered Services'),
+ 'monitoring/list/services?service_state=0&limit=10&sort=service_last_state_change&dir=desc'
+);
+$dashboard->add(
+ $this->translate('Host Problems'),
+ 'monitoring/list/hosts?host_problem=1&sort=host_severity'
+);