From 3606e5a5141ffd4036bc54cd5e8306141bccc91e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 May 2018 11:14:27 +0200 Subject: [PATCH] tactical: Allow to filter what is displayed refs #3334 --- .../controllers/TacticalController.php | 20 ++++++++--- .../views/scripts/tactical/index.phtml | 33 ++++++++++--------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/controllers/TacticalController.php b/modules/monitoring/application/controllers/TacticalController.php index 7a4e8ccce..6eb5ba0db 100644 --- a/modules/monitoring/application/controllers/TacticalController.php +++ b/modules/monitoring/application/controllers/TacticalController.php @@ -51,6 +51,16 @@ class TacticalController extends Controller ); $this->applyRestriction('monitoring/filter/objects', $stats); + $this->setupFilterControl($stats, null, ['host', 'service'], ['format']); + $this->view->setHelperFunction('filteredUrl', function ($path, array $params) { + $filter = clone $this->view->filterEditor->getFilter(); + foreach ($params as $column => $value) { + $filter = $filter->andFilter($filter->where($column, $value)); + } + + return $this->view->url($path)->setQueryString($filter->toQueryString()); + }); + $this->handleFormatRequest($stats); $summary = $stats->fetchRow(); @@ -83,16 +93,18 @@ class TacticalController extends Controller ->setLabelSmall($this->translate('Services Critical')); $this->view->hostStatusSummaryChart = $hostSummaryChart - ->setLabelBigUrl($this->view->url( + ->setLabelBigUrl($this->view->filteredUrl( 'monitoring/list/hosts', array( - 'host_state' => 1, 'host_handled' => 0, - 'sort' => 'host_last_check', 'dir' => 'asc' + 'host_state' => 1, + 'host_handled' => 0, + 'sort' => 'host_last_check', + 'dir' => 'asc' ) )) ->render(); $this->view->serviceStatusSummaryChart = $serviceSummaryChart - ->setLabelBigUrl($this->view->url( + ->setLabelBigUrl($this->view->filteredUrl( 'monitoring/list/services', array( 'service_state' => 2, diff --git a/modules/monitoring/application/views/scripts/tactical/index.phtml b/modules/monitoring/application/views/scripts/tactical/index.phtml index ef9f53f5a..4ee3a7d18 100644 --- a/modules/monitoring/application/views/scripts/tactical/index.phtml +++ b/modules/monitoring/application/views/scripts/tactical/index.phtml @@ -1,6 +1,7 @@ compact): ?>
tabs ?> + filterEditor ?>
@@ -13,43 +14,43 @@ hosts_up): ?> - + hosts_down_handled):?> - + hosts_down_unhandled):?> - + hosts_unreachable_handled):?> - + hosts_unreachable_unhandled):?> - + hosts_pending):?> - + hosts_not_checked):?> - + @@ -65,55 +66,55 @@
hosts_up ?> translate('Up') ?>
hosts_down_handled ?> translate('Down') ?> (translate('Handled') ?>)
hosts_down_unhandled ?> translate('Down') ?>
hosts_unreachable_handled ?> translate('Unreachable') ?> (translate('Handled') ?>)
hosts_unreachable_unhandled ?> translate('Unreachable') ?>
hosts_pending ?> translate('Pending') ?>
hosts_not_checked ?> translate('Not Checked') ?>
services_ok):?> - + services_warning_handled):?> - + services_warning_unhandled):?> - + services_critical_handled):?> - + services_critical_unhandled):?> - + services_unknown_handled):?> - + services_unknown_unhandled):?> - + services_pending):?> - + services_not_checked):?> - +
services_ok ?> translate('Ok') ?>
services_warning_handled ?> translate('Warning') ?> (translate('Handled') ?>)
services_warning_unhandled ?> translate('Warning') ?>
services_critical_handled ?> translate('Critical') ?> (translate('Handled') ?>)
services_critical_unhandled ?> translate('Critical') ?>
services_unknown_handled ?> translate('Unknown') ?> (translate('Handled') ?>)
services_unknown_unhandled ?> translate('Unknown') ?>
services_pending ?> translate('Pending') ?>
services_not_checked ?> translate('Not Checked') ?>