From 87664ffef9414e4344e7037de53a9ac9784be5f8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 12 Dec 2014 10:38:21 +0100 Subject: [PATCH] Use the Host and Service object class helpers instead of MonitoringState This also ensures that all state names that are shown to the user are properly translated. refs #7996 --- .../application/views/helpers/MonitoringState.php | 9 ++++++--- .../application/views/scripts/list/hosts.phtml | 6 ++++-- .../views/scripts/list/servicegrid.phtml | 7 ++++++- .../application/views/scripts/list/services.phtml | 10 ++++++---- .../views/scripts/show/components/header.phtml | 13 ++++++++++--- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/views/helpers/MonitoringState.php b/modules/monitoring/application/views/helpers/MonitoringState.php index 4db1a7a91..13bd93ea7 100644 --- a/modules/monitoring/application/views/helpers/MonitoringState.php +++ b/modules/monitoring/application/views/helpers/MonitoringState.php @@ -3,7 +3,7 @@ // {{{ICINGA_LICENSE_HEADER}}} /** - * @deprecated Crap. + * @deprecated Most of these helpers are currently only used in the MultiController, which is probably obsolete */ class Zend_View_Helper_MonitoringState extends Zend_View_Helper_Abstract { @@ -11,7 +11,7 @@ class Zend_View_Helper_MonitoringState extends Zend_View_Helper_Abstract private $hoststates = array('up', 'down', 'unreachable', 99 => 'pending', null => 'pending'); /** - * @deprecated The host or service object must know it's possible states. + * @deprecated Not used anywhere. */ public function monitoringState($object, $type = 'service') { @@ -22,6 +22,9 @@ class Zend_View_Helper_MonitoringState extends Zend_View_Helper_Abstract } } + /** + * @deprecated Not used anywhere. + */ public function monitoringStateById($id, $type = 'service') { if ($type === 'service') { @@ -91,7 +94,7 @@ class Zend_View_Helper_MonitoringState extends Zend_View_Helper_Abstract } /** - * @deprecated Not translated. + * @deprecated Not used anywhere. */ public function getStateTitle($object, $type) { diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 588d39712..7f3e73b0b 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -1,4 +1,6 @@ getHelper('MonitoringState'); if ($this->compact): ?> @@ -79,8 +81,8 @@ if ($hosts->count() === 0) { ?> - - monitoringState($host, 'host')) ?>
+ + host_state, true)); ?>
host_state !== 99): ?> prefixedTimeSince($host->host_last_state_change, true) ?> host_state > 0 && (int) $host->host_state_type === 0): ?> diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 19aef5d64..dd9be0394 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -1,3 +1,8 @@ + compact): ?>
tabs; ?> @@ -63,7 +68,7 @@ $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ' + )); ?>" title="escape($service->service_output); ?>" class="state_service_state); ?> service_handled ? 'handled' : ''; ?>"> · diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 2ea125527..2922abff5 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -1,4 +1,7 @@ getHelper('MonitoringState'); $selfUrl = 'monitoring/list/services'; @@ -54,9 +57,8 @@ foreach ($services as $service): $serviceStateName = strtolower($this->util()->getServiceStateName($service->service_state)); ?> - - translate(strtoupper($helper->monitoringState($service, 'service'))) ?>
- + + service_state, true)); ?>
compact): ?>prefixedTimeSince($service->service_last_state_change); ?>timeSince($service->service_last_state_change); ?> service_state > 0 && (int) $service->service_state_type === 0): ?>
@@ -106,7 +108,7 @@ foreach ($services as $service): service_display_name ?>showHost): ?> on host_name; ?> host_state != 0): ?> - (monitoringState($service, 'host')); ?>) + (host_state, true)); ?>)

escape(substr(strip_tags($service->service_output), 0, 10000)); ?>

diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index a2c835e4a..c44602260 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -1,9 +1,16 @@ -getType() === $object::TYPE_SERVICE ?> +getType() === $object::TYPE_SERVICE; + +?> compact): ?> - + - +
> translate($this->util()->getHostStateName($object->host_state)) ?>
prefixedTimeSince($object->host_last_state_change, true) ?> @@ -15,7 +22,7 @@
translate($this->util()->getServiceStateName($object->service_state)) ?>
prefixedTimeSince($object->service_last_state_change, true) ?>