From 860cc59155abbcb1b1c47ed33d0147e37e76e5a4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 5 Mar 2015 18:32:38 +0100 Subject: [PATCH 001/298] Implement new layout for service multi-view refs #8565 --- .../controllers/HostsController.php | 3 +- .../controllers/ServicesController.php | 89 +++++--- .../command/objects-command-form.phtml | 28 +-- .../partials/host/objects-header.phtml | 3 +- .../partials/host/servicesummary.phtml | 1 + .../partials/service/objects-header.phtml | 117 +++++++--- .../service/objects-tinysummary.phtml | 42 ++++ .../views/scripts/services/show.phtml | 216 ++++++++++++------ modules/monitoring/public/css/module.less | 7 +- public/css/icinga/monitoring-colors.less | 47 ++++ public/css/icinga/widgets.less | 42 ++-- public/js/icinga/behavior/tooltip.js | 2 +- 12 files changed, 425 insertions(+), 172 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 5dc72eeb0..1586ad723 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -77,7 +77,8 @@ class Monitoring_HostsController extends Controller count($this->hostList) ), 'label' => $this->translate('Hosts'), - 'url' => Url::fromRequest() + 'url' => Url::fromRequest(), + 'icon' => 'host' ) )->activate('show'); $this->setAutorefreshInterval(15); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1e907aab9..ceabd643e 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; @@ -28,6 +29,19 @@ class Monitoring_ServicesController extends Controller $serviceList = new ServiceList($this->backend); $serviceList->setFilter(Filter::fromQueryString((string) $this->params->without('service_problem', 'service_handled'))); $this->serviceList = $serviceList; + $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services'); + $this->getTabs()->add( + 'show', + array( + 'title' => sprintf( + $this->translate('Show summarized information for %u services'), + count($this->serviceList) + ), + 'label' => $this->translate('Services'), + 'url' => Url::fromRequest(), + 'icon' => 'services' + ) + )->activate('show'); } protected function handleCommandForm(ObjectsCommandForm $form) @@ -40,7 +54,11 @@ class Monitoring_ServicesController extends Controller 'service_problem', 'service_handled', 'service_acknowledged', - 'service_in_downtime' + 'service_in_downtime', + 'service_is_flapping', + 'service_notifications_enabled', + 'service_output', + 'service_last_ack' )); $form @@ -90,17 +108,6 @@ class Monitoring_ServicesController extends Controller public function showAction() { - $this->getTabs()->add( - 'show', - array( - 'title' => sprintf( - $this->translate('Show summarized information for %u services'), - count($this->serviceList) - ), - 'label' => $this->translate('Services'), - 'url' => Url::fromRequest() - ) - )->activate('show'); $this->setAutorefreshInterval(15); $checkNowForm = new CheckNowCommandForm(); $checkNowForm @@ -109,15 +116,21 @@ class Monitoring_ServicesController extends Controller $this->view->checkNowForm = $checkNowForm; $this->serviceList->setColumns(array( 'host_name', + 'host_output', 'host_state', + 'service_output', 'service_description', 'service_state', 'service_problem', 'service_handled', 'service_acknowledged', - 'service_in_downtime'/*, - 'service_passive_checks_enabled', + 'service_in_downtime', + 'service_is_flapping', 'service_notifications_enabled', + 'service_last_comment', + 'service_last_ack' + /*, + 'service_passive_checks_enabled', 'service_event_handler_enabled', 'service_flap_detection_enabled', 'service_active_checks_enabled', @@ -129,22 +142,34 @@ class Monitoring_ServicesController extends Controller $objectsInDowntime = array(); $downtimeFilterExpressions = array(); $serviceStates = array( - Service::getStateText(Service::STATE_OK) => 0, - Service::getStateText(Service::STATE_WARNING) => 0, - Service::getStateText(Service::STATE_CRITICAL) => 0, - Service::getStateText(Service::STATE_UNKNOWN) => 0, - Service::getStateText(Service::STATE_PENDING) => 0 + 'services_' . Service::getStateText(Service::STATE_OK) => 0, + 'services_' . Service::getStateText(Service::STATE_OK) . '_unhandled' => 0, + 'services_' . Service::getStateText(Service::STATE_WARNING) => 0, + 'services_' . Service::getStateText(Service::STATE_WARNING) . '_unhandled' => 0, + 'services_' . Service::getStateText(Service::STATE_CRITICAL) => 0, + 'services_' . Service::getStateText(Service::STATE_CRITICAL) . '_unhandled' => 0, + 'services_' . Service::getStateText(Service::STATE_UNKNOWN) => 0, + 'services_' . Service::getStateText(Service::STATE_UNKNOWN) . '_unhandled' => 0, + 'services_' . Service::getStateText(Service::STATE_PENDING) => 0, + 'services_' . Service::getStateText(Service::STATE_PENDING) . '_unhandled' => 0 ); $knownHostStates = array(); $hostStates = array( - Host::getStateText(Host::STATE_UP) => 0, - Host::getStateText(Host::STATE_DOWN) => 0, - Host::getStateText(Host::STATE_UNREACHABLE) => 0, - Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0 ); foreach ($this->serviceList as $service) { + $unhandled = false; + /** @var Service $service */ if ((bool) $service->problem === true && (bool) $service->handled === false) { + $unhandled = true; $unhandledObjects[] = $service; $unhandledFilterExpressions[] = Filter::matchAll( Filter::where('host', $service->getHost()->getName()), @@ -161,10 +186,11 @@ class Monitoring_ServicesController extends Controller Filter::where('downtime_service', $service->getName()) ); } - ++$serviceStates[$service::getStateText($service->state)]; + + ++$serviceStates['services_' . $service::getStateText($service->state) . ($unhandled ? '_unhandled' : '')]; if (! isset($knownHostStates[$service->getHost()->getName()])) { $knownHostStates[$service->getHost()->getName()] = true; - ++$hostStates[$service->getHost()->getStateText($service->host_state)]; + ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; } } if (! empty($acknowledgedObjects)) { @@ -174,15 +200,20 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + if (! empty($objectsInDowntime)) { + $removeDowntimeForm = new DeleteDowntimeCommandForm(); + $removeDowntimeForm->setObjects($objectsInDowntime) + ->handleRequest(); + $this->view->removeDowntimeForm = $removeDowntimeForm; + } $this->setAutorefreshInterval(15); - $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath( 'monitoring/services/process-check-result' ); - $this->view->hostStates = $hostStates; - $this->view->serviceStates = $serviceStates; + $this->view->hostStates = (object)$hostStates; + $this->view->serviceStates = (object)$serviceStates; $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); @@ -196,6 +227,7 @@ class Monitoring_ServicesController extends Controller ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); + /* $this->view->serviceStatesPieChart = $this->createPieChart( $serviceStates, $this->translate('Service State'), @@ -206,6 +238,7 @@ class Monitoring_ServicesController extends Controller $this->translate('Host State'), array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') ); + */ } protected function createPieChart(array $states, $title, array $colors) diff --git a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml index d387202c2..ece0aea34 100644 --- a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml @@ -1,31 +1,19 @@
+ + compact): ?> + + + +

translate('%d Services Selected'), count($objects)) ?>

render('partials/service/objects-header.phtml'); ?> +

translate('%d Hosts Selected'), count($objects)) ?>

render('partials/host/objects-header.phtml'); ?>
+
- - - - - - - - - getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?> - - getType() === $object::TYPE_HOST): ?> - - - - - - - - -
icon('host'); ?> translate('Host'); ?>icon('conf'); ?> translate('Service'); ?>
escape($object->getName()); ?>escape($object->getHost()->getName()); ?>escape($object->getName()); ?>

diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index f892df6f4..448be4c02 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,6 +1,7 @@ compact): ?> + 0): ?>

@@ -15,4 +16,4 @@ translate(strtoupper($text)), $count); ?>

- \ No newline at end of file + diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml index c0acdead4..bdd4d9af7 100644 --- a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml @@ -31,6 +31,7 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); translate('No services configured on this host'); ?> + stats->services_ok): ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 6389d992f..113e7c0a0 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,34 +1,85 @@ -compact): ?> - - + + + 0): ?> -
-
-

- translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount); ?> -

-
-
-   -
-
- $count): ?> - translate(strtoupper($text)), $count); ?>
- -
-
-
-
- - translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -
-
-   -
-
- $count): ?> - translate(strtoupper($text)), $count); ?>
- -
-
- \ No newline at end of file +

+ + + + + + + + + + + + + + 5) { + $desc = $service->getHost()->getName() . ' on ' . $service->getName(); + $hidden[] = $desc; + $hiddenRich[] = sprintf("
%s", $service->getStateText($service->service_state) ,$desc); + continue; + } + ?> + + + + + + + + + + + + + + + + + +
icon('service'); ?> translate('Service'); ?>icon('host'); ?> translate('Host'); ?>translate('Output'); ?>
service_state, true); ?>
+ service_handled && $service->service_state > 0): ?> + icon('attention-alt', $this->translate('Unhandled')) ?> + + + service_acknowledged && !$service->service_in_downtime): ?> + icon('ok', $this->translate('Acknowledged') . ( + $service->service_last_ack ? ': ' . $service->service_last_ack : '' + )) ?> + + + service_is_flapping): ?> + icon('flapping', $this->translate('Flapping')) ?> + + + service_notifications_enabled): ?> + icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> + + + service_in_downtime): ?> + icon('plug', $this->translate('In Downtime')) ?> + + + service_last_comment) && $service->service_last_comment !== null): ?> + icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> + + escape($service->getName()); ?>escape($service->getHost()->getName()); ?>

escape($service->service_output) ?>

+
+ +
+
+

+ diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml new file mode 100644 index 000000000..7707651d2 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml @@ -0,0 +1,42 @@ + + +

+ qlink( + sprintf($this->translate('%d Services Selected:'), count($objects)), + $listAllLink + ); ?> + + + services_ok): ?> + + + services_ok ?> + + + + 'critical', + 3 => 'unknown', + 1 => 'warning', + 4 => 'pending' + ) as $stateId => $state) { + + $stateName = 'services_' . $state; + $unhandledStateName = $stateName . '_unhandled'; + if ($serviceStates->$unhandledStateName) { + echo '' . $serviceStates->$unhandledStateName . ''; + } + if ($serviceStates->$stateName) { + echo '' . $serviceStates->$stateName . ''; + } + if ($serviceStates->$unhandledStateName) { + echo ''; + } + $stateName .= '_unhandled'; + }?> + +

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 015fecb95..9dc865010 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,47 +1,66 @@ + +
+ + compact): ?> + + + + render('partials/service/objects-tinysummary.phtml') ?> render('partials/service/objects-header.phtml'); ?> +
- translate('No services matching the filter'); ?> + translate('No services matching the filter'); ?> -

translatePlural('%u Service', '%u Services', $serviceCount), $serviceCount); ?>

-
qlink( - sprintf($this->translate('List all %u services'), $serviceCount), - $listAllLink - ); ?>
+ + +

qlink( - sprintf($this->translate('Reschedule the next check for all %u services'), $serviceCount), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?>
+ $this->translate('Reschedule the next check'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?>
qlink( - sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?>
+ $this->translate('Schedule a downtime'), + $downtimeAllLink, + null, + array('icon' => 'plug') + ); ?>
qlink( - sprintf($this->translate('Submit a passive check result for all %u services'), $serviceCount), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?>
- 0): ?> -
-

translatePlural( - '%u Unhandled Service Problem', - '%u Unhandled Service Problems', - $unhandledCount - ), - $unhandledCount - ); ?>

-
qlink( + $this->translate('Submit a passive check result'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?>
+

+ + 0): ?> +
+

+ icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

+ +

' . $unhandledCount . '') ?> + + +

+ qlink( sprintf( $this->translatePlural( 'Schedule a downtime for %u unhandled service problem', @@ -53,7 +72,9 @@ $downtimeUnhandledLink, null, array('icon' => 'plug') - ); ?>
+ ); ?> +
+
qlink( sprintf( $this->translatePlural( @@ -67,50 +88,101 @@ null, array('icon' => 'ok') ); ?>
-
- - 0): ?> -
-

translatePlural( - '%u Acknowledged Service Problem', - '%u Acknowledged Service Problems', - $acknowledgedCount - ), +

+ + +

+ + + 0): ?> + +

icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

+

+ translatePlural( + '%u Acknowledged Service Problem', + '%u Acknowledged Service Problems', $acknowledgedCount - ); ?> - - - - 0): ?> -

qlink( - sprintf( - $this->translatePlural( - 'List %u service currently in downtime', - 'List %u services currently in downtime', - $inDowntimeCount - ), - $inDowntimeCount ), + $acknowledgedCount + ); ?> +

+ + + + 0): ?> + +

icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

+

translatePlural( + '%u service currently in downtime', + '%u services currently in downtime', + $inDowntimeCount + ), $inDowntimeCount) ?> + +

+ qlink( + $this->translate('List all'), $inDowntimeLink, null, array('icon' => 'plug') - ); ?> - - getComments())) > 0): ?> -

qlink( - sprintf( - $this->translatePlural( - 'List %u service comment', - 'List %u service comments', - $commentCount - ), + );?> +

+ +
+ Delete All +
+

+ + + +getComments()) ?> + 0): ?> +

icon('comment') ?>

+

translatePlural( + 'There are no comments.', + 'There are %d comments', $commentCount - ), - $commentsLink, - null, - array('icon' => 'comment') - ); ?> - + ), $commentCount); + ?> + qlink( + $this->translate('List all'), + $commentsLink, + null, + array('icon' => 'comment') + ); ?>

+ + + + fetchComments(); ?> + + comments as $comment): ?> + + + + + + + +
+ populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getHost()->getName(), 'service' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
+ + \ No newline at end of file diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 6c205cd04..eb598bb5d 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -91,15 +91,16 @@ div.contacts div.notification-periods { margin-top: 0.5em; } -div.tinystatesummary { +.tinystatesummary { .page-header(); font-size: 1em; .badges { display: inline-block; margin-bottom: 4px; margin-left: 1em; + height: auto; } - .state > a { + .state > * { color: white; font-size: 0.8em; padding: 2px 5px; @@ -196,7 +197,7 @@ div.selection-info { .optionbox label { max-width: 6.5em; text-align: left; - vertical-align: middle; + vertgical-align: middle; margin-right: 0em; } diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 5c19bfe35..62d5a68cd 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -922,3 +922,50 @@ table.groupview { } /* End of monitoring groupsummary styles */ + +/* compact table */ +table.statesummary { + text-align: left; + width: auto; + border-collapse: separate; + + tbody { + white-space: nowrap; + } + + td { + padding: 0em 0.4em 0em 0.4em; + line-height: 1.2em; + } + + tr.state td.state { + width: auto; + font-weight: bold; + } + + td .pluginoutput { + font-size: 0.8em; + line-height: 1.2em; + padding-left: 0; + margin: 0; + } + + td.state { + min-width: 70px; + font-size: 0.7em; + text-align: center; + } + + td a { + color: inherit; + text-decoration: none; + } +} + +/* Up to 576px for 1em=16px, should fit 320px devices */ +@media screen and (max-width: 97em) { + + table.statesummary .collapse { + display: none; + } +} diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 45701a697..de33d6685 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -203,23 +203,13 @@ li li .badge-container { margin-right: 0.75em; } -/* -#layout.hoveredmenu .active > .badge-container { - display: none; -} - -#layout.hoveredmenu .hover > .badge-container { - //margin-right: 14.15em; - display: none; -} -*/ - .badge { position: relative; - top: 0.3em; + top: -0.15em; display: inline-block; min-width: 1em; padding: 3px 7px; + margin: 0 0.2em 0 0.2em; font-size: 0.8em; font-weight: 700; line-height: 1.1em; @@ -230,6 +220,11 @@ li li .badge-container { background-color: @colorInvalid; } +#menu nav ul .badge { + margin-right: 0em; + top: 0.3em; +} + #menu nav > ul > li.active > .badge-container { display: none; } @@ -277,7 +272,7 @@ li li .badge { background-color: @colorPending; } -.badge-pending { +.badge-unknown { background-color: @colorUnknown; } @@ -303,3 +298,24 @@ li li .badge { margin: 0em 0em 0em 0.1em; } + +.tipsy .tipsy-inner { + // overwrite tooltip max width, we need them to grow bigger + max-width: 300px; + text-align: left; +} + +.color-box { + position: relative; + top: 2px; + margin: 0px 3px 0px 3px; + display: inline-block; + width: 12px; + height: 12px; +} + +.oneline { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index c9a64257f..c0abcbd45 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -30,7 +30,7 @@ $('svg .chart-data', el).tipsy({ gravity: 'se', html: true }); $('.historycolorgrid a[title]', el).tipsy({ gravity: 's', offset: 2 }); $('img.icon[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); - $('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500 }); + $('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500, html: true }); // migrate or remove all orphaned tooltips $('.tipsy').each(function () { From ef16ba5f48543447ca81b5a7afc2a445eae9c52b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:23:11 +0100 Subject: [PATCH 002/298] Add commands for adding comments to services refs #8348 --- .../controllers/ServicesController.php | 40 +++++++- .../views/scripts/services/show.phtml | 95 ++++++++++++------- 2 files changed, 96 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index ceabd643e..a20572d0d 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -10,7 +10,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; @@ -58,7 +59,8 @@ class Monitoring_ServicesController extends Controller 'service_is_flapping', 'service_notifications_enabled', 'service_output', - 'service_last_ack' + 'service_last_ack', + 'service_last_comment' )); $form @@ -200,18 +202,23 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + /* if (! empty($objectsInDowntime)) { $removeDowntimeForm = new DeleteDowntimeCommandForm(); - $removeDowntimeForm->setObjects($objectsInDowntime) + $removeDowntimeForm + ->setObjects($objectsInDowntime) ->handleRequest(); $this->view->removeDowntimeForm = $removeDowntimeForm; } + */ $this->setAutorefreshInterval(15); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath( 'monitoring/services/process-check-result' ); + $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); + $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); $this->view->hostStates = (object)$hostStates; $this->view->serviceStates = (object)$serviceStates; $this->view->objects = $this->serviceList; @@ -250,6 +257,33 @@ class Monitoring_ServicesController extends Controller ->setSparklineClass('sparkline-multi'); } + + /** + * Add a service comment + */ + public function addCommentAction() + { + $this->assertPermission('monitoring/command/comment/add'); + + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Service Comments')); + $this->handleCommandForm($form); + } + + + /** + * Delete a comment + */ + public function deleteCommentAction() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $form = new DeleteCommentCommandForm(); + $form->setTitle($this->translate('Delete Service Comments')); + $this->handleCommandForm($form); + } + + /** * Acknowledge service problems */ diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 9dc865010..cd941df4d 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -14,6 +14,11 @@ use Icinga\Web\Url;
+

+ icon('reschedule') ?> + translate('Commands') ?> +

+ translate('No services matching the filter'); ?> @@ -41,6 +46,12 @@ use Icinga\Web\Url; null, array('icon' => 'reply') ); ?>
+
qlink( + $this->translate('Add a comment'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?>

0): ?> @@ -127,10 +138,6 @@ use Icinga\Web\Url; array('icon' => 'plug') );?> - -
- Delete All -

@@ -145,44 +152,60 @@ use Icinga\Web\Url; $commentCount ), $commentCount); ?> +

+ + + fetchComments(); ?> + comments as $comment): ?> + + + + + + +
+ populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getHost()->getName(), 'service' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
+

+ +
qlink( $this->translate('List all'), $commentsLink, null, array('icon' => 'comment') - ); ?>

+ ); ?> +
- - - fetchComments(); ?> + - comments as $comment): ?> - - - - - - - -
- populate( - array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) - ); - $delCommentForm->setAction( - $this->url( - 'monitoring/service/delete-comment', - array('host' => $service->getHost()->getName(), 'service' => $service->getName()) - ) - ); - echo $delCommentForm; - ?> - (type) ?>): - - comment) ?> -
- - \ No newline at end of file + + + From cb0ca6d6acb20c3c6040c79a148cd80487813dc5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:24:11 +0100 Subject: [PATCH 003/298] Remove unused piechart code --- .../Backend/LdapUserBackend.php | 1 - .../controllers/HostsController.php | 20 ----------- .../controllers/ServicesController.php | 33 ------------------- .../partials/host/objects-header.phtml | 3 -- .../views/scripts/services/show.phtml | 1 - 5 files changed, 58 deletions(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 016512ab4..62834211d 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -240,7 +240,6 @@ class LdapUserBackend extends UserBackend $users[] = $row->{$this->userNameAttribute}; } } - return $users; } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 1586ad723..19b501a88 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -13,7 +13,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandFor use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_HostsController extends Controller { @@ -58,11 +57,6 @@ class Monitoring_HostsController extends Controller $this->view->form = $form; $this->view->objects = $this->hostList; $this->view->hostStates = $hostStates; - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } @@ -153,20 +147,6 @@ class Monitoring_HostsController extends Controller ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); - } - - protected function createPieChart(array $states, $title, array $colors) - { - $chart = new InlinePie(array_values($states), $title, $colors); - return $chart - ->setSize(75) - ->setTitle('') - ->setSparklineClass('sparkline-multi'); } /** diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index a20572d0d..1514a0ea0 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -16,7 +16,6 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_ServicesController extends Controller { @@ -94,16 +93,6 @@ class Monitoring_ServicesController extends Controller $this->view->objects = $this->serviceList; $this->view->serviceStates = $serviceStates; $this->view->hostStates = $hostStates; - $this->view->serviceStatesPieChart = $this->createPieChart( - $serviceStates, - $this->translate('Service State'), - array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') - ); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } @@ -234,30 +223,8 @@ class Monitoring_ServicesController extends Controller ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); - /* - $this->view->serviceStatesPieChart = $this->createPieChart( - $serviceStates, - $this->translate('Service State'), - array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') - ); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); - */ } - protected function createPieChart(array $states, $title, array $colors) - { - $chart = new InlinePie(array_values($states), $title, $colors); - return $chart - ->setSize(75) - ->setTitle('') - ->setSparklineClass('sparkline-multi'); - } - - /** * Add a service comment */ diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 448be4c02..cd79bce5b 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -8,9 +8,6 @@ translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -
-   -
$count): ?> translate(strtoupper($text)), $count); ?>
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index cd941df4d..5cd3af1b6 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -69,7 +69,6 @@ use Icinga\Web\Url; 'Issue commands to the problematic services.'), '' . $unhandledCount . '') ?> -
qlink( sprintf( From f4257043050c64c5d28e4286131fd275a75e61ca Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:48:42 +0100 Subject: [PATCH 004/298] Fix service tooltip title refs #8565 --- .../views/scripts/partials/service/objects-header.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 113e7c0a0..11127ddf3 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -26,7 +26,7 @@ use Icinga\Web\Url; 5) { - $desc = $service->getHost()->getName() . ' on ' . $service->getName(); + $desc = $service->getName() . ' on ' . $service->getHost()->getName(); $hidden[] = $desc; $hiddenRich[] = sprintf("
%s", $service->getStateText($service->service_state) ,$desc); continue; From 71534369efd3b2a1f0794536d597d58494f9c65c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:31:34 +0100 Subject: [PATCH 005/298] Implement new layout for host multi-view refs #8543 --- .../controllers/HostsController.php | 30 +- .../views/scripts/hosts/show.phtml | 256 +++++++++++++----- .../partials/host/objects-header.phtml | 101 ++++++- 3 files changed, 297 insertions(+), 90 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 19b501a88..2c9ebc20e 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; @@ -36,7 +37,12 @@ class Monitoring_HostsController extends Controller 'host_problem', 'host_handled', 'host_acknowledged', - 'host_in_downtime' + 'host_in_downtime', + 'host_last_ack', + 'host_is_flapping', + 'host_last_comment', + 'host_output', + 'host_notifications_enabled' )); $form @@ -87,9 +93,13 @@ class Monitoring_HostsController extends Controller 'host_problem', 'host_handled', 'host_acknowledged', - 'host_in_downtime'/*, + 'host_in_downtime', + 'host_last_ack', + 'host_is_flapping', + 'host_last_comment', + 'host_output', + 'host_notifications_enabled',/*, 'host_passive_checks_enabled', - 'host_notifications_enabled', 'host_event_handler_enabled', 'host_flap_detection_enabled', 'host_active_checks_enabled', @@ -133,6 +143,8 @@ class Monitoring_HostsController extends Controller $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); + $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); + $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); $this->view->hostStates = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; @@ -149,6 +161,18 @@ class Monitoring_HostsController extends Controller ->setPath('monitoring/list/comments'); } + /** + * Add a host comments + */ + public function addCommentAction() + { + $this->assertPermission('monitoring/command/comment/add'); + + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Host Comments')); + $this->handleCommandForm($form); + } + /** * Acknowledge host problems */ diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 8655a31b1..b6cb454bf 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,116 +1,224 @@ + +
+ + compact): ?> + + + +

+ qlink( + sprintf($this->translate('%d Hosts Selected'), count($objects)), + $listAllLink + ); ?> +

+ render('partials/host/objects-header.phtml'); ?>
+
+

+ icon('reschedule') ?> + translate('Commands') ?> +

+ + translate('No hosts matching the filter'); ?> -

translatePlural('%u Host', '%u Hosts', $hostCount), $hostCount); ?>

-
qlink( - sprintf($this->translate('List all %u hosts'), $hostCount), - $listAllLink - ); ?>
+ +

-
qlink( - sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?>
-
qlink( - sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?>
-
qlink( - sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?>
- 0): ?> +
-

translatePlural( - '%u Unhandled Host Problem', - '%u Unhandled Host Problems', - $unhandledCount - ), - $unhandledCount - ); ?>

-
qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %u unhandled host problem', - 'Schedule a downtime for %u unhandled host problems', - $unhandledCount - ), - $unhandledCount - ), - $downtimeUnhandledLink, + qlink( + $this->translate('Reschedule the next check'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?> +
+ +
+ qlink( + $this->translate('Schedule a downtime'), + $downtimeAllLink, null, array('icon' => 'plug') - ); ?>
-
qlink( - sprintf( - $this->translatePlural( - 'Acknowledge %u unhandled host problem', - 'Acknowledge %u unhandled host problems', + ); ?> +
+ +
+ qlink( + $this->translate('Submit a passive check result'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?> +
+ +
+ qlink( + $this->translate('Add a comment'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?> +
+

+ + 0): ?> +
+

+ icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

+ + +

+ ' . $unhandledCount . '' + ) ?> + +

qlink( + sprintf( + $this->translatePlural( + 'Schedule a downtime for %u host', + 'Schedule a downtime for %u hosts', + $unhandledCount + ), + $unhandledCount + ), + $downtimeUnhandledLink, + null, + array('icon' => 'plug') + ); ?>
+ + +
qlink( + sprintf( + $this->translatePlural( + 'Acknowledge %u unhandled host', + 'Acknowledge %u unhandled hosts', + $unhandledCount + ), $unhandledCount ), - $unhandledCount - ), - $acknowledgeUnhandledLink, - null, - array('icon' => 'ok') - ); ?>
+ $acknowledgeUnhandledLink, + null, + array('icon' => 'ok') + ); ?>
+ +

+
+ 0): ?>
-

icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

+ +

translatePlural( '%u Acknowledged Host Problem', '%u Acknowledged Host Problems', $acknowledgedCount ), $acknowledgedCount - ); ?> + ); ?>

+
+ 0): ?> -

qlink( - sprintf( + +

translate('Downtimes') ?>

+

translatePlural( - 'List %u host currently in downtime', - 'List %u hosts currently in downtime', + '%u Host currently in downtime.', + '%u Hosts currently in downtime.', $inDowntimeCount ), $inDowntimeCount - ), - $inDowntimeLink, - null, - array('icon' => 'plug') - ); ?> + ) ?> qlink( + $this->translate('Alle anzeigen'), + $inDowntimeLink, + null + ); ?> + +

+ getComments())) > 0): ?> -

qlink( - sprintf( +

translate('Comments') ?>

+

+ translatePlural( - 'List %u host comment', - 'List %u host comments', + 'There is %u host comment.', + 'There are %u host comments.', $commentCount ), $commentCount - ), - $commentsLink, - null, - array('icon' => 'comment') - ); ?> + ) ?> + + qlink( + $this->translate('List all'), + $commentsLink, + null + ); ?> + +

+ + + + fetchComments(); ?> + comments as $comment): ?> + + + + + + +
+ populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
+ + +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index cd79bce5b..6c910d46a 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,16 +1,91 @@ -compact): ?> - - + + + + + 0): ?> -
-

- translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -

-
-
- $count): ?> - translate(strtoupper($text)), $count); ?>
- -
+ +

+ + + + + + + + + + + + + 5) { + $desc = $host->getName(); + $hidden[] = $desc; + $hiddenRich[] = sprintf("
%s", $host->getStateText($host->host_state) ,$desc); + continue; + } + ?> + + + + + + + + + + + + + + + + +
icon('host'); ?> translate('Host'); ?>translate('Output'); ?>
host_state, true); ?>
+ host_handled && $host->host_state > 0): ?> + icon('attention-alt', $this->translate('Unhandled')) ?> + + + host_acknowledged && !$host->host_in_downtime): ?> + icon('ok', $this->translate('Acknowledged') . ( + $host->host_last_ack ? ': ' . $host->host_last_ack : '' + )) ?> + + + host_is_flapping): ?> + icon('flapping', $this->translate('Flapping')) ?> + + + host_notifications_enabled): ?> + icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> + + + host_in_downtime): ?> + icon('plug', $this->translate('In Downtime')) ?> + + + host_last_comment) && $host->host_last_comment !== null): ?> + icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?> + + escape($host->getName()); ?>

escape($host->host_output) ?>

+
+ +
+
+

+ + + + + From 9fc80ec34fb9a4d57ef4d390375e2a82f89d7d0d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:45:29 +0100 Subject: [PATCH 006/298] Use more readable coding style in service multi-view refs #8565 --- .../views/scripts/services/show.phtml | 218 +++++++++--------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 5cd3af1b6..d9aed1581 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -20,124 +20,130 @@ use Icinga\Web\Url; - translate('No services matching the filter'); ?> + translate('No services matching the filter'); ?> - + -

+

-
qlink( + +
+ qlink( $this->translate('Reschedule the next check'), $rescheduleAllLink, null, array('icon' => 'reschedule') - ); ?>
-
qlink( + ); ?> +
+ +
+ qlink( $this->translate('Schedule a downtime'), $downtimeAllLink, null, array('icon' => 'plug') - ); ?>
-
qlink( + ); ?> +
+ +
+ qlink( $this->translate('Submit a passive check result'), $processCheckResultAllLink, null, array('icon' => 'reply') - ); ?>
-
qlink( + ); ?> +
+ +
+ qlink( $this->translate('Add a comment'), $addCommentLink, null, array('icon' => 'comment') - ); ?>
-

- - 0): ?> -
-

- icon('attention-alt') ?> - translatePlural( - 'Unhandled Problem', - 'Unhandled Problems', - $unhandledCount - ) ?> -

- -

' . $unhandledCount . '') ?> - -

- qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %u unhandled service problem', - 'Schedule a downtime for %u unhandled service problems', - $unhandledCount - ), - $unhandledCount - ), - $downtimeUnhandledLink, - null, - array('icon' => 'plug') ); ?> -
- -
qlink( - sprintf( - $this->translatePlural( - 'Acknowledge %u unhandled service problem', - 'Acknowledge %u unhandled service problems', - $unhandledCount - ), - $unhandledCount - ), - $acknowledgeUnhandledLink, - null, - array('icon' => 'ok') - ); ?>
+

- -
- - - 0): ?> - -

icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

-

- translatePlural( - '%u Acknowledged Service Problem', - '%u Acknowledged Service Problems', - $acknowledgedCount - ), - $acknowledgedCount - ); ?> -

- - - - 0): ?> - -

icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

-

translatePlural( - '%u service currently in downtime', - '%u services currently in downtime', - $inDowntimeCount - ), $inDowntimeCount) ?> - + 0): ?>

- qlink( - $this->translate('List all'), - $inDowntimeLink, - null, - array('icon' => 'plug') - );?> +

+ icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

+ +

' . $unhandledCount . '') ?> + +

+ qlink( + sprintf( + $this->translatePlural( + 'Schedule a downtime for %u unhandled service problem', + 'Schedule a downtime for %u unhandled service problems', + $unhandledCount + ), + $unhandledCount + ), + $downtimeUnhandledLink, + null, + array('icon' => 'plug') + ); ?> +
+ +
qlink( + sprintf( + $this->translatePlural( + 'Acknowledge %u unhandled service problem', + 'Acknowledge %u unhandled service problems', + $unhandledCount + ), + $unhandledCount + ), + $acknowledgeUnhandledLink, + null, + array('icon' => 'ok') + ); ?>
+

+
-

+ + + 0): ?> +

icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

+

+ translatePlural( + '%u Acknowledged Service Problem.', + '%u Acknowledged Service Problems.', + $acknowledgedCount + ), + $acknowledgedCount + ); ?> +

+ + + + 0 /*&& $auth->hasPermission('monitoring/command/comment/delete')*/): ?> +

icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

+

translatePlural( + '%u service currently in downtime.', + '%u services currently in downtime.', + $inDowntimeCount + ), $inDowntimeCount) ?> + + qlink( + $this->translate('List all'), + $inDowntimeLink, + null + );?> +

@@ -146,12 +152,18 @@ use Icinga\Web\Url;

icon('comment') ?>

translatePlural( - 'There are no comments.', - 'There are %d comments', + 'There is %d comment.', + 'There are %d comments.', $commentCount ), $commentCount); ?> + qlink( + $this->translate('List all'), + $commentsLink, + null + ); ?>

+ fetchComments(); ?> @@ -180,20 +192,9 @@ use Icinga\Web\Url;
+ + - + --> From 0623404963818b033d857a655de59bbb45b5567c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:46:49 +0100 Subject: [PATCH 007/298] Add missing layout color for "down" badge refs #8565 --- public/css/icinga/monitoring-colors.less | 2 +- public/css/icinga/widgets.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 62d5a68cd..609b3451c 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -951,7 +951,7 @@ table.statesummary { } td.state { - min-width: 70px; + min-width: 75px; font-size: 0.7em; text-align: center; } diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index de33d6685..b6a41c234 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -260,6 +260,10 @@ li li .badge { background-color: @colorCritical; } +.badge-down { + background-color: @colorCritical; +} + .badge-warning { background-color: @colorWarning; } From a077472226fe5a2c6472ac70243ebb76b0afd19d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:53:58 +0100 Subject: [PATCH 008/298] Make tabs available in all host controller actions refs #8565 --- .../controllers/HostsController.php | 24 +++++++++---------- .../views/scripts/services/show.phtml | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 2c9ebc20e..aa119c161 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -27,6 +27,18 @@ class Monitoring_HostsController extends Controller $hostList = new HostList($this->backend); $hostList->setFilter(Filter::fromQueryString((string) $this->params)); $this->hostList = $hostList; + $this->getTabs()->add( + 'show', + array( + 'title' => sprintf( + $this->translate('Show summarized information for %u hosts'), + count($this->hostList) + ), + 'label' => $this->translate('Hosts'), + 'url' => Url::fromRequest(), + 'icon' => 'host' + ) + )->activate('show'); } protected function handleCommandForm(ObjectsCommandForm $form) @@ -69,18 +81,6 @@ class Monitoring_HostsController extends Controller public function showAction() { - $this->getTabs()->add( - 'show', - array( - 'title' => sprintf( - $this->translate('Show summarized information for %u hosts'), - count($this->hostList) - ), - 'label' => $this->translate('Hosts'), - 'url' => Url::fromRequest(), - 'icon' => 'host' - ) - )->activate('show'); $this->setAutorefreshInterval(15); $checkNowForm = new CheckNowCommandForm(); $checkNowForm diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index d9aed1581..2933e6623 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,6 +1,5 @@

From f91ce0cfa1af1e7d5525c34938ae8777764b006f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 13:27:48 +0100 Subject: [PATCH 009/298] Fix delete comment command in host multi-view refs #8565 --- .../application/controllers/HostsController.php | 12 ++++++++++++ .../application/views/scripts/hosts/show.phtml | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index aa119c161..eaa3d03a4 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -173,6 +173,18 @@ class Monitoring_HostsController extends Controller $this->handleCommandForm($form); } + /** + * Delete a comment + */ + public function deleteCommentAction() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $form = new DeleteCommentCommandForm(); + $form->setTitle($this->translate('Delete Host Comments')); + $this->handleCommandForm($form); + } + /** * Acknowledge host problems */ diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index b6cb454bf..ffba365b1 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -14,8 +14,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; $listAllLink ); ?> - render('partials/host/objects-header.phtml'); ?> +
@@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?> - + translate('No hosts matching the filter'); ?> @@ -192,7 +192,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ); $delCommentForm->setAction( $this->url( - 'monitoring/service/delete-comment', + 'monitoring/host/delete-comment', array('host' => $service->getName()) ) ); From 4724eb907fc53d072c8675e33443eb3c56899df4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 14:49:33 +0100 Subject: [PATCH 010/298] Fix site layout of multi-views Fix responsiveness and add icons for plugin output section. refs 8565 --- .../views/scripts/hosts/show.phtml | 2 +- .../partials/host/objects-header.phtml | 8 +++---- .../partials/service/objects-header.phtml | 17 +++++++------ .../views/scripts/services/show.phtml | 2 +- public/css/icinga/layout-structure.less | 4 ++++ public/css/icinga/monitoring-colors.less | 24 +++++++------------ public/css/icinga/widgets.less | 5 ++++ 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index ffba365b1..20338b08e 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -18,7 +18,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
-
+

icon('reschedule') ?> translate('Commands') ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 6c910d46a..39445e277 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -18,8 +18,8 @@ $hiddenRich = array(); - icon('host'); ?> translate('Host'); ?> - translate('Output'); ?> + icon('host'); ?> translate('Host'); ?> + icon('paste'); ?> translate('Plugin Output'); ?> @@ -64,8 +64,8 @@ $hiddenRich = array(); icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?> - escape($host->getName()); ?> -

escape($host->host_output) ?>

+ escape($host->getName()); ?> + escape($host->host_output) ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 11127ddf3..fe23cde2c 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -15,12 +15,11 @@ use Icinga\Web\Url; - icon('service'); ?> translate('Service'); ?> - icon('host'); ?> translate('Host'); ?> - translate('Output'); ?> + icon('service'); ?> translate('Service'); ?> + icon('host'); ?> translate('Host'); ?> + icon('paste'); ?> translate('Plugin Output'); ?> - icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> - escape($service->getName()); ?> - escape($service->getHost()->getName()); ?> -

escape($service->service_output) ?>

+ escape($service->getName()); ?> + escape($service->getHost()->getName()); ?> + escape($service->service_output) ?> - -
+
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 2933e6623..8ee61859a 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -12,7 +12,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; render('partials/service/objects-header.phtml'); ?>
-
+

icon('reschedule') ?> translate('Commands') ?> diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index a8f135712..3aa7da077 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -370,3 +370,7 @@ html { position: absolute; width: 1px; } + +.no-padding-top { + padding-top: 0em; +} diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 609b3451c..ad80fbb45 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -929,10 +929,6 @@ table.statesummary { width: auto; border-collapse: separate; - tbody { - white-space: nowrap; - } - td { padding: 0em 0.4em 0em 0.4em; line-height: 1.2em; @@ -943,29 +939,27 @@ table.statesummary { font-weight: bold; } - td .pluginoutput { - font-size: 0.8em; + td { + font-size: 0.85em; line-height: 1.2em; - padding-left: 0; + padding-left: 0.2em; margin: 0; } td.state { + padding: 0.2em; min-width: 75px; - font-size: 0.7em; + font-size: 0.75em; text-align: center; } + td.name { + font-weight: bold; + } + td a { color: inherit; text-decoration: none; } } -/* Up to 576px for 1em=16px, should fit 320px devices */ -@media screen and (max-width: 97em) { - - table.statesummary .collapse { - display: none; - } -} diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index b6a41c234..7aaf8385e 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -272,6 +272,10 @@ li li .badge { background-color: @colorOk; } +.badge-up { + background-color: @colorOk; +} + .badge-pending { background-color: @colorPending; } @@ -323,3 +327,4 @@ li li .badge { white-space: nowrap; text-overflow: ellipsis; } + From c2c9e49df4a853afa7783439810ebb464a91281b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:01:52 +0100 Subject: [PATCH 011/298] Fix inconsistencies in text messages refs #8565 --- modules/monitoring/application/views/scripts/hosts/show.phtml | 4 ++-- .../monitoring/application/views/scripts/services/show.phtml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 20338b08e..e5b3cd181 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?>

- + translate('No hosts matching the filter'); ?> @@ -85,7 +85,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

' . $unhandledCount . '' ) ?> diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 8ee61859a..bbd22df1a 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -21,7 +21,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; translate('No services matching the filter'); ?> - +

@@ -77,7 +77,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

' . $unhandledCount . '') ?>

From 5c71f5a8ef0c16611042f4de96a7d3ae8c037ade Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:13:08 +0100 Subject: [PATCH 012/298] Open list all links to the next container refs #8565 --- .../monitoring/application/views/scripts/hosts/show.phtml | 8 +++++--- .../application/views/scripts/services/show.phtml | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index e5b3cd181..4c1d70ff6 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -151,9 +151,10 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ), $inDowntimeCount ) ?> qlink( - $this->translate('Alle anzeigen'), + $this->translate('List all'), $inDowntimeLink, - null + null, + array('data-base-target' => '_next') ); ?>

@@ -174,7 +175,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $commentsLink, - null + null, + array('data-base-target' => '_next') ); ?>

diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index bbd22df1a..d35125254 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -140,7 +140,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $inDowntimeLink, - null + null, + array('data-base-target' => '_next') );?>

@@ -159,7 +160,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $commentsLink, - null + null, + array('data-base-target' => '_next') ); ?>

From 2591f055d80df93fdc31a1888cc1ec09fdb60c7e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:22:14 +0100 Subject: [PATCH 013/298] Fix translation Remove calls to deprecated translation function. Always use plural forms for commands in multi-view to indicate that this will cause multiple commands to be issued. refs #8565 --- .../application/views/scripts/hosts/show.phtml | 16 ++++++++-------- .../scripts/partials/host/objects-header.phtml | 2 +- .../partials/service/objects-header.phtml | 5 ++++- .../views/scripts/services/show.phtml | 14 +++++++------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 4c1d70ff6..c8a4f9484 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?> - + translate('Issue commands to all %d selected hosts:'), count($objects)) ?> translate('No hosts matching the filter'); ?> @@ -36,7 +36,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

qlink( - $this->translate('Reschedule the next check'), + $this->translate('Reschedule next checks'), $rescheduleAllLink, null, array('icon' => 'reschedule') @@ -45,7 +45,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Schedule a downtime'), + $this->translate('Schedule downtimes'), $downtimeAllLink, null, array('icon' => 'plug') @@ -54,7 +54,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Submit a passive check result'), + $this->translate('Submit passive check results'), $processCheckResultAllLink, null, array('icon' => 'reply') @@ -63,7 +63,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Add a comment'), + $this->translate('Add comments'), $addCommentLink, null, array('icon' => 'comment') @@ -85,7 +85,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

translate('There are %s unhandled problems. Issue commands to the problematic hosts:'), '' . $unhandledCount . '' ) ?> @@ -142,7 +142,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; 0): ?> -

translate('Downtimes') ?>

+

icon('plug', $this->translate('Downtimes'))?> translate('Downtimes')?>

translatePlural( '%u Host currently in downtime.', @@ -161,7 +161,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; getComments())) > 0): ?> -

translate('Comments') ?>

+

icon('comment', $this->translate('Comments'))?> translate('Comments') ?>

translatePlural( diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 39445e277..c2f016ceb 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -74,7 +74,7 @@ $hiddenRich = array();

- + translate('%d more ...'), count($hidden)) ?>
diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index fe23cde2c..4501f0e7e 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -34,7 +34,9 @@ use Icinga\Web\Url; service_state, true); ?>
+ + service_handled && $service->service_state > 0): ?> icon('attention-alt', $this->translate('Unhandled')) ?> @@ -60,6 +62,7 @@ use Icinga\Web\Url; service_last_comment) && $service->service_last_comment !== null): ?> icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> + escape($service->getName()); ?> escape($service->getHost()->getName()); ?> @@ -72,7 +75,7 @@ use Icinga\Web\Url;
- + translate('%d more ...'), count($hidden)) ?>
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index d35125254..08e1737f3 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -21,7 +21,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; translate('No services matching the filter'); ?> - + translate('Issue commands to all %d selected services:'), count($objects)) ?>

@@ -30,7 +30,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Reschedule the next check'), + $this->translate('Reschedule next checks'), $rescheduleAllLink, null, array('icon' => 'reschedule') @@ -39,7 +39,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Schedule a downtime'), + $this->translate('Schedule downtimes'), $downtimeAllLink, null, array('icon' => 'plug') @@ -48,7 +48,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Submit a passive check result'), + $this->translate('Submit passive check results'), $processCheckResultAllLink, null, array('icon' => 'reply') @@ -57,7 +57,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
qlink( - $this->translate('Add a comment'), + $this->translate('Add comments'), $addCommentLink, null, array('icon' => 'comment') @@ -76,7 +76,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ) ?> -

translate('There are %s unhandled problems. ' . 'Issue commands to the problematic services:'), '' . $unhandledCount . '') ?> @@ -149,7 +149,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; getComments()) ?> 0): ?> -

icon('comment') ?>

+

icon('comment') ?> translate('Comments') ?>

translatePlural( 'There is %d comment.', From 9c45e99b5731b7b8336f066ce6e0f2b3c64ad4f4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 16:13:00 +0100 Subject: [PATCH 014/298] Add tiny statesummary to service multi-view refs #8565 --- .../controllers/HostsController.php | 19 +++++--- .../views/scripts/hosts/show.phtml | 7 +-- .../partials/host/objects-header.phtml | 6 +-- .../partials/host/objects-tinysummary.phtml | 44 +++++++++++++++++++ .../partials/service/objects-header.phtml | 1 - modules/monitoring/public/css/module.less | 12 +++++ 6 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index eaa3d03a4..ec4e470a2 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -111,14 +111,19 @@ class Monitoring_HostsController extends Controller $objectsInDowntime = array(); $downtimeFilterExpressions = array(); $hostStates = array( - Host::getStateText(Host::STATE_UP) => 0, - Host::getStateText(Host::STATE_DOWN) => 0, - Host::getStateText(Host::STATE_UNREACHABLE) => 0, - Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, ); foreach ($this->hostList as $host) { /** @var Host $host */ - if ((bool) $host->problem === true && (bool) $host->handled === false) { + $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; + if ($unhandled) { $unhandledObjects[] = $host; $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); } @@ -129,7 +134,7 @@ class Monitoring_HostsController extends Controller $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates[$host::getStateText($host->state)]; + ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -145,7 +150,7 @@ class Monitoring_HostsController extends Controller $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = $hostStates; + $this->view->hostStates = (object)$hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index c8a4f9484..f4ac40904 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,12 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -

- qlink( - sprintf($this->translate('%d Hosts Selected'), count($objects)), - $listAllLink - ); ?> -

+ render('partials/host/objects-tinysummary.phtml') ?> render('partials/host/objects-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index c2f016ceb..d535f367e 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -2,14 +2,12 @@ use Icinga\Module\Monitoring\Object\Host; ?> - - 0): ?>

@@ -71,8 +69,8 @@ $hiddenRich = array(); - -

+
translate('%d more ...'), count($hidden)) ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml new file mode 100644 index 000000000..fa841c633 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml @@ -0,0 +1,44 @@ + + +

+ qlink( + sprintf($this->translate('%d Hosts Selected:'), count($objects)), + $listAllLink + ); ?> + + + hosts_up): ?> + + + + hosts_up ?> + + + + + 'down', + 2 => 'unreachable', + 99 => 'pending' + ) as $stateId => $state) { + + $stateName = 'hosts_' . $state; + $unhandledStateName = $stateName . '_unhandled'; + if ($hostStates->$unhandledStateName) { + echo '' . $hostStates->$unhandledStateName . ''; + } + if ($hostStates->$stateName) { + echo '' . $hostStates->$stateName . ''; + } + if ($hostStates->$unhandledStateName) { + echo ''; + } + $stateName .= '_unhandled'; + }?> + + +

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 4501f0e7e..dd206a646 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,6 +1,5 @@ Date: Fri, 6 Mar 2015 17:30:59 +0100 Subject: [PATCH 015/298] Deduplicate state summary Use existing partials for rendering the state summary instead of a new one. refs #8565 --- .../controllers/HostsController.php | 14 +----- .../controllers/ServicesController.php | 36 +-------------- .../views/scripts/hosts/show.phtml | 2 +- .../partials/host/objects-tinysummary.phtml | 44 ------------------- .../service/objects-tinysummary.phtml | 42 ------------------ .../views/scripts/services/show.phtml | 2 +- .../library/Monitoring/Object/HostList.php | 27 ++++++++++++ .../library/Monitoring/Object/ObjectList.php | 11 +++++ .../library/Monitoring/Object/ServiceList.php | 42 ++++++++++++++++++ 9 files changed, 86 insertions(+), 134 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml delete mode 100644 modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ec4e470a2..55f8a6e60 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -110,16 +110,7 @@ class Monitoring_HostsController extends Controller $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, - ); + foreach ($this->hostList as $host) { /** @var Host $host */ $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; @@ -134,7 +125,6 @@ class Monitoring_HostsController extends Controller $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -150,7 +140,7 @@ class Monitoring_HostsController extends Controller $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = (object)$hostStates; + $this->view->stats = (object)$this->hostList->getStateSummary(); $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1514a0ea0..dcd95184c 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -132,35 +132,10 @@ class Monitoring_ServicesController extends Controller $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $serviceStates = array( - 'services_' . Service::getStateText(Service::STATE_OK) => 0, - 'services_' . Service::getStateText(Service::STATE_OK) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) . '_unhandled' => 0 - ); - $knownHostStates = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0 - ); - foreach ($this->serviceList as $service) { - $unhandled = false; + foreach ($this->serviceList as $service) { /** @var Service $service */ if ((bool) $service->problem === true && (bool) $service->handled === false) { - $unhandled = true; $unhandledObjects[] = $service; $unhandledFilterExpressions[] = Filter::matchAll( Filter::where('host', $service->getHost()->getName()), @@ -177,12 +152,6 @@ class Monitoring_ServicesController extends Controller Filter::where('downtime_service', $service->getName()) ); } - - ++$serviceStates['services_' . $service::getStateText($service->state) . ($unhandled ? '_unhandled' : '')]; - if (! isset($knownHostStates[$service->getHost()->getName()])) { - $knownHostStates[$service->getHost()->getName()] = true; - ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; - } } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -208,8 +177,7 @@ class Monitoring_ServicesController extends Controller ); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); - $this->view->hostStates = (object)$hostStates; - $this->view->serviceStates = (object)$serviceStates; + $this->view->stats = $this->serviceList->getStateSummary(); $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index f4ac40904..d56f92af4 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; - render('partials/host/objects-tinysummary.phtml') ?> + render('list/components/hostssummary.phtml') ?> render('partials/host/objects-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml deleted file mode 100644 index fa841c633..000000000 --- a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml +++ /dev/null @@ -1,44 +0,0 @@ - - -

- qlink( - sprintf($this->translate('%d Hosts Selected:'), count($objects)), - $listAllLink - ); ?> - - - hosts_up): ?> - - - - hosts_up ?> - - - - - 'down', - 2 => 'unreachable', - 99 => 'pending' - ) as $stateId => $state) { - - $stateName = 'hosts_' . $state; - $unhandledStateName = $stateName . '_unhandled'; - if ($hostStates->$unhandledStateName) { - echo '' . $hostStates->$unhandledStateName . ''; - } - if ($hostStates->$stateName) { - echo '' . $hostStates->$stateName . ''; - } - if ($hostStates->$unhandledStateName) { - echo ''; - } - $stateName .= '_unhandled'; - }?> - - -

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml deleted file mode 100644 index 7707651d2..000000000 --- a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml +++ /dev/null @@ -1,42 +0,0 @@ - - -

- qlink( - sprintf($this->translate('%d Services Selected:'), count($objects)), - $listAllLink - ); ?> - - - services_ok): ?> - - - services_ok ?> - - - - 'critical', - 3 => 'unknown', - 1 => 'warning', - 4 => 'pending' - ) as $stateId => $state) { - - $stateName = 'services_' . $state; - $unhandledStateName = $stateName . '_unhandled'; - if ($serviceStates->$unhandledStateName) { - echo '' . $serviceStates->$unhandledStateName . ''; - } - if ($serviceStates->$stateName) { - echo '' . $serviceStates->$stateName . ''; - } - if ($serviceStates->$unhandledStateName) { - echo ''; - } - $stateName .= '_unhandled'; - }?> - -

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 08e1737f3..1daa1a956 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; - render('partials/service/objects-tinysummary.phtml') ?> + render('list/components/servicesummary.phtml') ?> render('partials/service/objects-header.phtml'); ?>
diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index f0adced24..94157b6fc 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -25,4 +25,31 @@ class HostList extends ObjectList } return $hosts; } + + /** + * Create a state summary of all hosts that can be consumed by hostssummary.phtml + * + * @return object The summary + */ + public function getStateSummary() + { + $hostStates = $this->prepareStateNames('hosts_', array( + Host::getStateText(Host::STATE_UP), + Host::getStateText(Host::STATE_DOWN), + Host::getStateText(Host::STATE_UNREACHABLE), + Host::getStateText(Host::STATE_PENDING) + )); + + foreach ($this as $host) { + $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; + + $stateName = 'hosts_' . $host::getStateText($host->state); + ++$hostStates[$stateName]; + ++$hostStates[$stateName. ($unhandled ? '_unhandled' : '_handled')]; + } + + $hostStates['hosts_total'] = count($this); + + return (object)$hostStates; + } } diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 146499805..234ccb9bb 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -85,4 +85,15 @@ abstract class ObjectList implements Countable, IteratorAggregate { return $this->backend->select()->from('comment')->applyFilter($this->filter); } + + protected function prepareStateNames($prefix, array $names) { + $new = array(); + foreach ($names as $name) { + $new[$prefix . $name] = 0; + $new[$prefix . $name . '_handled'] = 0; + $new[$prefix . $name . '_unhandled'] = 0; + } + $new[$prefix . 'total'] = 0; + return $new; + } } diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index d9ffa0d8e..0625ae0f8 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -25,4 +25,46 @@ class ServiceList extends ObjectList } return $services; } + + /** + * Create a state summary of all services that can be consumed by servicesummary.phtml + * + * @return object The summary + */ + public function getStateSummary() + { + $serviceStates = $this->prepareStateNames('services_', array( + Service::getStateText(Service::STATE_OK), + Service::getStateText(Service::STATE_WARNING), + Service::getStateText(Service::STATE_CRITICAL), + Service::getStateText(Service::STATE_UNKNOWN), + Service::getStateText(Service::STATE_PENDING), + )); + + $hostStates = $this->prepareStateNames('hosts_', array( + Host::getStateText(Host::STATE_UP), + Host::getStateText(Host::STATE_DOWN), + Host::getStateText(Host::STATE_UNREACHABLE), + Host::getStateText(Host::STATE_PENDING), + )); + + foreach ($this as $service) { + $unhandled = false; + if ((bool) $service->problem === true && (bool) $service->handled === false) { + $unhandled = true; + } + + $stateName = 'services_' . $service::getStateText($service->state); + ++$serviceStates[$stateName]; + ++$serviceStates[$stateName . ($unhandled ? '_unhandled' : '_handled')]; + if (! isset($knownHostStates[$service->getHost()->getName()])) { + $knownHostStates[$service->getHost()->getName()] = true; + ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; + } + } + + $serviceStates['services_total'] = count($this); + + return (object)$serviceStates; + } } From 266e781a93d77473a0bc3c02a7cdcafb9df63d4b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 17:52:06 +0100 Subject: [PATCH 016/298] Deduplicate Hosts and Services-Controller Create functions in abstract class for filtering hosts and services, instead of reimplementing it in the controller. --- .../controllers/HostsController.php | 30 +++++--------- .../controllers/ServicesController.php | 41 ++++++++----------- .../library/Monitoring/Object/ObjectList.php | 33 +++++++++++++++ 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 55f8a6e60..ecbf6cf71 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -105,27 +105,19 @@ class Monitoring_HostsController extends Controller 'host_active_checks_enabled', 'host_obsessing'*/ )); - $unhandledObjects = array(); + $unhandledObjects = $this->hostList->getUnhandledObjects(); $unhandledFilterExpressions = array(); - $acknowledgedObjects = array(); - $objectsInDowntime = array(); - $downtimeFilterExpressions = array(); - - foreach ($this->hostList as $host) { - /** @var Host $host */ - $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; - if ($unhandled) { - $unhandledObjects[] = $host; - $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); - } - if ((bool) $host->acknowledged === true) { - $acknowledgedObjects[] = $host; - } - if ((bool) $host->in_downtime === true) { - $objectsInDowntime[] = $host; - $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); - } + foreach ($unhandledObjects as $object) { + $unhandledFilterExpressions[] = Filter::where('host', $object->getName()); } + + $objectsInDowntime = $this->hostList->getObjectsInDowntime(); + $downtimeFilterExpressions = array(); + foreach ($objectsInDowntime as $object) { + $downtimeFilterExpressions[] = Filter::where('downtime_host', $object->getName()); + } + + $acknowledgedObjects = $this->hostList->getAcknowledgedObjects(); if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index dcd95184c..691897a57 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -127,32 +127,25 @@ class Monitoring_ServicesController extends Controller 'service_active_checks_enabled', 'service_obsessing'*/ )); - $unhandledObjects = array(); + $unhandledObjects = $this->serviceList->getUnhandledObjects(); $unhandledFilterExpressions = array(); - $acknowledgedObjects = array(); - $objectsInDowntime = array(); - $downtimeFilterExpressions = array(); - - foreach ($this->serviceList as $service) { - /** @var Service $service */ - if ((bool) $service->problem === true && (bool) $service->handled === false) { - $unhandledObjects[] = $service; - $unhandledFilterExpressions[] = Filter::matchAll( - Filter::where('host', $service->getHost()->getName()), - Filter::where('service', $service->getName()) - ); - } - if ((bool) $service->acknowledged === true) { - $acknowledgedObjects[] = $service; - } - if ((bool) $service->in_downtime === true) { - $objectsInDowntime[] = $service; - $downtimeFilterExpressions[] = Filter::matchAll( - Filter::where('downtime_host', $service->getHost()->getName()), - Filter::where('downtime_service', $service->getName()) - ); - } + foreach ($unhandledObjects as $service) { + $unhandledFilterExpressions[] = Filter::matchAll( + Filter::where('host', $service->getHost()->getName()), + Filter::where('service', $service->getName()) + ); } + + $objectsInDowntime = $this->serviceList->getObjectsInDowntime(); + $downtimeFilterExpressions = array(); + foreach ($objectsInDowntime as $service) { + $downtimeFilterExpressions[] = Filter::matchAll( + Filter::where('downtime_host', $service->getHost()->getName()), + Filter::where('downtime_service', $service->getName()) + ); + } + + $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects(); if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 234ccb9bb..f28dded91 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -86,6 +86,39 @@ abstract class ObjectList implements Countable, IteratorAggregate return $this->backend->select()->from('comment')->applyFilter($this->filter); } + public function getAcknowledgedObjects() + { + $acknowledgedObjects = array(); + foreach ($this as $object) { + if ((bool) $object->acknowledged === true) { + $acknowledgedObjects[] = $object; + } + } + return $acknowledgedObjects; + } + + public function getObjectsInDowntime() + { + $objectsInDowntime = array(); + foreach ($this as $object) { + if ((bool) $object->in_downtime === true) { + $objectsInDowntime[] = $object; + } + } + return $objectsInDowntime; + } + + public function getUnhandledObjects() + { + $unhandledObjects = array(); + foreach ($this as $object) { + if ((bool) $object->problem === true && (bool) $object->handled === false) { + $unhandledObjects[] = $object; + } + } + return $unhandledObjects; + } + protected function prepareStateNames($prefix, array $names) { $new = array(); foreach ($names as $name) { From 95a83a41bd80a1b41aa94cb4b8b200f0eadb38ba Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 18:03:56 +0100 Subject: [PATCH 017/298] Provide a link back to all selected objects in multi-views refs #8565 --- .../monitoring/application/controllers/HostsController.php | 3 ++- .../views/scripts/partials/host/objects-header.phtml | 7 ++++++- .../views/scripts/partials/service/objects-header.phtml | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ecbf6cf71..b8e36e2b0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -39,6 +39,7 @@ class Monitoring_HostsController extends Controller 'icon' => 'host' ) )->activate('show'); + $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); } protected function handleCommandForm(ObjectsCommandForm $form) @@ -125,8 +126,8 @@ class Monitoring_HostsController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + $this->setAutorefreshInterval(15); - $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index d535f367e..322243be1 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -72,7 +72,12 @@ $hiddenRich = array();
- translate('%d more ...'), count($hidden)) ?> + + qlink( + sprintf($this->translate('%d more ...'), count($hidden)), + $listAllLink, + null + ) ?>
diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index dd206a646..5580446a1 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -74,7 +74,12 @@ use Icinga\Module\Monitoring\Object\Service;
- translate('%d more ...'), count($hidden)) ?> + + qlink( + sprintf($this->translate('%d more ...'), count($hidden)), + $listAllLink, + null + ) ?>
From b0b0ae157c344ec9f1bdfbc5efe9e14896608500 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 31 Mar 2015 16:29:33 +0200 Subject: [PATCH 018/298] Turn prepareStateName into more generic string utility function refs #8565 --- library/Icinga/Util/String.php | 41 +++++++++++++++++++ .../library/Monitoring/Object/HostList.php | 32 +++++++++++---- .../library/Monitoring/Object/ObjectList.php | 11 ----- .../library/Monitoring/Object/ServiceList.php | 41 ++++++++++++------- 4 files changed, 93 insertions(+), 32 deletions(-) diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index 9fb3cb223..d9bd5a6d3 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -79,4 +79,45 @@ class String return $matches; } + + /** + * Generates an array of strings that constitutes the cartesian product of all passed sets, with all + * string combinations concatenated using the passed join-operator. + * + *
+     *  cartesianProduct(
+     *      array(array('foo', 'bar'), array('mumble', 'grumble', null)),
+     *      '_'
+     *  );
+     *     => array('foo_mumble', 'foo_grumble', 'bar_mumble', 'bar_grumble', 'foo', 'bar')
+     * 
+ * + * @param array $sets An array of arrays containing all sets for which the cartesian + * product should be calculated. + * @param string $glue The glue used to join the strings, defaults to ''. + * + * @returns array The cartesian product in one array of strings. + */ + public static function cartesianProduct(array $sets, $glue = '') + { + $product = null; + foreach ($sets as $set) { + if (! isset($product)) { + $product = $set; + } else { + $newProduct = array(); + foreach ($product as $strA) { + foreach ($set as $strB) { + if ($strB === null) { + $newProduct []= $strA; + } else { + $newProduct []= $strA . $glue . $strB; + } + } + } + $product = $newProduct; + } + } + return $product; + } } diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index 94157b6fc..b5235eb75 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -3,6 +3,8 @@ namespace Icinga\Module\Monitoring\Object; +use Icinga\Util\String; + /** * A host list */ @@ -33,13 +35,7 @@ class HostList extends ObjectList */ public function getStateSummary() { - $hostStates = $this->prepareStateNames('hosts_', array( - Host::getStateText(Host::STATE_UP), - Host::getStateText(Host::STATE_DOWN), - Host::getStateText(Host::STATE_UNREACHABLE), - Host::getStateText(Host::STATE_PENDING) - )); - + $hostStates = array_fill_keys(self::getHostStatesSummaryEmpty(), 0); foreach ($this as $host) { $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; @@ -52,4 +48,26 @@ class HostList extends ObjectList return (object)$hostStates; } + + /** + * Return an empty array with all possible host state names + * + * @return array An array containing all possible host states as keys and 0 as values. + */ + public static function getHostStatesSummaryEmpty() + { + return String::cartesianProduct( + array( + array('hosts'), + array( + Host::getStateText(Host::STATE_UP), + Host::getStateText(Host::STATE_DOWN), + Host::getStateText(Host::STATE_UNREACHABLE), + Host::getStateText(Host::STATE_PENDING) + ), + array(null, 'handled', 'unhandled') + ), + '_' + ); + } } diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index f28dded91..62a15173c 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -118,15 +118,4 @@ abstract class ObjectList implements Countable, IteratorAggregate } return $unhandledObjects; } - - protected function prepareStateNames($prefix, array $names) { - $new = array(); - foreach ($names as $name) { - $new[$prefix . $name] = 0; - $new[$prefix . $name . '_handled'] = 0; - $new[$prefix . $name . '_unhandled'] = 0; - } - $new[$prefix . 'total'] = 0; - return $new; - } } diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index 0625ae0f8..861075004 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -3,6 +3,8 @@ namespace Icinga\Module\Monitoring\Object; +use Icinga\Util\String; + /** * A service list */ @@ -33,20 +35,8 @@ class ServiceList extends ObjectList */ public function getStateSummary() { - $serviceStates = $this->prepareStateNames('services_', array( - Service::getStateText(Service::STATE_OK), - Service::getStateText(Service::STATE_WARNING), - Service::getStateText(Service::STATE_CRITICAL), - Service::getStateText(Service::STATE_UNKNOWN), - Service::getStateText(Service::STATE_PENDING), - )); - - $hostStates = $this->prepareStateNames('hosts_', array( - Host::getStateText(Host::STATE_UP), - Host::getStateText(Host::STATE_DOWN), - Host::getStateText(Host::STATE_UNREACHABLE), - Host::getStateText(Host::STATE_PENDING), - )); + $serviceStates = array_fill_keys(self::getServiceStatesSummaryEmpty(), 0); + $hostStates = array_fill_keys(HostList::getHostStatesSummaryEmpty(), 0); foreach ($this as $service) { $unhandled = false; @@ -67,4 +57,27 @@ class ServiceList extends ObjectList return (object)$serviceStates; } + + /** + * Return an empty array with all possible host state names + * + * @return array An array containing all possible host states as keys and 0 as values. + */ + public static function getServiceStatesSummaryEmpty() + { + return String::cartesianProduct( + array( + array('services'), + array( + Service::getStateText(Service::STATE_OK), + Service::getStateText(Service::STATE_WARNING), + Service::getStateText(Service::STATE_CRITICAL), + Service::getStateText(Service::STATE_UNKNOWN), + Service::getStateText(Service::STATE_PENDING) + ), + array(null, 'handled', 'unhandled') + ), + '_' + ); + } } From 9fbd7822d05c794331b1c6ce8a3788e8c94fa4e9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 31 Mar 2015 17:41:57 +0200 Subject: [PATCH 019/298] Fix coding guideline violations --- library/Icinga/Web/Widget/FilterEditor.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 8bcb9aa60..cfe43351d 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -405,10 +405,10 @@ class FilterEditor extends AbstractWidget if ($this->addTo && $this->addTo === $filter->getId()) { return preg_replace( - '/ class="autosubmit"/', - ' class="autofocus"', - $this->selectOperator() - ) + '/ class="autosubmit"/', + ' class="autofocus"', + $this->selectOperator() + ) . '
  • ' . $this->selectColumn($filter) . $this->selectSign($filter) @@ -655,7 +655,7 @@ class FilterEditor extends AbstractWidget . t('Search...') . '" />'; - if ($this->filter->isEmpty()) { + if ($this->filter->isEmpty()) { $title = t('Filter this list'); } else { $title = t('Modify this filter'); From 5619ac960c47611c34075ee03b5506ebd00a016d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 2 Apr 2015 16:25:20 +0200 Subject: [PATCH 020/298] Add inline pies to host and service back to multi-select views Add old inline pie code and visualize handled/unhandled state. refs #8565 --- library/Icinga/Util/String.php | 14 +++++ library/Icinga/Web/Widget/Chart/InlinePie.php | 56 +++++++++++++++++++ .../controllers/HostsController.php | 10 +++- .../controllers/ServicesController.php | 21 ++++++- .../views/scripts/hosts/show.phtml | 7 +++ .../partials/host/objects-header.phtml | 8 --- .../partials/service/objects-header.phtml | 9 --- .../views/scripts/services/show.phtml | 10 ++++ .../library/Monitoring/Object/ServiceList.php | 41 ++++++++++++-- 9 files changed, 153 insertions(+), 23 deletions(-) diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index d9bd5a6d3..0d42d0e76 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -80,6 +80,20 @@ class String return $matches; } + /** + * Check if a string ends with a different string + * + * @param $haystack The string to search for matches + * @param $needle The string to match at the start of the haystack + * + * @return bool Whether or not needle is at the beginning of haystack + */ + public static function endsWith($haystack, $needle) + { + return $needle === '' || + (($temp = strlen($haystack) - strlen($needle)) >= 0 && false !== strpos($haystack, $needle, $temp)); + } + /** * Generates an array of strings that constitutes the cartesian product of all passed sets, with all * string combinations concatenated using the passed join-operator. diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 0bddc906d..70aadf666 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -5,11 +5,13 @@ namespace Icinga\Web\Widget\Chart; use Icinga\Chart\PieChart; use Icinga\Module\Monitoring\Plugin\PerfdataSet; +use Icinga\Util\String; use Icinga\Web\Widget\AbstractWidget; use Icinga\Web\Url; use Icinga\Util\Format; use Icinga\Application\Logger; use Icinga\Exception\IcingaException; +use stdClass; /** * A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the @@ -27,6 +29,45 @@ class InlinePie extends AbstractWidget const NUMBER_FORMAT_BYTES = 'bytes'; const NUMBER_FORMAT_RATIO = 'ratio'; + public static $colorsHostStates = array( + '#44bb77', // up + '#ff99aa', // down + '#cc77ff', // unreachable + '#77aaff' // pending + ); + + public static $colorsHostStatesHandledUnhandled = array( + '#44bb77', // up + '#44bb77', + '#ff99aa', // down + '#ff5566', + '#cc77ff', // unreachable + '#aa44ff', + '#77aaff', // pending + '#77aaff' + ); + + public static $colorsServiceStates = array( + '#44bb77', // Ok + '#ffaa44', // Warning + '#ff99aa', // Critical + '#aa44ff', // Unknown + '#77aaff' // Pending + ); + + public static $colorsServiceStatesHandleUnhandled = array( + '#44bb77', // Ok + '#44bb77', + '#ffaa44', // Warning + '#ffcc66', + '#ff99aa', // Critical + '#ff5566', + '#cc77ff', // Unknown + '#aa44ff', + '#77aaff', // Pending + '#77aaff' + ); + /** * The template string used for rendering this widget * @@ -231,4 +272,19 @@ EOD; $template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template); return $template; } + + public static function createFromStateSummary(stdClass $states, $title, array $colors) + { + $handledUnhandledStates = array(); + foreach ($states as $key => $value) { + if (String::endsWith($key, '_handled') || String::endsWith($key, '_unhandled')) { + $handledUnhandledStates[$key] = $value; + } + } + $chart = new self(array_values($handledUnhandledStates), $title, $colors); + return $chart + ->setSize(50) + ->setTitle('') + ->setSparklineClass('sparkline-multi'); + } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index b8e36e2b0..3c59f4643 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -14,6 +14,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; +use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_HostsController extends Controller { @@ -127,13 +128,20 @@ class Monitoring_HostsController extends Controller $this->view->removeAckForm = $removeAckForm; } + $hostStates = (object)$this->hostList->getStateSummary(); + $this->view->hostStatesPieChart = InlinePie::createFromStateSummary( + $hostStates, + $this->translate('Host State'), + InlinePie::$colorsHostStatesHandledUnhandled + ); + $this->setAutorefreshInterval(15); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->stats = (object)$this->hostList->getStateSummary(); + $this->view->stats = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 691897a57..e7199ed26 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -15,7 +15,9 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; +use Icinga\Util\String; use Icinga\Web\Url; +use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_ServicesController extends Controller { @@ -109,6 +111,8 @@ class Monitoring_ServicesController extends Controller 'host_name', 'host_output', 'host_state', + 'host_problem', + 'host_handled', 'service_output', 'service_description', 'service_state', @@ -153,6 +157,20 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + + $serviceStates = $this->serviceList->getServiceStateSummary(); + $this->view->serviceStatesPieChart = InlinePie::createFromStateSummary( + $serviceStates, + $this->translate('Service State'), + InlinePie::$colorsServiceStatesHandleUnhandled + ); + + $hostStates = $this->serviceList->getHostStateSummary(); + $this->view->hostStatesPieChart = InlinePie::createFromStateSummary( + $hostStates, + $this->translate('Host State'), + InlinePie::$colorsHostStatesHandledUnhandled + ); /* if (! empty($objectsInDowntime)) { $removeDowntimeForm = new DeleteDowntimeCommandForm(); @@ -170,7 +188,8 @@ class Monitoring_ServicesController extends Controller ); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); - $this->view->stats = $this->serviceList->getStateSummary(); + $this->view->stats = $serviceStates; + $this->view->hostStats = $hostStates; $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index d56f92af4..ab92a2f04 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -9,6 +9,13 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; render('list/components/hostssummary.phtml') ?> + +
    +
    + translate('Host States:') ?> +   +
    + render('partials/host/objects-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 322243be1..d2ce6a500 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -12,14 +12,6 @@ $hiddenRich = array();

- - - - - - - - diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 5580446a1..24524954c 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -10,15 +10,6 @@ use Icinga\Module\Monitoring\Object\Service; 0): ?>

icon('host'); ?> translate('Host'); ?>icon('paste'); ?> translate('Plugin Output'); ?>
- - - - - - - - - render('list/components/servicesummary.phtml') ?> +
+
+ translate('Service States:') ?> +   +
+
+ translate('Host States:') ?> +   +
+ render('partials/service/objects-header.phtml'); ?> diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index 861075004..4d0e053d7 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -10,6 +10,10 @@ use Icinga\Util\String; */ class ServiceList extends ObjectList { + protected $hostStateSummary; + + protected $serviceStateSummary; + protected $dataViewName = 'serviceStatus'; protected $columns = array('host_name', 'service_description'); @@ -33,7 +37,32 @@ class ServiceList extends ObjectList * * @return object The summary */ - public function getStateSummary() + public function getServiceStateSummary() + { + if (! $this->serviceStateSummary) { + $this->initStateSummaries(); + } + return (object)$this->serviceStateSummary; + } + + /** + * Create a state summary of all hosts that can be consumed by hostsummary.phtml + * + * @return object The summary + */ + public function getHostStateSummary() + { + if (! $this->hostStateSummary) { + $this->initStateSummaries(); + } + return (object)$this->hostStateSummary; + } + + /** + * Calculate the current state summary and populate hostStateSummary and serviceStateSummary + * properties + */ + protected function initStateSummaries() { $serviceStates = array_fill_keys(self::getServiceStatesSummaryEmpty(), 0); $hostStates = array_fill_keys(HostList::getHostStatesSummaryEmpty(), 0); @@ -47,15 +76,19 @@ class ServiceList extends ObjectList $stateName = 'services_' . $service::getStateText($service->state); ++$serviceStates[$stateName]; ++$serviceStates[$stateName . ($unhandled ? '_unhandled' : '_handled')]; + if (! isset($knownHostStates[$service->getHost()->getName()])) { - $knownHostStates[$service->getHost()->getName()] = true; + $unhandledHost = (bool) $service->host_problem === true && (bool) $service->host_handled === false; ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; + ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state) + . ($unhandledHost ? '_unhandled' : '_handled')]; + $knownHostStates[$service->getHost()->getName()] = true; } } $serviceStates['services_total'] = count($this); - - return (object)$serviceStates; + $this->hostStateSummary = $hostStates; + $this->serviceStateSummary = $serviceStates; } /** From 45a0982bebb411ed8a202696965c1438b5948c2c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 2 Apr 2015 16:44:05 +0200 Subject: [PATCH 021/298] Add new tab to switch between host and service multi-selection refs #8565 --- .../controllers/HostsController.php | 20 ++++++++++++++++++- .../controllers/ServicesController.php | 13 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 3c59f4643..632ca69ec 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -25,9 +25,14 @@ class Monitoring_HostsController extends Controller public function init() { + // Support switching from service-view using the host and service selection. The filter would error + // on any occurrence of a filter based on service. + $filterString = preg_replace('/(service=[^)&]*)/', '', (string)$this->params); + $hostList = new HostList($this->backend); - $hostList->setFilter(Filter::fromQueryString((string) $this->params)); + $hostList->setFilter(Filter::fromQueryString($filterString)); $this->hostList = $hostList; + $this->getTabs()->add( 'show', array( @@ -40,6 +45,19 @@ class Monitoring_HostsController extends Controller 'icon' => 'host' ) )->activate('show'); + + $this->getTabs()->add( + 'services', + array( + 'title' => sprintf( + $this->translate('Show summarized information for related services') + ), + 'label' => $this->translate('Services'), + 'url' => Url::fromPath('monitoring/services/show')->setParams(Url::fromRequest()->getParams()), + 'icon' => 'services' + ) + )->activate('show'); + $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index e7199ed26..91da11968 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -32,6 +32,19 @@ class Monitoring_ServicesController extends Controller $serviceList->setFilter(Filter::fromQueryString((string) $this->params->without('service_problem', 'service_handled'))); $this->serviceList = $serviceList; $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services'); + + $this->getTabs()->add( + 'hosts', + array( + 'title' => sprintf( + $this->translate('Show summarized information for hosts') + ), + 'label' => $this->translate('Hosts'), + 'url' => Url::fromPath('monitoring/hosts/show')->setParams(Url::fromRequest()->getParams()), + 'icon' => 'host' + ) + )->activate('show'); + $this->getTabs()->add( 'show', array( From 6c0f9cf6f55ac382c98c0a0d6ec3b68fb1d8b82e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 2 Apr 2015 16:51:09 +0200 Subject: [PATCH 022/298] Remove comment lists from multi-select views. refs #8565 --- .../controllers/HostsController.php | 3 +- .../views/scripts/hosts/show.phtml | 33 ------------------- .../views/scripts/services/show.phtml | 33 ------------------- 3 files changed, 1 insertion(+), 68 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 632ca69ec..53b10e113 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -171,8 +171,7 @@ class Monitoring_HostsController extends Controller $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); - $this->view->commentsLink = Url::fromRequest() - ->setPath('monitoring/list/comments'); + $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments'); } /** diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index ab92a2f04..cc62ba0f8 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,7 +1,3 @@ - -
compact): ?> @@ -183,35 +179,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

-
icon('service'); ?> translate('Service'); ?>icon('host'); ?> translate('Host'); ?>icon('paste'); ?> translate('Plugin Output'); ?>
- - fetchComments(); ?> - comments as $comment): ?> - - - - - - -
- populate( - array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) - ); - $delCommentForm->setAction( - $this->url( - 'monitoring/host/delete-comment', - array('host' => $service->getName()) - ) - ); - echo $delCommentForm; - ?> - (type) ?>): - - comment) ?> -
- @@ -94,7 +62,7 @@ if ($hosts->count() === 0) { host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> icon($this->resolveMacros($host->host_icon_image, $host)) ?> - + hostFlags($host)) ?> qlink( $host->host_display_name, $hostLink, diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 636303b6e..7f62904f2 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -66,39 +66,7 @@ foreach ($services as $service):

perfdata($service->service_perfdata, true, 8) ?>
- service_handled && $service->service_state > 0): ?> - icon('attention-alt', $this->translate('Unhandled')) ?> - - - service_acknowledged && !$service->service_in_downtime): ?> - icon('ok', $this->translate('Acknowledged') . ( - $service->service_last_ack ? ': ' . $service->service_last_ack : '' - )) ?> - - - service_is_flapping): ?> - icon('flapping', $this->translate('Flapping')) ?> - - - service_notifications_enabled): ?> - icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> - - - service_in_downtime): ?> - icon('plug', $this->translate('In Downtime')) ?> - - - service_last_comment) && $service->service_last_comment !== null): ?> - icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> - - - service_active_checks_enabled): ?> - service_passive_checks_enabled): ?> - icon('eye-off', $this->translate('Active And Passive Checks Disabled')) ?> - - icon('eye-off', $this->translate('Active Checks Disabled')) ?> - - + serviceFlags($service)); ?> service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> icon($this->resolveMacros($service->service_icon_image, $service)) ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index f6ea43d84..d47bd59e3 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -15,7 +15,7 @@ $hiddenRich = array(); 0): ?> -

+

@@ -23,71 +23,30 @@ $hiddenRich = array(); 5) { - $desc = $host->getName(); - $hidden[] = $desc; - $hiddenRich[] = sprintf("
%s", $host->getStateText($host->host_state) ,$desc); continue; } ?> - + - - - - - - +
host_state, true); ?>
- host_handled && $host->host_state > 0): ?> - icon('attention-alt', $this->translate('Unhandled')) ?> - - - host_acknowledged && !$host->host_in_downtime): ?> - icon('ok', $this->translate('Acknowledged') . ( - $host->host_last_ack ? ': ' . $host->host_last_ack : '' - )) ?> - - - host_is_flapping): ?> - icon('flapping', $this->translate('Flapping')) ?> - - - host_notifications_enabled): ?> - icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> - - - host_in_downtime): ?> - icon('plug', $this->translate('In Downtime')) ?> - - - host_last_comment) && $host->host_last_comment !== null): ?> - icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?> - - hostFlags($host)) ?> escape($host->getName()); ?> escape($host->host_output) ?>
-
- title=""> - qlink( - count($hidden) ? sprintf( - $this->translate('%d more ...'), - count($hidden) - ) : $this->translate('list all ...'), - $listAllLink, - null, - array('data-base-target' => '_next') - ); - ?> -
-
-

- +
+ qlink( + sprintf($this->translate('list all %d hosts ...'), $i), + $listAllLink, + null, + array('data-base-target' => '_next') + ); + ?> +
+

diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 3880e4473..e80fe2c0b 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -22,77 +22,29 @@ use Icinga\Module\Monitoring\Object\Service; 5 && $i < 20) { - $desc = $service->getName() . ' on ' . $service->getHost()->getName(); - $hidden[] = $desc; - $hiddenRich[] = sprintf("
%s", $service->getStateText($service->service_state) ,$desc); - } - if ($i == 20) { - $hiddenRich[] = '...'; - } - if ($i > 5) { + if ($i ++ > 5) { continue; } ?> - service_state, true); ?>
- - service_handled && $service->service_state > 0): ?> - icon('attention-alt', $this->translate('Unhandled')) ?> - - - service_acknowledged && !$service->service_in_downtime): ?> - icon('ok', $this->translate('Acknowledged') . ( - $service->service_last_ack ? ': ' . $service->service_last_ack : '' - )) ?> - - - service_is_flapping): ?> - icon('flapping', $this->translate('Flapping')) ?> - - - service_notifications_enabled): ?> - icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> - - - service_in_downtime): ?> - icon('plug', $this->translate('In Downtime')) ?> - - - service_last_comment) && $service->service_last_comment !== null): ?> - icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> - - + serviceFlags($service)) ?> escape($service->getName()); ?> escape($service->getHost()->getName()); ?> escape($service->service_output) ?> - - - -
- title=""> - - qlink( - count($hidden) ? sprintf( - $this->translate('%d more ...'), - count($hidden) - ) : $this->translate('list all ...'), - $listAllLink, - null, - array('data-base-target' => '_next') - ); - ?> -
- - - +
+ qlink( + sprintf($this->translate('List all %d services ...'), $i), + $listAllLink, + null, + array('data-base-target' => '_next') + ); + ?> +

From f4c69395b182a05f049e0cc8fcac1645a146b749 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 9 Apr 2015 17:15:26 +0200 Subject: [PATCH 035/298] Add missing database columns refs #8565 --- .../monitoring/application/controllers/HostsController.php | 4 +++- .../monitoring/application/controllers/ServicesController.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 293e0fd66..b20f8b13c 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -74,7 +74,9 @@ class Monitoring_HostsController extends Controller 'host_is_flapping', 'host_last_comment', 'host_output', - 'host_notifications_enabled' + 'host_notifications_enabled', + 'host_active_checks_enabled', + 'host_passive_checks_enabled' )); $form diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 68ff7f2e8..edee89878 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -75,10 +75,10 @@ class Monitoring_ServicesController extends Controller 'service_acknowledged', 'service_in_downtime', 'service_is_flapping', - 'service_notifications_enabled', 'service_output', 'service_last_ack', 'service_last_comment', + 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled' )); @@ -129,9 +129,9 @@ class Monitoring_ServicesController extends Controller 'service_acknowledged', 'service_in_downtime', 'service_is_flapping', - 'service_notifications_enabled', 'service_last_comment', 'service_last_ack', + 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled' /* From 2efea214da9f6b86571d46f9d96d609f894e0901 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 9 Apr 2015 17:16:14 +0200 Subject: [PATCH 036/298] Don't display piecharts for empty host and service sets refs #8565 --- .../partials/host/objects-header.phtml | 14 ++++------- .../partials/service/objects-header.phtml | 23 ++++++++----------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index d47bd59e3..95e595ac1 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,20 +1,14 @@ - -
- translate('States:') ?> -   -
- 0): ?> - +
+ translate('States:') ?> +   +

diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index e80fe2c0b..e0b330ece 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,22 +1,17 @@ -
- translate('Service states:') ?> -   -
-
- translate('Host states:') ?> -   -
- - 0): ?> +
+ translate('Service states:') ?> +   +
+
+ translate('Host states:') ?> +   +

From be05d3a73ae55aaf26d03033946496e4b00895fd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Apr 2015 13:23:34 +0200 Subject: [PATCH 037/298] Fix dashboard header handling refs #7876 --- public/js/icinga/loader.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 1c674b947..e63125a4d 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -760,12 +760,8 @@ // $container.html(content); } else { - if ($container.closest('.dashboard').length - ) { - if (! $('h1', $content).length) { - var title = $('h1', $container).first().detach(); - $('h1', $content).first().detach(); - } + if ($container.closest('.dashboard').length) { + var title = $('h1', $container).first().detach(); $container.html(title).append(content); } else if (action === 'replace') { $container.html(content); From ed2de3c4d04886e5af21ba0f828da2bb4dc0d40c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Apr 2015 14:20:36 +0200 Subject: [PATCH 038/298] Fix SortBox widget refs #7876 --- library/Icinga/Web/Controller.php | 8 +- library/Icinga/Web/StyleSheet.php | 3 +- library/Icinga/Web/Widget/SortBox.php | 127 +++++++++++--------------- public/css/icinga/controls.less | 18 ++++ 4 files changed, 78 insertions(+), 78 deletions(-) create mode 100644 public/css/icinga/controls.less diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index e7a1d51f5..da9486b9e 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -14,15 +14,15 @@ use Icinga\Web\Widget\SortBox; class Controller extends ModuleActionController { /** - * Create a sort control box at the 'sortControl' view parameter + * Create a SortBox widget at the `sortBox' view property * - * @param array $columns An array containing the sort columns, with the - * submit value as the key and the label as the value + * @param array $columns An array containing the sort columns, with the + * submit value as the key and the label as the value */ protected function setupSortControl(array $columns) { $req = $this->getRequest(); - $this->view->sortControl = SortBox::create( + $this->view->sortBox = SortBox::create( 'sortbox-' . $req->getActionName(), $columns )->applyRequest($req); diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 3f1e2b2a7..ab36d78c5 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -26,7 +26,8 @@ class StyleSheet 'css/icinga/pagination.less', 'css/icinga/monitoring-colors.less', 'css/icinga/selection-toolbar.less', - 'css/icinga/login.less' + 'css/icinga/login.less', + 'css/icinga/controls.less' ); public static function compileForPdf() diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index be96b614e..fc2025e5b 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -3,64 +3,57 @@ namespace Icinga\Web\Widget; -use Zend_Form_Element_Submit; use Icinga\Web\Form; use Icinga\Web\Request; -use Icinga\Web\Form\Decorator\ConditionalHidden; /** - * Sortbox widget + * SortBox widget * - * The "SortBox" Widget allows you to create a generic sort input for sortable views. - * It automatically creates a form containing a select box with all sort options and a - * dropbox with the sort direction. It also handles automatic submission of sorting changes and draws an additional - * submit button when JavaScript is disabled. + * The "SortBox" Widget allows you to create a generic sort input for sortable views. It automatically creates a form + * containing a select box with all sort options and a dropbox with the sort direction. It also handles automatic + * submission of sorting changes and draws an additional submit button when JavaScript is disabled. * - * The constructor takes an string for the component name ad an array containing the select options, where the key is - * the value to be submitted and the value is the label that will be shown. You then should call applyRequest in order - * to make sure the form is correctly populated when a request with a sort parameter is being made. + * The constructor takes an string for the component name and an array containing the select options, where the key is + * the value to be submitted and the value is the label that will be shown. You then should call applyRequest in order + * to make sure the form is correctly populated when a request with a sort parameter is being made. * - * Example: - *

+ * Example:
+ *  

  *      $this->view->sortControl = new SortBox(
- *      $this->getRequest()->getActionName(),
+ *          $this->getRequest()->getActionName(),
  *          $columns
  *      );
  *      $this->view->sortControl->applyRequest($this->getRequest());
- *      
- * By default the sortBox uses the GET parameter 'sort' for the sorting key and 'dir' for the sorting direction - * + *
*/ class SortBox extends AbstractWidget { - /** * An array containing all sort columns with their associated labels * * @var array */ - private $sortFields; + protected $sortFields; /** * The name of the form that will be created * * @var string */ - private $name; + protected $name; /** * A request object used for initial form population * - * @var \Icinga\Web\Request + * @var Request */ - private $request; + protected $request; /** * Create a SortBox with the entries from $sortFields * - * @param string $name The name of the sort form - * @param array $sortFields An array containing the columns and their labels to be displayed - * in the sort select box + * @param string $name The name for the SortBox + * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox */ public function __construct($name, array $sortFields) { @@ -69,13 +62,12 @@ class SortBox extends AbstractWidget } /** - * Create a SortBox with the entries from $sortFields + * Create a SortBox * - * @param string $name The name of the sort form - * @param array $sortFields An array containing the columns and their labels to be displayed - * in the sort select box + * @param string $name The name for the SortBox + * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox * - * @return static + * @return SortBox */ public static function create($name, array $sortFields) { @@ -85,9 +77,9 @@ class SortBox extends AbstractWidget /** * Apply the parameters from the given request on this SortBox * - * @param Request $request The request to use for populating the form + * @param Request $request The request to use for populating the form * - * @return $this + * @return $this */ public function applyRequest($request) { @@ -96,60 +88,49 @@ class SortBox extends AbstractWidget } /** - * Create a submit button that is hidden via the ConditionalDecorator - * in order to allow sorting changes to be submitted in a JavaScript-less environment - * - * @return Zend_Form_Element_Submit The submit button that is hidden by default - * @see ConditionalDecorator - */ - private function createFallbackSubmitButton() - { - $manualSubmitButton = new Zend_Form_Element_Submit( - array( - 'name' => 'submit_' . $this->name, - 'label' => 'Sort', - 'class' => '', - 'condition' => 0, - 'value' => '{{SUBMIT_ICON}}' - ) - ); - $manualSubmitButton->addDecorator(new ConditionalHidden()); - $manualSubmitButton->setAttrib('addLabelPlaceholder', true); - return $manualSubmitButton; - } - - /** - * Renders this widget via the given view and returns the - * HTML as a string + * Render this SortBox as HTML * * @return string */ public function render() { $form = new Form(); - $form->setAttrib('class', 'inline'); - $form->setMethod('POST'); $form->setTokenDisabled(); $form->setName($this->name); - $form->addElement('select', 'sort', array( - 'label' => 'Sort By', - 'multiOptions' => $this->sortFields, - 'style' => 'width: 12em', - 'autosubmit' => true + $form->setAttrib('class', 'sort-control inline'); + + $form->addElement( + 'select', + 'sort', + array( + 'autosubmit' => true, + 'label' => $this->view()->translate('Sort by'), + 'multiOptions' => $this->sortFields + ) + ); + $form->getElement('sort')->setDecorators(array( + array('ViewHelper'), + array('Label') )); - $form->addElement('select', 'dir', array( - 'multiOptions' => array( - 'asc' => 'Asc', - 'desc' => 'Desc', - ), - 'style' => 'width: 5em', - 'autosubmit' => true - )); - $sort = $form->getElement('sort')->setDecorators(array('ViewHelper')); - $dir = $form->getElement('dir')->setDecorators(array('ViewHelper')); + $form->addElement( + 'select', + 'dir', + array( + 'autosubmit' => true, + 'multiOptions' => array( + 'asc' => 'Asc', + 'desc' => 'Desc', + ), + 'decorators' => array( + array('ViewHelper') + ) + ) + ); + if ($this->request) { $form->populate($this->request->getParams()); } + return $form; } } diff --git a/public/css/icinga/controls.less b/public/css/icinga/controls.less new file mode 100644 index 000000000..9445beb46 --- /dev/null +++ b/public/css/icinga/controls.less @@ -0,0 +1,18 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +form.sort-control { + label { + width: auto; + margin-right: 0.5em; + } + + select[name=sort] { + width: 12em; + margin-left: 0; + } + + select[name=dir] { + width: 5em; + margin-left: 0; + } +} From 17262ae2bd46f75416c386dcd63280b7516a7c5a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Apr 2015 14:21:27 +0200 Subject: [PATCH 039/298] Make the sort control floating at the right by default refs #7876 --- public/css/icinga/controls.less | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/css/icinga/controls.less b/public/css/icinga/controls.less index 9445beb46..73e78b3e9 100644 --- a/public/css/icinga/controls.less +++ b/public/css/icinga/controls.less @@ -1,6 +1,8 @@ /*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ form.sort-control { + float: right; + label { width: auto; margin-right: 0.5em; From 5e92171ab7fd317531080687a6ec7efa3d3d1b0c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Apr 2015 15:15:03 +0200 Subject: [PATCH 040/298] Drop the `inline' view property, as it's not used anywhere --- .../monitoring/application/controllers/ListController.php | 4 ---- .../application/views/scripts/alertsummary/index.phtml | 6 ++---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b4167f83d..e1726a68d 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -22,10 +22,6 @@ class Monitoring_ListController extends Controller { $this->createTabs(); $this->view->compact = $this->_request->getParam('view') === 'compact'; - if ($this->_request->getParam('view') === 'inline') { - $this->view->compact = true; - $this->view->inline = true; - } } /** diff --git a/modules/monitoring/application/views/scripts/alertsummary/index.phtml b/modules/monitoring/application/views/scripts/alertsummary/index.phtml index dbfff6433..8bb36b518 100644 --- a/modules/monitoring/application/views/scripts/alertsummary/index.phtml +++ b/modules/monitoring/application/views/scripts/alertsummary/index.phtml @@ -59,8 +59,7 @@
partial('list/notifications.phtml', array( 'notifications' => $this->recentAlerts, - 'compact' => true, - 'inline' => true + 'compact' => true )); ?>
@@ -71,8 +70,7 @@
partial('list/notifications.phtml', array( 'notifications' => $this->notifications, - 'compact' => true, - 'inline' => true + 'compact' => true )); ?>
From 32e8b606b4384073fa9d3256d1c514376d35be53 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Apr 2015 15:17:59 +0200 Subject: [PATCH 041/298] Monitoring\Controller: Drop `compactView' property, as it's not used anywere --- .../monitoring/library/Monitoring/Controller.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index bf69182d7..c3cbe3c2d 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -21,16 +21,6 @@ class Controller extends IcingaWebController */ protected $backend; - /** - * Compact layout name - * - * Set to a string containing the compact layout name to use when - * 'compact' is set as the layout parameter, otherwise null - * - * @var string - */ - protected $compactView; - protected function moduleInit() { $this->backend = Backend::createBackend($this->_getParam('backend')); @@ -39,10 +29,6 @@ class Controller extends IcingaWebController protected function handleFormatRequest($query) { - if ($this->compactView !== null && ($this->_getParam('view', false) === 'compact')) { - $this->_helper->viewRenderer($this->compactView); - } - if ($this->_getParam('format') === 'sql') { echo '
'
                 . htmlspecialchars(wordwrap($query->dump()))

From 675d070b86808bb4ca6b520f2e5bae456875b7fc Mon Sep 17 00:00:00 2001
From: Johannes Meyer 
Date: Wed, 15 Apr 2015 15:33:00 +0200
Subject: [PATCH 042/298] Set the view property `compact' exactly once

refs #7876
---
 library/Icinga/Web/Controller/ActionController.php           | 1 +
 .../monitoring/application/controllers/ChartController.php   | 5 -----
 .../monitoring/application/controllers/ListController.php    | 1 -
 .../monitoring/application/controllers/ShowController.php    | 2 --
 .../monitoring/application/views/scripts/show/contact.phtml  | 5 ++++-
 5 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php
index 26e0e452a..b78090a7f 100644
--- a/library/Icinga/Web/Controller/ActionController.php
+++ b/library/Icinga/Web/Controller/ActionController.php
@@ -87,6 +87,7 @@ class ActionController extends Zend_Controller_Action
         $this->_helper->layout()->isIframe = $request->getUrl()->shift('isIframe');
         $this->_helper->layout()->moduleName = false;
 
+        $this->view->compact = $request->getParam('view') === 'compact';
         if ($this->rerenderLayout = $request->getUrl()->shift('renderLayout')) {
             $this->xhrLayout = 'body';
         }
diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php
index 08f9334ee..39f60c304 100644
--- a/modules/monitoring/application/controllers/ChartController.php
+++ b/modules/monitoring/application/controllers/ChartController.php
@@ -16,11 +16,6 @@ use Icinga\Chart\Unit\LinearUnit;
 
 class Monitoring_ChartController extends Controller
 {
-    public function init()
-    {
-        $this->view->compact = $this->_request->getParam('view') === 'compact';
-    }
-
     private function drawLogChart1()
     {
         $chart = new GridChart();
diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php
index e1726a68d..ac1d41590 100644
--- a/modules/monitoring/application/controllers/ListController.php
+++ b/modules/monitoring/application/controllers/ListController.php
@@ -21,7 +21,6 @@ class Monitoring_ListController extends Controller
     public function init()
     {
         $this->createTabs();
-        $this->view->compact = $this->_request->getParam('view') === 'compact';
     }
 
     /**
diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php
index 0d7df501a..fe5633ab2 100644
--- a/modules/monitoring/application/controllers/ShowController.php
+++ b/modules/monitoring/application/controllers/ShowController.php
@@ -167,8 +167,6 @@ class Monitoring_ShowController extends Controller
             ));
 
             $notifications->where('contact_object_id', $contact->contact_object_id);
-
-            $this->view->compact = true;
             $this->view->notifications = $notifications->paginate();
         }
 
diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml
index c4142707a..1ad5eccf9 100644
--- a/modules/monitoring/application/views/scripts/show/contact.phtml
+++ b/modules/monitoring/application/views/scripts/show/contact.phtml
@@ -57,7 +57,10 @@
 
 
 
-render('list/notifications.phtml') ?>
+partial('list/notifications.phtml', array(
+    'notifications' => $notifications,
+    'compact' => true
+)); ?>
 
 
translate('No notifications have been sent for this contact') ?>
From aa409bda72b86da27edc7db14f34ab9af3d8802a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Apr 2015 12:13:31 +0200 Subject: [PATCH 043/298] Fix formatting of js error log entries generated from responses Replace multiple whitespace characters with a single one and remove linebreaks. refs #8711 --- public/js/icinga/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 1c674b947..535e414a9 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -640,7 +640,7 @@ this.icinga.logger.error( req.status, errorThrown + ':', - $(req.responseText).text().slice(0, 100) + $(req.responseText).text().replace(/\s+/g, ' ').slice(0, 100) ); this.renderContentToContainer( req.responseText, From 36726560ddd3b76b88c079f556f8044ab12e1e1b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 16 Apr 2015 13:59:17 +0200 Subject: [PATCH 044/298] Document how to install Icinga Web 2 from Package --- doc/installation.md | 148 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 17 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index ef968974a..133f6cb98 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -3,21 +3,133 @@ The preferred way of installing Icinga Web 2 is to use the official package repositories depending on which operating system and distribution you are running. But it is also possible to install Icinga Web 2 directly from source. -## Installing Requirements +## Installing Requirements * A web server, e.g. Apache or nginx -* PHP >= 5.3.0 w/ gettext and OpenSSL support -* MySQL or PostgreSQL PHP libraries when using a database for authentication or storing user preferences into a database +* PHP >= 5.3.0 w/ gettext, intl and OpenSSL support +* MySQL or PostgreSQL PHP libraries when using a database for authentication or for storing preferences into a database * LDAP PHP library when using Active Directory or LDAP for authentication -* Icinga 1.x w/ Livestatus or IDO, Icinga 2 w/ Livestatus or IDO feature enabled +* Icinga 1.x w/ Livestatus or IDO; Icinga 2.x w/ Livestatus or IDO feature enabled +* MySQL or PostgreSQL PHP libraries when using IDO -## Installing Icinga Web 2 from Package +## Installing Icinga Web 2 from Package -A guide on how to install Icinga Web 2 from package will follow shortly. +Below is a list of official package repositories for installing Icinga Web 2 for various operating systems. -## Installing Icinga Web 2 from Source +Distribution | Repository +------------------------|--------------------------- +Debian | [debmon](http://debmon.org/packages/debmon-wheezy/icingaweb2), [Icinga Repository](http://packages.icinga.org/debian/) +Ubuntu | [Icinga Repository](http://packages.icinga.org/ubuntu/) +RHEL/CentOS | [Icinga Repository](http://packages.icinga.org/epel/) +openSUSE | [Icinga Repository](http://packages.icinga.org/openSUSE/) +SLES | [Icinga Repository](http://packages.icinga.org/SUSE/) +Gentoo | - +FreeBSD | - +ArchLinux | [Upstream](https://aur.archlinux.org/packages/icingaweb2) -**Step 1: Getting the Source** +Packages for distributions other than the ones listed above may also be available. +Please contact your distribution packagers. + +### Setting up Package Repositories + +You need to add the Icinga repository to your package management configuration for installing Icinga Web 2. +Below is a list with examples for various distributions. + +Debian (debmon): +```` +wget -O - http://debmon.org/debmon/repo.key 2>/dev/null | apt-key add - +echo 'deb http://debmon.org/debmon debmon-wheezy main' >/etc/apt/sources.list.d/debmon.list +apt-get update +```` + +Ubuntu Trusty: +```` +wget -O - http://packages.icinga.org/icinga.key | apt-key add - +add-apt-repository 'deb http://packages.icinga.org/ubuntu icinga-trusty main' +apt-get update +```` + +For other Ubuntu versions just replace trusty with your distribution's code name. + +RHEL and CentOS: +```` +rpm --import http://packages.icinga.org/icinga.key +curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo +yum makecache +```` + +Fedora: +```` +rpm --import http://packages.icinga.org/icinga.key +curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/fedora/ICINGA-release.repo +yum makecache +```` + +SLES 11: +```` +zypper ar http://packages.icinga.org/SUSE/ICINGA-release-11.repo +zypper ref +```` + +SLES 12: +```` +zypper ar http://packages.icinga.org/SUSE/ICINGA-release.repo +zypper ref +```` + +openSUSE: +```` +zypper ar http://packages.icinga.org/openSUSE/ICINGA-release.repo +zypper ref +```` + +The packages for RHEL/CentOS depend on other packages which are distributed as part of the +[EPEL repository](http://fedoraproject.org/wiki/EPEL). Please make sure to enable this repository by following +[these instructions](http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F). + +### Installing Icinga Web 2 + +You can install Icinga Web 2 by using your distribution's package manager to install the `icingaweb2` package. +Below is a list with examples for various distributions. + +Debian and Ubuntu: +```` +apt-get install icingaweb2 +```` + +RHEL, CentOS and Fedora: +```` +yum install icingaweb2 +```` + +SLES and openSUSE: +```` +zypper install icingaweb2 +```` + +### Preparing Web Setup + +You can set up Icinga Web 2 quickly and easily with the Icinga Web 2 setup wizard which is available the first time +you visit Icinga Web 2 in your browser. When using the web setup you are required to authenticate using a token. +In order to generate a token use the `icingacli`: +```` +icingacli setup token create +```` + +In case you do not remember the token you can show it using the `icingacli`: +```` +icingacli setup token show +```` + +Finally visit Icinga Web 2 in your browser to access the setup wizard and complete the installation: +`/icingaweb2/setup`. + +## Installing Icinga Web 2 from Source + +Although the preferred way of installing Icinga Web 2 is to use packages, it is also possible to install Icinga Web 2 +directly from source. + +### Getting the Source First of all, you need to download the sources. Icinga Web 2 is available through a Git repository. You can clone this repository either via git or http protocol using the following URLs: @@ -33,7 +145,7 @@ This version also offers snapshots for easy download which you can use if you do git clone git://git.icinga.org/icingaweb2.git ```` -**Step 2: Install the Source** +### Installing Icinga Web 2 Choose a target directory and move Icinga Web 2 there. @@ -41,7 +153,7 @@ Choose a target directory and move Icinga Web 2 there. mv icingaweb2 /usr/share/icingaweb2 ```` -**Step 3: Configuring the Web Server** +### Configuring the Web Server Use `icingacli` to generate web server configuration for either Apache or nginx. @@ -57,13 +169,15 @@ nginx: Save the output as new file in your webserver's configuration directory. -Example for Apache on RHEL/CentOS: +Example for Apache on RHEL or CentOS: ```` ./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb2/public > /etc/httpd/conf.d/icingaweb2.conf ```` +### Preparing Web Setup -**Step 4: Preparing Web Setup** +You can set up Icinga Web 2 quickly and easily with the Icinga Web 2 setup wizard which is available the first time +you visit Icinga Web 2 in your browser. Please follow the steps listed below for preparing the web setup. Because both web and CLI must have access to configuration and logs, permissions will be managed using a special system group. The web server user and CLI user have to be added to this system group. @@ -102,6 +216,7 @@ Use `icingacli` to create the configuration directory which defaults to **/etc/i ./bin/icingacli setup config directory ```` + When using the web setup you are required to authenticate using a token. In order to generate a token use the `icingacli`: ```` @@ -113,11 +228,10 @@ In case you do not remember the token you can show it using the `icingacli`: ./bin/icingacli setup token show ```` -**Step 5: Web Setup** +Finally visit Icinga Web 2 in your browser to access the setup wizard and complete the installation: +`/icingaweb2/setup`. -Visit Icinga Web 2 in your browser and complete installation using the web setup: /icingaweb2/setup - -## Upgrading to Icinga Web 2 Beta 2 +## Upgrading to Icinga Web 2 Beta 2 Icinga Web 2 Beta 2 introduces access control based on roles for secured actions. If you've already set up Icinga Web 2, you are required to create the file **roles.ini** beneath Icinga Web 2's configuration directory with the following @@ -134,7 +248,7 @@ If you delegated authentication to your web server using the `autologin` backend authentication backend to be able to log in again. The new name better reflects what’s going on. A similar change affects environments that opted for not storing preferences, your new backend is `none`. -## Upgrading to Icinga Web 2 Beta 3 +## Upgrading to Icinga Web 2 Beta 3 Because Icinga Web 2 Beta 3 does not introduce any backward incompatible change you don't have to change your configuration files after upgrading to Icinga Web 2 Beta 3. From 3015028f5df2e4c5c81813fffb515c26043705e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Fri, 10 Apr 2015 13:20:09 +0200 Subject: [PATCH 045/298] Remove quotation marks in password example Otherwise the quotation marks are included in the password. Signed-off-by: Eric Lippmann --- doc/authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authentication.md b/doc/authentication.md index 604c85a2e..13a821441 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -107,7 +107,7 @@ Icinga Web 2 uses the MD5 based BSD password algorithm. For generating a passwor command: ```` -openssl passwd -1 "password" +openssl passwd -1 password ```` > Note: The switch to `openssl passwd` is the **number one** (`-1`) for using the MD5 based BSD password algorithm. From 168577ff336aec67d398109f47435df2babf8c31 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Apr 2015 14:29:06 +0200 Subject: [PATCH 046/298] Use icon instead of the letter 'X' in close tab --- library/Icinga/Web/Widget/Tabs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 770f5093f..aa5e7cda6 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -49,7 +49,7 @@ EOT; */ private $closeTpl = <<< 'EOT' EOT; From f07c0d83e8c2be5a68d90385d6e17fe839303ed5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Apr 2015 18:25:23 +0200 Subject: [PATCH 047/298] Add option to change tooltip settings from data attributes refs #9025 --- public/js/icinga/behavior/tooltip.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index c9a64257f..a1a94b62b 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -30,7 +30,18 @@ $('svg .chart-data', el).tipsy({ gravity: 'se', html: true }); $('.historycolorgrid a[title]', el).tipsy({ gravity: 's', offset: 2 }); $('img.icon[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); - $('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500 }); + $('[title]', el).each(function (i, el) { + var $el = $(el); + var delay = 500; + if ($el.data('tooltip-delay') !== undefined) { + delay = $el.data('tooltip-delay'); + } + var gravity = $.fn.tipsy.autoNS; + if ($el.data('tooltip-gravity')) { + gravity = $el.data('tooltip-gravity'); + } + $el.tipsy({ gravity: gravity, delayIn: delay }); + }); // migrate or remove all orphaned tooltips $('.tipsy').each(function () { From 0974b70e0e2bde622670d1a4ad34752a03164e26 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Apr 2015 18:27:47 +0200 Subject: [PATCH 048/298] Display service grid tooltips on the top fixes #9025 --- .../application/views/scripts/list/servicegrid.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index a2e7502ea..9219e5dda 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -50,7 +50,8 @@ foreach ($serviceDescriptions as $service_description): ?> 'service_description' => $service_description ), array( - 'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $service_description) + 'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $service_description), + 'data-tooltip-gravity' => 's' ), false ); ?> From 6898a4e0d5d2594ffbf761a0cdf6d1f29c8c49cf Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Apr 2015 18:30:49 +0200 Subject: [PATCH 049/298] Display icon tooltips without delay Original functionality was broken when changing the icon library. --- library/Icinga/Web/Widget/Chart/HistoryColorGrid.php | 3 ++- public/js/icinga/behavior/tooltip.js | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php b/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php index d1c9a677f..8ffd3ea00 100644 --- a/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php +++ b/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php @@ -127,7 +127,8 @@ class HistoryColorGrid extends AbstractWidget { . ' opacity: ' . $this->opacity . ';" ' . 'aria-label="' . $entry['caption'] . '" ' . 'title="' . $entry['caption'] . '" ' . - 'href="' . $entry['url'] . '"' . + 'href="' . $entry['url'] . '" ' . + 'data-tooltip-delay="0"' . '>'; } else { return ' Date: Thu, 16 Apr 2015 21:01:08 +0200 Subject: [PATCH 050/298] Revert "Do not destroy all global on mailto link clicks" This reverts commit 16b9c73436bab9318d1a09f5caaba8412fd168c2. As I already mentioned, this re-introduces the problem that you'll get ugly "lost connection to web server" notifications. Easiest way to reproduce this: click your browsers reload button while a request is pending - or just click reload a couple of times while showing the dashboard. refs #7759 --- public/js/icinga/events.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 491ca82f2..7e87a8fb6 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -100,6 +100,7 @@ // Destroy Icinga, clean up and interrupt pending requests on unload $( window ).on('unload', { self: this }, this.onUnload); + $( window ).on('beforeunload', { self: this }, this.onUnload); // We catch scroll events in our containers $('.container').on('scroll', { self: this }, this.icinga.events.onContainerScroll); @@ -555,6 +556,7 @@ $(window).off('resize', this.onWindowResize); $(window).off('load', this.onLoad); $(window).off('unload', this.onUnload); + $(window).off('beforeunload', this.onUnload); $(document).off('scroll', '.container', this.onContainerScroll); $(document).off('click', 'a', this.linkClicked); $(document).off('click', 'table.action tr[href]', this.rowSelected); From 6d0870ad2e8b75cff9b61e1af2dbc04375c22ce8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 10:04:24 +0200 Subject: [PATCH 051/298] Adjust padding and margin of .content and .controls refs #7876 --- modules/monitoring/public/css/module.less | 3 +++ public/css/icinga/controls.less | 1 + public/css/icinga/layout-structure.less | 12 ++++++------ public/css/icinga/tabs.less | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 050a8fb5b..f121bb66f 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -94,11 +94,14 @@ div.contacts div.notification-periods { div.tinystatesummary { .page-header(); font-size: 1em; + margin-bottom: 0.5em; + .badges { display: inline-block; margin-bottom: 4px; margin-left: 1em; } + .state > a { color: white; font-size: 0.8em; diff --git a/public/css/icinga/controls.less b/public/css/icinga/controls.less index 73e78b3e9..b8e82b795 100644 --- a/public/css/icinga/controls.less +++ b/public/css/icinga/controls.less @@ -1,6 +1,7 @@ /*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ form.sort-control { + .dontprint; float: right; label { diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index a1bf3682d..b10c6e6ed 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -119,12 +119,12 @@ html { .container .controls { top: 0; background-color: white; - padding: 0; + padding: 1em 1em 0; z-index: 100; } .container .fake-controls { - padding: 0; + padding: 1em 1em 0; } .container .controls .pagination { @@ -149,10 +149,6 @@ html { font-size: 0.9em; } -.container .controls > * { - margin-left: 1em; -} - .container .controls .pagination { margin-left: 1.2em; } @@ -161,6 +157,10 @@ html { padding: 1em; } +.controls + .fake-controls + .content { + padding-top: 0; +} + .dashboard .content { padding: 0; overflow: auto; diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index 8d391b038..6d35c5e20 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -1,12 +1,12 @@ /*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ ul.tabs { - padding: 1em 0 0 0; + padding: 0; list-style-type: inside; } .controls ul.tabs { - margin-left: 0em; + margin-left: -1em; margin-top: -3.54em; height: 2.6em; overflow: hidden; From b52b5071348f066c31cea3565e71b339defda25c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 10:05:48 +0200 Subject: [PATCH 052/298] FilterEditor: Fix css --- library/Icinga/Web/Widget/FilterEditor.php | 30 ++++++++++++---------- public/css/icinga/widgets.less | 22 +++++++++++----- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index ad9b1b5b2..7812cdf47 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -649,7 +649,7 @@ class FilterEditor extends AbstractWidget public function renderSearch() { - $html = '
' . $this->renderSearch() . $this->shorten($this->filter, 50) . ''; } - return $this->renderSearch() - . '' - . '
  • ' - . $this->renderFilter($this->filter) - . '
' - . '
' - . '' - . '' - . '
' - . ''; + return '
' + . $this->renderSearch() + . '
' + . '
  • ' + . $this->renderFilter($this->filter) + . '
' + . '
' + . '' + . '' + . '
' + . '' + . '
'; } protected function shorten($string, $length) diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 45701a697..1993704b6 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -48,8 +48,22 @@ table.multiselect tr[href] td { -ms-user-select: none; } -#main form.filterEditor input[type=text], #main form.filterEditor select { - width: 12em; +#main div.filter { + margin-top: 1em; + + form.editor { + input[type=text], select { + width: 12em; + } + + ul.tree li.active { + background-color: #eee; + } + + div.buttons { + float: right; + } + } } ul.datafilter li { @@ -281,10 +295,6 @@ li li .badge { background-color: @colorUnknown; } -.widgetFilter li.active { - background-color: #eee; -} - .sparkline-box { position: relative; top: -3px; From 7735e5d31d0cf1e8fb70530502a4ee965b237954 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:07:18 +0200 Subject: [PATCH 053/298] Fix padding and margin of .content and .controls refs #7876 --- public/css/icinga/layout-structure.less | 4 ---- public/css/icinga/main-content.less | 6 ------ public/css/icinga/tabs.less | 1 + 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index b10c6e6ed..23a598b52 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -157,10 +157,6 @@ html { padding: 1em; } -.controls + .fake-controls + .content { - padding-top: 0; -} - .dashboard .content { padding: 0; overflow: auto; diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 32054e242..b442723cb 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -118,7 +118,6 @@ table.avp a:hover { /* Definitively monitoring-only: */ table.objectstate { - margin: 1em; border-collapse: separate; border-spacing: 1px; } @@ -194,11 +193,6 @@ table.benchmark { color: inherit; } -/* controls have no padding as of tabs */ -.controls > h1 { - margin-right: 1em; -} - [class^="icon-"]:before, [class*=" icon-"]:before { text-decoration: none; } diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index 6d35c5e20..2c02bfb94 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -7,6 +7,7 @@ ul.tabs { .controls ul.tabs { margin-left: -1em; + margin-right: -1em; margin-top: -3.54em; height: 2.6em; overflow: hidden; From 2bd31ee39509c99458860fe1b8b72fa5ef01227f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:08:41 +0200 Subject: [PATCH 054/298] Icinga\Web\Controller: Add helper functions to create control widgets refs #7876 --- library/Icinga/Web/Controller.php | 72 ++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index da9486b9e..42bd94b5e 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -3,8 +3,10 @@ namespace Icinga\Web; +use Zend_Paginator; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Widget\SortBox; +use Icinga\Web\Widget\Limiter; /** * This is the controller all modules should inherit from @@ -16,15 +18,75 @@ class Controller extends ModuleActionController /** * Create a SortBox widget at the `sortBox' view property * + * In case the current view has been requested as compact this method does nothing. + * * @param array $columns An array containing the sort columns, with the * submit value as the key and the label as the value + * + * @return $this */ protected function setupSortControl(array $columns) { - $req = $this->getRequest(); - $this->view->sortBox = SortBox::create( - 'sortbox-' . $req->getActionName(), - $columns - )->applyRequest($req); + if (! $this->view->compact) { + $req = $this->getRequest(); + $this->view->sortBox = SortBox::create( + 'sortbox-' . $req->getActionName(), + $columns + )->applyRequest($req); + } + + return $this; + } + + /** + * Create a Limiter widget at the `limiter' view property + * + * In case the current view has been requested as compact this method does nothing. + * + * @return $this + */ + protected function setupLimitControl() + { + if (! $this->view->compact) { + $this->view->limiter = new Limiter(); + } + + return $this; + } + + /** + * Set the view property `paginator' to the given Zend_Paginator + * + * In case the current view has been requested as compact this method does nothing. + * + * @param Zend_Paginator $paginator The Zend_Paginator for which to show a pagination control + * + * @return $this + */ + protected function setupPaginationControl(Zend_Paginator $paginator) + { + if (! $this->view->compact) { + $this->view->paginator = $paginator; + } + + return $this; + } + + /** + * Set the view property `filterEditor' to the given FilterEditor + * + * In case the current view has been requested as compact this method does nothing. + * + * @param Form $editor The FilterEditor + * + * @return $this + */ + protected function setupFilterControl($editor) + { + if (! $this->view->compact) { + $this->view->filterEditor = $editor; + } + + return $this; } } From d5cc340439fba9008df8e4aaae82581d8c1596a8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:09:17 +0200 Subject: [PATCH 055/298] ApplicationLog: Ensure dashboard compliance refs #7876 --- application/controllers/ListController.php | 3 +++ application/views/scripts/list/applicationlog.phtml | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index feaf13921..985c53512 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -52,5 +52,8 @@ class ListController extends Controller 'fields' => $pattern ))); $this->view->logData = $resource->select()->order('DESC')->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->logData); } } diff --git a/application/views/scripts/list/applicationlog.phtml b/application/views/scripts/list/applicationlog.phtml index 583fde516..cc412eb9c 100644 --- a/application/views/scripts/list/applicationlog.phtml +++ b/application/views/scripts/list/applicationlog.phtml @@ -1,9 +1,12 @@ +compact): ?>
- tabs->render($this) ?> -
- logData ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
- +
logData !== null): ?>
From 57d519bca8a96a29e2c2265a5ebdf86f3855ae6d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:09:35 +0200 Subject: [PATCH 056/298] ModuleOverview: Ensure dashboard compliance refs #7876 --- application/controllers/ConfigController.php | 12 ++++++++++-- application/views/scripts/config/modules.phtml | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 491a33ef3..370b8f5d0 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -11,14 +11,14 @@ use Icinga\Forms\Config\GeneralConfigForm; use Icinga\Forms\Config\ResourceConfigForm; use Icinga\Forms\ConfirmRemovalForm; use Icinga\Security\SecurityException; -use Icinga\Web\Controller\ActionController; +use Icinga\Web\Controller; use Icinga\Web\Notification; use Icinga\Web\Widget; /** * Application and module configuration */ -class ConfigController extends ActionController +class ConfigController extends Controller { /** * The first allowed config action according to the user's permissions @@ -130,6 +130,14 @@ class ConfigController extends ActionController ->order('enabled', 'desc') ->order('name') ->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->modules); + // TODO: Not working + /*$this->setupSortControl(array( + 'name' => $this->translate('Modulename'), + 'path' => $this->translate('Installation Path'), + 'enabled' => $this->translate('State') + ));*/ } public function moduleAction() diff --git a/application/views/scripts/config/modules.phtml b/application/views/scripts/config/modules.phtml index 9121de405..2abf16fc6 100644 --- a/application/views/scripts/config/modules.phtml +++ b/application/views/scripts/config/modules.phtml @@ -1,8 +1,12 @@ +compact): ?>
-tabs ?> -paginationControl($modules) ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
- +
From 5f4a61f36e4e5dc3da7298a68dc03d008773146a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:09:50 +0200 Subject: [PATCH 057/298] Alertsummary: Ensure dashboard compliance refs #7876 --- .../controllers/AlertsummaryController.php | 4 +++- .../views/scripts/alertsummary/index.phtml | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 0d3917e90..aea8def93 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -69,8 +69,10 @@ class Monitoring_AlertsummaryController extends Controller 'notification_state' ) ); - $this->view->notifications = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->notifications); } /** diff --git a/modules/monitoring/application/views/scripts/alertsummary/index.phtml b/modules/monitoring/application/views/scripts/alertsummary/index.phtml index 8bb36b518..d96ca5bdc 100644 --- a/modules/monitoring/application/views/scripts/alertsummary/index.phtml +++ b/modules/monitoring/application/views/scripts/alertsummary/index.phtml @@ -1,12 +1,13 @@ +compact): ?>
- tabs ?> -
+ tabs; ?> +
- widget('limiter') ?> - paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?> + limiter; ?> + paginator; ?>
- +
From 93889442834a464085fe3e7a36a7978ed9cf57c7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:10:21 +0200 Subject: [PATCH 058/298] show/history: Ensure dashboard compliance refs #7876 --- .../controllers/ShowController.php | 3 ++ .../views/scripts/show/history.phtml | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index fe5633ab2..bf8c5298d 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -73,6 +73,9 @@ class Monitoring_ShowController extends Controller $this->view->history = $this->view->object->eventhistory->getQuery()->paginate($this->params->get('limit', 50)); $this->handleFormatRequest($this->view->object->eventhistory); $this->fetchHostStats(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->history); } public function servicesAction() diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index d82f454f6..d2fd1a383 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -1,29 +1,33 @@ getType() === 'host'; -?> - +if (! $this->compact): ?>
- + tabs; ?> + render('partials/host/object-header.phtml'); ?> - + render('partials/service/object-header.phtml'); ?> - +

translate('This Object\'s Event History'); ?>

- widget('limiter', array('url' => $url, 'max' => $history->count())); ?> - paginationControl($history, null, null, array('preserve' => $this->preserve)); ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
- +
- - translate('No history available for this object'); ?> -
- +translate('No history available for this object') . '
'; + return; +} +?> Date: Fri, 17 Apr 2015 16:10:49 +0200 Subject: [PATCH 059/298] show/contact: Ensure dashboard compliance refs #7876 --- .../monitoring/application/controllers/ShowController.php | 4 ++-- .../monitoring/application/views/scripts/show/contact.phtml | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index bf8c5298d..968512c26 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -145,9 +145,7 @@ class Monitoring_ShowController extends Controller 'contact_notify_host_flapping', 'contact_notify_host_downtime', )); - $query->where('contact_name', $contactName); - $contact = $query->getQuery()->fetchRow(); if ($contact) { @@ -171,6 +169,8 @@ class Monitoring_ShowController extends Controller $notifications->where('contact_object_id', $contact->contact_object_id); $this->view->notifications = $notifications->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->notifications); } $this->view->contact = $contact; diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index 1ad5eccf9..027301c88 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -1,6 +1,8 @@ getHelper('ContactFlags') ?>
- tabs ?> + compact): ?> + tabs; ?> +

translate('Contact details') ?>

- tabs ?> -
+ tabs; ?> +
@@ -21,6 +20,8 @@ $firstRow = !$beingExtended;
+ +
From 74cf3cf3753dc8be236597d623283fb780f226ec Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:12:35 +0200 Subject: [PATCH 061/298] list/hosts: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 20 +++++------ .../views/scripts/list/hosts.phtml | 34 +++++++------------ 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index ac1d41590..a1e22d442 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -117,18 +117,8 @@ class Monitoring_ListController extends Controller 'host_current_check_attempt', 'host_max_check_attempts' ), $this->extraColumns())); - $this->filterQuery($query); - $this->applyRestriction('monitoring/hosts/filter', $query); - - $this->setupSortControl(array( - 'host_severity' => $this->translate('Severity'), - 'host_state' => $this->translate('Current State'), - 'host_display_name' => $this->translate('Hostname'), - 'host_address' => $this->translate('Address'), - 'host_last_check' => $this->translate('Last Check') - )); $this->view->hosts = $query->paginate(); $this->view->stats = $this->backend->select()->from('statusSummary', array( @@ -142,6 +132,16 @@ class Monitoring_ListController extends Controller 'hosts_unreachable_unhandled', 'hosts_pending', ))->getQuery()->fetchRow(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->hosts); + $this->setupSortControl(array( + 'host_severity' => $this->translate('Severity'), + 'host_state' => $this->translate('Current State'), + 'host_display_name' => $this->translate('Hostname'), + 'host_address' => $this->translate('Address'), + 'host_last_check' => $this->translate('Last Check') + )); } /** diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index a7511fcd8..3efb70320 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -1,33 +1,25 @@ compact): ?> -
- +if (! $this->compact): ?>
- tabs ?> -
- render('list/components/selectioninfo.phtml') ?> - render('list/components/hostssummary.phtml') ?> - translate('Sort by') ?> sortControl->render($this) ?> + tabs; ?> +
+ render('list/components/selectioninfo.phtml'); ?> + render('list/components/hostssummary.phtml'); ?>
- -widget('limiter')->setMaxLimit($this->hosts->count()) ?> -paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?> -selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())) ?> + sortBox; ?> + limiter; ?> + paginator; ?> + selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())); ?> + filterEditor; ?>
- +
-filterEditor ?> count() === 0) { - echo $this->translate('No hosts matching the filter'); - if (! $this->compact) { - echo '
'; - } +if (count($hosts) === 0) { + echo $this->translate('No hosts found matching the filter') . '
'; return; } ?> From 29648191e4be272138b7b73a77a14c721fca18a4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:12:56 +0200 Subject: [PATCH 062/298] list/services: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 14 ++----- .../views/scripts/list/services.phtml | 42 ++++++++----------- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a1e22d442..e69c9034f 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -205,11 +205,12 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->extraColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query); - $this->applyRestriction('monitoring/services/filter', $query); + $this->view->services = $query->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->services); $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), @@ -221,14 +222,6 @@ class Monitoring_ListController extends Controller 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') )); - $limit = $this->params->get('limit'); - $this->view->limit = $limit; - if ($limit === 0) { - $this->view->services = $query->getQuery()->fetchAll(); - } else { - // TODO: Workaround, paginate should be able to fetch limit from new params - $this->view->services = $query->paginate($this->params->get('limit')); - } $this->view->stats = $this->backend->select()->from('statusSummary', array( 'services_total', @@ -247,7 +240,6 @@ class Monitoring_ListController extends Controller 'services_unknown_handled', 'services_pending', ))->getQuery()->fetchRow(); - } /** diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 3f1437dae..7473f7f25 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -4,41 +4,33 @@ use Icinga\Module\Monitoring\Object\Service; $selfUrl = 'monitoring/list/services'; -if (!$this->compact): ?> +if (! $this->compact): ?>
-tabs ?> -
-render('list/components/selectioninfo.phtml') ?> -render('list/components/servicesummary.phtml') ?> -
-translate('Sort by') ?> sortControl ?> + tabs; ?> +
+ render('list/components/selectioninfo.phtml'); ?> + render('list/components/servicesummary.phtml'); ?> +
+ sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
-limit === 0): ?> -widget('limiter') ?> - -widget('limiter')->setCurrentPageCount($this->services->count()) ?> -paginationControl($services, null, null, array('preserve' => $this->preserve)) ?> -
-
-filterEditor ?> - + - +if (count($services) === 0) { + echo $this->translate('No services found matching the filter') . '
'; + return; +} +?>
" data-icinga-multiselect-data="service_description,host_name"> -href( 'monitoring/service/show', array( From 5f19ec1b2e5d02325268da114ca903f5d140bf80 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:13:22 +0200 Subject: [PATCH 063/298] list/downtimes: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 8 +++-- .../views/scripts/list/downtimes.phtml | 32 ++++++++----------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e69c9034f..f1f758e9c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -250,8 +250,10 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab('downtimes', $this->translate('Downtimes'), $this->translate('List downtimes')); $this->setAutorefreshInterval(12); + $query = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', 'objecttype' => 'downtime_objecttype', @@ -273,9 +275,11 @@ class Monitoring_ListController extends Controller 'host_display_name', 'service_display_name' )); - $this->filterQuery($query); + $this->view->downtimes = $query->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->downtimes); $this->setupSortControl(array( 'downtime_is_in_effect' => $this->translate('Is In Effect'), 'host_display_name' => $this->translate('Host'), @@ -289,8 +293,6 @@ class Monitoring_ListController extends Controller 'downtime_duration' => $this->translate('Duration') )); - $this->view->downtimes = $query->paginate(); - if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); } diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 2387e9487..b279d4063 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -1,30 +1,24 @@ - -compact): ?> +if (! $this->compact): ?>
- tabs->render($this); ?> -
- translate('Sort by'); ?> sortControl->render($this); ?> - filterEditor): ?> - filterPreview ?> - -
- widget('limiter', array('url' => $this->url, 'max' => $downtimes->count())); ?> - paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
-filterEditor ?> - - translate('No active downtimes'); ?> -
- +translate('No downtimes found matching the filter') . ''; + return; +} +?>
From a09e41e3b8fbe2249e739d01cc3961aa5a531d47 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:13:36 +0200 Subject: [PATCH 064/298] list/notifications: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 5 ++++ .../views/scripts/list/notifications.phtml | 26 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index f1f758e9c..b040da72d 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -306,12 +306,14 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab( 'notifications', $this->translate('Notifications'), $this->translate('List notifications') ); $this->setAutorefreshInterval(15); + $query = $this->backend->select()->from('notification', array( 'host_name', 'service_description', @@ -324,6 +326,9 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); $this->view->notifications = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->notifications); $this->setupSortControl(array( 'notification_start_time' => $this->translate('Notification Start') )); diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 9a3b424b4..c49f5fc3f 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -1,26 +1,24 @@ - -compact): ?> +if (! $this->compact): ?>
- tabs ?> -
- translate('Sort by') ?> sortControl->render($this) ?> -
- widget('limiter') ?> - paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
- - translate('No notifications matching the filter') ?> - +translate('No notifications found matching the filter') . '
'; + return; +} +?>
Date: Fri, 17 Apr 2015 16:13:56 +0200 Subject: [PATCH 065/298] list/contacts: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 4 +++ .../views/scripts/list/contacts.phtml | 27 ++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b040da72d..8a09ef213 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -339,7 +339,9 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab('contacts', $this->translate('Contacts'), $this->translate('List contacts')); + $query = $this->backend->select()->from('contact', array( 'contact_name', 'contact_id', @@ -363,6 +365,8 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->view->contacts = $query->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->contacts); $this->setupSortControl(array( 'contact_name' => $this->translate('Name'), 'contact_alias' => $this->translate('Alias'), diff --git a/modules/monitoring/application/views/scripts/list/contacts.phtml b/modules/monitoring/application/views/scripts/list/contacts.phtml index 80405f7c6..78910cead 100644 --- a/modules/monitoring/application/views/scripts/list/contacts.phtml +++ b/modules/monitoring/application/views/scripts/list/contacts.phtml @@ -1,18 +1,21 @@ +compact): ?>
- tabs ?> -
- sortControl->render($this); ?> -
- paginationControl($contacts, null, null, array('preserve' => $this->preserve)); ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
- +
- translate('No contacts matching the filter'); - return; - } - foreach ($contacts as $contact): ?> +translate('No contacts found matching the filter') . '
'; + return; +} +?> +
img('/static/gravatar', array('email' => $contact->contact_email)); ?> qlink( From b9249dac4e3de98b4c04cbd6f973b28461ab4044 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:14:13 +0200 Subject: [PATCH 066/298] list/contactgroups: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 9 +++++++- .../views/scripts/list/contactgroups.phtml | 21 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 8a09ef213..3e6abce48 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -424,11 +424,13 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab( 'contactgroups', $this->translate('Contact Groups'), $this->translate('List contact groups') ); + $query = $this->backend->select()->from('contactgroup', array( 'contactgroup_name', 'contactgroup_alias', @@ -436,7 +438,7 @@ class Monitoring_ListController extends Controller 'contact_alias', 'contact_email', 'contact_pager', - ))->order('contactgroup_alias'); + )); $this->filterQuery($query); // Fetch and prepare all contact groups: @@ -453,6 +455,11 @@ class Monitoring_ListController extends Controller } // TODO: Find a better naming $this->view->groupData = $groupData; + + $this->setupSortControl(array( + 'contactgroup_name' => $this->translate('Contactgroup Name'), + 'contactgroup_alias' => $this->translate('Contactgroup Alias') + )); } public function commentsAction() diff --git a/modules/monitoring/application/views/scripts/list/contactgroups.phtml b/modules/monitoring/application/views/scripts/list/contactgroups.phtml index 09083a387..5e3b038a7 100644 --- a/modules/monitoring/application/views/scripts/list/contactgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/contactgroups.phtml @@ -1,17 +1,22 @@ -compact): ?> +compact): ?>
- tabs ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
- $groupInfo): ?> +if (count($groupData) === 0) { + echo $this->translate('No contactgroups found matching the filter') . '
'; + return; +} +?> +
+ $groupInfo): ?>

From 2190e553be82f60005aa855e354f7903d2767012 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:14:29 +0200 Subject: [PATCH 067/298] list/comments: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 4 ++++ .../views/scripts/list/comments.phtml | 24 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 3e6abce48..61fb84956 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -467,8 +467,10 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab('comments', $this->translate('Comments'), $this->translate('List comments')); $this->setAutorefreshInterval(12); + $query = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', 'objecttype' => 'comment_objecttype', @@ -486,6 +488,8 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->view->comments = $query->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->comments); $this->setupSortControl( array( 'comment_timestamp' => $this->translate('Comment Timestamp'), diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index cdbe28244..ee752b037 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -1,20 +1,20 @@ -compact): ?> +compact): ?>
- tabs->render($this); ?> -
- translate('Sort by'); ?> sortControl->render($this); ?> -
- widget('limiter', array('url' => $this->url, 'max' => $comments->count())); ?> - paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?> + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
- - translate('No comments matching the filter'); ?> -
- +translate('No comments found matching the filter') . '
'; + return; +} +?>
From 7ae7bf38c47617c24252a31c4c541a22a5910249 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:14:46 +0200 Subject: [PATCH 068/298] list/servicegroups: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 5 +++ .../views/scripts/list/servicegroups.phtml | 32 ++++++++----------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 61fb84956..def41fb57 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -510,12 +510,14 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab( 'servicegroups', $this->translate('Service Groups'), $this->translate('List service groups') ); $this->setAutorefreshInterval(12); + $query = $this->backend->select()->from('groupsummary', array( 'servicegroup_name', 'servicegroup_alias', @@ -547,6 +549,9 @@ class Monitoring_ListController extends Controller // service groups. We should separate them. $this->filterQuery($query); $this->view->servicegroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->servicegroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'servicegroup_alias' => $this->translate('Service Group Name'), diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index 9ef23a95a..9fb8d0e08 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -1,24 +1,20 @@ -compact): ?> -
- +compact): ?>
- tabs ?> -
- translate('Sort by'); ?> sortControl->render($this); ?> -
- widget('limiter')->setMaxLimit(count($servicegroups)); ?> - paginationControl($servicegroups, null, null, array('preserve' => $this->preserve)); ?> -
-
+ tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> filterEditor; ?> +
- translate('No service groups matching the filter'); - echo '
'; - return; - } - ?> +
+translate('No servicegroups found matching the filter') . '
'; + return; +} +?>
From faa29e3dee6e93a5ed8d0142f75040d9d6055a0b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:14:59 +0200 Subject: [PATCH 069/298] list/hostgroups: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 5 +++ .../views/scripts/list/hostgroups.phtml | 32 ++++++++----------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index def41fb57..f655f7192 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -569,8 +569,10 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups')); $this->setAutorefreshInterval(12); + $query = $this->backend->select()->from('groupsummary', array( 'hostgroup_name', 'hostgroup_alias', @@ -602,6 +604,9 @@ class Monitoring_ListController extends Controller // service groups. We should separate them. $this->filterQuery($query); $this->view->hostgroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->hostgroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 1e3eb29ac..ef8cd78ea 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -1,24 +1,20 @@ -compact): ?> -
- +compact): ?>
- tabs ?> -
- translate('Sort by'); ?> sortControl->render($this); ?> -
- widget('limiter')->setMaxLimit(count($hostgroups)); ?> - paginationControl($hostgroups, null, null, array('preserve' => $this->preserve)); ?> -
-
+ tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> filterEditor; ?> +
- translate('No host groups matching the filter'); - echo '
'; - return; - } - ?> +
+translate('No hostgroups found matching the filter') . '
'; + return; +} +?>
translate('Last Problem'); ?>
From 7be00791a79eabd76465f3ee4d09c68c3a6f44d5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:15:58 +0200 Subject: [PATCH 070/298] list/eventhistory: Ensure dashboard compliance refs #7876 --- .../controllers/ListController.php | 5 ++- .../views/scripts/list/eventhistory.phtml | 33 +++++++------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index f655f7192..a6c38c2e1 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -624,6 +624,7 @@ class Monitoring_ListController extends Controller if ($url = $this->hasBetterUrl()) { return $this->redirectNow($url); } + $this->addTitleTab( 'eventhistory', $this->translate('Event Overview'), @@ -645,11 +646,13 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); + $this->view->history = $query->paginate(); + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->history); $this->setupSortControl(array( 'timestamp' => $this->translate('Occurence') )); - $this->view->history = $query->paginate(); } public function servicegridAction() diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index b76b5a796..9ab581d59 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -1,32 +1,23 @@ - -compact): ?> +if (! $this->compact): ?>
- tabs ?> -
-
- translate('Sort by') ?> sortControl ?> -
-
- - widget('limiter', array('url' => $this->url, 'max' => $this->history->count())); ?> - paginationControl($history, null, null, array('preserve' => $this->preserve)); ?> - + tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
-
-filterEditor ?> - - translate('No history events matching the filter') ?> -
- - +translate('No history events found matching the filter') . ''; + return; +} +?>
translate('Last Problem'); ?>
From 58b93101c70af2b2c1dc95a230b4584320dca322 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:18:56 +0200 Subject: [PATCH 071/298] multiselect views: Ensure dashboard compliance refs #7876 --- .../monitoring/application/views/scripts/hosts/show.phtml | 5 ++++- .../views/scripts/partials/host/objects-header.phtml | 3 --- .../views/scripts/partials/service/objects-header.phtml | 3 --- .../monitoring/application/views/scripts/services/show.phtml | 5 ++++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 5c00cf827..9d532d6dd 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,9 +1,12 @@
+ compact): ?> + + render('partials/host/objects-header.phtml'); ?>
- translate('No hosts matching the filter'); ?> + translate('No hosts found matching the filter'); ?>

translatePlural('%u Host', '%u Hosts', $hostCount), $hostCount); ?>

qlink( diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index f5edd0213..838a78dd8 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,6 +1,3 @@ -compact): ?> - - 0): ?>
translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 1ac27b934..25a7117dd 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,6 +1,3 @@ -compact): ?> - - 0): ?>
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index a71e32792..8bf45a32c 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,9 +1,12 @@
+ compact): ?> + + render('partials/service/objects-header.phtml'); ?>
- translate('No services matching the filter'); ?> + translate('No services found matching the filter'); ?>

translatePlural('%u Service', '%u Services', $serviceCount), $serviceCount); ?>

qlink( From b2246c2aff322ac8800dde80564b3e82a67f92c5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:19:30 +0200 Subject: [PATCH 072/298] host/show: Ensure dashboard compliance refs #7876 --- modules/monitoring/application/views/scripts/host/show.phtml | 3 +++ .../views/scripts/partials/host/object-header.phtml | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/host/show.phtml b/modules/monitoring/application/views/scripts/host/show.phtml index 867692301..32389515b 100644 --- a/modules/monitoring/application/views/scripts/host/show.phtml +++ b/modules/monitoring/application/views/scripts/host/show.phtml @@ -1,4 +1,7 @@
+ compact): ?> + tabs; ?> + render('partials/host/object-header.phtml') ?> render('partials/host/servicesummary.phtml') ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 69d0f62f5..0efedf328 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -1,11 +1,7 @@ -compact): ?> - -
diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index b50aff9bc..c6dbb4730 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -10,9 +10,7 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->host_last_state_change, true); ?>
From b9f9ea614236e8a65bad6698091aede4fcf97cb7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:19:38 +0200 Subject: [PATCH 073/298] service/show: Ensure dashboard compliance refs #7876 --- .../views/scripts/partials/service/object-header.phtml | 4 ---- .../monitoring/application/views/scripts/service/show.phtml | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 5f3ccb70f..45111fe1e 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -1,12 +1,8 @@ -compact): ?> - - - - downtime->is_flexible && $this->downtime->is_in_effect): ?> - - - - - - - - - - - - - - + From bb7afd9b2b4a1579188902720182aa2a955dd179 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:25:43 +0200 Subject: [PATCH 145/298] Add tooltips to downtime detail view refs #8902 --- .../views/scripts/downtime/show.phtml | 75 ++++++++++++++----- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index d71b92c55..c6084a29f 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -80,37 +80,72 @@

- +
diff --git a/modules/monitoring/application/views/scripts/service/show.phtml b/modules/monitoring/application/views/scripts/service/show.phtml index 3a09e2bf4..4d33644ce 100644 --- a/modules/monitoring/application/views/scripts/service/show.phtml +++ b/modules/monitoring/application/views/scripts/service/show.phtml @@ -1,4 +1,7 @@
+ compact): ?> + tabs; ?> + render('partials/service/object-header.phtml') ?>

translate("Service detail information") ?>

From 78e4df2ce99a6ff3f8b8b734479564f9c5bce4a0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:20:06 +0200 Subject: [PATCH 074/298] monitoring health views: Ensure dashboard compliance refs #7876 --- .../views/scripts/process/disable-notifications.phtml | 4 +++- .../monitoring/application/views/scripts/process/info.phtml | 6 +++--- .../application/views/scripts/process/not-running.phtml | 4 +++- .../application/views/scripts/process/performance.phtml | 5 +++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml index 9b9a2b133..e8c75e53f 100644 --- a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml +++ b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml @@ -1,6 +1,8 @@ +compact): ?>
- tabs->showOnlyCloseButton() ?> + tabs->showOnlyCloseButton(); ?>
+

notifications_enabled === false): ?> diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 835228814..8cb5aebe1 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -1,12 +1,12 @@ runtimeVariables()->create($this->runtimevariables); $cp = $this->checkPerformance()->create($this->checkperformance); -?> +if (! $this->compact): ?>
- tabs ?> + tabs; ?>
+
diff --git a/modules/monitoring/application/views/scripts/process/not-running.phtml b/modules/monitoring/application/views/scripts/process/not-running.phtml index 58b6c2980..8439fc49e 100644 --- a/modules/monitoring/application/views/scripts/process/not-running.phtml +++ b/modules/monitoring/application/views/scripts/process/not-running.phtml @@ -1,6 +1,8 @@ +compact): ?>
- tabs ?> + tabs; ?>
+
translate('%s is currently not up and running'), $this->backendName) ?>
diff --git a/modules/monitoring/application/views/scripts/process/performance.phtml b/modules/monitoring/application/views/scripts/process/performance.phtml index 6276d76d1..0bff8891f 100644 --- a/modules/monitoring/application/views/scripts/process/performance.phtml +++ b/modules/monitoring/application/views/scripts/process/performance.phtml @@ -1,7 +1,8 @@ +compact): ?>
-tabs ?> + tabs; ?>
-runtimeVariables()->create($this->runtimevariables); $cp = $this->checkPerformance()->create($this->checkperformance); From c099b7ddd70e9ae5c0ff3824eab9614961653dca Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:20:22 +0200 Subject: [PATCH 075/298] eventgrid: Ensure dashboard compliance refs #7876 --- .../views/scripts/list/eventgrid.phtml | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/eventgrid.phtml b/modules/monitoring/application/views/scripts/list/eventgrid.phtml index 1af75caf9..6936e9063 100644 --- a/modules/monitoring/application/views/scripts/list/eventgrid.phtml +++ b/modules/monitoring/application/views/scripts/list/eventgrid.phtml @@ -1,21 +1,25 @@ - - - -
- tabs->render($this); ?> -
- -
-
- +if (! $this->compact): ?> +
+ tabs; ?> + sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?> + +
+
translate('No state changes in the selected time period.') . '
'; + return; +} + $settings = array( 'cnt_up' => array( 'tooltip' => $this->translate('%d hosts ok on %s'), @@ -63,11 +67,8 @@ $to = intval($form->getValue('to', time())); if ($to - $from > 315360000) { $from = $to - 315360000; } -$data = array(); -if (count($summary) === 0) { - echo $this->translate('No state changes in the selected time period.'); -} +$data = array(); foreach ($summary as $entry) { $day = $entry->day; $value = $entry->$column; From 14a555629d8016955c5f4642ac357f6ef3629c3c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:20:29 +0200 Subject: [PATCH 076/298] servicegrid: Ensure dashboard compliance refs #7876 --- .../views/scripts/list/servicegrid.phtml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index a2e7502ea..6fb6db63e 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -1,28 +1,28 @@ -compact): ?> +if (! $this->compact): ?>
tabs; ?> -
- translate('Sort by'); ?> sortControl; ?> -
+ sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?>
- pivot->toArray(); +if (count($pivotData) === 0) { + echo $this->translate('No services found matching the filter') . ''; + return; +} + $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ')'; ?> - - - translate('No Services matching the filter'); ?> - - +
$serviceStates): ?> From dbf471feac723f77aa159e76cb968490b924f521 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 17 Apr 2015 16:21:14 +0200 Subject: [PATCH 077/298] Use the helper to setup the FilterEditor widget refs #7876 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a6c38c2e1..78c88dabc 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -689,7 +689,7 @@ class Monitoring_ListController extends Controller ->handleRequest($this->getRequest()); $query->applyFilter($editor->getFilter()); - $this->view->filterEditor = $editor; + $this->setupFilterControl($editor); $this->view->filter = $editor->getFilter(); if ($sort = $this->params->get('sort')) { From 8dba5752dcb43c9da8008bccdb8576b9419b372f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 10:09:33 +0200 Subject: [PATCH 078/298] ModuleManager: Improve error messages when en-/disabling modules --- .../Icinga/Application/Modules/Manager.php | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 8f48d7b77..90e55f0b4 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -12,7 +12,6 @@ use Icinga\Exception\ConfigurationError; use Icinga\Exception\SystemPermissionException; use Icinga\Exception\ProgrammingError; use Icinga\Exception\NotReadableError; -use Icinga\Exception\NotFoundError; /** * Module manager that handles detecting, enabling and disabling of modules @@ -199,7 +198,6 @@ class Manager * * @return $this * @throws ConfigurationError When trying to enable a module that is not installed - * @throws NotFoundError In case the "enabledModules" directory does not exist * @throws SystemPermissionException When insufficient permissions for the application exist */ public function enableModule($name) @@ -218,14 +216,15 @@ class Manager if (! is_dir($this->enableDir) && !@mkdir($this->enableDir, 02770, true)) { $error = error_get_last(); throw new SystemPermissionException( - 'Failed to create enabledModule directory "%s" (%s)', + 'Failed to create enabledModules directory "%s" (%s)', $this->enableDir, $error['message'] ); } elseif (! is_writable($this->enableDir)) { throw new SystemPermissionException( - 'Cannot enable module "%s". Insufficient system permissions for enabling modules.', - $name + 'Cannot enable module "%s". Check the permissions for the enabledModules directory: %s', + $name, + $this->enableDir ); } @@ -237,10 +236,11 @@ class Manager $error = error_get_last(); if (strstr($error["message"], "File exists") === false) { throw new SystemPermissionException( - 'Could not enable module "%s" due to file system errors. ' + 'Cannot enable module "%s" at %s due to file system errors. ' . 'Please check path and mounting points because this is not a permission error. ' . 'Primary error was: %s', $name, + $this->enableDir, $error['message'] ); } @@ -259,32 +259,37 @@ class Manager * @return $this * * @throws ConfigurationError When the module is not installed or it's not a symlink - * @throws SystemPermissionException When the module can't be disabled + * @throws SystemPermissionException When insufficient permissions for the application exist */ public function disableModule($name) { if (! $this->hasEnabled($name)) { return $this; } + if (! is_writable($this->enableDir)) { throw new SystemPermissionException( - 'Could not disable module. Module path is not writable.' + 'Cannot disable module "%s". Check the permissions for the enabledModules directory: %s', + $name, + $this->enableDir ); } + $link = $this->enableDir . DIRECTORY_SEPARATOR . $name; if (! file_exists($link)) { throw new ConfigurationError( - 'Could not disable module. The module %s was not found.', + 'Cannot disable module "%s". Module is not installed.', $name ); } if (! is_link($link)) { throw new ConfigurationError( - 'Could not disable module. The module "%s" is not a symlink. ' + 'Cannot disable module %s at %s. ' . 'It looks like you have installed this module manually and moved it to your module folder. ' . 'In order to dynamically enable and disable modules, you have to create a symlink to ' - . 'the enabled_modules folder.', - $name + . 'the enabledModules folder.', + $name, + $this->enableDir ); } @@ -292,10 +297,11 @@ class Manager if (! @unlink($link)) { $error = error_get_last(); throw new SystemPermissionException( - 'Could not disable module "%s" due to file system errors. ' + 'Cannot enable module "%s" at %s due to file system errors. ' . 'Please check path and mounting points because this is not a permission error. ' . 'Primary error was: %s', $name, + $this->enableDir, $error['message'] ); } From ce6be0cc0f8242885d625aab2dbd8b044b1f5753 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 20 Apr 2015 11:11:35 +0200 Subject: [PATCH 079/298] Only use JS tooltips when non-native tooltip behavior is required Only display JS tooltips when there are specific requirements for delay, there is a specific alignment or HTML markup can be rendered in the tooltip. fixes #9025 --- public/js/icinga/behavior/tooltip.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index d3dc6c539..e0826b005 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -31,15 +31,25 @@ $('i[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); $('[title]', el).each(function (i, el) { var $el = $(el); - var delay = 500; + var delay, gravity; if ($el.data('tooltip-delay') !== undefined) { delay = $el.data('tooltip-delay'); } - var gravity = $.fn.tipsy.autoNS; if ($el.data('tooltip-gravity')) { gravity = $el.data('tooltip-gravity'); } - $el.tipsy({ gravity: gravity, delayIn: delay }); + if (delay === undefined && + gravity === undefined && + !$el.data('title-rich')) { + // use native tooltips for everything that doesn't + // require specific behavior or html markup + return; + } + delay = delay === undefined ? 500 : delay; + $el.tipsy({ + gravity: gravity || $.fn.tipsy.autoNS, + delayIn: delay + }); }); // migrate or remove all orphaned tooltips From 423b92f8dce5b2e4cf7b0dd18d2e581fa93fa3fd Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 20 Apr 2015 12:02:17 +0200 Subject: [PATCH 080/298] Remove gravity settings from servicegrid refs #9025 --- .../application/views/scripts/list/servicegrid.phtml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 9219e5dda..a2e7502ea 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -50,8 +50,7 @@ foreach ($serviceDescriptions as $service_description): ?> 'service_description' => $service_description ), array( - 'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $service_description), - 'data-tooltip-gravity' => 's' + 'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $service_description) ), false ); ?> From 593ea7add5d3e5e6803a4950552fbd137841e140 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:02:12 +0200 Subject: [PATCH 081/298] Move monitoring module renderers from global module to monitoring module refs #7642 --- .../library/Monitoring}/Web/Menu/MonitoringMenuItemRenderer.php | 0 .../library/Monitoring}/Web/Menu/ProblemMenuItemRenderer.php | 0 .../Monitoring}/Web/Menu/UnhandledHostMenuItemRenderer.php | 0 .../Monitoring}/Web/Menu/UnhandledServiceMenuItemRenderer.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {library/Icinga => modules/monitoring/library/Monitoring}/Web/Menu/MonitoringMenuItemRenderer.php (100%) rename {library/Icinga => modules/monitoring/library/Monitoring}/Web/Menu/ProblemMenuItemRenderer.php (100%) rename {library/Icinga => modules/monitoring/library/Monitoring}/Web/Menu/UnhandledHostMenuItemRenderer.php (100%) rename {library/Icinga => modules/monitoring/library/Monitoring}/Web/Menu/UnhandledServiceMenuItemRenderer.php (100%) diff --git a/library/Icinga/Web/Menu/MonitoringMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php similarity index 100% rename from library/Icinga/Web/Menu/MonitoringMenuItemRenderer.php rename to modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php diff --git a/library/Icinga/Web/Menu/ProblemMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/ProblemMenuItemRenderer.php similarity index 100% rename from library/Icinga/Web/Menu/ProblemMenuItemRenderer.php rename to modules/monitoring/library/Monitoring/Web/Menu/ProblemMenuItemRenderer.php diff --git a/library/Icinga/Web/Menu/UnhandledHostMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/UnhandledHostMenuItemRenderer.php similarity index 100% rename from library/Icinga/Web/Menu/UnhandledHostMenuItemRenderer.php rename to modules/monitoring/library/Monitoring/Web/Menu/UnhandledHostMenuItemRenderer.php diff --git a/library/Icinga/Web/Menu/UnhandledServiceMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/UnhandledServiceMenuItemRenderer.php similarity index 100% rename from library/Icinga/Web/Menu/UnhandledServiceMenuItemRenderer.php rename to modules/monitoring/library/Monitoring/Web/Menu/UnhandledServiceMenuItemRenderer.php From 4b43fbe5276219499bca90c2f36a29a70b5997d5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 13:03:13 +0200 Subject: [PATCH 082/298] Host- and Service multiselection: Ensure dashboard compliance refs #7876 --- .../monitoring/application/controllers/HostsController.php | 2 +- .../monitoring/application/controllers/ServicesController.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 27d26e51b..7ffd02394 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -26,7 +26,7 @@ class Monitoring_HostsController extends Controller public function init() { $hostList = new HostList($this->backend); - $hostList->setFilter(Filter::fromQueryString((string) $this->params)); + $hostList->setFilter(Filter::fromQueryString((string) $this->params->without('view'))); $this->hostList = $hostList; } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index b82d6f00e..d902b3b75 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -27,7 +27,9 @@ class Monitoring_ServicesController extends Controller public function init() { $serviceList = new ServiceList($this->backend); - $serviceList->setFilter(Filter::fromQueryString((string) $this->params->without('service_problem', 'service_handled'))); + $serviceList->setFilter(Filter::fromQueryString( + (string) $this->params->without('service_problem', 'service_handled', 'view') + )); $this->serviceList = $serviceList; } From c76e4e35837326538d64afcde0f1ad68bc681d1a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:05:23 +0200 Subject: [PATCH 083/298] Change the global namespace to the module specific namespace refs #7642 --- .../Monitoring/Web/Menu/MonitoringMenuItemRenderer.php | 5 +++-- .../library/Monitoring/Web/Menu/ProblemMenuItemRenderer.php | 2 +- .../Monitoring/Web/Menu/UnhandledHostMenuItemRenderer.php | 4 +--- .../Monitoring/Web/Menu/UnhandledServiceMenuItemRenderer.php | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php index 33e1c6a60..7df80e034 100644 --- a/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php +++ b/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php @@ -1,10 +1,11 @@ Date: Mon, 20 Apr 2015 13:06:45 +0200 Subject: [PATCH 084/298] Do not forcibly hide controls in the dashboard Our views respect view=compact now entirely so there is no need for such a generic "solution" since it also prevents some views from being completely displayed in the dashboard such as the host, service and contact detail view. refs #7876 --- public/css/icinga/layout-structure.less | 2 +- public/js/icinga/ui.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index 23a598b52..9d0d38def 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -163,7 +163,7 @@ html { } .dashboard .controls { - display: none; + padding: 0; } /* Not growing larger than 3840px at 1em=16px right now */ diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index 2c85a2df9..3bfb87c61 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -716,8 +716,6 @@ }, initializeControls: function (parent) { - - var self = this; if ($(parent).closest('.dashboard').length) { return; } @@ -747,7 +745,6 @@ }, fixControls: function ($parent) { - var self = this; if ('undefined' === typeof $parent) { @@ -773,6 +770,11 @@ $('.controls', $parent).each(function (idx, el) { var $el = $(el); + + if ($el.closest('.dashboard').length) { + return; + } + var $fake = $el.next('.fake-controls'); var y = $parent.scrollTop(); From a9819907ed934c94245dd6a42466824ebfcb5fa3 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:08:49 +0200 Subject: [PATCH 085/298] Add namespaced item renderer class loader refs #7642 --- library/Icinga/Web/Menu.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index e95f14c88..056e2ff88 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -117,13 +117,17 @@ class Menu implements RecursiveIterator foreach ($props as $key => $value) { $method = 'set' . implode('', array_map('ucfirst', explode('_', strtolower($key)))); if ($key === 'renderer') { - $class = '\Icinga\Web\Menu\\' . $value; - if (!class_exists($class)) { - throw new ConfigurationError( - sprintf('ItemRenderer with class "%s" does not exist', $class) - ); + if (class_exists($value)) { + $value = new $value; + } else { + $class = '\Icinga\Web\Menu\\' . $value; + if (!class_exists($class)) { + throw new ConfigurationError( + sprintf('ItemRenderer with class "%s" does not exist', $class) + ); + } + $value = new $class; } - $value = new $class; } if (method_exists($this, $method)) { $this->{$method}($value); From c43947d66648a76b3ff9c8c1279e8b9dc407f8f0 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:11:52 +0200 Subject: [PATCH 086/298] Update renderer property definition for problems section refs #7642 --- modules/monitoring/configuration.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 05fa86148..a7f8047c4 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -94,17 +94,17 @@ $this->provideSearchUrl($this->translate('Servicegroups'), 'monitoring/list/serv * Problems Section */ $section = $this->menuSection($this->translate('Problems'), array( - 'renderer' => 'ProblemMenuItemRenderer', + 'renderer' => 'Icinga\Module\Monitoring\Web\Menu\ProblemMenuItemRenderer', 'icon' => 'block', 'priority' => 20 )); $section->add($this->translate('Unhandled Hosts'), array( - 'renderer' => 'UnhandledHostMenuItemRenderer', + 'renderer' => 'Icinga\Module\Monitoring\Web\Menu\UnhandledHostMenuItemRenderer', 'url' => 'monitoring/list/hosts?host_problem=1&host_handled=0', 'priority' => 30 )); $section->add($this->translate('Unhandled Services'), array( - 'renderer' => 'UnhandledServiceMenuItemRenderer', + 'renderer' => 'Icinga\Module\Monitoring\Web\Menu\UnhandledServiceMenuItemRenderer', 'url' => 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity', 'priority' => 40 )); From 8b18c5a60a6873122bc4c38871e0096dce1b2ffb Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 13:18:36 +0200 Subject: [PATCH 087/298] Fix parameters to ignore when setting a filter for the ServiceList refs #7876 --- .../monitoring/application/controllers/ServicesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index d902b3b75..0f94e91aa 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -28,7 +28,7 @@ class Monitoring_ServicesController extends Controller { $serviceList = new ServiceList($this->backend); $serviceList->setFilter(Filter::fromQueryString( - (string) $this->params->without('service_problem', 'service_handled', 'view') + (string) $this->params->without(array('service_problem', 'service_handled', 'view')) )); $this->serviceList = $serviceList; } From 76305269a91f410575baf3fb65971e5b89d2b7bb Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 13:18:57 +0200 Subject: [PATCH 088/298] Hide the top margin for group views in the dashboard refs #7876 --- public/css/icinga/monitoring-colors.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 5c19bfe35..8ab95b3cc 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -814,6 +814,10 @@ div.timeline { /* Monitoring groupsummary styles */ +.dashboard table.groupview { + margin-top: 0; +} + table.groupview { width: 100%; margin-top: 1em; From 7bc07c4368c539727c41d215150b27789297ff6e Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 13:21:37 +0200 Subject: [PATCH 089/298] Force absolute nampesace for module menu item renderer refs #7642 --- library/Icinga/Web/Menu.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 056e2ff88..bca1e17d1 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -117,10 +117,11 @@ class Menu implements RecursiveIterator foreach ($props as $key => $value) { $method = 'set' . implode('', array_map('ucfirst', explode('_', strtolower($key)))); if ($key === 'renderer') { + $value = '\\' . ltrim($value, '\\'); if (class_exists($value)) { $value = new $value; } else { - $class = '\Icinga\Web\Menu\\' . $value; + $class = '\Icinga\Web\Menu' . $value; if (!class_exists($class)) { throw new ConfigurationError( sprintf('ItemRenderer with class "%s" does not exist', $class) From 0be8b8997b1cf4dd8e4ca49d1584b6710ff596e1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 13:25:29 +0200 Subject: [PATCH 090/298] Timeline: Do not enable infinite scrolling when shown in the dashboard refs #7876 --- modules/monitoring/public/js/module.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/public/js/module.js b/modules/monitoring/public/js/module.js index 03cfc1c3d..3421be2cf 100644 --- a/modules/monitoring/public/js/module.js +++ b/modules/monitoring/public/js/module.js @@ -44,7 +44,8 @@ /** * Prepare the timer to handle the timeline's infinite loading */ - if ($('div.timeline').length) { + var $timeline = $('div.timeline'); + if ($timeline.length && !$timeline.closest('.dashboard').length) { if (this.scrollCheckTimer === null) { this.scrollCheckTimer = this.module.icinga.timer.register( this.checkTimelinePosition, From 6b3dd63bb344bf45116e5513264b3f4c5b21520f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:55:18 +0200 Subject: [PATCH 091/298] Doc module: Fix div.controls of the index controller's index action refs #7876 --- modules/doc/application/views/scripts/index/index.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/doc/application/views/scripts/index/index.phtml b/modules/doc/application/views/scripts/index/index.phtml index 0b98623ac..67ee52ac1 100644 --- a/modules/doc/application/views/scripts/index/index.phtml +++ b/modules/doc/application/views/scripts/index/index.phtml @@ -1,6 +1,7 @@ -
+
showOnlyCloseButton(); ?>

translate('Available documentations'); ?>

+
  • qlink( From 0997eaf45935b5252cf5a3467938a05ea3b6cd84 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:56:30 +0200 Subject: [PATCH 092/298] Host detail view: Fix that the list of services is missing all tabs refs #7876 --- .../monitoring/application/views/scripts/show/services.phtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/views/scripts/show/services.phtml b/modules/monitoring/application/views/scripts/show/services.phtml index 57b4b204e..d3a0c3ef8 100644 --- a/modules/monitoring/application/views/scripts/show/services.phtml +++ b/modules/monitoring/application/views/scripts/show/services.phtml @@ -1,4 +1,7 @@
    + compact): ?> + tabs; ?> + render('partials/host/object-header.phtml') ?> render('partials/host/servicesummary.phtml') ?>
    From 1ff9449ad7a23a1f32b237938ba14d6fcac88b00 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:58:25 +0200 Subject: [PATCH 093/298] List views: Show the output and dashboard actions for all views refs #7876 --- application/controllers/ListController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 985c53512..972573dc1 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -3,6 +3,8 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Web\Url; +use Icinga\Web\Widget\Tabextension\DashboardAction; +use Icinga\Web\Widget\Tabextension\OutputFormat; use Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Data\ConfigObject; @@ -29,7 +31,7 @@ class ListController extends Controller 'list/' . str_replace(' ', '', $action) ) - ))->activate($action); + ))->extend(new OutputFormat())->extend(new DashboardAction())->activate($action); } /** From 48df225f987a0bf3140b28735558f0fd8c04ac12 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:58:47 +0200 Subject: [PATCH 094/298] Alertsummary: Add dashboard action refs #7876 --- .../application/controllers/AlertsummaryController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index aea8def93..dcc805286 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -6,6 +6,7 @@ use Icinga\Chart\Unit\LinearUnit; use Icinga\Chart\Unit\StaticAxis; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Web\Widget\SelectBox; +use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Url; class Monitoring_AlertsummaryController extends Controller @@ -44,7 +45,7 @@ class Monitoring_AlertsummaryController extends Controller 'label' => $this->translate('Alert Summary'), 'url' => Url::fromRequest() ) - )->activate('alertsummary'); + )->extend(new DashboardAction())->activate('alertsummary'); $this->view->title = $this->translate('Alert Summary'); $this->view->intervalBox = $this->createIntervalBox(); From 4e27ff962cfaaa35cd62f8d505020070e9c623ae Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:59:05 +0200 Subject: [PATCH 095/298] Host multiselection view: Add dashboard action refs #7876 --- modules/monitoring/application/controllers/HostsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 7ffd02394..e208da312 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -15,6 +15,7 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; use Icinga\Web\Widget\Chart\InlinePie; +use Icinga\Web\Widget\Tabextension\DashboardAction; class Monitoring_HostsController extends Controller { @@ -80,7 +81,7 @@ class Monitoring_HostsController extends Controller 'label' => $this->translate('Hosts'), 'url' => Url::fromRequest() ) - )->activate('show'); + )->extend(new DashboardAction())->activate('show'); $this->setAutorefreshInterval(15); $checkNowForm = new CheckNowCommandForm(); $checkNowForm From 41222fd34ebe1301b9853335598dc10f32a0f9a9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:59:20 +0200 Subject: [PATCH 096/298] Service multiselection view: Add dashboard action refs #7876 --- .../monitoring/application/controllers/ServicesController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 0f94e91aa..8aa27272a 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -16,6 +16,7 @@ use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Web\Url; use Icinga\Web\Widget\Chart\InlinePie; +use Icinga\Web\Widget\Tabextension\DashboardAction; class Monitoring_ServicesController extends Controller { @@ -103,7 +104,7 @@ class Monitoring_ServicesController extends Controller 'label' => $this->translate('Services'), 'url' => Url::fromRequest() ) - )->activate('show'); + )->extend(new DashboardAction())->activate('show'); $this->setAutorefreshInterval(15); $checkNowForm = new CheckNowCommandForm(); $checkNowForm From a4f08067e4b8da9e85d872d610d76c90011f2c24 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:59:32 +0200 Subject: [PATCH 097/298] Applicationlog: : Add dashboard action refs #7876 --- .../application/controllers/ListController.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 78c88dabc..9eb014421 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -728,15 +728,6 @@ class Monitoring_ListController extends Controller */ private function createTabs() { - $tabs = $this->getTabs(); - if (in_array($this->_request->getActionName(), array( - 'hosts', - 'services', - 'eventhistory', - 'eventgrid', - 'notifications' - ))) { - $tabs->extend(new OutputFormat())->extend(new DashboardAction()); - } + $this->getTabs()->extend(new OutputFormat())->extend(new DashboardAction()); } } From 48f9cf61e7ce785a439ec42e13b020bcc841a476 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:59:44 +0200 Subject: [PATCH 098/298] Monitoring health view: Add dashboard action refs #7876 --- .../monitoring/application/controllers/ProcessController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index b20bd7576..a07ac5f3a 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -1,6 +1,7 @@ $this->translate('Monitoring Health'), 'url' =>'monitoring/process/info' ) - ); + )->extend(new DashboardAction()); } /** From a3eb6e37f294df32fabff10920268ec808acf685 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 14:59:54 +0200 Subject: [PATCH 099/298] Tactical overview: Add dashboard action refs #7876 --- .../monitoring/application/controllers/TacticalController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/TacticalController.php b/modules/monitoring/application/controllers/TacticalController.php index 33681528c..d9da6d3d5 100644 --- a/modules/monitoring/application/controllers/TacticalController.php +++ b/modules/monitoring/application/controllers/TacticalController.php @@ -2,6 +2,7 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Module\Monitoring\Controller as MonitoringController; +use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Url; class Monitoring_TacticalController extends MonitoringController @@ -18,7 +19,7 @@ class Monitoring_TacticalController extends MonitoringController 'label' => $this->translate('Tactical Overview'), 'url' => Url::fromRequest() ) - )->activate('tactical_overview'); + )->extend(new DashboardAction())->activate('tactical_overview'); $this->view->statusSummary = $this->backend->select()->from( 'statusSummary', From b68fd935295a9cede0f405e78f7339a997524846 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 15:00:01 +0200 Subject: [PATCH 100/298] Timeline: Add dashboard action refs #7876 --- .../monitoring/application/controllers/TimelineController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index f1ef32592..25827c766 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Timeline\TimeLine; use Icinga\Module\Monitoring\Timeline\TimeRange; use Icinga\Module\Monitoring\Web\Widget\SelectBox; +use Icinga\Web\Widget\Tabextension\DashboardAction; class Monitoring_TimelineController extends Controller { @@ -22,7 +23,7 @@ class Monitoring_TimelineController extends Controller 'label' => $this->translate('Timeline'), 'url' => Url::fromRequest() ) - )->activate('timeline'); + )->extend(new DashboardAction())->activate('timeline'); $this->view->title = $this->translate('Timeline'); // TODO: filter for hard_states (precedence adjustments necessary!) From 9bbb23ae7dd7ffab8462bda7158a03d657dd918b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 16:08:51 +0200 Subject: [PATCH 101/298] Revert "Adjust command links so that they'll use `service_description'" This reverts commit cee189a5fc2b94173eda5587ab5a5ce4125a06d0. Conflicts: modules/monitoring/application/views/scripts/list/comments.phtml modules/monitoring/application/views/scripts/list/downtimes.phtml --- .../monitoring/application/views/scripts/list/comments.phtml | 4 ++-- .../monitoring/application/views/scripts/list/downtimes.phtml | 4 ++-- .../views/scripts/show/components/acknowledgement.phtml | 2 +- .../views/scripts/show/components/checkstatistics.phtml | 2 +- .../application/views/scripts/show/components/command.phtml | 2 +- .../application/views/scripts/show/components/comments.phtml | 2 +- .../application/views/scripts/show/components/downtime.phtml | 2 +- .../views/scripts/show/components/notifications.phtml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 53a00835a..ee6302fef 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -91,8 +91,8 @@ if (count($comments) === 0) { ); } else { $delCommentForm->setAction($this->url('monitoring/service/delete-comment', array( - 'host_name' => $comment->host_name, - 'service_description' => $comment->service_description + 'host_name' => $comment->host_name, + 'service' => $comment->service_description ))); } echo $delCommentForm; diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index b279d4063..3bab05104 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -117,8 +117,8 @@ if (count($downtimes) === 0) { $delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host_name' => $downtime->host_name))); } else { $delDowntimeForm->setAction($this->url('monitoring/service/delete-downtime', array( - 'host_name' => $downtime->host_name, - 'service_description' => $downtime->service_description + 'host_name' => $downtime->host_name, + 'service' => $downtime->service_description ))); } echo $delDowntimeForm; diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index b91807d4f..588be561c 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -31,7 +31,7 @@ if ($object->acknowledged): ?> } else { $ackLink = $this->href( 'monitoring/service/acknowledge-problem', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()) + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index 8fbdb9059..ef1432565 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -31,7 +31,7 @@ if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( $this->translate('Reschedule'), 'monitoring/service/reschedule-check', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()), + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'reschedule', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 0b028ba71..3068c8e1d 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -26,7 +26,7 @@ $command = array_shift($parts); echo $this->qlink( $this->translate('Process check result'), 'monitoring/service/process-check-result', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()), + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'reply', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 61ae96517..adeef6200 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -18,7 +18,7 @@ echo $this->qlink( $this->translate('Add comment'), 'monitoring/service/add-comment', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()), + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'comment', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 9eb4b6c18..abb150892 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -20,7 +20,7 @@ echo $this->qlink( $this->translate('Schedule downtime'), 'monitoring/service/schedule-downtime', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()), + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'plug', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/notifications.phtml b/modules/monitoring/application/views/scripts/show/components/notifications.phtml index dfed6d483..fa4314620 100644 --- a/modules/monitoring/application/views/scripts/show/components/notifications.phtml +++ b/modules/monitoring/application/views/scripts/show/components/notifications.phtml @@ -10,7 +10,7 @@ } else { $ackLink = $this->href( 'monitoring/service/send-custom-notification', - array('host_name' => $object->getHost()->getName(), 'service_description' => $object->getName()) + array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> From 96fb0370a44e65f4946a76d0b0e24a1eb836f630 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 16:09:14 +0200 Subject: [PATCH 102/298] Revert "Require `service_description' instead of `service' to show a particular service" This reverts commit 09ab6019423e858d222a570c65f247bfcb09e62f. --- .../application/controllers/ServiceController.php | 6 +----- .../application/controllers/ShowController.php | 6 +++--- modules/monitoring/application/views/helpers/Link.php | 2 +- .../application/views/scripts/list/servicegrid.phtml | 4 ++-- .../application/views/scripts/list/services.phtml | 4 ++-- .../application/views/scripts/show/history.phtml | 6 +++--- .../library/Monitoring/Object/MonitoredObject.php | 9 +++------ .../Web/Controller/MonitoredObjectController.php | 4 ++-- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 86579343f..4f9bdeb1a 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -25,11 +25,7 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function init() { - $service = new Service( - $this->backend, - $this->params->get('host_name'), - $this->params->get('service_description') - ); + $service = new Service($this->backend, $this->params->get('host_name'), $this->params->get('service')); $this->applyRestriction('monitoring/services/filter', $service); diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 968512c26..13b55da7d 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -194,8 +194,8 @@ class Monitoring_ShowController extends Controller } else { $isService = true; $params = array( - 'host_name' => $object->getHost()->getName(), - 'service_description' => $object->getName() + 'host_name' => $object->getHost()->getName(), + 'service' => $object->getName() ); } $tabs = $this->getTabs(); @@ -223,7 +223,7 @@ class Monitoring_ShowController extends Controller ), 'label' => $this->translate('Service'), 'icon' => 'service', - 'url' => 'monitoring/service/show', + 'url' => 'monitoring/show/service', 'urlParams' => $params, ) ); diff --git a/modules/monitoring/application/views/helpers/Link.php b/modules/monitoring/application/views/helpers/Link.php index 7f1324573..454d37682 100644 --- a/modules/monitoring/application/views/helpers/Link.php +++ b/modules/monitoring/application/views/helpers/Link.php @@ -55,7 +55,7 @@ class Zend_View_Helper_Link extends Zend_View_Helper_Abstract $this->view->qlink( $serviceLinkText, 'monitoring/service/show', - array('host_name' => $host, 'service_description' => $service), + array('host_name' => $host, 'service' => $service), array('title' => sprintf( $this->view->translate('Show detailed information for service %s on host %s'), $service, diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 6fb6db63e..2802ad9b4 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -82,8 +82,8 @@ foreach ($serviceDescriptions as $service_description): ?> '', 'monitoring/service/show', array( - 'host_name' => $service->host_name, - 'service_description' => $service->service_description + 'host_name' => $service->host_name, + 'service' => $service->service_description ), array( 'aria-describedby' => $service->host_name . '_' . $service->service_description . '_desc', diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 7473f7f25..12dec8c75 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -34,8 +34,8 @@ if (count($services) === 0) { $serviceLink = $this->href( 'monitoring/service/show', array( - 'host_name' => $service->host_name, - 'service_description' => $service->service_description + 'host_name' => $service->host_name, + 'service' => $service->service_description ) ); $hostLink = $this->href( diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index d2fd1a383..392490595 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -146,10 +146,10 @@ $output = $this->tickets ? preg_replace_callback( $this->translate('%s on %s', 'Service running on host'), $hostContext ? $this->qlink( $event->service_display_name, - 'monitoring/service/show', + 'monitoring/show/service', array( - 'host_name' => $event->host_name, - 'service_description' => $event->service_description + 'host_name' => $event->host_name, + 'service' => $event->service_description ), array('title' => sprintf( $this->translate('Show detailed information for service %s on host %s'), diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index a653ea6ed..084eb86cc 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -556,14 +556,11 @@ abstract class MonitoredObject implements Filterable */ public static function fromParams(UrlParams $params) { - if ($params->has('service_description') && $params->has('host_name')) { - return new Service( - MonitoringBackend::instance(), - $params->get('host_name'), - $params->get('service_description') - ); + if ($params->has('service') && $params->has('host_name')) { + return new Service(MonitoringBackend::instance(), $params->get('host_name'), $params->get('service')); } elseif ($params->has('host_name')) { return new Host(MonitoringBackend::instance(), $params->get('host_name')); } + return null; } } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index de0c3fbfe..3f71cb2c0 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -172,8 +172,8 @@ abstract class MonitoredObjectController extends Controller } else { $isService = true; $params = array( - 'host_name' => $object->getHost()->getName(), - 'service_description' => $object->getName() + 'host_name' => $object->getHost()->getName(), + 'service' => $object->getName() ); } $tabs->add( From 894457a1c13dd362b6f91d6094a5e22b6d9540ca Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 16:11:08 +0200 Subject: [PATCH 103/298] Revert "Adjust command links so that they'll use `host_name' instead of `host'" This reverts commit b9aee47d1f44893ef953bf9168e21f368b95ed7f. Conflicts: modules/monitoring/application/views/scripts/list/comments.phtml modules/monitoring/application/views/scripts/list/downtimes.phtml --- .../monitoring/application/views/scripts/list/comments.phtml | 4 ++-- .../monitoring/application/views/scripts/list/downtimes.phtml | 4 ++-- .../views/scripts/show/components/acknowledgement.phtml | 4 ++-- .../views/scripts/show/components/checkstatistics.phtml | 4 ++-- .../application/views/scripts/show/components/command.phtml | 4 ++-- .../application/views/scripts/show/components/comments.phtml | 4 ++-- .../application/views/scripts/show/components/downtime.phtml | 4 ++-- .../views/scripts/show/components/notifications.phtml | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index ee6302fef..9f383345c 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -87,11 +87,11 @@ if (count($comments) === 0) { $delCommentForm->populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); if ($comment->objecttype === 'host') { $delCommentForm->setAction( - $this->url('monitoring/host/delete-comment', array('host_name' => $comment->host_name)) + $this->url('monitoring/host/delete-comment', array('host' => $comment->host_name)) ); } else { $delCommentForm->setAction($this->url('monitoring/service/delete-comment', array( - 'host_name' => $comment->host_name, + 'host' => $comment->host_name, 'service' => $comment->service_description ))); } diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 3bab05104..3f882a733 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -114,10 +114,10 @@ if (count($downtimes) === 0) { $delDowntimeForm = clone $delDowntimeForm; $delDowntimeForm->populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url)); if (! $isService) { - $delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host_name' => $downtime->host_name))); + $delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host' => $downtime->host_name))); } else { $delDowntimeForm->setAction($this->url('monitoring/service/delete-downtime', array( - 'host_name' => $downtime->host_name, + 'host' => $downtime->host_name, 'service' => $downtime->service_description ))); } diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 588be561c..e7b79354d 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -26,12 +26,12 @@ if ($object->acknowledged): ?> if ($object->getType() === $object::TYPE_HOST) { $ackLink = $this->href( 'monitoring/host/acknowledge-problem', - array('host_name' => $object->getName()) + array('host' => $object->getName()) ); } else { $ackLink = $this->href( 'monitoring/service/acknowledge-problem', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index ef1432565..2a4e4b033 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -31,7 +31,7 @@ if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( $this->translate('Reschedule'), 'monitoring/service/reschedule-check', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'reschedule', 'data-base-target' => '_self', @@ -44,7 +44,7 @@ if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( $this->translate('Reschedule'), 'monitoring/host/reschedule-check', - array('host_name' => $object->getName()), + array('host' => $object->getName()), array( 'icon' => 'reschedule', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 3068c8e1d..d7fca7cfa 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -15,7 +15,7 @@ $command = array_shift($parts); echo $this->qlink( $this->translate('Process check result'), 'monitoring/host/process-check-result', - array('host_name' => $object->getName()), + array('host' => $object->getName()), array( 'icon' => 'reply', 'data-base-target' => '_self', @@ -26,7 +26,7 @@ $command = array_shift($parts); echo $this->qlink( $this->translate('Process check result'), 'monitoring/service/process-check-result', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'reply', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index adeef6200..5a4d351c0 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -7,7 +7,7 @@ echo $this->qlink( $this->translate('Add comment'), 'monitoring/host/add-comment', - array('host_name' => $object->getName()), + array('host' => $object->getName()), array( 'icon' => 'comment', 'data-base-target' => '_self', @@ -18,7 +18,7 @@ echo $this->qlink( $this->translate('Add comment'), 'monitoring/service/add-comment', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'comment', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index abb150892..b338f8a71 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -7,7 +7,7 @@ echo $this->qlink( $this->translate('Schedule downtime'), 'monitoring/host/schedule-downtime', - array('host_name' => $object->getName()), + array('host' => $object->getName()), array( 'icon' => 'plug', 'data-base-target' => '_self', @@ -20,7 +20,7 @@ echo $this->qlink( $this->translate('Schedule downtime'), 'monitoring/service/schedule-downtime', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()), + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( 'icon' => 'plug', 'data-base-target' => '_self', diff --git a/modules/monitoring/application/views/scripts/show/components/notifications.phtml b/modules/monitoring/application/views/scripts/show/components/notifications.phtml index fa4314620..af57eb934 100644 --- a/modules/monitoring/application/views/scripts/show/components/notifications.phtml +++ b/modules/monitoring/application/views/scripts/show/components/notifications.phtml @@ -5,12 +5,12 @@ if ($object->getType() === $object::TYPE_HOST) { $ackLink = $this->href( 'monitoring/host/send-custom-notification', - array('host_name' => $object->getName()) + array('host' => $object->getName()) ); } else { $ackLink = $this->href( 'monitoring/service/send-custom-notification', - array('host_name' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> From f11ea045577c25af14b3b961edd45cef33be59a9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 16:11:22 +0200 Subject: [PATCH 104/298] Revert "Require `host_name' instead of `host' to show or list particular objects" This reverts commit b93d18a0fc2507d360f122afdfb27317b7708fd4. --- doc/accessibility/link-labels.html | 2 +- .../monitoring/application/controllers/HostController.php | 2 +- .../application/controllers/ServiceController.php | 2 +- .../monitoring/application/controllers/ShowController.php | 6 +++--- modules/monitoring/application/views/helpers/Link.php | 4 ++-- .../monitoring/application/views/helpers/PluginOutput.php | 2 +- .../monitoring/application/views/scripts/list/hosts.phtml | 4 ++-- .../application/views/scripts/list/servicegrid.phtml | 6 +++--- .../application/views/scripts/list/services.phtml | 8 ++++---- .../views/scripts/partials/host/servicesummary.phtml | 2 +- .../application/views/scripts/show/history.phtml | 4 ++-- .../library/Monitoring/Object/MonitoredObject.php | 8 ++++---- .../Web/Controller/MonitoredObjectController.php | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/accessibility/link-labels.html b/doc/accessibility/link-labels.html index a65b909de..439adb85e 100644 --- a/doc/accessibility/link-labels.html +++ b/doc/accessibility/link-labels.html @@ -8,7 +8,7 @@ - localhost diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 5b336a26b..11179c1fa 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -26,7 +26,7 @@ class Monitoring_HostController extends MonitoredObjectController */ public function init() { - $host = new Host($this->backend, $this->params->get('host_name')); + $host = new Host($this->backend, $this->params->get('host')); $this->applyRestriction('monitoring/hosts/filter', $host); diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 4f9bdeb1a..3dc98c3b8 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -25,7 +25,7 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function init() { - $service = new Service($this->backend, $this->params->get('host_name'), $this->params->get('service')); + $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); $this->applyRestriction('monitoring/services/filter', $service); diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 13b55da7d..c1522d2a1 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -189,12 +189,12 @@ class Monitoring_ShowController extends Controller if ($object->getType() === $object::TYPE_HOST) { $isService = false; $params = array( - 'host_name' => $object->getName() + 'host' => $object->getName() ); } else { $isService = true; $params = array( - 'host_name' => $object->getHost()->getName(), + 'host' => $object->getHost()->getName(), 'service' => $object->getName() ); } @@ -208,7 +208,7 @@ class Monitoring_ShowController extends Controller ), 'label' => $this->translate('Host'), 'icon' => 'host', - 'url' => 'monitoring/host/show', + 'url' => 'monitoring/show/host', 'urlParams' => $params, ) ); diff --git a/modules/monitoring/application/views/helpers/Link.php b/modules/monitoring/application/views/helpers/Link.php index 454d37682..8faf6e5fb 100644 --- a/modules/monitoring/application/views/helpers/Link.php +++ b/modules/monitoring/application/views/helpers/Link.php @@ -33,7 +33,7 @@ class Zend_View_Helper_Link extends Zend_View_Helper_Abstract return $this->view->qlink( $linkText, 'monitoring/host/show', - array('host_name' => $host), + array('host' => $host), array('title' => sprintf($this->view->translate('Show detailed information for host %s'), $host)) ); } @@ -55,7 +55,7 @@ class Zend_View_Helper_Link extends Zend_View_Helper_Abstract $this->view->qlink( $serviceLinkText, 'monitoring/service/show', - array('host_name' => $host, 'service' => $service), + array('host' => $host, 'service' => $service), array('title' => sprintf( $this->view->translate('Show detailed information for service %s on host %s'), $service, diff --git a/modules/monitoring/application/views/helpers/PluginOutput.php b/modules/monitoring/application/views/helpers/PluginOutput.php index 8778d01b3..d494a7810 100644 --- a/modules/monitoring/application/views/helpers/PluginOutput.php +++ b/modules/monitoring/application/views/helpers/PluginOutput.php @@ -65,7 +65,7 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract parse_str($m[1], $params); if (isset($params['host'])) { $tag->setAttribute('href', $this->view->baseUrl( - '/monitoring/host/show?host_name=' . urlencode($params['host'] + '/monitoring/host/show?host=' . urlencode($params['host'] ))); } } else { diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 3efb70320..d1cdaf1b3 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -34,7 +34,7 @@ if (count($hosts) === 0) { host_state); - $hostLink = $this->href('monitoring/host/show', array('host_name' => $host->host_name)); + $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name)); $icons = array(); if (! $host->host_handled && $host->host_state > 0){ @@ -104,7 +104,7 @@ if (count($hosts) === 0) { ), 'monitoring/show/services', array( - 'host_name' => $host->host_name, + 'host' => $host->host_name, 'service_problem' => 1, 'service_handled' => 0 ), diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 2802ad9b4..a9cbac445 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -68,7 +68,7 @@ foreach ($serviceDescriptions as $service_description): ?> qlink( $host_name, 'monitoring/show/services?' . $serviceFilter, - array('host_name' => $host_name), + array('host' => $host_name), array('title' => sprintf($this->translate('List all reported services on host %s'), $host_name)) ); ?> @@ -80,9 +80,9 @@ foreach ($serviceDescriptions as $service_description): ?> qlink( '', - 'monitoring/service/show', + 'monitoring/show/service', array( - 'host_name' => $service->host_name, + 'host' => $service->host_name, 'service' => $service->service_description ), array( diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 12dec8c75..b8d344bde 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -34,14 +34,14 @@ if (count($services) === 0) { $serviceLink = $this->href( 'monitoring/service/show', array( - 'host_name' => $service->host_name, - 'service' => $service->service_description + 'host' => $service->host_name, + 'service' => $service->service_description ) ); $hostLink = $this->href( - 'monitoring/host/show', + 'monitoring/show/host', array( - 'host_name' => $service->host_name, + 'host' => $service->host_name, ) ); $serviceStateName = Service::getStateText($service->service_state); diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml index 23cc21e97..c0acdead4 100644 --- a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml @@ -3,7 +3,7 @@ use Icinga\Web\Url; use Icinga\Module\Monitoring\Object\Service; -$selfUrl = Url::fromPath('monitoring/show/services', array('host_name' => $object->host_name)); +$selfUrl = Url::fromPath('monitoring/show/services', array('host' => $object->host_name)); $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); ?>
    compact ? ' data-base-target="col1"' : ''; ?>> stats->services_total): ?> diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 392490595..3777d0384 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -148,8 +148,8 @@ $output = $this->tickets ? preg_replace_callback( $event->service_display_name, 'monitoring/show/service', array( - 'host_name' => $event->host_name, - 'service' => $event->service_description + 'host' => $event->host_name, + 'service' => $event->service_description ), array('title' => sprintf( $this->translate('Show detailed information for service %s on host %s'), diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 084eb86cc..05f201428 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -556,10 +556,10 @@ abstract class MonitoredObject implements Filterable */ public static function fromParams(UrlParams $params) { - if ($params->has('service') && $params->has('host_name')) { - return new Service(MonitoringBackend::instance(), $params->get('host_name'), $params->get('service')); - } elseif ($params->has('host_name')) { - return new Host(MonitoringBackend::instance(), $params->get('host_name')); + if ($params->has('service') && $params->has('host')) { + return new Service(MonitoringBackend::instance(), $params->get('host'), $params->get('service')); + } elseif ($params->has('host')) { + return new Host(MonitoringBackend::instance(), $params->get('host')); } return null; } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 3f71cb2c0..04102e9d2 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -167,12 +167,12 @@ abstract class MonitoredObjectController extends Controller if ($object->getType() === $object::TYPE_HOST) { $isService = false; $params = array( - 'host_name' => $object->getName() + 'host' => $object->getName() ); } else { $isService = true; $params = array( - 'host_name' => $object->getHost()->getName(), + 'host' => $object->getHost()->getName(), 'service' => $object->getName() ); } From 1e064a537923fef693da74c796e479ef31a83eb8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2015 16:13:03 +0200 Subject: [PATCH 105/298] Revert "Fix host and service multiselection" This reverts commit 1f4b3aa8ea66ac51275d050c19f0801da033d2d7. --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index d1cdaf1b3..04fadf2ec 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -28,7 +28,7 @@ if (count($hosts) === 0) { data-base-target="_next" class="action multiselect" data-icinga-multiselect-url="href('monitoring/hosts/show') ?>" - data-icinga-multiselect-data="host_name" + data-icinga-multiselect-data="host" >
compact): ?> compact" style="table-layout: auto;" data-icinga-multiselect-url="href("monitoring/services/show") ?>" - data-icinga-multiselect-data="service_description,host_name"> + data-icinga-multiselect-data="service,host"> href( From f543321ac4fa173d491ed7f7d7c28326c0da9ce3 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 17:02:42 +0200 Subject: [PATCH 106/298] Replace MenuItemRenderer interface with a base class MenuItemRenderer refs #7658 --- library/Icinga/Web/Menu/MenuItemRenderer.php | 102 ++++++++++++++++++- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Menu/MenuItemRenderer.php b/library/Icinga/Web/Menu/MenuItemRenderer.php index 15e6b2930..33c653a7c 100644 --- a/library/Icinga/Web/Menu/MenuItemRenderer.php +++ b/library/Icinga/Web/Menu/MenuItemRenderer.php @@ -3,11 +3,107 @@ namespace Icinga\Web\Menu; +use Icinga\Application\Icinga; use Icinga\Web\Menu; +use Icinga\Web\View; /** - * Renders the html content of a single menu item + * Default MenuItemRenderer class */ -interface MenuItemRenderer { - public function render(Menu $menu); +class MenuItemRenderer +{ + /** + * Contains element specific attributes + * + * @var array + */ + protected $attributes = array(); + + /** + * View + * + * @var View|null + */ + protected $view; + + /** + * Set the view + * + * @param View $view + * + * @return $this + */ + public function setView(View $view) + { + $this->view = $view; + return $this; + } + + /** + * Get the view + * + * @return View + */ + public function getView() + { + if ($this->view === null) { + $this->view = Icinga::app()->getViewRenderer()->view; + } + return $this->view; + } + + /** + * Renders the html content of a single menu item + * + * @param Menu $menu + * + * @return string + */ + public function render(Menu $menu) + { + return $this->createLink($menu); + } + + /** + * Creates a menu item link element + * + * @param Menu $menu + * + * @return string + */ + public function createLink(Menu $menu) + { + if ($menu->getIcon() && strpos($menu->getIcon(), '.') === false) { + return sprintf( + '%s', + $menu->getUrl() ? : '#', + $this->getAttributes(), + $menu->getIcon(), + $this->getView()->escape($menu->getTitle()) + ); + } + + return sprintf( + '%s%s', + $menu->getUrl() ? : '#', + $this->getAttributes(), + $menu->getIcon() ? ' ' : '', + $this->getView()->escape($menu->getTitle()) + ); + } + + /** + * Returns element specific attributes if present + * + * @return string + */ + protected function getAttributes() + { + $attributes = ''; + $view = $this->getView(); + foreach ($this->attributes as $attribute => $value) { + $attributes .= ' ' . $view->escape($attribute) . '="' . $view->escape($value) . '"'; + } + return $attributes; + } } From 4eb5f75c62056b6c9b19c156c52bac165b1169ba Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 17:04:46 +0200 Subject: [PATCH 107/298] Use default MenuItemRenderer as renderer if no custom renderer is set refs #7658 --- library/Icinga/Web/MenuRenderer.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/library/Icinga/Web/MenuRenderer.php b/library/Icinga/Web/MenuRenderer.php index 7d2cd5ad3..4dec9404e 100644 --- a/library/Icinga/Web/MenuRenderer.php +++ b/library/Icinga/Web/MenuRenderer.php @@ -4,6 +4,7 @@ namespace Icinga\Web; use Exception; +use Icinga\Web\Menu\MenuItemRenderer; use RecursiveIteratorIterator; use Icinga\Application\Logger; use Icinga\Web\Menu\PermittedMenuItemFilter; @@ -32,6 +33,11 @@ class MenuRenderer extends RecursiveIteratorIterator */ protected $useCustomRenderer = false; + /** + * @var MenuItemRenderer + */ + protected $defaultRenderer; + /** * Create a new MenuRenderer * @@ -45,6 +51,7 @@ class MenuRenderer extends RecursiveIteratorIterator } else { $this->url = Url::fromPath($url); } + $this->defaultRenderer = new MenuItemRenderer(); parent::__construct(new PermittedMenuItemFilter($menu), RecursiveIteratorIterator::CHILD_FIRST); } @@ -114,22 +121,8 @@ class MenuRenderer extends RecursiveIteratorIterator Logger::error('Could not invoke custom renderer. Exception: '. $e->getMessage()); } } - if ($child->getIcon() && strpos($child->getIcon(), '.') === false) { - return sprintf( - '%s', - $child->getUrl() ?: '#', - $child->getIcon(), - htmlspecialchars($child->getTitle()) - ); - } - return sprintf( - '%s%s', - $child->getUrl() ?: '#', - $child->getIcon() - ? ' ' - : '', - htmlspecialchars($child->getTitle()) - ); + + return $this->defaultRenderer->render($child); } /** From 9ebf4742de1bfe7484e7b521bd9dff4d52f91eba Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 20 Apr 2015 17:07:34 +0200 Subject: [PATCH 108/298] Use the MenuItemRenderer render() implemnetations refs #7658 --- .../Web/Menu/ForeignMenuItemRenderer.php | 16 +++------ .../Web/Menu/MonitoringMenuItemRenderer.php | 34 ++++++------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php index 2ed418bf3..b898b4d08 100644 --- a/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php +++ b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php @@ -9,15 +9,9 @@ use Icinga\Web\Url; /** * A menu item with a link that surpasses the regular navigation link behavior */ -class ForeignMenuItemRenderer implements MenuItemRenderer { - - public function render(Menu $menu) - { - return sprintf( - '%s%s', - $menu->getUrl() ?: '#', - $menu->getIcon() ? ' ' : '', - htmlspecialchars($menu->getTitle()) - ); - } +class ForeignMenuItemRenderer extends MenuItemRenderer +{ + protected $attributes = array( + 'target' => '_self' + ); } diff --git a/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php index 7df80e034..80ffb3d9c 100644 --- a/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php +++ b/modules/monitoring/library/Monitoring/Web/Menu/MonitoringMenuItemRenderer.php @@ -6,10 +6,9 @@ namespace Icinga\Module\Monitoring\Web\Menu; use Icinga\Web\Menu as Menu; use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Web\Menu\MenuItemRenderer; -use Icinga\Web\Url; - -class MonitoringMenuItemRenderer implements MenuItemRenderer { +class MonitoringMenuItemRenderer extends MenuItemRenderer +{ protected static $summary; protected $columns = array(); @@ -70,31 +69,18 @@ class MonitoringMenuItemRenderer implements MenuItemRenderer { public function render(Menu $menu) { - $count = $this->countItems(); - $badge = ''; - if ($count) { - $badge = sprintf( + return $this->getBadge() . $this->createLink($menu); + } + + protected function getBadge() + { + if ($count = $this->countItems()) { + return sprintf( '
%s
', $this->getBadgeTitle(), $count ); } - if ($menu->getIcon() && strpos($menu->getIcon(), '.') === false) { - return sprintf( - '%s %s', - $badge, - $menu->getUrl() ?: '#', - $menu->getIcon(), - htmlspecialchars($menu->getTitle()) - ); - } - - return sprintf( - '%s%s%s', - $badge, - $menu->getUrl() ?: '#', - $menu->getIcon() ? ' ' : '', - htmlspecialchars($menu->getTitle()) - ); + return ''; } } From d6e7061de3e9b8cce25f44fb0bfe79ed1b49a97d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 20 Apr 2015 17:54:47 +0200 Subject: [PATCH 109/298] Implement Icinga\Web\Widget\FilterEditor::setSearchColumns() for specifying custom search columns --- library/Icinga/Web/Widget/FilterEditor.php | 88 ++++++++++++++++------ 1 file changed, 64 insertions(+), 24 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 7812cdf47..63293050c 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -6,6 +6,7 @@ namespace Icinga\Web\Widget; use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\FilterExpression; use Icinga\Data\Filter\FilterChain; +use Icinga\Data\Filter\FilterOr; use Icinga\Web\Url; use Icinga\Application\Icinga; use Icinga\Exception\ProgrammingError; @@ -39,6 +40,8 @@ class FilterEditor extends AbstractWidget protected $ignoreParams = array(); + protected $searchColumns = null; + /** * @var string */ @@ -73,6 +76,12 @@ class FilterEditor extends AbstractWidget return $this->filter; } + public function setSearchColumns(array $searchColumns) + { + $this->searchColumns = $searchColumns; + return $this; + } + public function setUrl($url) { $this->url = $url; @@ -147,6 +156,26 @@ class FilterEditor extends AbstractWidget return $filter; } + protected function resetSearchColumns(Filter &$filter) + { + if ($filter->isChain()) { + $filters = &$filter->filters(); + if (!($empty = empty($filters))) { + foreach ($filters as $k => &$f) { + if (false === $this->resetSearchColumns($f)) { + unset($filters[$k]); + } + } + } + return $empty || !empty($filters); + } + return $filter->isExpression() ? !( + in_array($filter->getColumn(), $this->searchColumns) + && + $filter->getSign() === '=' + ) : true; + } + public function handleRequest($request) { $this->setUrl($request->getUrl()->without($this->ignoreParams)); @@ -179,33 +208,44 @@ class FilterEditor extends AbstractWidget $filter = $this->getFilter(); if ($search !== null) { - if (strpos($search, '=') === false) { - // TODO: Ask the view for (multiple) search columns - switch($request->getActionName()) { - case 'services': - $searchCol = 'service'; - break; - case 'hosts': - $searchCol = 'host'; - break; - case 'hostgroups': - $searchCol = 'hostgroup'; - break; - case 'servicegroups': - $searchCol = 'servicegroup'; - break; - default: - $searchCol = null; - } + if ($this->searchColumns === null) { + if (strpos($search, '=') === false) { + // TODO: Ask the view for (multiple) search columns + switch($request->getActionName()) { + case 'services': + $searchCol = 'service'; + break; + case 'hosts': + $searchCol = 'host'; + break; + case 'hostgroups': + $searchCol = 'hostgroup'; + break; + case 'servicegroups': + $searchCol = 'servicegroup'; + break; + default: + $searchCol = null; + } - if ($searchCol === null) { - throw new Exception('Cannot search here'); + if ($searchCol === null) { + throw new Exception('Cannot search here'); + } + $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); + } else { + list($k, $v) = preg_split('/=/', $search); + $filter = $this->mergeRootExpression($filter, $k, '=', $v); } - $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); - } else { - list($k, $v) = preg_split('/=/', $search); - $filter = $this->mergeRootExpression($filter, $k, '=', $v); + if (false === $this->resetSearchColumns($filter)) { + $filter = Filter::matchAll(); + } + + $filters = array(); + foreach ($this->searchColumns as $searchColumn) { + $filters[] = Filter::expression($searchColumn, '=', "*$search*"); + } + $filter->andFilter(new FilterOr($filters)); } $url = $this->url()->setQueryString( From d3964a31fb5c5543da17fa5e99ef8fd69240b4f8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 20 Apr 2015 21:49:45 +0200 Subject: [PATCH 110/298] MenuItemRenderer: add missing use clause Otherwise this completely broke Icinga Web as soon as a single module used a legacy icon. refs #7658 --- library/Icinga/Web/Menu/MenuItemRenderer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Web/Menu/MenuItemRenderer.php b/library/Icinga/Web/Menu/MenuItemRenderer.php index 33c653a7c..d40650d91 100644 --- a/library/Icinga/Web/Menu/MenuItemRenderer.php +++ b/library/Icinga/Web/Menu/MenuItemRenderer.php @@ -5,6 +5,7 @@ namespace Icinga\Web\Menu; use Icinga\Application\Icinga; use Icinga\Web\Menu; +use Icinga\Web\Url; use Icinga\Web\View; /** From 9393d11c0b1b698c89e3291d4801bb249de7cc4a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 22 Apr 2015 16:44:00 +0200 Subject: [PATCH 111/298] Display an error message when enabled modules cannot be read because /etc/icingaweb2 is not readable resolves #9141 --- library/Icinga/Application/Modules/Manager.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 90e55f0b4..84ee5e650 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -101,6 +101,16 @@ class Manager */ private function detectEnabledModules() { + if (false === file_exists($parent = dirname($this->enableDir))) { + return; + } + if (false === is_readable($parent)) { + throw new NotReadableError( + 'Cannot read enabled modules. Module directory\'s parent directory "%s" is not readable', + $parent + ); + } + if (! file_exists($this->enableDir)) { return; } From 1daecbbca0cd5d3251e81a9702f87ca60f6781f7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 22 Apr 2015 17:04:31 +0200 Subject: [PATCH 112/298] Don't use `false === ...' when `! ...' is enough --- library/Icinga/Application/Modules/Manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 84ee5e650..e3e5ec6f2 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -101,10 +101,10 @@ class Manager */ private function detectEnabledModules() { - if (false === file_exists($parent = dirname($this->enableDir))) { + if (! file_exists($parent = dirname($this->enableDir))) { return; } - if (false === is_readable($parent)) { + if (! is_readable($parent)) { throw new NotReadableError( 'Cannot read enabled modules. Module directory\'s parent directory "%s" is not readable', $parent From 9cd7765d9ed57aa9e0ebf110604d90aaed4645d2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 22 Apr 2015 17:25:51 +0200 Subject: [PATCH 113/298] If session_save_path() returns '', use sys_get_temp_dir() resolves #8994 --- library/Icinga/Web/Session/PhpSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index f4aa72fa3..7f47763c0 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -77,7 +77,7 @@ class PhpSession extends Session } } - $sessionSavePath = session_save_path(); + $sessionSavePath = session_save_path() ?: sys_get_temp_dir(); if (session_module_name() === 'files' && !is_writable($sessionSavePath)) { throw new ConfigurationError("Can't save session, path '$sessionSavePath' is not writable."); } From 6ba6cb79404c02dc95648604148bfd0e1a89a66d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Apr 2015 11:58:54 +0200 Subject: [PATCH 114/298] Improve layout of dictionaries in the host and service detail views resolves #8474 --- modules/monitoring/application/views/helpers/Customvar.php | 2 +- modules/monitoring/public/css/module.less | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Customvar.php b/modules/monitoring/application/views/helpers/Customvar.php index 32391b6ce..87bde6b77 100644 --- a/modules/monitoring/application/views/helpers/Customvar.php +++ b/modules/monitoring/application/views/helpers/Customvar.php @@ -38,7 +38,7 @@ class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract protected function renderObject($object) { - if (empty($object)) { + if (0 === count((array) $object)) { return '{}'; } $out = "{
    \n"; diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index f121bb66f..549328ef8 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -177,11 +177,14 @@ table.avp form.object-features div.header h4 { margin: 0; } -table.avp .customvar ul { +table.avp .customvar ul, +table.avp .customvar ul li { list-style-type: none; margin: 0; + margin-top: -0.5em; + margin-bottom: -0.5em; padding: 0; - padding-left: 1.5em; + padding-left: 0.5em; } div.selection-info { From e4a98430216b14218418fb16b6e15b6bfad929b6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Apr 2015 12:38:29 +0200 Subject: [PATCH 115/298] Show Icinga 2 boolean variables in the host and service detail views resolves #8747 --- .../monitoring/application/views/helpers/Customvar.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Customvar.php b/modules/monitoring/application/views/helpers/Customvar.php index 87bde6b77..bb9f70a7e 100644 --- a/modules/monitoring/application/views/helpers/Customvar.php +++ b/modules/monitoring/application/views/helpers/Customvar.php @@ -15,8 +15,12 @@ class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract public function customvar($struct) { - if (is_string($struct) || is_int($struct) || is_float($struct)) { - return $this->view->escape((string) $struct); + if (is_scalar($struct)) { + return $this->view->escape( + is_string($struct) + ? $struct + : var_export($struct, true) + ); } elseif (is_array($struct)) { return $this->renderArray($struct); } elseif (is_object($struct)) { From a976d777b349421bde3e15ba0569dc9fbbbceb21 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Apr 2015 13:31:02 +0200 Subject: [PATCH 116/298] Show custom variables visually separated in the host and service detail views resolves #8966 --- .../views/scripts/show/components/customvars.phtml | 5 +++++ modules/monitoring/public/css/module.less | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index aa2e479e4..50b82dbef 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -1,3 +1,8 @@ +
+ +customvars as $name => $value) { diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 549328ef8..4cc68e18e 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -173,7 +173,8 @@ form.instance-features span.description, form.object-features span.description { } } -table.avp form.object-features div.header h4 { +table.avp form.object-features div.header h4, +table.avp h4.customvar { margin: 0; } From 39042ab306c85af0b5320987e959c9f2b4135718 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Apr 2015 17:44:00 +0200 Subject: [PATCH 117/298] Log each line of a multiline log message separatly resolves #9000 --- library/Icinga/Application/Logger.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/Logger.php b/library/Icinga/Application/Logger.php index 925695dad..61d5f4329 100644 --- a/library/Icinga/Application/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -199,7 +199,9 @@ class Logger $this->writer->log(static::ERROR, $error_message); } - $this->writer->log($level, $message); + foreach (explode("\n", $message) as $msg) { + $this->writer->log($level, $msg); + } } } From a429617a9523afb270a6b9393855a48232653d5a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 24 Apr 2015 10:17:35 +0200 Subject: [PATCH 118/298] Revert "Log each line of a multiline log message separatly" This reverts commit 39042ab306c85af0b5320987e959c9f2b4135718. --- library/Icinga/Application/Logger.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/Icinga/Application/Logger.php b/library/Icinga/Application/Logger.php index 61d5f4329..925695dad 100644 --- a/library/Icinga/Application/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -199,9 +199,7 @@ class Logger $this->writer->log(static::ERROR, $error_message); } - foreach (explode("\n", $message) as $msg) { - $this->writer->log($level, $msg); - } + $this->writer->log($level, $message); } } From 5ba539b7c11407f751b33eb6a441180112e2ecdb Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 24 Apr 2015 10:28:45 +0200 Subject: [PATCH 119/298] SyslogWriter: replace \n w/ 4 spaces in multiline log messages --- library/Icinga/Application/Logger/Writer/SyslogWriter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Logger/Writer/SyslogWriter.php b/library/Icinga/Application/Logger/Writer/SyslogWriter.php index e18c5eeec..4494c9971 100644 --- a/library/Icinga/Application/Logger/Writer/SyslogWriter.php +++ b/library/Icinga/Application/Logger/Writer/SyslogWriter.php @@ -67,6 +67,6 @@ class SyslogWriter extends LogWriter public function log($level, $message) { openlog($this->ident, LOG_PID, $this->facility); - syslog(static::$severityMap[$level], $message); + syslog(static::$severityMap[$level], str_replace("\n", ' ', $message)); } } From 3d53e6f9b58654577ce7cecc9a3863f37864d614 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 24 Apr 2015 11:10:40 +0200 Subject: [PATCH 120/298] Icinga\Protocol\File\FileReader::count(): call iterator_count() only once per instance and cache the returned value --- library/Icinga/Protocol/File/FileReader.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Protocol/File/FileReader.php b/library/Icinga/Protocol/File/FileReader.php index aaef31840..8fb1ed4cb 100644 --- a/library/Icinga/Protocol/File/FileReader.php +++ b/library/Icinga/Protocol/File/FileReader.php @@ -26,6 +26,13 @@ class FileReader implements Selectable, Countable */ protected $filename; + /** + * Cache for static::count() + * + * @var int + */ + protected $count = null; + /** * Create a new reader * @@ -71,7 +78,10 @@ class FileReader implements Selectable, Countable */ public function count() { - return iterator_count($this->iterate()); + if ($this->count === null) { + $this->count = iterator_count($this->iterate()); + } + return $this->count; } /** From ec82b3bc0902c347feec2ddef7eb008cd0ad2f15 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 24 Apr 2015 15:04:19 +0200 Subject: [PATCH 121/298] Implement Icinga\Protocol\File\LogFileIterator --- .../Icinga/Protocol/File/LogFileIterator.php | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 library/Icinga/Protocol/File/LogFileIterator.php diff --git a/library/Icinga/Protocol/File/LogFileIterator.php b/library/Icinga/Protocol/File/LogFileIterator.php new file mode 100644 index 000000000..4b587b58e --- /dev/null +++ b/library/Icinga/Protocol/File/LogFileIterator.php @@ -0,0 +1,154 @@ +file = new SplFileObject($filename); + $this->file->setFlags( + SplFileObject::DROP_NEW_LINE | + SplFileObject::READ_AHEAD + ); + $this->fields = $fields; + } + + public function rewind() + { + $this->file->rewind(); + $this->index = 0; + $this->nextMessage(); + } + + public function next() + { + $this->file->next(); + ++$this->index; + $this->nextMessage(); + } + + /** + * @return string + */ + public function current() + { + return $this->current; + } + + /** + * @return int + */ + public function key() + { + return $this->index; + } + + /** + * @return boolean + */ + public function valid() + { + return $this->valid; + } + + protected function nextMessage() + { + $message = $this->next === null ? array() : array($this->next); + $this->valid = null; + while ($this->file->valid()) { + if (false === ($res = preg_match( + $this->fields, $current = $this->file->current() + ))) { + throw new IcingaException('Failed at preg_match()'); + } + if (empty($message)) { + if ($res === 1) { + $message[] = $current; + } + } else if ($res === 1) { + $this->next = $current; + $this->valid = true; + break; + } else { + $message[] = $current; + } + + $this->file->next(); + } + if ($this->valid === null) { + $this->next = null; + $this->valid = ! empty($message); + } + + if ($this->valid) { + while (! empty($message)) { + $matches = array(); + if (false === ($res = preg_match( + $this->fields, implode(PHP_EOL, $message), $matches + ))) { + throw new IcingaException('Failed at preg_match()'); + } + if ($res === 1) { + $this->current = $matches; + return; + } + array_pop($message); + } + $this->valid = false; + } + } From 7c0be30def6ab64edc800a5c503da7ca5b2dd364 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 24 Apr 2015 16:30:29 +0200 Subject: [PATCH 122/298] Handle and display multiline log messages correctly --- application/controllers/ListController.php | 8 +++----- application/views/scripts/list/applicationlog.phtml | 2 +- library/Icinga/Protocol/File/FileReader.php | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 972573dc1..ca7265f0e 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -44,14 +44,12 @@ class ListController extends Controller } $this->addTitleTab('application log'); - $pattern = '/^(?[0-9]{4}(-[0-9]{2}){2}' // date - . 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time - . ' - (?[A-Za-z]+)' // loglevel - . ' - (?.*)$/'; $resource = new FileReader(new ConfigObject(array( 'filename' => Config::app()->get('logging', 'file'), - 'fields' => $pattern + 'fields' => '/(?[0-9]{4}(?:-[0-9]{2}){2}' // date + . 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time + . ' - (?[A-Za-z]+) - (?.*)(?!.)/msS' // loglevel, message ))); $this->view->logData = $resource->select()->order('DESC')->paginate(); diff --git a/application/views/scripts/list/applicationlog.phtml b/application/views/scripts/list/applicationlog.phtml index cc412eb9c..00102e855 100644 --- a/application/views/scripts/list/applicationlog.phtml +++ b/application/views/scripts/list/applicationlog.phtml @@ -19,7 +19,7 @@ escape($value->loglevel) ?> diff --git a/library/Icinga/Protocol/File/FileReader.php b/library/Icinga/Protocol/File/FileReader.php index 8fb1ed4cb..2c43d390a 100644 --- a/library/Icinga/Protocol/File/FileReader.php +++ b/library/Icinga/Protocol/File/FileReader.php @@ -58,7 +58,7 @@ class FileReader implements Selectable, Countable */ public function iterate() { - return new FileIterator($this->filename, $this->fields); + return new LogFileIterator($this->filename, $this->fields); } /** From 6f0fd7d44de11efb4631ccb5730c0b337c570560 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 27 Apr 2015 13:06:55 +0200 Subject: [PATCH 123/298] Remove right petrol border from plugin output in the host and service detail views resolves #8967 --- modules/monitoring/public/css/module.less | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 4cc68e18e..97d236966 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -32,7 +32,6 @@ p.pluginoutput { } div.pluginoutput { - border-right: solid 5px @colorPetrol; overflow: auto; color: black; margin-bottom: 1em; From c839cc0b0884fa33fa0cf95c5af84c60af6f3a61 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 27 Apr 2015 13:16:54 +0200 Subject: [PATCH 124/298] Remove exclamation mark from the notification "Authentication order updated!" resolves #8960 --- application/forms/Config/AuthenticationBackendReorderForm.php | 2 +- application/locale/it_IT/LC_MESSAGES/icinga.po | 2 +- application/locale/pt_BR/LC_MESSAGES/icinga.po | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/forms/Config/AuthenticationBackendReorderForm.php b/application/forms/Config/AuthenticationBackendReorderForm.php index e4ac90c12..34f20d851 100644 --- a/application/forms/Config/AuthenticationBackendReorderForm.php +++ b/application/forms/Config/AuthenticationBackendReorderForm.php @@ -51,7 +51,7 @@ class AuthenticationBackendReorderForm extends ConfigForm try { if ($configForm->move($backendName, $position)->save()) { - Notification::success($this->translate('Authentication order updated!')); + Notification::success($this->translate('Authentication order updated')); } else { return false; } diff --git a/application/locale/it_IT/LC_MESSAGES/icinga.po b/application/locale/it_IT/LC_MESSAGES/icinga.po index 2b867ca14..c61195216 100644 --- a/application/locale/it_IT/LC_MESSAGES/icinga.po +++ b/application/locale/it_IT/LC_MESSAGES/icinga.po @@ -199,7 +199,7 @@ msgid "Authentication backend name missing" msgstr "Nome del Backend di autenticazione non specificato" #: /usr/share/icingaweb2/application/forms/Config/AuthenticationBackendReorderForm.php:54 -msgid "Authentication order updated!" +msgid "Authentication order updated" msgstr "Ordine di autenticazione aggiornato!" #: /usr/share/icingaweb2/application/forms/AutoRefreshForm.php:44 diff --git a/application/locale/pt_BR/LC_MESSAGES/icinga.po b/application/locale/pt_BR/LC_MESSAGES/icinga.po index 01dc18a9f..ba35c265e 100644 --- a/application/locale/pt_BR/LC_MESSAGES/icinga.po +++ b/application/locale/pt_BR/LC_MESSAGES/icinga.po @@ -130,7 +130,7 @@ msgid "Authentication backend name missing" msgstr "Falta o nome do backend de autenticação" #: /usr/local/icingaweb/application/forms/Config/AuthenticationBackendReorderForm.php:55 -msgid "Authentication order updated!" +msgid "Authentication order updated" msgstr "Ordem da autenticação atualizada!" #: /usr/local/icingaweb/application/forms/Config/AuthenticationBackendConfigForm.php:307 From 9917e63e020991bfc3895fb954968efc610a0f31 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 27 Apr 2015 13:16:54 +0200 Subject: [PATCH 125/298] Remove exclamation mark from the notification "Authentication order updated!"'s translations --- application/locale/it_IT/LC_MESSAGES/icinga.po | 2 +- application/locale/pt_BR/LC_MESSAGES/icinga.po | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/locale/it_IT/LC_MESSAGES/icinga.po b/application/locale/it_IT/LC_MESSAGES/icinga.po index c61195216..73d616bfa 100644 --- a/application/locale/it_IT/LC_MESSAGES/icinga.po +++ b/application/locale/it_IT/LC_MESSAGES/icinga.po @@ -200,7 +200,7 @@ msgstr "Nome del Backend di autenticazione non specificato" #: /usr/share/icingaweb2/application/forms/Config/AuthenticationBackendReorderForm.php:54 msgid "Authentication order updated" -msgstr "Ordine di autenticazione aggiornato!" +msgstr "Ordine di autenticazione aggiornato" #: /usr/share/icingaweb2/application/forms/AutoRefreshForm.php:44 msgid "Auto refresh successfully disabled" diff --git a/application/locale/pt_BR/LC_MESSAGES/icinga.po b/application/locale/pt_BR/LC_MESSAGES/icinga.po index ba35c265e..16aba2378 100644 --- a/application/locale/pt_BR/LC_MESSAGES/icinga.po +++ b/application/locale/pt_BR/LC_MESSAGES/icinga.po @@ -131,7 +131,7 @@ msgstr "Falta o nome do backend de autenticação" #: /usr/local/icingaweb/application/forms/Config/AuthenticationBackendReorderForm.php:55 msgid "Authentication order updated" -msgstr "Ordem da autenticação atualizada!" +msgstr "Ordem da autenticação atualizada" #: /usr/local/icingaweb/application/forms/Config/AuthenticationBackendConfigForm.php:307 msgid "Autologin" From f3ca80ffced18497322a74b8b49e94e88bb31cdc Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 27 Apr 2015 14:44:19 +0200 Subject: [PATCH 126/298] Don't fetchAll() and loop afterwards in the alert summary report refs #8340 --- .../application/controllers/AlertsummaryController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index dcc805286..5b4e2e3fa 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -274,7 +274,6 @@ class Monitoring_AlertsummaryController extends Controller ); $defects = array(); - $records = $query->getQuery()->fetchAll(); $period = $this->createPeriod($interval); foreach ($period as $entry) { @@ -282,7 +281,7 @@ class Monitoring_AlertsummaryController extends Controller $defects[$id] = array($id, 0); } - foreach ($records as $item) { + foreach ($query as $item) { $id = $this->getPeriodFormat($interval, $item->timestamp); if (empty($defects[$id])) { $defects[$id] = array($id, 0); From d27b94dcecdd18b59912c851234b80fdd5d93cec Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 28 Apr 2015 12:52:59 +0200 Subject: [PATCH 127/298] Revert "Don't fetchAll() and loop afterwards in the alert summary report" This reverts commit f3ca80ffced18497322a74b8b49e94e88bb31cdc. --- .../application/controllers/AlertsummaryController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 5b4e2e3fa..dcc805286 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -274,6 +274,7 @@ class Monitoring_AlertsummaryController extends Controller ); $defects = array(); + $records = $query->getQuery()->fetchAll(); $period = $this->createPeriod($interval); foreach ($period as $entry) { @@ -281,7 +282,7 @@ class Monitoring_AlertsummaryController extends Controller $defects[$id] = array($id, 0); } - foreach ($query as $item) { + foreach ($records as $item) { $id = $this->getPeriodFormat($interval, $item->timestamp); if (empty($defects[$id])) { $defects[$id] = array($id, 0); From 034421d0cba6fcf117445e04746663b8e50fc5ed Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 30 Apr 2015 15:20:19 +0200 Subject: [PATCH 128/298] Fix form tests utilizing Mockery's partial mock functionality Since an update of Mockery, partial mocks do not call the constructor of their mocked classes anymore without explicitly passing a non empty array. This is a regression of the following bug: https://github.com/padraic/mockery/issues/144 --- .../forms/Config/Authentication/DbBackendFormTest.php | 6 ++++-- .../forms/Config/Authentication/LdapBackendFormTest.php | 6 ++++-- .../forms/Config/Resource/LdapResourceFormTest.php | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index b7d1ea3c1..fb93f6050 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -31,7 +31,8 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(2); - $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); @@ -56,7 +57,8 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(0); - $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); diff --git a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php index d31033ba9..56ea08987 100644 --- a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php @@ -31,7 +31,8 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andReturnNull(); - $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); @@ -55,7 +56,8 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException); - $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); diff --git a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php index d074f1b3b..f382f8bb8 100644 --- a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php @@ -29,7 +29,8 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock() ); - $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); @@ -51,7 +52,8 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock() ); - $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + // Passing array(null) is required to make Mockery call the constructor... + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]', array(null)); $form->shouldReceive('getView->escape') ->with(Mockery::type('string')) ->andReturnUsing(function ($s) { return $s; }); From 7f28c0a2372694b0a55df4f107dfe3933ce290b6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 30 Apr 2015 16:06:05 +0200 Subject: [PATCH 129/298] Implement ProblemMenuItemRenderer refs # 4139 --- library/Icinga/Web/Menu.php | 23 ++++++- .../Web/Menu/ProblemMenuItemRenderer.php | 64 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 library/Icinga/Web/Menu/ProblemMenuItemRenderer.php diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index bca1e17d1..476d73879 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -234,7 +234,8 @@ class Menu implements RecursiveIterator $section = $this->add(t('System'), array( 'icon' => 'wrench', - 'priority' => 200 + 'priority' => 200, + 'renderer' => 'ProblemMenuItemRenderer' )); $section->add(t('Configuration'), array( 'url' => 'config', @@ -469,6 +470,26 @@ class Menu implements RecursiveIterator return $this->permission; } + /** + * Get parent menu + * + * @return \Icinga\Web\Menu + */ + public function getParent() + { + return $this->parent; + } + + /** + * Get submenus + * + * @return array + */ + public function getSubMenus() + { + return $this->subMenus; + } + /** * Set permission a user is required to have granted to display the menu item * diff --git a/library/Icinga/Web/Menu/ProblemMenuItemRenderer.php b/library/Icinga/Web/Menu/ProblemMenuItemRenderer.php new file mode 100644 index 000000000..010bdc034 --- /dev/null +++ b/library/Icinga/Web/Menu/ProblemMenuItemRenderer.php @@ -0,0 +1,64 @@ +getParent() !== null && $menu->hasSubMenus()) { + /** @var $submenu Menu */ + foreach ($menu->getSubMenus() as $submenu) { + $renderer = $submenu->getRenderer(); + if (method_exists($renderer, 'getSummary')) { + if ($renderer->getSummary() !== null) { + $this->summary[] = $renderer->getSummary(); + } + } + } + } + return $this->getBadge() . $this->createLink($menu); + } + + /** + * Get the problem badge + * + * @return string + */ + protected function getBadge() + { + if (count($this->summary) > 0) { + $problems = 0; + $titles = array(); + + foreach ($this->summary as $summary) { + $problems += $summary['problems']; + $titles[] = $summary['title']; + } + + return sprintf( + '
%s
', + implode(', ', $titles), + $problems + ); + } + return ''; + } +} From 5075ccdf38698d03fb11b8f02cd4ae77fdd14826 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 30 Apr 2015 16:08:10 +0200 Subject: [PATCH 130/298] Add ProblemMenuItemRenderer to system menu as renderer refs #4139 --- modules/monitoring/configuration.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index a7f8047c4..fd3ee334d 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -208,7 +208,8 @@ $section->add($this->translate('Alert Summary'), array( $section = $this->menuSection($this->translate('System')); $section->add($this->translate('Monitoring Health'), array( 'url' => 'monitoring/process/info', - 'priority' => 120 + 'priority' => 120, + 'renderer' => 'Icinga\Module\Monitoring\Web\Menu\BackendAvailabilityMenuItemRenderer' )); /* From 880b1eb21a2740aac5a0ea6df1eabefb1ddcfc6a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 30 Apr 2015 16:12:36 +0200 Subject: [PATCH 131/298] Add better styling for backend-not-running class refs #4139 --- modules/monitoring/public/css/module.less | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 4cc68e18e..881e38f09 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -173,19 +173,15 @@ form.instance-features span.description, form.object-features span.description { } } -table.avp form.object-features div.header h4, -table.avp h4.customvar { +table.avp form.object-features div.header h4 { margin: 0; } -table.avp .customvar ul, -table.avp .customvar ul li { +table.avp .customvar ul { list-style-type: none; margin: 0; - margin-top: -0.5em; - margin-bottom: -0.5em; padding: 0; - padding-left: 0.5em; + padding-left: 1.5em; } div.selection-info { @@ -219,3 +215,10 @@ hr.command-separator { border: none; border-bottom: 2px solid @colorPetrol; } + +div.backend-not-running { + background: @colorCritical; + color: white; + text-align: center; + padding: 0.1em; +} From 8484a27b5685f22ab209808c453893b04186c548 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 30 Apr 2015 16:13:10 +0200 Subject: [PATCH 132/298] Add a backend problem menu item renderer to system menu refs #4139 --- .../BackendAvailabilityMenuItemRenderer.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php diff --git a/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php new file mode 100644 index 000000000..186351a40 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php @@ -0,0 +1,62 @@ +select()->from( + 'programstatus', + array( + 'is_currently_running' + ) + )->getQuery()->fetchRow()->is_currently_running; + } + + /** + * @see MenuItemRenderer::render() + */ + public function render(Menu $menu) + { + return $this->getBadge() . $this->createLink($menu); + } + + protected function getBadge() + { + if (! (bool)$this->isCurrentlyRunning()) { + return sprintf( + '
%s
', + mt('monitoring', 'monitoring backend is not running'), + 1 + ); + } + return ''; + } + + /** + * Get the problem data for the summary + * + * @return array|null + */ + public function getSummary() + { + if (! (bool)$this->isCurrentlyRunning()) { + return array( + 'problems' => 1, + 'title' => mt('monitoring', 'monitoring backend is not running') + ); + } + return null; + } +} From d43f4729f10797c8388578852323de2e7aa440c8 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 30 Apr 2015 17:25:14 +0200 Subject: [PATCH 133/298] Monitoring_ListController::filterQuery(): preserve parameter `_dev' resolves #8453 --- .../monitoring/application/controllers/ListController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 9eb014421..e6147c31b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -684,7 +684,10 @@ class Monitoring_ListController extends Controller { $editor = Widget::create('filterEditor') ->setQuery($query) - ->preserveParams('limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns') + ->preserveParams( + 'limit', 'sort', 'dir', 'format', 'view', 'backend', + 'stateType', 'addColumns', '_dev' + ) ->ignoreParams('page') ->handleRequest($this->getRequest()); $query->applyFilter($editor->getFilter()); From ffe23a184f0a1659ffeb8cfc0d05a7b36fd9a7c1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 30 Apr 2015 17:47:23 +0200 Subject: [PATCH 134/298] Don't display "Add To Dashboard" on the dashboard resolves #9026 --- library/Icinga/Web/Widget/Tabextension/DashboardSettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php index f05786a0c..f6b2cad2c 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php @@ -22,7 +22,7 @@ class DashboardSettings implements Tabextension 'dashboard_add', array( 'icon' => 'img/icons/dashboard.png', - 'label' => t('Add To Dashboard'), + 'label' => t('Add New Pane Or Dashlet'), 'url' => Url::fromPath('dashboard/new-dashlet') ) ); From ab0b478e4f40c9a5f796d26adae4bacf50fabef1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 30 Apr 2015 17:49:42 +0200 Subject: [PATCH 135/298] Icinga\Web\Widget\Tabextension\DashboardAction::apply(): translate label "Add To Dashboard" --- library/Icinga/Web/Widget/Tabextension/DashboardAction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php index ca9bc99be..569bc6f67 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php @@ -24,7 +24,7 @@ class DashboardAction implements Tabextension 'dashboard', array( 'icon' => 'dashboard', - 'label' => 'Add To Dashboard', + 'label' => t('Add To Dashboard'), 'url' => Url::fromPath('dashboard/new-dashlet'), 'urlParams' => array( 'url' => rawurlencode(Url::fromRequest()->getRelativeUrl()) From 993cb315725ec5c49508ca534ca1f5f0023b6d45 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 4 May 2015 14:39:12 +0200 Subject: [PATCH 136/298] Fix the permission for the toggle object feature assertion fixes #9198 --- .../forms/Command/Object/ToggleObjectFeaturesCommandForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index a6c20f630..34fbb4c2c 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -30,7 +30,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { - $toggleDisabled = $this->hasPermission('monitoring/command/feature/instance') ? null : ''; + $toggleDisabled = $this->hasPermission('monitoring/command/feature/object') ? null : ''; $this->addElements(array( array( 'checkbox', From 612fefba9cfad1bfc850cf6a490a4363208b6a4a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 5 May 2015 12:36:26 +0200 Subject: [PATCH 137/298] Fix the permission wildcards assertion fixes #9202 --- library/Icinga/User.php | 18 +++++++++--------- test/php/library/Icinga/UserTest.php | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/library/Icinga/User.php b/library/Icinga/User.php index 18d44af96..f9df0d664 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -413,30 +413,30 @@ class User /** * Whether the user has a given permission * - * @param string $permission + * @param string $requiredPermission * * @return bool */ - public function can($permission) + public function can($requiredPermission) { - if (isset($this->permissions['*']) || isset($this->permissions[$permission])) { + if (isset($this->permissions['*']) || isset($this->permissions[$requiredPermission])) { return true; } // If the permission to check contains a wildcard, grant the permission if any permit related to the permission // matches - $any = strpos($permission, '*'); - foreach ($this->permissions as $permitted) { - if ($any !== false) { + $any = strpos($requiredPermission, '*'); + foreach ($this->permissions as $grantedPermission) { + if ($any !== false && strpos($grantedPermission, '*') === false) { $wildcard = $any; } else { // If the permit contains a wildcard, grant the permission if it's related to the permit - $wildcard = strpos($permitted, '*'); + $wildcard = strpos($grantedPermission, '*'); } if ($wildcard !== false) { - if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { + if (substr($requiredPermission, 0, $wildcard) === substr($grantedPermission, 0, $wildcard)) { return true; } - } elseif ($permission === $permitted) { + } elseif ($requiredPermission === $grantedPermission) { return true; } } diff --git a/test/php/library/Icinga/UserTest.php b/test/php/library/Icinga/UserTest.php index 9c14a93d3..ffdcbd905 100644 --- a/test/php/library/Icinga/UserTest.php +++ b/test/php/library/Icinga/UserTest.php @@ -66,12 +66,16 @@ class UserTest extends BaseTestCase $user->setPermissions(array( 'test', 'test/some/specific', - 'test/more/*' + 'test/more/*', + 'test/wildcard-with-wildcard/*' )); $this->assertTrue($user->can('test')); $this->assertTrue($user->can('test/some/specific')); $this->assertTrue($user->can('test/more/everything')); + $this->assertTrue($user->can('test/wildcard-with-wildcard/*')); + $this->assertTrue($user->can('test/wildcard/sub/sub')); $this->assertFalse($user->can('not/test')); $this->assertFalse($user->can('test/some/not/so/specific')); + $this->assertFalse($user->can('test/wildcard2/*')); } } From be696e5adfd756940ad832f27d44d952403b9091 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 5 May 2015 12:50:35 +0200 Subject: [PATCH 138/298] LogFileIterator: Fix missing closing bracket --- library/Icinga/Protocol/File/LogFileIterator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Protocol/File/LogFileIterator.php b/library/Icinga/Protocol/File/LogFileIterator.php index 4b587b58e..0815a5376 100644 --- a/library/Icinga/Protocol/File/LogFileIterator.php +++ b/library/Icinga/Protocol/File/LogFileIterator.php @@ -152,3 +152,4 @@ class LogFileIterator implements Iterator $this->valid = false; } } +} From 0e4201a997bc9c7b9469d6471d7c29c85f7517f6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 5 May 2015 15:20:25 +0200 Subject: [PATCH 139/298] Add info about the active ido endpoint to monitoring health overview resolves #9223 --- .../application/controllers/ProcessController.php | 1 + .../monitoring/application/views/scripts/process/info.phtml | 6 ++++++ .../Monitoring/Backend/Ido/Query/ProgramstatusQuery.php | 1 + 3 files changed, 8 insertions(+) diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index a07ac5f3a..bec7ec852 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -49,6 +49,7 @@ class Monitoring_ProcessController extends Controller array( 'is_currently_running', 'process_id', + 'endpoint_name', 'program_start_time', 'status_update_time', 'last_command_check', diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 8cb5aebe1..de322ac83 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -49,6 +49,12 @@ if (! $this->compact): ?> ? $this->programStatus->global_host_event_handler : $this->translate('N/A'); ?> +
+ + +
+

translate('Custom variables') ?>

+
- escape($value->message) ?> + escape($value->message), false) ?>
translate('Active IDO Endpoint'); ?>programStatus->endpoint_name + ? $this->programStatus->endpoint_name + : $this->translate('N/A') ?>
programStatus->is_currently_running === true): ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php index d63db8173..1f44cff8f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php @@ -26,6 +26,7 @@ class ProgramstatusQuery extends IdoQuery END END', 'process_id' => 'process_id', + 'endpoint_name' => 'endpoint_name', 'daemon_mode' => 'daemon_mode', 'last_command_check' => 'UNIX_TIMESTAMP(programstatus.last_command_check)', 'last_log_rotation' => 'UNIX_TIMESTAMP(programstatus.last_log_rotation)', From d1f1f5d7d7454dc8a269091d58e8e89797992d61 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 5 May 2015 16:32:18 +0200 Subject: [PATCH 140/298] ProgrammStatusQuery: Add fallback if ido_version is older than required resolves #9223 --- .../Monitoring/Backend/Ido/Query/ProgramstatusQuery.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php index 1f44cff8f..57f8ed1ac 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php @@ -48,4 +48,13 @@ class ProgramstatusQuery extends IdoQuery 'global_service_event_handler' => 'global_service_event_handler', ) ); + + protected function joinBaseTables() + { + parent::joinBaseTables(); + + if (version_compare($this->getIdoVersion(), '1.11.7', '<')) { + $this->columnMap['programstatus']['endpoint_name'] = '(0)'; + } + } } From defda53ff5ba9e99ba3c01418e846193de60bb18 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 1 May 2015 16:00:55 +0200 Subject: [PATCH 141/298] Show icinga program version in Monitoring Health Also emphasize on the backends used. fixes #9207 --- .../application/controllers/ProcessController.php | 1 + .../application/views/scripts/process/info.phtml | 12 +++++++++--- .../Backend/Ido/Query/ProgramstatusQuery.php | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index bec7ec852..2e52733bd 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -52,6 +52,7 @@ class Monitoring_ProcessController extends Controller 'endpoint_name', 'program_start_time', 'status_update_time', + 'program_version', 'last_command_check', 'last_log_rotation', 'global_service_event_handler', diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index de322ac83..5ebecce4d 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -19,6 +19,12 @@ if (! $this->compact): ?>

translate('Process Info') ?>

+ + + + @@ -50,7 +56,7 @@ if (! $this->compact): ?> : $this->translate('N/A'); ?> - + @@ -60,14 +66,14 @@ if (! $this->compact): ?> programStatus->is_currently_running === true): ?>
translate('%s has been up and running with PID %d since %s'), + $this->translate('Backend %s has been up and running with PID %d since %s'), $this->backendName, $this->programStatus->process_id, $this->timeSince($this->programStatus->program_start_time)) ?>
- translate('%s is not running'), $this->backendName) ?> + translate('Backend %s is not running'), $this->backendName) ?>
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php index 57f8ed1ac..d1e0b71b4 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php @@ -12,6 +12,7 @@ class ProgramstatusQuery extends IdoQuery 'programstatus' => array( 'id' => 'programstatus_id', 'status_update_time' => 'UNIX_TIMESTAMP(programstatus.status_update_time)', + 'program_version' => 'program_version', 'program_start_time' => 'UNIX_TIMESTAMP(programstatus.program_start_time)', 'program_end_time' => 'UNIX_TIMESTAMP(programstatus.program_end_time)', 'is_currently_running' => 'CASE WHEN (programstatus.is_currently_running = 0) @@ -56,5 +57,8 @@ class ProgramstatusQuery extends IdoQuery if (version_compare($this->getIdoVersion(), '1.11.7', '<')) { $this->columnMap['programstatus']['endpoint_name'] = '(0)'; } + if (version_compare($this->getIdoVersion(), '1.11.8', '<')) { + $this->columnMap['programstatus']['program_version'] = '(NULL)'; + } } } From 6df031dc786256e0bd42f8047d6c308e90abedf6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 6 May 2015 14:21:46 +0200 Subject: [PATCH 142/298] Add proper respond http codes to service and host controller fixes #6281 --- application/controllers/ErrorController.php | 6 +++++- .../application/controllers/HostController.php | 13 ++++++++++++- .../application/controllers/ServiceController.php | 13 ++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index a77d36f4f..b1343dc81 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -34,7 +34,11 @@ class ErrorController extends ActionController $path = preg_split('~/~', $path); $path = array_shift($path); $this->getResponse()->setHttpResponseCode(404); - $this->view->message = $this->translate('Page not found.'); + $title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage()); + $this->view->title = 'Server error: ' . $title; + if ($this->getInvokeArg('displayExceptions')) { + $this->view->stackTrace = $exception->getTraceAsString(); + } if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) { $this->view->message .= ' ' . sprintf( $this->translate('Enabling the "%s" module might help!'), diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 11179c1fa..f820fc27f 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -1,6 +1,7 @@ params->get('host') === null) { + throw new MissingParameterException( + $this->translate('Required parameter \'%s\' is missing'), + 'host' + ); + } + $host = new Host($this->backend, $this->params->get('host')); $this->applyRestriction('monitoring/hosts/filter', $host); if ($host->fetch() === false) { - throw new Zend_Controller_Action_Exception($this->translate('Host not found')); + throw new Zend_Controller_Action_Exception( + sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')), + 404 + ); } $this->object = $host; $this->createTabs(); diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 3dc98c3b8..4df109b3e 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -1,6 +1,7 @@ params->get('host') === null || $this->params->get('service') === null) { + throw new MissingParameterException( + $this->translate('One of the required parameters \'%s\' is missing'), + 'host or service' + ); + } + $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); $this->applyRestriction('monitoring/services/filter', $service); if ($service->fetch() === false) { - throw new Zend_Controller_Action_Exception($this->translate('Service not found')); + throw new Zend_Controller_Action_Exception( + sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')), + 404 + ); } $this->object = $service; $this->createTabs(); From 7b6641dc848b6fd912b32de960760854715a35eb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 14:49:27 +0200 Subject: [PATCH 143/298] Add basic downtime controller and views refs #8902 --- .../controllers/DowntimeController.php | 79 ++++++++ .../views/scripts/downtime/show.phtml | 179 ++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 modules/monitoring/application/controllers/DowntimeController.php create mode 100644 modules/monitoring/application/views/scripts/downtime/show.phtml diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php new file mode 100644 index 000000000..13e7f9e14 --- /dev/null +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -0,0 +1,79 @@ +params->get('downtime_id'); + + $this->downtime = $this->backend->select()->from('downtime', array( + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author_name' => 'downtime_author_name', + 'start' => 'downtime_start', + 'scheduled_start' => 'downtime_scheduled_start', + 'scheduled_end' => 'downtime_scheduled_end', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_fixed' => 'downtime_is_fixed', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host_state' => 'downtime_host_state', + 'service_state' => 'downtime_service_state', + 'host_name', + 'host', + 'service', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + + $this->getTabs() + ->add( + 'downtime', + array( + 'title' => $this->translate( + 'Display detailed information about a downtime.' + ), + 'icon' => 'plug', + 'label' => $this->translate('Downtime'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtime')->extend(new DashboardAction()); + } + + public function showAction() + { + $this->view->downtime = $this->downtime; + $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm->setObjects($this->downtime); + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); + $this->view->showHostLink = Url::fromPath('monitoring/host/show') + ->setParam('host', $this->downtime->host); + $this->view->showServiceLink = Url::fromPath('monitoring/service/show') + ->setParam('host', $this->downtime->host) + ->setParam('service', $this->downtime->service_description); + } +} diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml new file mode 100644 index 000000000..806897e90 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -0,0 +1,179 @@ +service_description)) { + $isService = true; + $stateName = Service::getStateText($downtime->service_state); +} else { + $isService = false; + $stateName = Host::getStateText($downtime->host_state); +} +?> + +
+ compact): ?> + tabs; ?> + +

+ + link()->service( + $downtime->service_description, + $downtime->service_display_name, + $downtime->host_name, + $downtime->host_display_name + ); + $icon = $this->icon('service', $this->translate('Service')); + ?> + + icon('host', $this->translate('Host')); + $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) + ?> + + translate( + 'Downtime for %s', + 'Downtime for host or service.' + ), + $link + ); ?> + +

+
+ +
+ + is_flexible): ?> + is_in_effect): ?> + translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + date('d.m.y H:i', $downtime->scheduled_start), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + date('d.m.y', $downtime->scheduled_start), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
+
+ +
translate('Program Version') ?>programStatus->program_version + ? $this->programStatus->program_version + : $this->translate('N/A') ?>
translate('Program Start Time') ?> dateFormat()->formatDateTime($this->programStatus->program_start_time) ?>
translate('Active IDO Endpoint'); ?>translate('Active Endpoint'); ?> programStatus->endpoint_name ? $this->programStatus->endpoint_name : $this->translate('N/A') ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + downtime->is_flexible && $this->downtime->is_in_effect): ?> + + + + + + + + + + + + + + + + + + + + + +
translate('Author') ?>escape($this->downtime->author_name) ?>
translate('Comments') ?>escape($this->downtime->comment) ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Is Flexible') ?> + escape( + $this->downtime->is_flexible ? + $this->translate('Yes') : $this->translate('No') + ); + ?> +
translate('In Effect') ?> + escape( + $this->downtime->is_in_effect ? + $this->translate('Yes') : $this->translate('No') + ); + ?> +
translate('Start') ?>start); ?>
translate('End') ?>end); ?>
translate('Duration') ?>format()->duration($this->escape($this->downtime->duration)); ?>
translate('Commands') ?> + populate(array('downtime_id' => $downtime->id, 'redirect' => $this->listAllLink)); + if (! $isService) { + $delDowntimeForm->setAction( + $this->url('monitoring/host/delete-downtime', + array('host' => $downtime->host_name)) + ); + } else { + $delDowntimeForm->setAction( + $this->url('monitoring/service/delete-downtime', array( + 'host' => $downtime->host_name, + 'service' => $downtime->service_description + )) + ); + } + echo $delDowntimeForm; + ?> +
+ +
+ From ff47b892e9c2d4ab78cd34443ccab75d5a2d6167 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:24:17 +0200 Subject: [PATCH 144/298] Improve order and content of downtime properties Add rows for missing properties, reorder and group related properties. refs #8902 --- .../controllers/DowntimeController.php | 40 +++++++++++- .../views/scripts/downtime/show.phtml | 64 +++---------------- 2 files changed, 47 insertions(+), 57 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 13e7f9e14..af2888383 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -19,13 +19,15 @@ class Monitoring_DowntimeController extends Controller { protected $downtime; + protected $isService; + /** * Add tabs */ public function init() { $downtimeId = $this->params->get('downtime_id'); - + $this->downtime = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', 'objecttype' => 'downtime_objecttype', @@ -50,6 +52,12 @@ class Monitoring_DowntimeController extends Controller 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + if (isset($this->downtime->service_description)) { + $this->isService = true; + } else { + $this->isService = false; + } + $this->getTabs() ->add( 'downtime', @@ -67,8 +75,8 @@ class Monitoring_DowntimeController extends Controller public function showAction() { $this->view->downtime = $this->downtime; - $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); - $this->view->delDowntimeForm->setObjects($this->downtime); + $this->view->isService = $this->isService; + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') ->setParam('host', $this->downtime->host); @@ -76,4 +84,30 @@ class Monitoring_DowntimeController extends Controller ->setParam('host', $this->downtime->host) ->setParam('service', $this->downtime->service_description); } + + private function createDelDowntimeForm() + { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setObjects($this->downtime); + $delDowntimeForm->populate( + array( + 'downtime_id' => $this->downtime->id, + 'redirect' => Url::fromPath('monitoring/list/downtimes') + ) + ); + if (! $this->isService) { + $delDowntimeForm->setAction( + $this->view->url('monitoring/host/delete-downtime', + array('host' => $this->downtime->host_name)) + ); + } else { + $delDowntimeForm->setAction( + $this->view->url('monitoring/service/delete-downtime', array( + 'host' => $this->downtime->host_name, + 'service' => $this->downtime->service_description + )) + ); + } + return $delDowntimeForm; + } } diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 806897e90..d71b92c55 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,22 +1,9 @@ -service_description)) { - $isService = true; - $stateName = Service::getStateText($downtime->service_state); -} else { - $isService = false; - $stateName = Host::getStateText($downtime->host_state); -} -?> -
compact): ?> tabs; ?> -

- +

+ isService): ?> link()->service( $downtime->service_description, @@ -34,7 +21,7 @@ if (isset($downtime->service_description)) { translate( - 'Downtime for %s', + 'Downtime on %s', 'Downtime for host or service.' ), $link @@ -43,12 +30,12 @@ if (isset($downtime->service_description)) {

-
+
is_flexible): ?> is_in_effect): ?> isService ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), date('d.m.y', $downtime->start), @@ -59,7 +46,7 @@ if (isset($downtime->service_description)) { ); ?> isService ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), date('d.m.y H:i', $downtime->scheduled_start), @@ -70,7 +57,7 @@ if (isset($downtime->service_description)) { is_in_effect): ?> isService ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), date('d.m.y', $downtime->start), @@ -80,7 +67,7 @@ if (isset($downtime->service_description)) { ); ?> isService ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), date('d.m.y', $downtime->scheduled_start), @@ -132,43 +119,12 @@ if (isset($downtime->service_description)) { ?>
translate('Start') ?>start); ?>
translate('End') ?>end); ?>
translate('Duration') ?>format()->duration($this->escape($this->downtime->duration)); ?>
translate('Commands') ?> - populate(array('downtime_id' => $downtime->id, 'redirect' => $this->listAllLink)); - if (! $isService) { - $delDowntimeForm->setAction( - $this->url('monitoring/host/delete-downtime', - array('host' => $downtime->host_name)) - ); - } else { - $delDowntimeForm->setAction( - $this->url('monitoring/service/delete-downtime', array( - 'host' => $downtime->host_name, - 'service' => $downtime->service_description - )) - ); - } - echo $delDowntimeForm; - ?> +
- + - + - - - + + + - - - + + + - - - - - - + + - - + + + + + + + + + downtime->is_flexible): ?> + + + + + + + + + + + + + + + +
translate('Author') ?>escape($this->downtime->author_name) ?>icon('user') ?> escape($this->downtime->author_name) ?>
translate('Comments') ?>escape($this->downtime->comment) ?>
translate('Comment') ?>icon('comment') ?> escape($this->downtime->comment) ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Entry Time') ?> escape($this->downtime->entry_time)) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Is Flexible') ?>
escape( + $this->downtime->is_flexible ? + $this->translate('Flexible') : $this->translate('Fixed') + ); ?> escape( $this->downtime->is_flexible ? - $this->translate('Yes') : $this->translate('No') - ); - ?> + $this->translate('Flexible downtimes have a hard start and end time,' + . ' but also an additional restriction on the duration in which ' + . ' the host or service may actually be down.') : + $this->translate('Fixed downtimes have a static start and end time.') + ); ?>
translate('In Effect') ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Duration') ?>format()->duration($this->escape($this->downtime->duration)); ?>
translate('Actual start time') ?>start); ?>
translate('Actual end time') ?>end); ?>
translate('In effect') ?> escape( $this->downtime->is_in_effect ? From ab0720fe95f6361596a21324752a762e7dc634e0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:26:08 +0200 Subject: [PATCH 146/298] Add support for multi-selection to downtime list refs #8902 --- .../views/scripts/list/downtimes.phtml | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 3f882a733..2dd62761e 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -19,8 +19,10 @@ if (count($downtimes) === 0) { return; } ?> - - +
- - icon('service', $this->translate('Service')); ?> - link()->service( - $downtime->service_description, $downtime->service_display_name, $downtime->host_name, $downtime->host_display_name - ) ?> - - icon('host', $this->translate('Host')); ?> - link()->host($downtime->host_name, $downtime->host_display_name) ?> - + icon('service'); + } else { + echo $this->icon('host'); + } + ?> + qlink( + sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name), + 'monitoring/downtime/show', + array('downtime_id' => $downtime->id), + array('title' => sprintf( + $this->translate('Show detailed information for downtime on %s for %s'), + $downtime->service_display_name, + $downtime->host_display_name + ))) ?>
icon('comment', $this->translate('Comment')); ?> [escape($downtime->author_name) ?>] escape($downtime->comment) ?>
From 9114a34223c227eb0440b64fe97d46ca2642c808 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 11:31:53 +0200 Subject: [PATCH 147/298] Display host and service state in downtime detail area refs #8902 --- .../controllers/DowntimeController.php | 6 + .../views/scripts/downtime/show.phtml | 121 ++++++++++-------- 2 files changed, 76 insertions(+), 51 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index af2888383..32c183ba1 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -2,6 +2,8 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Module\Monitoring\Controller; +use Icinga\Module\Monitoring\Object\Service; +use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -76,6 +78,10 @@ class Monitoring_DowntimeController extends Controller { $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; + $this->view->stateName = isset($this->downtime->service_description) ? + Service::getStateText($this->downtime->service_state) : + Host::getStateText($this->downtime->host_state); + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index c6084a29f..34751cd7c 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -2,6 +2,75 @@ compact): ?> tabs; ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ + is_flexible): ?> + is_in_effect): ?> + isService + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + date('d.m.y H:i', $downtime->scheduled_start), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + isService + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + date('d.m.y', $downtime->scheduled_start), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
+

isService): ?>
- - is_flexible): ?> - is_in_effect): ?> - isService - ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') - : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') - : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), - date('d.m.y H:i', $downtime->scheduled_start), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - is_in_effect): ?> - isService - ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') - : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') - : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), - date('d.m.y', $downtime->scheduled_start), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - - -
-
- - +
From 20b25e656be03a4258316f5ae9b48418ea35288c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 12:19:58 +0200 Subject: [PATCH 148/298] Show better error message for unknown downtimes refs #8902 --- .../application/controllers/DowntimeController.php | 4 +++- .../application/views/scripts/downtime/show.phtml | 6 ++++++ .../application/views/scripts/list/downtimes.phtml | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 32c183ba1..37f466807 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -76,12 +76,14 @@ class Monitoring_DowntimeController extends Controller public function showAction() { + if (false === $this->downtime) { + return; + } $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); - $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 34751cd7c..ddc91eeeb 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,4 +1,10 @@
+ + translate('No scheduled downtime matching the filter.') ?> +
+ + + compact): ?> tabs; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 2dd62761e..b21e3c3fb 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -15,7 +15,8 @@ if (! $this->compact): ?> translate('No downtimes found matching the filter') . ''; + echo $this->translate('No downtimes found matching the filter,' + . ' maybe the downtime already expired.') . ''; return; } ?> From a87e1f91d9b9ae5c169850985d19016c8025bb42 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 14:43:30 +0200 Subject: [PATCH 149/298] Implement detail view for multiple downtimes refs #8902 --- .../controllers/DowntimesController.php | 122 ++++++++++++++++++ .../views/scripts/downtimes/show.phtml | 41 ++++++ 2 files changed, 163 insertions(+) create mode 100644 modules/monitoring/application/controllers/DowntimesController.php create mode 100644 modules/monitoring/application/views/scripts/downtimes/show.phtml diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php new file mode 100644 index 000000000..b0057466f --- /dev/null +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -0,0 +1,122 @@ +filter = Filter::fromQueryString(str_replace( + 'downtime_id', + 'downtime_internal_id', + (string)$this->params + )); + $this->downtimes = $this->backend->select()->from('downtime', array( + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author_name' => 'downtime_author_name', + 'start' => 'downtime_start', + 'scheduled_start' => 'downtime_scheduled_start', + 'scheduled_end' => 'downtime_scheduled_end', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_fixed' => 'downtime_is_fixed', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host_state' => 'downtime_host_state', + 'service_state' => 'downtime_service_state', + 'host_name', + 'host', + 'service', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->addFilter($this->filter)->getQuery()->fetchAll(); + $this->getTabs() + ->add( + 'downtimes', + array( + 'title' => $this->translate( + 'Display detailed information about multiple downtimes.' + ), + 'icon' => 'plug', + 'label' => $this->translate('Downtimes'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtimes')->extend(new DashboardAction()); + } + + public function showAction() + { + if (false === $this->downtimes) { + return; + } + $this->view->downtimes = $this->downtimes; + $this->view->isService = $this->isService; + + // $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString($this->filter->toQueryString()); + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') + ->setParams($this->params); + } + + public function removeAllAction() + { + + } + + private function createDelDowntimeForm() + { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setObjects($this->downtimes); + $delDowntimeForm->populate( + array( + 'downtime_id' => $this->downtime->id, + 'redirect' => Url::fromPath('monitoring/list/downtimes') + ) + ); + if (! $this->isService) { + $delDowntimeForm->setAction( + $this->view->url('monitoring/host/delete-downtime', + array('host' => $this->downtime->host_name)) + ); + } else { + $delDowntimeForm->setAction( + $this->view->url('monitoring/service/delete-downtime', array( + 'host' => $this->downtime->host_name, + 'service' => $this->downtime->service_description + )) + ); + } + return $delDowntimeForm; + } +} diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml new file mode 100644 index 000000000..89ecc7073 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -0,0 +1,41 @@ +
+ + translate('No scheduled downtimes matching the filter.') ?> +
+ + + + compact): ?> + tabs; ?> + + +

+ +

+ + +
+

+ translate('You have selected') ?> + qlink( + sprintf($this->translate('%d downtimes'), count($downtimes)), + $listAllLink, + null, + array('title' => $this->translate('List all selected downtimes.')) + ) ?> +

+ qlink( + sprintf( + $this->translate('Remove all %d downtimes.'), + count($downtimes) + ), + $removeAllLink, + null, + array( + 'icon' => 'trash', + 'title' => $this->translate('Remove all selected downtimes.') + ) + ) ?> +
+

+
From 07c5e67304e993b7c6ba45b842a2f5fffb44474c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 16:35:35 +0200 Subject: [PATCH 150/298] Display additional downtime info in multiselection detail view refs #8902 --- .../controllers/DowntimesController.php | 24 +-- .../views/scripts/downtimes/show.phtml | 153 ++++++++++++++---- 2 files changed, 138 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index b0057466f..eec408110 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -23,8 +23,6 @@ class Monitoring_DowntimesController extends Controller { protected $downtimes; - protected $isService; - protected $filter; /** @@ -72,6 +70,20 @@ class Monitoring_DowntimesController extends Controller 'url' =>'monitoring/downtimes/show' ) )->activate('downtimes')->extend(new DashboardAction()); + + foreach ($this->downtimes as $downtime) { + if (isset($downtime->service_description)) { + $downtime->isService = true; + } else { + $downtime->isService = false; + } + + if ($downtime->isService) { + $downtime->stateText = Service::getStateText($downtime->service_state); + } else { + $downtime->stateText = Host::getStateText($downtime->host_state); + } + } } public function showAction() @@ -80,9 +92,6 @@ class Monitoring_DowntimesController extends Controller return; } $this->view->downtimes = $this->downtimes; - $this->view->isService = $this->isService; - - // $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') @@ -90,11 +99,6 @@ class Monitoring_DowntimesController extends Controller } public function removeAllAction() - { - - } - - private function createDelDowntimeForm() { $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm->setObjects($this->downtimes); diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index 89ecc7073..a683722ac 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -8,34 +8,129 @@ compact): ?> tabs; ?> - -

- -

- -
-

- translate('You have selected') ?> - qlink( - sprintf($this->translate('%d downtimes'), count($downtimes)), - $listAllLink, - null, - array('title' => $this->translate('List all selected downtimes.')) - ) ?> -

- qlink( - sprintf( - $this->translate('Remove all %d downtimes.'), - count($downtimes) - ), - $removeAllLink, - null, - array( - 'icon' => 'trash', - 'title' => $this->translate('Remove all selected downtimes.') - ) - ) ?> -
-

+

+ translate('%d Downtimes'), count($downtimes)) ?> + 5 ? + sprintf($this->translate('(%d not shown)'), count ($downtimes) - 5) + : ''; + ?> +

+

+

translate('Author') ?>
+ + 5) { + continue; + } ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ isService): ?> + icon('service') ?> + service ?> on host_name ?>. + + icon('host') ?> + host_name ?>. + + + is_flexible): ?> + is_in_effect): ?> + isService + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + date('d.m.y H:i', $downtime->scheduled_start), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + isService + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + date('d.m.y', $downtime->scheduled_start), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + +
+

+ qlink( + sprintf($this->translate('List all %d downtimes …'), count($downtimes)), + $listAllLink, + null, + array( + 'title' => $this->translate('List all'), + 'data-base-target' => "_next" + ) + ) ?> +

+

+
+
+

icon('reschedule') ?> translate('Commands') ?>

+

+ translate('Issue commands to all %s selected downtimes.'), + '' . count($downtimes) . '' + ) + ?> +

+ qlink( + sprintf( + $this->translate('Remove all %d scheduled downtimes'), + count($downtimes) + ), + $removeAllLink, + null, + array( + 'icon' => 'trash', + 'title' => $this->translate('Remove all selected downtimes.') + ) + ) ?> +
+

From 400f351ea580800d22f56c23c0512839686f1b25 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 16:55:59 +0200 Subject: [PATCH 151/298] Improve detail view layout refs #8902 --- .../views/scripts/downtime/show.phtml | 57 +++++++++---------- .../views/scripts/downtimes/show.phtml | 12 +--- 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index ddc91eeeb..ade9495b0 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -76,45 +76,44 @@

- -

- isService): ?> - link()->service( - $downtime->service_description, - $downtime->service_display_name, - $downtime->host_name, - $downtime->host_display_name - ); - $icon = $this->icon('service', $this->translate('Service')); - ?> - - icon('host', $this->translate('Host')); - $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) - ?> - - translate( - 'Downtime on %s', - 'Downtime for host or service.' - ), - $link - ); ?> - -

+

translate('Downtime detail information') ?>

+ + + + - + - + diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index a683722ac..c7ddb0ae6 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -8,14 +8,6 @@ compact): ?> tabs; ?> - -

- translate('%d Downtimes'), count($downtimes)) ?> - 5 ? - sprintf($this->translate('(%d not shown)'), count ($downtimes) - 5) - : ''; - ?> -

+ isService ? $this->translate('Service') : $this->translate('Host') ?> + + isService): ?> + link()->service( + $downtime->service_description, + $downtime->service_display_name, + $downtime->host_name, + $downtime->host_display_name + ); + $icon = $this->icon('service', $this->translate('Service')); + ?> + + icon('host', $this->translate('Host')); + $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) + ?> + + + +
translate('Author') ?>icon('user') ?> escape($this->downtime->author_name) ?>icon('user', $this->translate('User')) ?> escape($this->downtime->author_name) ?>
translate('Comment') ?>icon('comment') ?> escape($this->downtime->comment) ?>icon('comment', $this->translate('Comment')) ?> escape($this->downtime->comment) ?>
translate('Entry Time') ?>
@@ -40,10 +32,10 @@ From d316b31cbb5358df479a7370b6152196909a4294 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 16:50:55 +0200 Subject: [PATCH 156/298] Fix downtime removal command in detail view Use removal command for single downtimes in detail view. Move removing single and multiple downtimees into seperate forms. refs #8902 --- .../controllers/DowntimeController.php | 18 ++-- .../controllers/DowntimesController.php | 4 +- .../controllers/ListController.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 95 +++++++++++-------- .../Object/DeleteDowntimeQuickCommandForm.php | 36 ------- .../Object/DeleteDowntimesCommandForm.php | 89 +++++++++++++++++ .../Controller/MonitoredObjectController.php | 4 +- 7 files changed, 159 insertions(+), 91 deletions(-) delete mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 086e39f10..7a769b4d6 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -100,11 +100,17 @@ class Monitoring_DowntimeController extends Controller { $this->assertPermission('monitoring/command/downtime/delete'); - $delDowntimeForm = new DeleteDowntimeQuickCommandForm(); - $delDowntimeForm->setDowntimes(array($this->downtime)) - ->populate( - array('redirect' => Url::fromPath('monitoring/list/downtimes')) - ); + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setAction( + Url::fromPath('monitoring/downtime/show') + ->setParam('downtime_id', $this->downtime->id) + ); + $delDowntimeForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/downtimes'), + 'downtime_id' => $this->downtime->id + ) + ); $delDowntimeForm->handleRequest(); return $delDowntimeForm; } diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 608e3c9fc..28ba76cb4 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -5,7 +5,7 @@ use Icinga\Data\Filter\Filter; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -107,7 +107,7 @@ class Monitoring_DowntimesController extends Controller $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm = new DeleteDowntimesCommandForm(); $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); $delDowntimeForm->addDescription(sprintf( $this->translate('Confirm removal of %d downtimes.'), diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b0b0d9f2e..e6147c31b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\OutputFormat; @@ -294,7 +294,7 @@ class Monitoring_ListController extends Controller )); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { - $this->view->delDowntimeForm = new DeleteDowntimeQuickCommandForm(); + $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 72728cd5a..8862c2b53 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -12,8 +12,6 @@ use Icinga\Web\Notification; */ class DeleteDowntimeCommandForm extends CommandForm { - protected $downtimes; - /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -22,50 +20,76 @@ class DeleteDowntimeCommandForm extends CommandForm { $this->setAttrib('class', 'inline'); } - - /** + + /** * (non-PHPDoc) * @see \Icinga\Web\Form::createElements() For the method documentation. */ public function createElements(array $formData = array()) { - $this->addElements(array( + $this->addElements( array( - 'hidden', - 'redirect', array( - 'decorators' => array('ViewHelper') + 'hidden', + 'downtime_id', + array( + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) ) ) - )); + ); return $this; } - - /** - * (non-PHPDoc) - * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. - */ - public function getSubmitLabel() - { - return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); - } /** * (non-PHPDoc) - * @see \Icinga\Web\Form::onSuccess() For the method documentation. + * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + */ + public function addSubmitButton() + { + $this->addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this downtime'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { - foreach ($this->downtimes as $downtime) { - $delDowntime = new DeleteDowntimeCommand(); - $delDowntime->setDowntimeId($downtime->id); - $delDowntime->setDowntimeType( - isset($downtime->service_description) ? - DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : - DeleteDowntimeCommand::DOWNTIME_TYPE_HOST - ); - $this->getTransport($this->request)->send($delDowntime); - } + $id = $this->getElement('downtime_id')->getValue(); + + // Presence of downtime id, only delete this specific downtime + $firstDowntime = $this->downtimes[0]; + + $delDowntime = new DeleteDowntimeCommand(); + $delDowntime->setDowntimeId($id); + $delDowntime->setDowntimeType( + isset($firstDowntime->service_description) ? + DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : + DeleteDowntimeCommand::DOWNTIME_TYPE_HOST + ); + $this->getTransport($this->request)->send($delDowntime); + $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); @@ -73,17 +97,4 @@ class DeleteDowntimeCommandForm extends CommandForm Notification::success($this->translate('Deleting downtime.')); return true; } - - /** - * Set the downtimes to be deleted upon success - * - * @param type $downtimes - * - * @return $this - */ - public function setDowntimes($downtimes) - { - $this->downtimes = $downtimes; - return $this; - } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php deleted file mode 100644 index adbfcae43..000000000 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php +++ /dev/null @@ -1,36 +0,0 @@ -addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this downtime'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; - } -} diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php new file mode 100644 index 000000000..f460f3601 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -0,0 +1,89 @@ +setAttrib('class', 'inline'); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::createElements() For the method documentation. + */ + public function createElements(array $formData = array()) + { + $this->addElements(array( + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) + ) + )); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. + */ + public function getSubmitLabel() + { + return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. + */ + public function onSuccess() + { + foreach ($this->downtimes as $downtime) { + $delDowntime = new DeleteDowntimeCommand(); + $delDowntime->setDowntimeId($downtime->id); + $delDowntime->setDowntimeType( + isset($downtime->service_description) ? + DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : + DeleteDowntimeCommand::DOWNTIME_TYPE_HOST + ); + $this->getTransport($this->request)->send($delDowntime); + } + $redirect = $this->getElement('redirect')->getValue(); + if (! empty($redirect)) { + $this->setRedirectUrl($redirect); + } + Notification::success($this->translate('Deleting downtime.')); + return true; + } + + /** + * Set the downtimes to be deleted upon success + * + * @param type $downtimes + * + * @return $this + */ + public function setDowntimes($downtimes) + { + $this->downtimes = $downtimes; + return $this; + } +} diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 42060d2f0..94d9f6399 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -89,9 +89,7 @@ abstract class MonitoredObjectController extends Controller } if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm - ->setDowntimes($this->object->downtimes) - ->handleRequest(); + $delDowntimeForm->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } $this->view->object = $this->object; From dedc1759672c1ef8e2e2f4ff10c31d9cee4512d5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 18:18:09 +0200 Subject: [PATCH 157/298] Add basic comment detail view refs #8903 --- .../controllers/CommentController.php | 88 +++++++++++++++++++ .../views/scripts/comment/show.phtml | 76 ++++++++++++++++ .../views/scripts/list/comments.phtml | 35 ++++++-- .../partials/comment/comment-header.phtml | 57 ++++++++++++ 4 files changed, 248 insertions(+), 8 deletions(-) create mode 100644 modules/monitoring/application/controllers/CommentController.php create mode 100644 modules/monitoring/application/views/scripts/comment/show.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php new file mode 100644 index 000000000..8d700770b --- /dev/null +++ b/modules/monitoring/application/controllers/CommentController.php @@ -0,0 +1,88 @@ +params->get('comment_id'); + + $this->comment = $this->backend->select()->from('comment', array( + 'id' => 'comment_internal_id', + 'objecttype' => 'comment_objecttype', + 'comment' => 'comment_data', + 'author' => 'comment_author_name', + 'timestamp' => 'comment_timestamp', + 'type' => 'comment_type', + 'persistent' => 'comment_is_persistent', + 'expiration' => 'comment_expiration', + 'host_name', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->where('comment_internal_id', $commentId)->getQuery()->fetchRow(); + + if (false === $this->comment) { + throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); + } + + $this->getTabs() + ->add( + 'comment', + array( + 'title' => $this->translate( + 'Display detailed information about a comment.' + ), + 'icon' => 'comment', + 'label' => $this->translate('Comment'), + 'url' =>'monitoring/comments/show' + ) + )->activate('comment')->extend(new DashboardAction()); + } + + public function showAction() + { + $this->view->comment = $this->comment; + if ($this->hasPermission('monitoring/command/comment/delete')) { + $this->view->delCommentForm = $this->createDelCommentForm(); + } + } + + private function createDelCommentForm() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm->setAction( + Url::fromPath('monitoring/comment/show') + ->setParam('comment_id', $this->comment->id) + ); + $delCommentForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/comments'), + 'comment_id' => $this->comment->id + ) + ); + $delCommentForm->handleRequest(); + return $delCommentForm; + } +} diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml new file mode 100644 index 000000000..c5492a1cf --- /dev/null +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -0,0 +1,76 @@ +
+ compact): ?> + tabs; ?> + + + render('partials/comment/comment-header.phtml'); ?> +
+
+ +

translate('Comment detail information') ?>

+
isService): ?> - icon('service') ?> + icon('service', $this->translate('Service')) ?> service ?> on host_name ?>. - icon('host') ?> + icon('host', $this->translate('Host')) ?> host_name ?>. From b186ce2cacc6da511a2cb5a1f696f12cb097c51e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Apr 2015 17:53:17 +0200 Subject: [PATCH 152/298] Handle non-existed downtime ids with exceptions refs #8902 --- .../application/controllers/DowntimeController.php | 7 ++++--- .../controllers/DowntimesController.php | 6 ++++++ .../application/views/scripts/downtime/show.phtml | 14 ++++---------- .../application/views/scripts/downtimes/show.phtml | 5 ----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 37f466807..26a88ae3b 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -54,6 +54,10 @@ class Monitoring_DowntimeController extends Controller 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + if (false === $this->downtime) { + throw new Zend_Controller_Action_Exception($this->translate('Downtime not found')); + } + if (isset($this->downtime->service_description)) { $this->isService = true; } else { @@ -76,9 +80,6 @@ class Monitoring_DowntimeController extends Controller public function showAction() { - if (false === $this->downtime) { - return; - } $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; $this->view->stateName = isset($this->downtime->service_description) ? diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index eec408110..fe4e9f5bb 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -58,6 +58,12 @@ class Monitoring_DowntimesController extends Controller 'host_display_name', 'service_display_name' ))->addFilter($this->filter)->getQuery()->fetchAll(); + if (false === $this->downtimes) { + throw new Zend_Controller_Action_Exception( + $this->translate('Downtime not found') + ); + } + $this->getTabs() ->add( 'downtimes', diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index ade9495b0..6ecc11a7b 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,13 +1,7 @@ -
- - translate('No scheduled downtime matching the filter.') ?> -
- - - - compact): ?> - tabs; ?> - +
+ compact): ?> + tabs; ?> + diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index c7ddb0ae6..caff167f2 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -1,9 +1,4 @@
- - translate('No scheduled downtimes matching the filter.') ?> -
- - compact): ?> tabs; ?> From 6ddb0042309d5c088ece002962839936f7def6a2 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Apr 2015 18:04:10 +0200 Subject: [PATCH 153/298] Move removal command actions into the downtime controllers refs #8902 --- .../controllers/DowntimeController.php | 33 ++++------ .../controllers/DowntimesController.php | 41 +++++------- .../controllers/ListController.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 63 +++++++++---------- .../Object/DeleteDowntimeQuickCommandForm.php | 36 +++++++++++ .../Command/Object/DeleteDowntimeCommand.php | 42 ++++++++++--- .../IcingaCommandFileCommandRenderer.php | 2 +- .../Controller/MonitoredObjectController.php | 12 +--- 8 files changed, 131 insertions(+), 102 deletions(-) create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 26a88ae3b..086e39f10 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -85,38 +85,27 @@ class Monitoring_DowntimeController extends Controller $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); - $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') ->setParam('host', $this->downtime->host); $this->view->showServiceLink = Url::fromPath('monitoring/service/show') ->setParam('host', $this->downtime->host) ->setParam('service', $this->downtime->service_description); + if ($this->hasPermission('monitoring/command/downtime/delete')) { + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + } } private function createDelDowntimeForm() { - $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm->setObjects($this->downtime); - $delDowntimeForm->populate( - array( - 'downtime_id' => $this->downtime->id, - 'redirect' => Url::fromPath('monitoring/list/downtimes') - ) - ); - if (! $this->isService) { - $delDowntimeForm->setAction( - $this->view->url('monitoring/host/delete-downtime', - array('host' => $this->downtime->host_name)) + $this->assertPermission('monitoring/command/downtime/delete'); + + $delDowntimeForm = new DeleteDowntimeQuickCommandForm(); + $delDowntimeForm->setDowntimes(array($this->downtime)) + ->populate( + array('redirect' => Url::fromPath('monitoring/list/downtimes')) ); - } else { - $delDowntimeForm->setAction( - $this->view->url('monitoring/service/delete-downtime', array( - 'host' => $this->downtime->host_name, - 'service' => $this->downtime->service_description - )) - ); - } + $delDowntimeForm->handleRequest(); return $delDowntimeForm; } } diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index fe4e9f5bb..608e3c9fc 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -94,39 +94,28 @@ class Monitoring_DowntimesController extends Controller public function showAction() { - if (false === $this->downtimes) { - return; - } $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all') ->setParams($this->params); } public function removeAllAction() { + $this->assertPermission('monitoring/command/downtime/delete'); + $this->view->downtimes = $this->downtimes; + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString($this->filter->toQueryString()); $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm->setObjects($this->downtimes); - $delDowntimeForm->populate( - array( - 'downtime_id' => $this->downtime->id, - 'redirect' => Url::fromPath('monitoring/list/downtimes') - ) - ); - if (! $this->isService) { - $delDowntimeForm->setAction( - $this->view->url('monitoring/host/delete-downtime', - array('host' => $this->downtime->host_name)) - ); - } else { - $delDowntimeForm->setAction( - $this->view->url('monitoring/service/delete-downtime', array( - 'host' => $this->downtime->host_name, - 'service' => $this->downtime->service_description - )) - ); - } - return $delDowntimeForm; + $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); + $delDowntimeForm->addDescription(sprintf( + $this->translate('Confirm removal of %d downtimes.'), + count($this->downtimes) + )); + $delDowntimeForm->setDowntimes($this->downtimes) + ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) + ->handleRequest(); + $this->view->delDowntimeForm = $delDowntimeForm; } -} +} \ No newline at end of file diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e6147c31b..b0b0d9f2e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\OutputFormat; @@ -294,7 +294,7 @@ class Monitoring_ListController extends Controller )); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { - $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm = new DeleteDowntimeQuickCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index d240251cf..72728cd5a 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -4,13 +4,16 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; +use \Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; /** * Form for deleting host or service downtimes */ -class DeleteDowntimeCommandForm extends ObjectsCommandForm +class DeleteDowntimeCommandForm extends CommandForm { + protected $downtimes; + /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -27,14 +30,6 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm public function createElements(array $formData = array()) { $this->addElements(array( - array( - 'hidden', - 'downtime_id', - array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), array( 'hidden', 'redirect', @@ -45,48 +40,50 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm )); return $this; } - + /** * (non-PHPDoc) - * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ - public function addSubmitButton() + public function getSubmitLabel() { - $this->addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this downtime'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; + return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); } - + /** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { - foreach ($this->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); - $delDowntime - ->setObject($object) - ->setDowntimeId($this->getElement('downtime_id')->getValue()); + $delDowntime->setDowntimeId($downtime->id); + $delDowntime->setDowntimeType( + isset($downtime->service_description) ? + DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : + DeleteDowntimeCommand::DOWNTIME_TYPE_HOST + ); $this->getTransport($this->request)->send($delDowntime); } $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success($this->translate('Deleting downtime..')); + Notification::success($this->translate('Deleting downtime.')); return true; } + + /** + * Set the downtimes to be deleted upon success + * + * @param type $downtimes + * + * @return $this + */ + public function setDowntimes($downtimes) + { + $this->downtimes = $downtimes; + return $this; + } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php new file mode 100644 index 000000000..adbfcae43 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php @@ -0,0 +1,36 @@ +addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this downtime'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } +} diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php index 52ad99e1b..96dc8f755 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php @@ -3,19 +3,22 @@ namespace Icinga\Module\Monitoring\Command\Object; +use Icinga\Module\Monitoring\Command\IcingaCommand; + /** * Delete a host or service downtime */ -class DeleteDowntimeCommand extends ObjectCommand +class DeleteDowntimeCommand extends IcingaCommand { /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation. + * Downtime for a host */ - protected $allowedObjects = array( - self::TYPE_HOST, - self::TYPE_SERVICE - ); + const DOWNTIME_TYPE_HOST = 'host'; + + /** + * Downtime for a service + */ + const DOWNTIME_TYPE_SERVICE = 'service'; /** * ID of the downtime that is to be deleted @@ -23,6 +26,31 @@ class DeleteDowntimeCommand extends ObjectCommand * @var int */ protected $downtimeId; + + /** + * + * @var type + */ + protected $downtimeType = self::DOWNTIME_TYPE_HOST; + + /** + * Set the downtime type, either host or service + * + * @param string $type the downtime type + */ + public function setDowntimeType($type) + { + $this->downtimeType = $type; + } + + /** + * + * @return type + */ + public function getDowntimeType() + { + return $this->downtimeType; + } /** * Set the ID of the downtime that is to be deleted diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index cf88d7d2e..83fbd4364 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -337,7 +337,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteDowntime(DeleteDowntimeCommand $command) { - if ($command->getObject()->getType() === $command::TYPE_HOST) { + if ($command->getDowntimeType() === 'host') { $commandString = 'DEL_HOST_DOWNTIME'; } else { $commandString = 'DEL_SVC_DOWNTIME'; diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 04102e9d2..42060d2f0 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -90,7 +90,7 @@ abstract class MonitoredObjectController extends Controller if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm - ->setObjects($this->object) + ->setDowntimes($this->object->downtimes) ->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } @@ -147,16 +147,6 @@ abstract class MonitoredObjectController extends Controller $this->handleCommandForm(new DeleteCommentCommandForm()); } - /** - * Delete a downtime - */ - public function deleteDowntimeAction() - { - $this->assertHttpMethod('POST'); - $this->assertPermission('monitoring/command/downtime/delete'); - $this->handleCommandForm(new DeleteDowntimeCommandForm()); - } - /** * Create tabs */ From be566746a94544ba86b9ad64d4e07cbeca644227 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 13:43:30 +0200 Subject: [PATCH 154/298] Provide downtime header in remove and remove-all commands Add new show script for downtimes and move downtime headers into partials to deduplicate code. refs #8902 --- .../views/scripts/downtime/remove.phtml | 11 +++ .../views/scripts/downtime/show.phtml | 71 +------------- .../views/scripts/downtimes/remove-all.phtml | 12 +++ .../views/scripts/downtimes/show.phtml | 96 +------------------ .../partials/downtime/downtime-header.phtml | 67 +++++++++++++ .../partials/downtime/downtimes-header.phtml | 92 ++++++++++++++++++ 6 files changed, 187 insertions(+), 162 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/downtime/remove.phtml create mode 100644 modules/monitoring/application/views/scripts/downtimes/remove-all.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml diff --git a/modules/monitoring/application/views/scripts/downtime/remove.phtml b/modules/monitoring/application/views/scripts/downtime/remove.phtml new file mode 100644 index 000000000..57fe36655 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtime/remove.phtml @@ -0,0 +1,11 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/downtime/downtime-header.phtml'); ?> +
+
+ +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 6ecc11a7b..aed35b9ac 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -3,75 +3,8 @@ tabs; ?> -
- - - - -
- is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> -
- dateTimeRenderer( - ($downtime->is_in_effect ? $downtime->end : $downtime->start), - true - )->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('in %s', 'timespan') - ); - ?> -
- - is_flexible): ?> - is_in_effect): ?> - isService - ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') - : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') - : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), - date('d.m.y H:i', $downtime->scheduled_start), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - is_in_effect): ?> - isService - ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') - : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') - : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), - date('d.m.y', $downtime->scheduled_start), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - - -
+ render('partials/downtime/downtime-header.phtml'); ?>
-

translate('Downtime detail information') ?>

@@ -177,7 +110,7 @@ diff --git a/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml b/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml new file mode 100644 index 000000000..fed0e12f7 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml @@ -0,0 +1,12 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/downtime/downtimes-header.phtml'); ?> +
+ +
+ +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index caff167f2..98999f012 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -3,98 +3,8 @@ compact): ?> tabs; ?> -

-

translate('Commands') ?> - +
- - 5) { - continue; - } ?> - - - - - - -
- is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> -
- dateTimeRenderer( - ($downtime->is_in_effect ? $downtime->end : $downtime->start), - true - )->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('in %s', 'timespan') - ); - ?> -
- isService): ?> - icon('service', $this->translate('Service')) ?> - service ?> on host_name ?>. - - icon('host', $this->translate('Host')) ?> - host_name ?>. - - - is_flexible): ?> - is_in_effect): ?> - isService - ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') - : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') - : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), - date('d.m.y H:i', $downtime->scheduled_start), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - is_in_effect): ?> - isService - ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') - : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), - date('d.m.y', $downtime->start), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - isService - ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') - : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), - date('d.m.y', $downtime->scheduled_start), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - -
-

- qlink( - sprintf($this->translate('List all %d downtimes …'), count($downtimes)), - $listAllLink, - null, - array( - 'title' => $this->translate('List all'), - 'data-base-target' => "_next" - ) - ) ?> -

+ + render('partials/downtime/downtimes-header.phtml'); ?>

@@ -119,5 +29,5 @@ ) ) ?>
-

+

diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml new file mode 100644 index 000000000..92759a12a --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml @@ -0,0 +1,67 @@ + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ + is_flexible): ?> + is_in_effect): ?> + isService + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + date('d.m.y H:i', $downtime->scheduled_start), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + isService + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + date('d.m.y', $downtime->scheduled_start), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml new file mode 100644 index 000000000..54cd0210c --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml @@ -0,0 +1,92 @@ + + + 5) { + continue; + } ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ isService): ?> + icon('service', $this->translate('Service')) ?> + service ?> on host_name ?>. + + icon('host', $this->translate('Host')) ?> + host_name ?>. + + + is_flexible): ?> + is_in_effect): ?> + isService + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + date('d.m.y H:i', $downtime->scheduled_start), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + isService + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + date('d.m.y', $downtime->start), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + isService + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + date('d.m.y', $downtime->scheduled_start), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + +
+ +

+ qlink( + sprintf($this->translate('List all %d downtimes …'), count($downtimes)), + $listAllLink, + null, + array( + 'title' => $this->translate('List all'), + 'data-base-target' => "_next" + ) + ) ?> +

\ No newline at end of file From a46dece13650902ee130391bc71002c7beb96098 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 16:30:04 +0200 Subject: [PATCH 155/298] Provie link to detail view in downtime partial refs #8902 --- .../scripts/show/components/downtime.phtml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index b338f8a71..bfb9bbf45 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -47,12 +47,15 @@ foreach ($object->downtimes as $downtime) { ) : $this->escape($downtime->comment); if ((bool) $downtime->is_in_effect) { - $state = 'in downtime since ' . $this->timeSince($downtime->start); + $state = 'in downtime since '; + $time = $this->timeSince($downtime->start); } else { if ((bool) $downtime->is_fixed) { - $state = 'scheduled ' . $this->timeUntil($downtime->start); + $state = 'scheduled '; + $time = $this->timeUntil($downtime->start); } else { - $state = 'scheduled flexible ' . $this->timeUntil($downtime->start); + $state = 'scheduled flexible '; + $time = $this->timeUntil($downtime->start); } } @@ -65,7 +68,14 @@ foreach ($object->downtimes as $downtime) { $delDowntimeForm->populate(array('downtime_id' => $downtime->id)); echo $delDowntimeForm; } ?> - translate('Downtime'); ?> - ', $commentText); ?> + translate('Downtime'); ?> + qlink( + $state, + 'monitoring/downtime/show', + array('downtime_id' => $downtime->id), + array('data-base-target' => '_next') + ) . $time ; ?> - ', $commentText); ?>
+ + + comment->objecttype === 'service'): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
translate('Service') ?> + icon('service', $this->translate('Service')); ?> + link()->service( + $this->comment->service_description, + $this->comment->service_display_name, + $this->comment->host_name, + $this->comment->host_display_name + ); ?> + translate('Host') ?> + icon('host', $this->translate('Host')); ?> + link()->host( + $this->comment->host_name, + $this->comment->host_display_name + ); ?> +
translate('Author') ?>icon('user', $this->translate('User')) ?> escape($this->comment->author) ?>
translate('Persistent') ?>escape($this->comment->persistent) ? $this->translate('Yes') : $this->translate('No') ?>
translate('Created') ?>escape($this->comment->timestamp)) ?>
translate('Expires') ?> + comment->expiration ? sprintf( + $this->translate('This comment expires on %s at %s.'), + date('d.m.y', $this->comment->expiration), + date('H:i', $this->comment->expiration) + ) : $this->translate('This comment does not expire.'); ?> +
translate('Commands') ?> + +
+ +
+ diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 9f383345c..8810c6e67 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -15,7 +15,10 @@ if (count($comments) === 0) { return; } ?> - +
objecttype === 'service'): ?> icon('service', $this->translate('Service')); ?> - link()->service( - $comment->service_description, - $comment->service_display_name, - $comment->host_name, - $comment->host_display_name - ); ?> + + qlink( + sprintf( + $this->translate('%s on %s', 'Service running on host'), + $comment->service_display_name, + $comment->host_display_name + ), + 'monitoring/comment/show', + array('comment_id' => $comment->id), + array('title' => sprintf( + $this->translate('Show detailed information for comment on %s for %s'), + $comment->service_display_name, + $comment->host_display_name + ))) ?> icon('host', $this->translate('Host')); ?> - link()->host($comment->host_name, $comment->host_display_name); ?> + + qlink( + $comment->host_display_name, + 'monitoring/comment/show', + array('comment_id' => $comment->id), + array('title' => sprintf( + $this->translate('Show detailed information for comment on %s'), + $comment->host_display_name + ))) ?>
icon('comment', $this->translate('Comment')); ?> author) diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml new file mode 100644 index 000000000..6b9a5c53e --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml @@ -0,0 +1,57 @@ +
+ + + + + +
+ + type) { + case 'flapping': + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $tooltip = $this->translate('Comment was caused by a flapping host or service.'); + break; + case 'comment': + $icon = 'user'; + $title = $this->translate('User Comment'); + $tooltip = $this->translate('Comment was created by an user.'); + break; + case 'downtime': + $icon = 'plug'; + $title = $this->translate('Downtime'); + $tooltip = $this->translate('Comment was caused by a downtime.'); + break; + case 'ack': + $icon = 'ok'; + $title = $this->translate('Acknowledgement'); + $tooltip = $this->translate('Comment was caused by an acknowledgement.'); + break; + } + ?> + + escape($title); ?> +
+ icon($icon, $tooltip) ?> + prefixedTimeSince($comment->timestamp); ?> +
+ objecttype === 'service'): ?> + icon('service', $this->translate('Service')); ?> + link()->service( + $comment->service_description, + $comment->service_display_name, + $comment->host_name, + $comment->host_display_name + ); ?> + + icon('host', $this->translate('Host')); ?> + link()->host($comment->host_name, $comment->host_display_name); ?> + + +
+ icon('comment', $this->translate('Comment')); ?> author) + ? '[' . $comment->author . '] ' + : ''; + ?>escape($comment->comment); ?> +
From 32da02c16239ab8475e48e029d3c514e11742117 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 14:30:25 +0200 Subject: [PATCH 158/298] Deduplicate comment views Move comment detail and description into separate partial to reduce code duplication --- .../views/scripts/list/comments.phtml | 36 ++----------- .../comment/comment-description.phtml | 27 ++++++++++ .../partials/comment/comment-detail.phtml | 18 +++++++ .../partials/comment/comment-header.phtml | 51 +------------------ 4 files changed, 52 insertions(+), 80 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/comment/comment-description.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 8810c6e67..248c40490 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -18,40 +18,14 @@ if (count($comments) === 0) { + data-icinga-multiselect-data="comment_id"> - - type) { - case 'flapping': - $icon = 'flapping'; - $title = $this->translate('Flapping'); - $tooltip = $this->translate('Comment was caused by a flapping host or service.'); - break; - case 'comment': - $icon = 'user'; - $title = $this->translate('User Comment'); - $tooltip = $this->translate('Comment was created by an user.'); - break; - case 'downtime': - $icon = 'plug'; - $title = $this->translate('Downtime'); - $tooltip = $this->translate('Comment was caused by a downtime.'); - break; - case 'ack': - $icon = 'ok'; - $title = $this->translate('Acknowledgement'); - $tooltip = $this->translate('Comment was caused by an acknowledgement.'); - break; - } - ?> + comment = $comment; ?> +
- icon($icon, $tooltip) ?> -
- escape($title); ?> -
- prefixedTimeSince($comment->timestamp); ?> + render('partials/comment/comment-description.phtml'); ?>
objecttype === 'service'): ?> diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-description.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-description.phtml new file mode 100644 index 000000000..2c5f07133 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-description.phtml @@ -0,0 +1,27 @@ +type) { + case 'flapping': + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $tooltip = $this->translate('Comment was caused by a flapping host or service.'); + break; + case 'comment': + $icon = 'user'; + $title = $this->translate('User Comment'); + $tooltip = $this->translate('Comment was created by an user.'); + break; + case 'downtime': + $icon = 'plug'; + $title = $this->translate('Downtime'); + $tooltip = $this->translate('Comment was caused by a downtime.'); + break; + case 'ack': + $icon = 'ok'; + $title = $this->translate('Acknowledgement'); + $tooltip = $this->translate('Comment was caused by an acknowledgement.'); + break; +} +?> +escape($title); ?>
+icon($icon, $tooltip) ?> +prefixedTimeSince($comment->timestamp); ?> diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml new file mode 100644 index 000000000..e31f1fdce --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml @@ -0,0 +1,18 @@ +objecttype === 'service'): ?> + icon('service', $this->translate('Service')); ?> + link()->service( + $comment->service_description, + $comment->service_display_name, + $comment->host_name, + $comment->host_display_name + ); ?> + + icon('host', $this->translate('Host')); ?> + link()->host($comment->host_name, $comment->host_display_name); ?> + + +
+icon('comment', $this->translate('Comment')); ?> author) + ? '[' . $comment->author . '] ' + : ''; +?>escape($comment->comment); ?> diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml index 6b9a5c53e..ce0eabe03 100644 --- a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml @@ -1,57 +1,10 @@ -
- - type) { - case 'flapping': - $icon = 'flapping'; - $title = $this->translate('Flapping'); - $tooltip = $this->translate('Comment was caused by a flapping host or service.'); - break; - case 'comment': - $icon = 'user'; - $title = $this->translate('User Comment'); - $tooltip = $this->translate('Comment was created by an user.'); - break; - case 'downtime': - $icon = 'plug'; - $title = $this->translate('Downtime'); - $tooltip = $this->translate('Comment was caused by a downtime.'); - break; - case 'ack': - $icon = 'ok'; - $title = $this->translate('Acknowledgement'); - $tooltip = $this->translate('Comment was caused by an acknowledgement.'); - break; - } - ?> - - escape($title); ?> -
- icon($icon, $tooltip) ?> - prefixedTimeSince($comment->timestamp); ?> + render('partials/comment/comment-description.phtml'); ?>
- objecttype === 'service'): ?> - icon('service', $this->translate('Service')); ?> - link()->service( - $comment->service_description, - $comment->service_display_name, - $comment->host_name, - $comment->host_display_name - ); ?> - - icon('host', $this->translate('Host')); ?> - link()->host($comment->host_name, $comment->host_display_name); ?> - - -
- icon('comment', $this->translate('Comment')); ?> author) - ? '[' . $comment->author . '] ' - : ''; - ?>escape($comment->comment); ?> + render('partials/comment/comment-detail.phtml'); ?>
From cab198eadc67b7274fde6dec2f21c989cbdd1e8f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 14:50:29 +0200 Subject: [PATCH 159/298] Fix whitespaces and unused comments --- .../application/controllers/DowntimesController.php | 8 +------- .../application/views/scripts/downtimes/show.phtml | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 28ba76cb4..3a79a9f40 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -9,13 +9,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - /** * Display detailed information about a downtime */ @@ -58,6 +51,7 @@ class Monitoring_DowntimesController extends Controller 'host_display_name', 'service_display_name' ))->addFilter($this->filter)->getQuery()->fetchAll(); + if (false === $this->downtimes) { throw new Zend_Controller_Action_Exception( $this->translate('Downtime not found') diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index 98999f012..35edc04f4 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -29,5 +29,5 @@ ) ) ?> -

+

From ca839d51236148d1de2d401e16eb8613bf55d02e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 14:51:26 +0200 Subject: [PATCH 160/298] Display amount of selected rows refs #8903 --- .../application/views/scripts/list/comments.phtml | 6 ++++++ .../application/views/scripts/list/downtimes.phtml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 248c40490..dd0c4a7f8 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -1,6 +1,12 @@ compact): ?>
tabs; ?> +
+ render('list/components/selectioninfo.phtml'); ?> +
+
+ getTotalItemCount() ?> translate('Comments') ?>: +
sortBox; ?> limiter; ?> paginator; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index b21e3c3fb..f1351a225 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -5,6 +5,12 @@ use Icinga\Module\Monitoring\Object\Service; if (! $this->compact): ?>
tabs; ?> +
+ render('list/components/selectioninfo.phtml'); ?> +
+
+ getTotalItemCount() ?> translate('Downtimes') ?> +
sortBox; ?> limiter; ?> paginator; ?> From 0c7d8ab48164a90ce55940f497eed43d8cc17ab4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 14:59:39 +0200 Subject: [PATCH 161/298] Add controlle for handling multiple comments refs #8903 --- .../controllers/CommentsController.php | 86 +++++++++++++++++++ .../views/scripts/comment/remove.phtml | 11 +++ .../views/scripts/comments/remove-all.phtml | 12 +++ .../views/scripts/comments/show.phtml | 32 +++++++ .../partials/comment/comment-header.phtml | 2 +- .../partials/comment/comments-header.phtml | 30 +++++++ 6 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 modules/monitoring/application/controllers/CommentsController.php create mode 100644 modules/monitoring/application/views/scripts/comment/remove.phtml create mode 100644 modules/monitoring/application/views/scripts/comments/remove-all.phtml create mode 100644 modules/monitoring/application/views/scripts/comments/show.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php new file mode 100644 index 000000000..9e477d3bb --- /dev/null +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -0,0 +1,86 @@ +filter = Filter::fromQueryString(str_replace( + 'comment_id', + 'comment_internal_id', + (string)$this->params + )); + $this->comments = $this->backend->select()->from('comment', array( + 'id' => 'comment_internal_id', + 'objecttype' => 'comment_objecttype', + 'comment' => 'comment_data', + 'author' => 'comment_author_name', + 'timestamp' => 'comment_timestamp', + 'type' => 'comment_type', + 'persistent' => 'comment_is_persistent', + 'expiration' => 'comment_expiration', + 'host_name', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->addFilter($this->filter)->getQuery()->fetchAll(); + + if (false === $this->comments) { + throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); + } + + $this->getTabs() + ->add( + 'comments', + array( + 'title' => $this->translate( + 'Display detailed information about multiple comments.' + ), + 'icon' => 'comment', + 'label' => $this->translate('Comments'), + 'url' =>'monitoring/comments/show' + ) + )->activate('comments')->extend(new DashboardAction()); + } + + public function showAction() + { + $this->view->comments = $this->comments; + $this->view->listAllLink = Url::fromPath('monitoring/list/comments') + ->setQueryString($this->filter->toQueryString()); + $this->view->removeAllLink = Url::fromPath('monitoring/comments/remove-all') + ->setParams($this->params); + } + + public function removeAllAction() + { + $this->assertPermission('monitoring/command/comment/delete'); + $this->view->comments = $this->comments; + $this->view->listAllLink = Url::fromPath('monitoring/list/comments') + ->setQueryString($this->filter->toQueryString()); + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm->setTitle($this->view->translate('Remove all Comments')); + $delCommentForm->addDescription(sprintf( + $this->translate('Confirm removal of %d comments.'), + count($this->comments) + )); + $delCommentForm->setObjects($this->comments) + ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) + ->handleRequest(); + $this->view->delCommentForm = $delCommentForm; + } +} diff --git a/modules/monitoring/application/views/scripts/comment/remove.phtml b/modules/monitoring/application/views/scripts/comment/remove.phtml new file mode 100644 index 000000000..73f8c68a8 --- /dev/null +++ b/modules/monitoring/application/views/scripts/comment/remove.phtml @@ -0,0 +1,11 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/downtime/downtime-header.phtml'); ?> +
+
+ +
diff --git a/modules/monitoring/application/views/scripts/comments/remove-all.phtml b/modules/monitoring/application/views/scripts/comments/remove-all.phtml new file mode 100644 index 000000000..698c4eea7 --- /dev/null +++ b/modules/monitoring/application/views/scripts/comments/remove-all.phtml @@ -0,0 +1,12 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/comment/comments-header.phtml'); ?> +
+ +
+ +
diff --git a/modules/monitoring/application/views/scripts/comments/show.phtml b/modules/monitoring/application/views/scripts/comments/show.phtml new file mode 100644 index 000000000..f54f3904a --- /dev/null +++ b/modules/monitoring/application/views/scripts/comments/show.phtml @@ -0,0 +1,32 @@ +
+ compact): ?> + tabs; ?> + + + render('partials/comment/comments-header.phtml'); ?> +
+ +
+

icon('reschedule') ?> translate('Commands') ?>

+

+ translate('Issue commands to all %s selected comments.'), + '' . count($comments) . '' + ) + ?> +

+ qlink( + sprintf( + $this->translate('Remove all %d scheduled comments'), + count($comments) + ), + $removeAllLink, + null, + array( + 'icon' => 'trash', + 'title' => $this->translate('Remove all selected comments.') + ) + ) ?> +
+

+
diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml index ce0eabe03..c3e0fadda 100644 --- a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml @@ -1,6 +1,6 @@ -
+ render('partials/comment/comment-description.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml new file mode 100644 index 000000000..4ec725549 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml @@ -0,0 +1,30 @@ + + 5) { + continue; + } + $this->comment = $comment; + ?> + + + + + + +
+ render('partials/comment/comment-description.phtml'); ?> + + render('partials/comment/comment-detail.phtml'); ?> +
+ +

+ qlink( + sprintf($this->translate('List all %d comments …'), count($comments)), + $listAllLink, + null, + array( + 'title' => $this->translate('List all'), + 'data-base-target' => "_next" + ) + ) ?> +

From 6ff903c8a986355a3fb502e996e2f4cb53a66722 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 15:04:33 +0200 Subject: [PATCH 162/298] Remove useless comments --- .../application/controllers/CommentController.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index 8d700770b..9defa18fe 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -6,12 +6,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - /** * Display detailed information about a comment */ From c71786a6241a386f25b4cb4a37579d713f81e913 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 15:43:24 +0200 Subject: [PATCH 163/298] Remove useless comments --- .../application/controllers/CommentController.php | 3 --- .../application/controllers/CommentsController.php | 3 --- .../application/controllers/DowntimeController.php | 9 --------- .../application/controllers/DowntimesController.php | 3 --- 4 files changed, 18 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index 9defa18fe..a595ffeca 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -13,9 +13,6 @@ class Monitoring_CommentController extends Controller { protected $comment; - /** - * Add tabs - */ public function init() { $commentId = $this->params->get('comment_id'); diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 9e477d3bb..85fddcb50 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -14,9 +14,6 @@ class Monitoring_CommentsController extends Controller { protected $comments; - /** - * Add tabs - */ public function init() { $this->filter = Filter::fromQueryString(str_replace( diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 7a769b4d6..dcf4dc373 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -8,12 +8,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - /** * Display detailed information about a downtime */ @@ -23,9 +17,6 @@ class Monitoring_DowntimeController extends Controller protected $isService; - /** - * Add tabs - */ public function init() { $downtimeId = $this->params->get('downtime_id'); diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 3a79a9f40..bbd3e1bb4 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -18,9 +18,6 @@ class Monitoring_DowntimesController extends Controller protected $filter; - /** - * Add tabs - */ public function init() { $this->filter = Filter::fromQueryString(str_replace( From e6740c5093f591ac25c78d171b7a614a4ba228a7 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 15:51:17 +0200 Subject: [PATCH 164/298] Set link target to next page in all comment views refs #8903 --- .../application/views/scripts/comment/show.phtml | 8 +++++--- .../application/views/scripts/comments/show.phtml | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index c5492a1cf..fa2682d2e 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -2,15 +2,17 @@ compact): ?> tabs; ?> - - render('partials/comment/comment-header.phtml'); ?> + +
+ render('partials/comment/comment-header.phtml'); ?> +

translate('Comment detail information') ?>

- + comment->objecttype === 'service'): ?> diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index ab9eb6548..5d5d21217 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -22,7 +22,7 @@ if (count($comments) === 0) { } ?>
translate('Service') ?> diff --git a/modules/monitoring/application/views/scripts/comments/show.phtml b/modules/monitoring/application/views/scripts/comments/show.phtml index f54f3904a..6298749b2 100644 --- a/modules/monitoring/application/views/scripts/comments/show.phtml +++ b/modules/monitoring/application/views/scripts/comments/show.phtml @@ -1,9 +1,11 @@
- compact): ?> - tabs; ?> - - - render('partials/comment/comments-header.phtml'); ?> + compact): ?> + tabs; ?> + + +
+ render('partials/comment/comments-header.phtml'); ?> +
From 5477a2f18e497fcd497168357bf784fa0cce6440 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 16:01:14 +0200 Subject: [PATCH 165/298] Escape missing variables refs #8903 --- .../monitoring/application/views/scripts/list/comments.phtml | 2 +- .../views/scripts/partials/comment/comment-detail.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index dd0c4a7f8..ab9eb6548 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -64,7 +64,7 @@ if (count($comments) === 0) {
icon('comment', $this->translate('Comment')); ?> author) - ? '[' . $comment->author . '] ' + ? '[' . $this->escape($comment->author) . '] ' : ''; ?>escape($comment->comment); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml index e31f1fdce..98ee0534b 100644 --- a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml @@ -13,6 +13,6 @@
icon('comment', $this->translate('Comment')); ?> author) - ? '[' . $comment->author . '] ' + ? '[' . $this->escape($comment->author) . '] ' : ''; ?>escape($comment->comment); ?> From e5e3e8030052e7cd0e983a649dcbe59fe3f0e8c7 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 16:29:07 +0200 Subject: [PATCH 166/298] Conform to coding guidelines --- .../controllers/CommentController.php | 49 +++++++++++++------ .../controllers/CommentsController.php | 45 +++++++++++------ .../views/scripts/comment/show.phtml | 2 +- .../views/scripts/list/comments.phtml | 2 +- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index a595ffeca..e5e181449 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -11,17 +11,27 @@ use Icinga\Web\Widget\Tabextension\DashboardAction; */ class Monitoring_CommentController extends Controller { + /** + * The fetched comment + * + * @var stdClass + */ protected $comment; + /** + * Fetch the first comment with the given id and add tabs + * + * @throws Zend_Controller_Action_Exception + */ public function init() { $commentId = $this->params->get('comment_id'); $this->comment = $this->backend->select()->from('comment', array( - 'id' => 'comment_internal_id', + 'id' => 'comment_internal_id', 'objecttype' => 'comment_objecttype', 'comment' => 'comment_data', - 'author' => 'comment_author_name', + 'author' => 'comment_author_name', 'timestamp' => 'comment_timestamp', 'type' => 'comment_type', 'persistent' => 'comment_is_persistent', @@ -35,21 +45,23 @@ class Monitoring_CommentController extends Controller if (false === $this->comment) { throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); } - - $this->getTabs() - ->add( - 'comment', - array( - 'title' => $this->translate( - 'Display detailed information about a comment.' - ), - 'icon' => 'comment', - 'label' => $this->translate('Comment'), - 'url' =>'monitoring/comments/show' - ) + + $this->getTabs()->add( + 'comment', + array( + 'title' => $this->translate( + 'Display detailed information about a comment.' + ), + 'icon' => 'comment', + 'label' => $this->translate('Comment'), + 'url' =>'monitoring/comments/show' + ) )->activate('comment')->extend(new DashboardAction()); } - + + /** + * Display comment detail view + */ public function showAction() { $this->view->comment = $this->comment; @@ -57,7 +69,12 @@ class Monitoring_CommentController extends Controller $this->view->delCommentForm = $this->createDelCommentForm(); } } - + + /** + * Create a command form to delete a single comment + * + * @return DeleteCommentCommandForm + */ private function createDelCommentForm() { $this->assertPermission('monitoring/command/comment/delete'); diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 85fddcb50..bde2170e3 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -12,14 +12,24 @@ use Icinga\Data\Filter\Filter; */ class Monitoring_CommentsController extends Controller { + /** + * The fetched comments + * + * @var array + */ protected $comments; + /** + * Fetch all comments matching the current filter and add tabs + * + * @throws Zend_Controller_Action_Exception + */ public function init() { $this->filter = Filter::fromQueryString(str_replace( - 'comment_id', - 'comment_internal_id', - (string)$this->params + 'comment_id', + 'comment_internal_id', + (string)$this->params )); $this->comments = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', @@ -40,20 +50,22 @@ class Monitoring_CommentsController extends Controller throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); } - $this->getTabs() - ->add( - 'comments', - array( - 'title' => $this->translate( - 'Display detailed information about multiple comments.' - ), - 'icon' => 'comment', - 'label' => $this->translate('Comments'), - 'url' =>'monitoring/comments/show' - ) + $this->getTabs()->add( + 'comments', + array( + 'title' => $this->translate( + 'Display detailed information about multiple comments.' + ), + 'icon' => 'comment', + 'label' => $this->translate('Comments'), + 'url' =>'monitoring/comments/show' + ) )->activate('comments')->extend(new DashboardAction()); } - + + /** + * Display the detail view for a comment list + */ public function showAction() { $this->view->comments = $this->comments; @@ -63,6 +75,9 @@ class Monitoring_CommentsController extends Controller ->setParams($this->params); } + /** + * Display the form for removing a comment list + */ public function removeAllAction() { $this->assertPermission('monitoring/command/comment/delete'); diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index fa2682d2e..88a25a57b 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -21,7 +21,7 @@ $this->comment->service_description, $this->comment->service_display_name, $this->comment->host_name, - $this->comment->host_display_name + $this->comment->host_display_names ); ?>
From 1586275521ccd02bc14360b448809a9fc0a6c41d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 16:30:26 +0200 Subject: [PATCH 167/298] Conform to coding guidelines in downtime controller --- .../controllers/DowntimeController.php | 33 ++++++++++++++++--- .../controllers/DowntimesController.php | 29 +++++++++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index dcf4dc373..ec1da00ef 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -13,10 +13,25 @@ use Icinga\Web\Widget\Tabextension\DashboardAction; */ class Monitoring_DowntimeController extends Controller { + /** + * The fetched downtime + * + * @var stdClass + */ protected $downtime; - + + /** + * If the downtime is a service or not + * + * @var boolean + */ protected $isService; - + + /** + * Fetch the downtime matching the given id and add tabs + * + * @throws Zend_Controller_Action_Exception + */ public function init() { $downtimeId = $this->params->get('downtime_id'); @@ -54,7 +69,7 @@ class Monitoring_DowntimeController extends Controller } else { $this->isService = false; } - + $this->getTabs() ->add( 'downtime', @@ -68,7 +83,10 @@ class Monitoring_DowntimeController extends Controller ) )->activate('downtime')->extend(new DashboardAction()); } - + + /** + * Display the detail view for a downtime + */ public function showAction() { $this->view->downtime = $this->downtime; @@ -86,7 +104,12 @@ class Monitoring_DowntimeController extends Controller $this->view->delDowntimeForm = $this->createDelDowntimeForm(); } } - + + /** + * Create a command form to delete a single comment + * + * @return DeleteDowntimeCommandForm + */ private function createDelDowntimeForm() { $this->assertPermission('monitoring/command/downtime/delete'); diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index bbd3e1bb4..d25a757b5 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -14,10 +14,25 @@ use Icinga\Web\Widget\Tabextension\DashboardAction; */ class Monitoring_DowntimesController extends Controller { + /** + * The fetched downtimes + * + * @var array + */ protected $downtimes; - + + /** + * A filter matching all current downtimes + * + * @var Filter + */ protected $filter; - + + /** + * Fetch all downtimes matching the current filter and add tabs + * + * @throws Zend_Controller_Action_Exception + */ public function init() { $this->filter = Filter::fromQueryString(str_replace( @@ -82,7 +97,10 @@ class Monitoring_DowntimesController extends Controller } } } - + + /** + * Display the detail view for a downtime list + */ public function showAction() { $this->view->downtimes = $this->downtimes; @@ -91,7 +109,10 @@ class Monitoring_DowntimesController extends Controller $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all') ->setParams($this->params); } - + + /** + * Display the form for removing a downtime list + */ public function removeAllAction() { $this->assertPermission('monitoring/command/downtime/delete'); From 31879755539b4a72caede73e0d27ea1e883a81ad Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 17:02:14 +0200 Subject: [PATCH 168/298] Conform to coding guidelines --- .../controllers/DowntimesController.php | 31 +++++++++---------- .../Object/DeleteDowntimeCommandForm.php | 2 +- .../Object/DeleteDowntimesCommandForm.php | 21 ++++++++----- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index d25a757b5..2931f7d3e 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -36,9 +36,9 @@ class Monitoring_DowntimesController extends Controller public function init() { $this->filter = Filter::fromQueryString(str_replace( - 'downtime_id', - 'downtime_internal_id', - (string)$this->params + 'downtime_id', + 'downtime_internal_id', + (string)$this->params )); $this->downtimes = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', @@ -66,22 +66,21 @@ class Monitoring_DowntimesController extends Controller if (false === $this->downtimes) { throw new Zend_Controller_Action_Exception( - $this->translate('Downtime not found') + $this->translate('Downtime not found') ); } - $this->getTabs() - ->add( - 'downtimes', - array( - 'title' => $this->translate( - 'Display detailed information about multiple downtimes.' - ), - 'icon' => 'plug', - 'label' => $this->translate('Downtimes'), - 'url' =>'monitoring/downtimes/show' - ) - )->activate('downtimes')->extend(new DashboardAction()); + $this->getTabs()->add( + 'downtimes', + array( + 'title' => $this->translate( + 'Display detailed information about multiple downtimes.' + ), + 'icon' => 'plug', + 'label' => $this->translate('Downtimes'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtimes'); foreach ($this->downtimes as $downtime) { if (isset($downtime->service_description)) { diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 8862c2b53..070451e7f 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -84,7 +84,7 @@ class DeleteDowntimeCommandForm extends CommandForm $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($id); $delDowntime->setDowntimeType( - isset($firstDowntime->service_description) ? + isset($firstDowntime->service_description) ? DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : DeleteDowntimeCommand::DOWNTIME_TYPE_HOST ); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index f460f3601..f11ac1128 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -12,6 +12,11 @@ use Icinga\Web\Notification; */ class DeleteDowntimesCommandForm extends CommandForm { + /** + * The downtimes to delete on success + * + * @var array + */ protected $downtimes; /** @@ -31,12 +36,12 @@ class DeleteDowntimesCommandForm extends CommandForm { $this->addElements(array( array( - 'hidden', - 'redirect', - array( - 'decorators' => array('ViewHelper') - ) + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') ) + ) )); return $this; } @@ -60,7 +65,7 @@ class DeleteDowntimesCommandForm extends CommandForm $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($downtime->id); $delDowntime->setDowntimeType( - isset($downtime->service_description) ? + isset($downtime->service_description) ? DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : DeleteDowntimeCommand::DOWNTIME_TYPE_HOST ); @@ -76,9 +81,9 @@ class DeleteDowntimesCommandForm extends CommandForm /** * Set the downtimes to be deleted upon success - * + * * @param type $downtimes - * + * * @return $this */ public function setDowntimes($downtimes) From 11c9cde5570875c490228387460d70fcf4648ace Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 17:05:18 +0200 Subject: [PATCH 169/298] Remove dashboard action from multi view refs #8903 --- .../monitoring/application/controllers/CommentsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index bde2170e3..2e8656085 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -60,7 +60,7 @@ class Monitoring_CommentsController extends Controller 'label' => $this->translate('Comments'), 'url' =>'monitoring/comments/show' ) - )->activate('comments')->extend(new DashboardAction()); + )->activate('comments'); } /** From 7c8ff44fd1c1c524fcf70a110e0c80b808ebf877 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 4 May 2015 17:59:16 +0200 Subject: [PATCH 170/298] Fix comment and downtime list inline forms refs #8903 refs #8902 --- .../application/controllers/CommentController.php | 9 +++++++++ .../application/controllers/DowntimeController.php | 9 +++++++++ .../application/controllers/DowntimesController.php | 1 - .../application/views/scripts/list/comments.phtml | 11 +---------- .../application/views/scripts/list/downtimes.phtml | 9 +-------- public/js/icinga/events.js | 4 ++++ 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index e5e181449..b5b374c12 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -70,6 +70,15 @@ class Monitoring_CommentController extends Controller } } + /** + * Receive DeleteCommentCommandForm post from other controller + */ + public function removeAction() + { + $this->assertHttpMethod('POST'); + $this->createDelCommentForm(); + } + /** * Create a command form to delete a single comment * diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index ec1da00ef..20eebc6ca 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -105,6 +105,15 @@ class Monitoring_DowntimeController extends Controller } } + /** + * Receive DeleteDowntimeCommandForm post from other controller + */ + public function removeAction() + { + $this->assertHttpMethod('POST'); + $this->createDelDowntimeForm(); + } + /** * Create a command form to delete a single comment * diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 2931f7d3e..f6dc53cb3 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -7,7 +7,6 @@ use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm; use Icinga\Web\Url; -use Icinga\Web\Widget\Tabextension\DashboardAction; /** * Display detailed information about a downtime diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 5d5d21217..141c688e7 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -84,16 +84,7 @@ if (count($comments) === 0) { populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); - if ($comment->objecttype === 'host') { - $delCommentForm->setAction( - $this->url('monitoring/host/delete-comment', array('host' => $comment->host_name)) - ); - } else { - $delCommentForm->setAction($this->url('monitoring/service/delete-comment', array( - 'host' => $comment->host_name, - 'service' => $comment->service_description - ))); - } + $delCommentForm->setAction($this->url('monitoring/comment/remove', array('comment_id' => $comment->id))); echo $delCommentForm; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index f1351a225..859326b2e 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -129,14 +129,7 @@ if (count($downtimes) === 0) { populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url)); - if (! $isService) { - $delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host' => $downtime->host_name))); - } else { - $delDowntimeForm->setAction($this->url('monitoring/service/delete-downtime', array( - 'host' => $downtime->host_name, - 'service' => $downtime->service_description - ))); - } + $delDowntimeForm->setAction($this->url('monitoring/downtime/remove', array('downtime_id' => $downtime->id))); echo $delDowntimeForm; ?> diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 7e87a8fb6..cc927feb6 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -303,6 +303,10 @@ var data = self.icinga.ui.getSelectionKeys($table); var url = $table.data('icinga-multiselect-url'); + if ($(event.target).closest('form').length) { + // allow form actions in table rows to pass through + return; + } event.stopPropagation(); event.preventDefault(); From b35dd4ddfee5789b0363b07e2c3209b34cec7f6a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 14:03:09 +0200 Subject: [PATCH 171/298] Separate forms for deleting single and multiple comments refs #8624 --- .../controllers/CommentController.php | 15 +-- .../controllers/CommentsController.php | 4 +- .../controllers/DowntimeController.php | 15 +-- .../controllers/ListController.php | 4 +- .../Object/DeleteCommentCommandForm.php | 50 +++++----- .../Object/DeleteCommentsCommandForm.php | 92 +++++++++++++++++++ .../Object/DeleteDowntimeCommandForm.php | 29 +++--- .../views/scripts/comment/show.phtml | 4 +- .../scripts/show/components/downtime.phtml | 7 +- .../Command/Object/DeleteCommentCommand.php | 43 +++++++-- .../IcingaCommandFileCommandRenderer.php | 7 +- .../Controller/MonitoredObjectController.php | 6 +- 12 files changed, 201 insertions(+), 75 deletions(-) create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index b5b374c12..1c7f3e36d 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -67,6 +67,13 @@ class Monitoring_CommentController extends Controller $this->view->comment = $this->comment; if ($this->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = $this->createDelCommentForm(); + $this->view->delCommentForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/comments'), + 'comment_id' => $this->comment->id, + 'comment_is_service' => isset($this->comment->service_description) + ) + ); } } @@ -82,7 +89,7 @@ class Monitoring_CommentController extends Controller /** * Create a command form to delete a single comment * - * @return DeleteCommentCommandForm + * @return DeleteCommentsCommandForm */ private function createDelCommentForm() { @@ -93,12 +100,6 @@ class Monitoring_CommentController extends Controller Url::fromPath('monitoring/comment/show') ->setParam('comment_id', $this->comment->id) ); - $delCommentForm->populate( - array( - 'redirect' => Url::fromPath('monitoring/list/comments'), - 'comment_id' => $this->comment->id - ) - ); $delCommentForm->handleRequest(); return $delCommentForm; } diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 2e8656085..106dd4650 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -2,7 +2,7 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Module\Monitoring\Controller; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Data\Filter\Filter; @@ -84,7 +84,7 @@ class Monitoring_CommentsController extends Controller $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); - $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm->setTitle($this->view->translate('Remove all Comments')); $delCommentForm->addDescription(sprintf( $this->translate('Confirm removal of %d comments.'), diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 20eebc6ca..1fed470fe 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -5,6 +5,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -102,6 +103,13 @@ class Monitoring_DowntimeController extends Controller ->setParam('service', $this->downtime->service_description); if ($this->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + $this->view->delDowntimeForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/downtimes'), + 'downtime_id' => $this->downtime->id, + 'downtime_is_service' => $this->isService + ) + ); } } @@ -122,18 +130,11 @@ class Monitoring_DowntimeController extends Controller private function createDelDowntimeForm() { $this->assertPermission('monitoring/command/downtime/delete'); - $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm->setAction( Url::fromPath('monitoring/downtime/show') ->setParam('downtime_id', $this->downtime->id) ); - $delDowntimeForm->populate( - array( - 'redirect' => Url::fromPath('monitoring/list/downtimes'), - 'downtime_id' => $this->downtime->id - ) - ); $delDowntimeForm->handleRequest(); return $delDowntimeForm; } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e6147c31b..53b0e1edd 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -3,7 +3,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -501,7 +501,7 @@ class Monitoring_ListController extends Controller ); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { - $this->view->delCommentForm = new DeleteCommentCommandForm(); + $this->view->delCommentForm = new DeleteCommentsCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 93b928b86..1c8144475 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -4,12 +4,13 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand; +use Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; /** * Form for deleting host or service comments */ -class DeleteCommentCommandForm extends ObjectsCommandForm +class DeleteCommentCommandForm extends CommandForm { /** * (non-PHPDoc) @@ -26,23 +27,34 @@ class DeleteCommentCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { - $this->addElements(array( + $this->addElements( array( - 'hidden', - 'comment_id', array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), - array( - 'hidden', - 'redirect', + 'hidden', + 'comment_id', + array( + 'required' => true, + 'validators' => array('NotEmpty'), + 'decorators' => array('ViewHelper') + ) + ), array( - 'decorators' => array('ViewHelper') + 'hidden', + 'comment_is_service', + array( + 'filters' => array('Boolean'), + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) ) ) - )); + ); return $this; } @@ -74,14 +86,10 @@ class DeleteCommentCommandForm extends ObjectsCommandForm */ public function onSuccess() { - foreach ($this->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ - $delComment = new DeleteCommentCommand(); - $delComment - ->setObject($object) - ->setCommentId($this->getElement('comment_id')->getValue()); - $this->getTransport($this->request)->send($delComment); - } + $cmd = new DeleteCommentCommand(); + $cmd->setIsService($this->getElement('comment_is_service')->getValue()) + ->setCommentId($this->getElement('comment_id')->getValue()); + $this->getTransport($this->request)->send($cmd); $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php new file mode 100644 index 000000000..119020411 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -0,0 +1,92 @@ +setAttrib('class', 'inline'); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::createElements() For the method documentation. + */ + public function createElements(array $formData = array()) + { + $this->addElements(array( + array( + 'hidden', + 'comment_id', + array( + 'required' => true, + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) + ) + )); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + */ + public function addSubmitButton() + { + $this->addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this comment'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. + */ + public function onSuccess() + { + foreach ($this->objects as $object) { + /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + $delComment = new DeleteCommentCommand(); + $delComment + ->setObject($object) + ->setCommentId($this->getElement('comment_id')->getValue()); + $this->getTransport($this->request)->send($delComment); + } + $redirect = $this->getElement('redirect')->getValue(); + if (! empty($redirect)) { + $this->setRedirectUrl($redirect); + } + Notification::success($this->translate('Deleting comment..')); + return true; + } +} diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 070451e7f..1d959caab 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -33,6 +33,16 @@ class DeleteDowntimeCommandForm extends CommandForm 'hidden', 'downtime_id', array( + 'required' => true, + 'validators' => array('NotEmpty'), + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'downtime_is_service', + array( + 'filters' => array('Boolean'), 'decorators' => array('ViewHelper') ) ), @@ -76,20 +86,11 @@ class DeleteDowntimeCommandForm extends CommandForm */ public function onSuccess() { - $id = $this->getElement('downtime_id')->getValue(); - - // Presence of downtime id, only delete this specific downtime - $firstDowntime = $this->downtimes[0]; - - $delDowntime = new DeleteDowntimeCommand(); - $delDowntime->setDowntimeId($id); - $delDowntime->setDowntimeType( - isset($firstDowntime->service_description) ? - DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : - DeleteDowntimeCommand::DOWNTIME_TYPE_HOST - ); - $this->getTransport($this->request)->send($delDowntime); - + $cmd = new DeleteDowntimeCommand(); + $cmd->setDowntimeId($this->getElement('downtime_id')->getValue()); + $cmd->setIsService($this->getElement('downtime_is_service')->getValue()); + $this->getTransport($this->request)->send($cmd); + $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index 88a25a57b..9010021c3 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -16,12 +16,12 @@ comment->objecttype === 'service'): ?> diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index bfb9bbf45..a10863054 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -65,7 +65,12 @@ foreach ($object->downtimes as $downtime) { diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 1268a4050..0d35b77cd 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -131,10 +131,9 @@ if (count($downtimes) === 0) { $delDowntimeForm->populate( array( 'downtime_id' => $downtime->id, - 'redirect' => $this->url + 'downtime_is_service' => isset($downtime->service_description) ) ); - $delDowntimeForm->setAction($this->url('monitoring/downtime/remove', array('downtime_id' => $downtime->id))); echo $delDowntimeForm; ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 5a4d351c0..478b1e7f3 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -48,7 +48,12 @@ foreach ($object->comments as $comment) { @@ -31,7 +32,8 @@ link()->host( $this->comment->host_name, $this->comment->host_display_name - ); ?> + ); + ?> @@ -55,10 +57,11 @@ diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 9c0921b9e..9d27b1268 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -62,7 +62,7 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; } - if ( ! in_array((int) $this->object->state, array(0, 99))) { + if (! in_array((int) $this->object->state, array(0, 99))) { if ((bool) $this->object->acknowledged) { if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) { $removeAckForm = new RemoveAcknowledgementCommandForm(); From fff2d5c816cdd12d7aca63123d5d0b4e16ff3922 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:29:46 +0200 Subject: [PATCH 182/298] Use consistent controller names refs #8624 --- .../monitoring/application/controllers/CommentsController.php | 4 ++-- .../application/controllers/DowntimesController.php | 4 ++-- .../scripts/comments/{remove-all.phtml => delete-all.phtml} | 0 .../scripts/downtimes/{remove-all.phtml => delete-all.phtml} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename modules/monitoring/application/views/scripts/comments/{remove-all.phtml => delete-all.phtml} (100%) rename modules/monitoring/application/views/scripts/downtimes/{remove-all.phtml => delete-all.phtml} (100%) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 64eeeb361..e9a885dbe 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -70,14 +70,14 @@ class Monitoring_CommentsController extends Controller $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/comments/remove-all') + $this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all') ->setParams($this->params); } /** * Display the form for removing a comment list */ - public function removeAllAction() + public function deleteAllAction() { $this->assertPermission('monitoring/command/comment/delete'); diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index a5d49cd97..dfd5a6758 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -104,14 +104,14 @@ class Monitoring_DowntimesController extends Controller $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all') + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all') ->setParams($this->params); } /** * Display the form for removing a downtime list */ - public function removeAllAction() + public function deleteAllAction() { $this->assertPermission('monitoring/command/downtime/delete'); $this->view->downtimes = $this->downtimes; diff --git a/modules/monitoring/application/views/scripts/comments/remove-all.phtml b/modules/monitoring/application/views/scripts/comments/delete-all.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/comments/remove-all.phtml rename to modules/monitoring/application/views/scripts/comments/delete-all.phtml diff --git a/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml b/modules/monitoring/application/views/scripts/downtimes/delete-all.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/downtimes/remove-all.phtml rename to modules/monitoring/application/views/scripts/downtimes/delete-all.phtml From 8c5f2662ea9d99485283e973ee095a251b2f07c7 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:33:38 +0200 Subject: [PATCH 183/298] Fix redirects in downtime multi view refs #8624 --- .../monitoring/application/controllers/DowntimesController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index dfd5a6758..49424ed3a 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -123,6 +123,7 @@ class Monitoring_DowntimesController extends Controller $this->translate('Confirm removal of %d downtimes.'), count($this->downtimes) )); + $delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')); $delDowntimeForm->setDowntimes($this->downtimes)->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } From c3b4ea71d3a65ef1cb454141f80bb55acae91ed4 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 11 May 2015 10:32:34 +0200 Subject: [PATCH 184/298] Add ido schema and instance availability validation refs #9203 --- .../forms/Config/BackendConfigForm.php | 63 +++++++++++++++++++ .../forms/Setup/IdoResourcePage.php | 11 +++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index d89c6623f..567f7a575 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -3,6 +3,10 @@ namespace Icinga\Module\Monitoring\Forms\Config; +use Exception; +use Icinga\Data\ConfigObject; +use Icinga\Data\ResourceFactory; +use Icinga\Web\Form; use InvalidArgumentException; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; @@ -271,4 +275,63 @@ class BackendConfigForm extends ConfigForm ) ); } + + /** + * Validate the ido instance schema resource + * + * @param Form $form + * @param ConfigObject $resourceConfig + * + * @return bool Whether validation succeeded or not + */ + public static function isValidIdoSchema(Form $form, ConfigObject $resourceConfig) + { + try { + $resource = ResourceFactory::createResource($resourceConfig); + $result = $resource->select()->from('icinga_dbversion', array('version')); + $result->fetchOne(); + } catch (Exception $e) { + $form->addError( + $form->translate( + 'IDO schema validation failed, it looks like that the IDO schema is missing in the given database.' + ) + ); + return false; + } + return true; + } + + /** + * Validate the ido instance availability + * + * @param Form $form + * @param ConfigObject $resourceConfig + * + * @return bool Whether validation succeeded or not + */ + public static function isValidIdoInstance(Form $form, ConfigObject $resourceConfig) + { + $resource = ResourceFactory::createResource($resourceConfig); + $result = $resource->select()->from('icinga_instances', array('instance_name')); + $instances = $result->fetchAll(); + + if (count($instances) === 1) { + return true; + } elseif (count($instances) > 1) { + $form->addError( + $form->translate( + 'WARNING: IDO instance validation failed, because there are multiple instances available.' + ) + ); + return false; + } + + $form->addError( + $form->translate( + 'IDO instance validation failed, because there is no IDO instance available.' + ) + ); + + return false; + } } diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index f52601359..b856c590c 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -3,6 +3,8 @@ namespace Icinga\Module\Monitoring\Forms\Setup; +use Icinga\Data\ConfigObject; +use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm; use Icinga\Web\Form; use Icinga\Forms\Config\Resource\DbResourceForm; @@ -53,7 +55,14 @@ class IdoResourcePage extends Form } if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { - if (false === DbResourceForm::isValidResource($this)) { + $configObject = new ConfigObject($this->getValues()); + if (false === DbResourceForm::isValidResource($this, $configObject)) { + $this->addSkipValidationCheckbox(); + return false; + } elseif (false === BackendConfigForm::isValidIdoSchema($this, $configObject)) { + $this->addSkipValidationCheckbox(); + return false; + } elseif (false === BackendConfigForm::isValidIdoInstance($this, $configObject)) { $this->addSkipValidationCheckbox(); return false; } From 152c6a8f7f0699133c85507744b3fa2cb2865aa6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 May 2015 13:36:58 +0200 Subject: [PATCH 185/298] Merge Monitoring_ListController::hasBetterUrl() into Icinga\Web\Controller::init() refs #9220 --- library/Icinga/Web/Controller.php | 21 ++++++ .../controllers/ListController.php | 66 +------------------ 2 files changed, 22 insertions(+), 65 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 42bd94b5e..6fa578c22 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -15,6 +15,27 @@ use Icinga\Web\Widget\Limiter; */ class Controller extends ModuleActionController { + /** + * @see ActionController::init + */ + public function init() + { + parent::init(); + + $request = $this->getRequest(); + $url = Url::fromRequest(); + + if ($request->isPost() && ($sort = $request->getPost('sort'))) { + $url->setParam('sort', $sort); + if ($dir = $request->getPost('dir')) { + $url->setParam('dir', $dir); + } else { + $url->removeParam('dir'); + } + $this->redirectNow($url); + } + } + /** * Create a SortBox widget at the `sortBox' view property * diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 518bd6528..b8b959a18 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -20,6 +20,7 @@ class Monitoring_ListController extends Controller */ public function init() { + parent::init(); $this->createTabs(); } @@ -41,25 +42,6 @@ class Monitoring_ListController extends Controller return $query; } - protected function hasBetterUrl() - { - $request = $this->getRequest(); - $url = Url::fromRequest(); - - if ($this->getRequest()->isPost()) { - if ($request->getPost('sort')) { - $url->setParam('sort', $request->getPost('sort')); - if ($request->getPost('dir')) { - $url->setParam('dir', $request->getPost('dir')); - } else { - $url->removeParam('dir'); - } - return $url; - } - } - return false; - } - /** * Overwrite the backend to use (used for testing) * @@ -75,10 +57,6 @@ class Monitoring_ListController extends Controller */ public function hostsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - // Handle soft and hard states if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') { $stateColumn = 'host_hard_state'; @@ -149,10 +127,6 @@ class Monitoring_ListController extends Controller */ public function servicesAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - // Handle soft and hard states if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') { $stateColumn = 'service_hard_state'; @@ -247,10 +221,6 @@ class Monitoring_ListController extends Controller */ public function downtimesAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab('downtimes', $this->translate('Downtimes'), $this->translate('List downtimes')); $this->setAutorefreshInterval(12); @@ -304,10 +274,6 @@ class Monitoring_ListController extends Controller */ public function notificationsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab( 'notifications', $this->translate('Notifications'), @@ -337,10 +303,6 @@ class Monitoring_ListController extends Controller public function contactsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab('contacts', $this->translate('Contacts'), $this->translate('List contacts')); $query = $this->backend->select()->from('contact', array( @@ -380,9 +342,6 @@ class Monitoring_ListController extends Controller public function eventgridAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } $this->addTitleTab('eventgrid', $this->translate('Event Grid'), $this->translate('Show the Event Grid')); $form = new StatehistoryForm(); @@ -422,10 +381,6 @@ class Monitoring_ListController extends Controller public function contactgroupsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab( 'contactgroups', $this->translate('Contact Groups'), @@ -465,10 +420,6 @@ class Monitoring_ListController extends Controller public function commentsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab('comments', $this->translate('Comments'), $this->translate('List comments')); $this->setAutorefreshInterval(12); @@ -509,10 +460,6 @@ class Monitoring_ListController extends Controller public function servicegroupsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab( 'servicegroups', $this->translate('Service Groups'), @@ -568,10 +515,6 @@ class Monitoring_ListController extends Controller public function hostgroupsAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups')); $this->setAutorefreshInterval(12); @@ -623,10 +566,6 @@ class Monitoring_ListController extends Controller public function eventhistoryAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } - $this->addTitleTab( 'eventhistory', $this->translate('Event Overview'), @@ -659,9 +598,6 @@ class Monitoring_ListController extends Controller public function servicegridAction() { - if ($url = $this->hasBetterUrl()) { - return $this->redirectNow($url); - } $this->addTitleTab('servicegrid', $this->translate('Service Grid'), $this->translate('Show the Service Grid')); $this->setAutorefreshInterval(15); $query = $this->backend->select()->from('serviceStatus', array( From 295254d1d5313bcc8bbcb210c405a1486c859dbf Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 May 2015 14:07:57 +0200 Subject: [PATCH 186/298] Rename Icinga\Web\Widget\SortBox::applyRequest() to ...::setRequest() refs #9220 --- library/Icinga/Web/Controller.php | 2 +- library/Icinga/Web/Widget/SortBox.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 6fa578c22..939147321 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -53,7 +53,7 @@ class Controller extends ModuleActionController $this->view->sortBox = SortBox::create( 'sortbox-' . $req->getActionName(), $columns - )->applyRequest($req); + )->setRequest($req); } return $this; diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index fc2025e5b..80c413658 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -14,7 +14,7 @@ use Icinga\Web\Request; * submission of sorting changes and draws an additional submit button when JavaScript is disabled. * * The constructor takes an string for the component name and an array containing the select options, where the key is - * the value to be submitted and the value is the label that will be shown. You then should call applyRequest in order + * the value to be submitted and the value is the label that will be shown. You then should call setRequest in order * to make sure the form is correctly populated when a request with a sort parameter is being made. * * Example: @@ -23,7 +23,7 @@ use Icinga\Web\Request; * $this->getRequest()->getActionName(), * $columns * ); - * $this->view->sortControl->applyRequest($this->getRequest()); + * $this->view->sortControl->setRequest($this->getRequest()); * */ class SortBox extends AbstractWidget @@ -81,7 +81,7 @@ class SortBox extends AbstractWidget * * @return $this */ - public function applyRequest($request) + public function setRequest($request) { $this->request = $request; return $this; From 6658415b6fa14d59c595a542dbc79e4125468085 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 11 May 2015 14:40:23 +0200 Subject: [PATCH 187/298] Remove uneeded use statements --- .../monitoring/application/controllers/HostsController.php | 1 - .../application/controllers/ServicesController.php | 5 ----- 2 files changed, 6 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index c390894bf..6c3c6850e 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -12,7 +12,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; -use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; use Icinga\Web\Widget\Chart\InlinePie; diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 7148aae57..1365fbb8a 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -13,12 +13,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommand use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; -use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; -use Icinga\Util\String; use Icinga\Web\Url; -use Icinga\Web\UrlParams; use Icinga\Web\Widget\Chart\InlinePie; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -208,7 +204,6 @@ class Monitoring_ServicesController extends Controller $form = new AddCommentCommandForm(); $form->setTitle($this->translate('Add Service Comments')); $this->handleCommandForm($form); - } From 17ebe07e578713ee0c61af9f628ca3f2a9986205 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 May 2015 15:37:00 +0200 Subject: [PATCH 188/298] Implement Icinga\Web\Widget\SortBox::setQuery() refs #9220 --- library/Icinga/Web/Widget/SortBox.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 80c413658..1026596ca 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -5,6 +5,7 @@ namespace Icinga\Web\Widget; use Icinga\Web\Form; use Icinga\Web\Request; +use Icinga\Data\Sortable; /** * SortBox widget @@ -49,6 +50,13 @@ class SortBox extends AbstractWidget */ protected $request; + /** + * What to apply sort parameters on + * + * @var Sortable + */ + protected $query = null; + /** * Create a SortBox with the entries from $sortFields * @@ -87,6 +95,17 @@ class SortBox extends AbstractWidget return $this; } + /** + * @param Sortable $query + * + * @return $this + */ + public function setQuery(Sortable $query) + { + $this->query = $query; + return $this; + } + /** * Render this SortBox as HTML * From 32659647b93864ebdaf9042738ca8ee689c7da48 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 May 2015 16:09:20 +0200 Subject: [PATCH 189/298] Implement Icinga\Web\Widget\SortBox::handleRequest() refs #9220 --- library/Icinga/Web/Widget/SortBox.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 1026596ca..7896fb8ef 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -6,6 +6,7 @@ namespace Icinga\Web\Widget; use Icinga\Web\Form; use Icinga\Web\Request; use Icinga\Data\Sortable; +use Icinga\Application\Icinga; /** * SortBox widget @@ -106,6 +107,17 @@ class SortBox extends AbstractWidget return $this; } + public function handleRequest(Request $request = null) + { + if ($request === null) { + $request = Icinga::app()->getFrontController()->getRequest(); + } + if ($sort = $request->getParam('sort')) { + $this->query->order($sort, $request->getParam('dir')); + } + return $this; + } + /** * Render this SortBox as HTML * From e1c3d23d127a50fe86c6fe53f0baf467fbe133e3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 May 2015 16:28:23 +0200 Subject: [PATCH 190/298] Icinga\Web\Controller::setupSortControl(): set query on the newly created SortBox (if given) refs #9220 --- library/Icinga/Web/Controller.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 939147321..4f3fb5794 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -41,19 +41,24 @@ class Controller extends ModuleActionController * * In case the current view has been requested as compact this method does nothing. * - * @param array $columns An array containing the sort columns, with the + * @param array $columns An array containing the sort columns, with the * submit value as the key and the label as the value + * @param Sortable $query Query to set on the newly created SortBox * * @return $this */ - protected function setupSortControl(array $columns) + protected function setupSortControl(array $columns, Sortable $query = null) { if (! $this->view->compact) { $req = $this->getRequest(); - $this->view->sortBox = SortBox::create( + $this->view->sortBox = $sortBox = SortBox::create( 'sortbox-' . $req->getActionName(), $columns )->setRequest($req); + if ($query !== null) { + $sortBox->setQuery($query); + } + $sortBox->handleRequest(); } return $this; From dd58f1466c6b5f6ee8efd399b27c29c15c383fc2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 10:16:51 +0200 Subject: [PATCH 191/298] Don't apply sort rules in Monitoring_ListController::filterQuery() refs #9220 --- .../controllers/ListController.php | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b8b959a18..ece98d28c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -119,7 +119,7 @@ class Monitoring_ListController extends Controller 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Address'), 'host_last_check' => $this->translate('Last Check') - )); + ), $query); } /** @@ -195,7 +195,7 @@ class Monitoring_ListController extends Controller 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') - )); + ), $query); $this->view->stats = $this->backend->select()->from('statusSummary', array( 'services_total', @@ -261,7 +261,7 @@ class Monitoring_ListController extends Controller 'downtime_scheduled_start' => $this->translate('Scheduled Start'), 'downtime_scheduled_end' => $this->translate('Scheduled End'), 'downtime_duration' => $this->translate('Duration') - )); + ), $query); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); @@ -298,7 +298,7 @@ class Monitoring_ListController extends Controller $this->setupPaginationControl($this->view->notifications); $this->setupSortControl(array( 'notification_start_time' => $this->translate('Notification Start') - )); + ), $query); } public function contactsAction() @@ -337,7 +337,7 @@ class Monitoring_ListController extends Controller 'contact_pager' => $this->translate('Pager Address / Number'), 'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'), 'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod') - )); + ), $query); } public function eventgridAction() @@ -415,7 +415,7 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'contactgroup_name' => $this->translate('Contactgroup Name'), 'contactgroup_alias' => $this->translate('Contactgroup Alias') - )); + ), $query); } public function commentsAction() @@ -449,7 +449,8 @@ class Monitoring_ListController extends Controller 'service_display_name' => $this->translate('Service'), 'comment_type' => $this->translate('Comment Type'), 'comment_expiration' => $this->translate('Expiration') - ) + ), + $query ); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { @@ -510,7 +511,7 @@ class Monitoring_ListController extends Controller 'services_critical' => $this->translate('Services CRITICAL'), 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') - )); + ), $query); } public function hostgroupsAction() @@ -561,7 +562,7 @@ class Monitoring_ListController extends Controller 'services_critical' => $this->translate('Services CRITICAL'), 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') - )); + ), $query); } public function eventhistoryAction() @@ -593,7 +594,7 @@ class Monitoring_ListController extends Controller $this->setupPaginationControl($this->view->history); $this->setupSortControl(array( 'timestamp' => $this->translate('Occurence') - )); + ), $query); } public function servicegridAction() @@ -611,7 +612,7 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'host_name' => $this->translate('Hostname'), 'service_description' => $this->translate('Service description') - )); + ), $query); $pivot = $query->pivot('service_description', 'host_name'); $this->view->pivot = $pivot; $this->view->horizontalPaginator = $pivot->paginateXAxis(); @@ -633,9 +634,6 @@ class Monitoring_ListController extends Controller $this->setupFilterControl($editor); $this->view->filter = $editor->getFilter(); - if ($sort = $this->params->get('sort')) { - $query->order($sort, $this->params->get('dir')); - } $this->handleFormatRequest($query); return $query; } From afa0dc0956b23ae91e654d4d0ea7defd0378c321 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 10:29:50 +0200 Subject: [PATCH 192/298] SortBox::handleRequest(): check whether $this->query !== null refs #9220 --- library/Icinga/Web/Widget/SortBox.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 7896fb8ef..022efdf32 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -109,11 +109,13 @@ class SortBox extends AbstractWidget public function handleRequest(Request $request = null) { - if ($request === null) { - $request = Icinga::app()->getFrontController()->getRequest(); - } - if ($sort = $request->getParam('sort')) { - $this->query->order($sort, $request->getParam('dir')); + if ($this->query !== null) { + if ($request === null) { + $request = Icinga::app()->getFrontController()->getRequest(); + } + if ($sort = $request->getParam('sort')) { + $this->query->order($sort, $request->getParam('dir')); + } } return $this; } From 7353c0d287513366d067053c79f8d1b321e399d4 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 16:35:14 +0200 Subject: [PATCH 193/298] IdoQuery::initializeForPostgres(): cast only valid IP addresses to inet fixes #7165 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 2e6bec024..fda2f188e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -370,7 +370,11 @@ abstract class IdoQuery extends DbQuery if ($count > 0) { $this->columnsWithoutCollation[] = $this->getMappedField($key); } - $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); + $value = preg_replace( + '/inet_aton\(([[:word:].]+)\)/i', + '(CASE WHEN $1 ~ \'(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}\' THEN $1::inet - \'0.0.0.0\' ELSE NULL END)', + $value + ); $value = preg_replace( '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', 'CASE WHEN ($1 < \'1970-01-03 00:00:00+00\'::timestamp with time zone) THEN 0 ELSE UNIX_TIMESTAMP($1) END', From d43513dcacf50e149b312d76962349cc63f288c6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 16:38:31 +0200 Subject: [PATCH 194/298] Controller: use Icinga\Data\Sortable --- library/Icinga/Web/Controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 4f3fb5794..b70dbd3fc 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -7,6 +7,7 @@ use Zend_Paginator; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Widget\SortBox; use Icinga\Web\Widget\Limiter; +use Icinga\Data\Sortable; /** * This is the controller all modules should inherit from From 3c73f281570f45694292788061723274a85507b2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 17:19:20 +0200 Subject: [PATCH 195/298] Display performance data metrics with value 0 fixes #8744 --- modules/monitoring/application/views/helpers/Perfdata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 36cbaa319..67d3a819f 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -50,7 +50,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract if (! $compact) { foreach ($perfdata->toArray() as $value) { if ($value === '') { - $value = '-'; + $value = '0'; } $row .= ''; } From 9e4c00506d3bc5c0493eb615013ec18b02888df1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 17:22:25 +0200 Subject: [PATCH 196/298] Revert "Display performance data metrics with value 0" This reverts commit 3c73f281570f45694292788061723274a85507b2. --- modules/monitoring/application/views/helpers/Perfdata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 67d3a819f..36cbaa319 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -50,7 +50,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract if (! $compact) { foreach ($perfdata->toArray() as $value) { if ($value === '') { - $value = '0'; + $value = '-'; } $row .= ''; } From 9e3d65e4e99d4343ea97145046ff0cefad4cc2a5 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 17:44:53 +0200 Subject: [PATCH 197/298] Display performance data metrics with value 0 fixes #8744 --- modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php b/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php index 269107c82..d503bc19f 100644 --- a/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php +++ b/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php @@ -83,7 +83,7 @@ class PerfdataSet implements IteratorAggregate $label = trim($this->readLabel()); $value = trim($this->readUntil(' ')); - if ($label && $value) { + if ($label) { $this->perfdata[] = new Perfdata($label, $value); } } From ca79b020e30c5f039e7eb8c5cb75f797b8bf3a4d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 14:33:29 +0200 Subject: [PATCH 198/298] ListController: set up sort control before paginating a query --- .../controllers/ListController.php | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index ece98d28c..1261c7685 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -97,6 +97,13 @@ class Monitoring_ListController extends Controller ), $this->extraColumns())); $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); + $this->setupSortControl(array( + 'host_severity' => $this->translate('Severity'), + 'host_state' => $this->translate('Current State'), + 'host_display_name' => $this->translate('Hostname'), + 'host_address' => $this->translate('Address'), + 'host_last_check' => $this->translate('Last Check') + ), $query); $this->view->hosts = $query->paginate(); $this->view->stats = $this->backend->select()->from('statusSummary', array( @@ -113,13 +120,6 @@ class Monitoring_ListController extends Controller $this->setupLimitControl(); $this->setupPaginationControl($this->view->hosts); - $this->setupSortControl(array( - 'host_severity' => $this->translate('Severity'), - 'host_state' => $this->translate('Current State'), - 'host_display_name' => $this->translate('Hostname'), - 'host_address' => $this->translate('Address'), - 'host_last_check' => $this->translate('Last Check') - ), $query); } /** @@ -181,10 +181,6 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('serviceStatus', $columns); $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); - $this->view->services = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->services); $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), @@ -196,6 +192,10 @@ class Monitoring_ListController extends Controller 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') ), $query); + $this->view->services = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->services); $this->view->stats = $this->backend->select()->from('statusSummary', array( 'services_total', @@ -246,10 +246,6 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->view->downtimes = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->downtimes); $this->setupSortControl(array( 'downtime_is_in_effect' => $this->translate('Is In Effect'), 'host_display_name' => $this->translate('Host'), @@ -262,6 +258,10 @@ class Monitoring_ListController extends Controller 'downtime_scheduled_end' => $this->translate('Scheduled End'), 'downtime_duration' => $this->translate('Duration') ), $query); + $this->view->downtimes = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->downtimes); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); @@ -292,13 +292,13 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); + $this->setupSortControl(array( + 'notification_start_time' => $this->translate('Notification Start') + ), $query); $this->view->notifications = $query->paginate(); $this->setupLimitControl(); $this->setupPaginationControl($this->view->notifications); - $this->setupSortControl(array( - 'notification_start_time' => $this->translate('Notification Start') - ), $query); } public function contactsAction() @@ -326,10 +326,6 @@ class Monitoring_ListController extends Controller 'contact_notify_host_downtime', )); $this->filterQuery($query); - $this->view->contacts = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->contacts); $this->setupSortControl(array( 'contact_name' => $this->translate('Name'), 'contact_alias' => $this->translate('Alias'), @@ -338,6 +334,10 @@ class Monitoring_ListController extends Controller 'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'), 'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod') ), $query); + $this->view->contacts = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->contacts); } public function eventgridAction() @@ -397,6 +397,11 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); + $this->setupSortControl(array( + 'contactgroup_name' => $this->translate('Contactgroup Name'), + 'contactgroup_alias' => $this->translate('Contactgroup Alias') + ), $query); + // Fetch and prepare all contact groups: $contactgroups = $query->getQuery()->fetchAll(); $groupData = array(); @@ -411,11 +416,6 @@ class Monitoring_ListController extends Controller } // TODO: Find a better naming $this->view->groupData = $groupData; - - $this->setupSortControl(array( - 'contactgroup_name' => $this->translate('Contactgroup Name'), - 'contactgroup_alias' => $this->translate('Contactgroup Alias') - ), $query); } public function commentsAction() @@ -438,10 +438,6 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->view->comments = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->comments); $this->setupSortControl( array( 'comment_timestamp' => $this->translate('Comment Timestamp'), @@ -452,6 +448,10 @@ class Monitoring_ListController extends Controller ), $query ); + $this->view->comments = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->comments); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = new DeleteCommentCommandForm(); @@ -498,10 +498,6 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); - $this->view->servicegroups = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->servicegroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'servicegroup_alias' => $this->translate('Service Group Name'), @@ -512,6 +508,10 @@ class Monitoring_ListController extends Controller 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') ), $query); + $this->view->servicegroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->servicegroups); } public function hostgroupsAction() @@ -549,10 +549,6 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); - $this->view->hostgroups = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->hostgroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), @@ -563,6 +559,10 @@ class Monitoring_ListController extends Controller 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') ), $query); + $this->view->hostgroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->hostgroups); } public function eventhistoryAction() @@ -588,13 +588,13 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); + $this->setupSortControl(array( + 'timestamp' => $this->translate('Occurence') + ), $query); $this->view->history = $query->paginate(); $this->setupLimitControl(); $this->setupPaginationControl($this->view->history); - $this->setupSortControl(array( - 'timestamp' => $this->translate('Occurence') - ), $query); } public function servicegridAction() From 59753acece33c46fbd2070cf0e525343fa30caf6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 14:40:40 +0200 Subject: [PATCH 199/298] SortBox::handleRequest(): set query order direction to asc if it's not given --- library/Icinga/Web/Widget/SortBox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 022efdf32..895e9120c 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -114,7 +114,7 @@ class SortBox extends AbstractWidget $request = Icinga::app()->getFrontController()->getRequest(); } if ($sort = $request->getParam('sort')) { - $this->query->order($sort, $request->getParam('dir')); + $this->query->order($sort, $request->getParam('dir', 'asc')); } } return $this; From 43d8968bd2ccde47ca6dacd55695032519d4742b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 16:22:47 +0200 Subject: [PATCH 200/298] GroupsummaryQuery: add columns hosts_up_last_state_change hosts_pending_last_state_change hosts_down_last_state_change_handled hosts_unreachable_last_state_change_handled hosts_down_last_state_change_unhandled hosts_unreachable_last_state_change_unhandled refs #8860 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 28 +++++++++++-------- .../Monitoring/DataView/Groupsummary.php | 6 ++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 8b72bbf79..fd389562e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -11,17 +11,23 @@ class GroupSummaryQuery extends IdoQuery protected $columnMap = array( 'hoststatussummary' => array( - 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', - 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', - 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', - 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', - 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', - 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', - 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', - 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', - 'hostgroup_name' => 'hostgroup_name', - 'hostgroup_alias' => 'hostgroup_alias', - 'hostgroup' => 'hostgroup' + 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', + 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', + 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', + 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', + 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', + 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', + 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)', + 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', + 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', + 'hostgroup_name' => 'hostgroup_name', + 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup' => 'hostgroup' ), 'servicestatussummary' => array( 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index 562bed1da..d29c1c418 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -25,6 +25,12 @@ class Groupsummary extends DataView 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', + 'hosts_up_last_state_change', + 'hosts_pending_last_state_change', + 'hosts_down_last_state_change_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_unreachable_last_state_change_unhandled', 'services_total', 'services_ok', 'services_unknown', From ab2f8e09d687dc105a979f5ac2113c43745f2054 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 16:31:25 +0200 Subject: [PATCH 201/298] Calculate states for host group view from host states refs #8860 --- .../controllers/ListController.php | 6 ++ .../views/scripts/list/hostgroups.phtml | 90 ++++++++----------- 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 1261c7685..948050db6 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -528,6 +528,12 @@ class Monitoring_ListController extends Controller 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', + 'hosts_up_last_state_change', + 'hosts_pending_last_state_change', + 'hosts_down_last_state_change_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_unreachable_last_state_change_unhandled', 'services_ok', 'services_unknown_handled', 'services_unknown_unhandled', diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index ef8cd78ea..90e96e660 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -1,4 +1,7 @@ -compact): ?> +compact): ?>
tabs; ?> sortBox; ?> @@ -15,7 +18,7 @@ if (count($hostgroups) === 0) { return; } ?> -
translate('Service') ?> - icon('service', $this->translate('Service')); ?> + icon('service', $this->translate('Service')); ?> link()->service( $this->comment->service_description, $this->comment->service_display_name, $this->comment->host_name, - $this->comment->host_display_names + $this->comment->host_display_name ); ?> populate(array('downtime_id' => $downtime->id)); + $delDowntimeForm->populate( + array( + 'downtime_id' => $downtime->id, + 'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE + ) + ); echo $delDowntimeForm; } ?> translate('Downtime'); ?> diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php index 00ba63a78..75f2ffb8e 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php @@ -3,20 +3,13 @@ namespace Icinga\Module\Monitoring\Command\Object; +use Icinga\Module\Monitoring\Command\IcingaCommand; + /** * Delete a host or service comment */ -class DeleteCommentCommand extends ObjectCommand +class DeleteCommentCommand extends IcingaCommand { - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation. - */ - protected $allowedObjects = array( - self::TYPE_HOST, - self::TYPE_SERVICE - ); - /** * ID of the comment that is to be deleted * @@ -24,6 +17,13 @@ class DeleteCommentCommand extends ObjectCommand */ protected $commentId; + /** + * The type of the comment, either 'host' or 'service' + * + * @var boolean + */ + protected $isService = false; + /** * Set the ID of the comment that is to be deleted * @@ -46,4 +46,27 @@ class DeleteCommentCommand extends ObjectCommand { return $this->commentId; } + + /** + * Whether the command affects a service comment + * + * @return boolean + */ + public function getIsService() + { + return $this->isService; + } + + /** + * Set whether the command affects a service + * + * @param boolean $value The value, defaults to true + * + * @return this fluent interface + */ + public function setIsService($value = true) + { + $this->isService = (bool) $value; + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index 83fbd4364..19d7574ca 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -323,14 +323,9 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteComment(DeleteCommentCommand $command) { - if ($command->getObject()->getType() === $command::TYPE_HOST) { - $commandString = 'DEL_HOST_COMMENT'; - } else { - $commandString = 'DEL_SVC_COMMENT'; - } return sprintf( '%s;%u', - $commandString, + $command->getIsService() ? 'DEL_SVC_COMMENT' : 'DEL_HOST_COMMENT', $command->getCommentId() ); } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 94d9f6399..3629a4182 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Web\Controller; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; @@ -81,7 +81,7 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) { - $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm ->setObjects($this->object) ->handleRequest(); @@ -142,7 +142,7 @@ abstract class MonitoredObjectController extends Controller { $this->assertHttpMethod('POST'); $this->assertPermission('monitoring/command/comment/delete'); - $this->handleCommandForm(new DeleteCommentCommandForm()); + $this->handleCommandForm(new DeleteCommentsCommandForm()); } /** From ffd12e325cf59a628c8a19d586c1103d04400f01 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 14:05:16 +0200 Subject: [PATCH 172/298] Improve up downtime command form properties Use a flag instead of a enumeration in delete downtime command form, to remove needless boilerplate. refs #8624 --- .../Object/DeleteDowntimeCommandForm.php | 2 +- .../Command/Object/DeleteDowntimeCommand.php | 34 +++++++------------ .../IcingaCommandFileCommandRenderer.php | 7 +--- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 1d959caab..31ec778fa 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -21,7 +21,7 @@ class DeleteDowntimeCommandForm extends CommandForm $this->setAttrib('class', 'inline'); } - /** + /** * (non-PHPDoc) * @see \Icinga\Web\Form::createElements() For the method documentation. */ diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php index 96dc8f755..a2c593f26 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php @@ -10,46 +10,38 @@ use Icinga\Module\Monitoring\Command\IcingaCommand; */ class DeleteDowntimeCommand extends IcingaCommand { - /** - * Downtime for a host - */ - const DOWNTIME_TYPE_HOST = 'host'; - - /** - * Downtime for a service - */ - const DOWNTIME_TYPE_SERVICE = 'service'; - /** * ID of the downtime that is to be deleted * * @var int */ protected $downtimeId; - + /** + * If the command affects a service downtime * - * @var type + * @var boolean */ - protected $downtimeType = self::DOWNTIME_TYPE_HOST; - + protected $isService = false; + /** - * Set the downtime type, either host or service + * Set if this command affects a service * - * @param string $type the downtime type + * @param type $value */ - public function setDowntimeType($type) + public function setIsService($value = true) { - $this->downtimeType = $type; + $this->isService = (bool) $value; } /** - * + * Return whether the command affects a service + * * @return type */ - public function getDowntimeType() + public function getIsService() { - return $this->downtimeType; + return $this->isService; } /** diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index 19d7574ca..f6a35dcc2 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -332,14 +332,9 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteDowntime(DeleteDowntimeCommand $command) { - if ($command->getDowntimeType() === 'host') { - $commandString = 'DEL_HOST_DOWNTIME'; - } else { - $commandString = 'DEL_SVC_DOWNTIME'; - } return sprintf( '%s;%u', - $commandString, + $command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME', $command->getDowntimeId() ); } From 4463f16f04972f4eae8eb7fb9a62cf8de015dfd3 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 15:11:54 +0200 Subject: [PATCH 173/298] Add abbillity to remove multiple comments by id refs #8624 --- .../controllers/CommentsController.php | 4 +- .../Object/DeleteCommentsCommandForm.php | 47 +++++++++++-------- .../Object/DeleteDowntimesCommandForm.php | 8 +--- .../views/scripts/list/comments.phtml | 8 +++- .../views/scripts/list/downtimes.phtml | 7 ++- .../Controller/MonitoredObjectController.php | 8 ++-- 6 files changed, 48 insertions(+), 34 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 106dd4650..9521af7c9 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -90,8 +90,8 @@ class Monitoring_CommentsController extends Controller $this->translate('Confirm removal of %d comments.'), count($this->comments) )); - $delCommentForm->setObjects($this->comments) - ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) + $delCommentForm->setComments($this->comments) + ->setRedirectUrl(Url::fromPath('monitoring/list/comments')) ->handleRequest(); $this->view->delCommentForm = $delCommentForm; } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php index 119020411..57f6aae5a 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -4,13 +4,21 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand; +use \Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; /** * Form for deleting host or service comments */ -class DeleteCommentsCommandForm extends ObjectsCommandForm +class DeleteCommentsCommandForm extends CommandForm { + /** + * The comments deleted on success + * + * @var array + */ + protected $comments; + /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -27,20 +35,10 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm public function createElements(array $formData = array()) { $this->addElements(array( - array( - 'hidden', - 'comment_id', - array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), array( 'hidden', 'redirect', - array( - 'decorators' => array('ViewHelper') - ) + array('decorators' => array('ViewHelper')) ) )); return $this; @@ -74,13 +72,11 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm */ public function onSuccess() { - foreach ($this->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ - $delComment = new DeleteCommentCommand(); - $delComment - ->setObject($object) - ->setCommentId($this->getElement('comment_id')->getValue()); - $this->getTransport($this->request)->send($delComment); + foreach ($this->comments as $comment) { + $cmd = new DeleteCommentCommand(); + $cmd->setCommentId($comment->id) + ->setIsService(isset($comment->service_description)); + $this->getTransport($this->request)->send($cmd); } $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { @@ -89,4 +85,17 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm Notification::success($this->translate('Deleting comment..')); return true; } + + /** + * Set the comments to be deleted upon success + * + * @param array $comments + * + * @return this fluent interface + */ + public function setComments(array $comments) + { + $this->comments = $comments; + return $this; + } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index f11ac1128..566ad572c 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -64,11 +64,7 @@ class DeleteDowntimesCommandForm extends CommandForm foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($downtime->id); - $delDowntime->setDowntimeType( - isset($downtime->service_description) ? - DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : - DeleteDowntimeCommand::DOWNTIME_TYPE_HOST - ); + $delDowntime->setIsService(isset($downtime->service_description)); $this->getTransport($this->request)->send($delDowntime); } $redirect = $this->getElement('redirect')->getValue(); @@ -86,7 +82,7 @@ class DeleteDowntimesCommandForm extends CommandForm * * @return $this */ - public function setDowntimes($downtimes) + public function setDowntimes(array $downtimes) { $this->downtimes = $downtimes; return $this; diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 141c688e7..690095360 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -83,7 +83,13 @@ if (count($comments) === 0) { populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); + $delCommentForm->populate( + array( + 'comment_id' => $comment->id, + 'comment_is_service' => isset($comment->service_description), + 'redirect' => $this->url + ) + ); $delCommentForm->setAction($this->url('monitoring/comment/remove', array('comment_id' => $comment->id))); echo $delCommentForm; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 859326b2e..1268a4050 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -128,7 +128,12 @@ if (count($downtimes) === 0) { populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url)); + $delDowntimeForm->populate( + array( + 'downtime_id' => $downtime->id, + 'redirect' => $this->url + ) + ); $delDowntimeForm->setAction($this->url('monitoring/downtime/remove', array('downtime_id' => $downtime->id))); echo $delDowntimeForm; ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 3629a4182..ce565df86 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Web\Controller; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; @@ -81,10 +81,8 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) { - $delCommentForm = new DeleteCommentsCommandForm(); - $delCommentForm - ->setObjects($this->object) - ->handleRequest(); + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm->handleRequest(); $this->view->delCommentForm = $delCommentForm; } if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { From b314c074cc277de1102cfbac5f050df886adc73f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:20:59 +0200 Subject: [PATCH 174/298] Fix downtime and comment form redirects refs #8624 --- .../application/controllers/DowntimesController.php | 4 +--- .../monitoring/application/controllers/ListController.php | 6 ++++-- .../application/views/scripts/list/comments.phtml | 4 +--- .../application/views/scripts/list/downtimes.phtml | 3 +-- .../views/scripts/show/components/comments.phtml | 7 ++++++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index f6dc53cb3..a5d49cd97 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -123,9 +123,7 @@ class Monitoring_DowntimesController extends Controller $this->translate('Confirm removal of %d downtimes.'), count($this->downtimes) )); - $delDowntimeForm->setDowntimes($this->downtimes) - ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) - ->handleRequest(); + $delDowntimeForm->setDowntimes($this->downtimes)->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } } \ No newline at end of file diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 53b0e1edd..518bd6528 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -3,7 +3,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -295,6 +295,7 @@ class Monitoring_ListController extends Controller if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm->handleRequest(); } } @@ -501,7 +502,8 @@ class Monitoring_ListController extends Controller ); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { - $this->view->delCommentForm = new DeleteCommentsCommandForm(); + $this->view->delCommentForm = new DeleteCommentCommandForm(); + $this->view->delCommentForm->handleRequest(); } } diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 690095360..f05adff1f 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -86,11 +86,9 @@ if (count($comments) === 0) { $delCommentForm->populate( array( 'comment_id' => $comment->id, - 'comment_is_service' => isset($comment->service_description), - 'redirect' => $this->url + 'comment_is_service' => isset($comment->service_description) ) ); - $delCommentForm->setAction($this->url('monitoring/comment/remove', array('comment_id' => $comment->id))); echo $delCommentForm; ?> populate(array('comment_id' => $comment->id)); + $delCommentForm->populate( + array( + 'comment_id' => $comment->id, + 'comment_is_service' => isset($comment->service_description) + ) + ); echo $delCommentForm; } ?> (translate('Comment'); ?>): ', $commentText); ?> From ac599e642ad07703bb3665623854e83ac176a570 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:21:34 +0200 Subject: [PATCH 175/298] Add submit button label to multi comment form refs #8624 --- .../Object/DeleteCommentsCommandForm.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php index 57f6aae5a..805002922 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -46,24 +46,11 @@ class DeleteCommentsCommandForm extends CommandForm /** * (non-PHPDoc) - * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ - public function addSubmitButton() + public function getSubmitLabel() { - $this->addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this comment'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; + return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); } /** From 7cf2cb034e30192180377e5842c0508f8dc020c5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:22:17 +0200 Subject: [PATCH 176/298] Remove unused and redundant controller actions refs #8624 --- .../application/controllers/CommentController.php | 9 --------- .../Web/Controller/MonitoredObjectController.php | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index 1c7f3e36d..c97f12558 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -77,15 +77,6 @@ class Monitoring_CommentController extends Controller } } - /** - * Receive DeleteCommentCommandForm post from other controller - */ - public function removeAction() - { - $this->assertHttpMethod('POST'); - $this->createDelCommentForm(); - } - /** * Create a command form to delete a single comment * diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index ce565df86..9c0921b9e 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -133,16 +133,6 @@ abstract class MonitoredObjectController extends Controller */ abstract public function scheduleDowntimeAction(); - /** - * Delete a comment - */ - public function deleteCommentAction() - { - $this->assertHttpMethod('POST'); - $this->assertPermission('monitoring/command/comment/delete'); - $this->handleCommandForm(new DeleteCommentsCommandForm()); - } - /** * Create tabs */ From 1fa550838d8bb63c647d8dd6c773ac58bed64544 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:37:35 +0200 Subject: [PATCH 177/298] Coding guidelines and cleanup --- .../monitoring/application/controllers/CommentsController.php | 2 +- .../forms/Command/Object/DeleteDowntimesCommandForm.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 9521af7c9..dcd1523e8 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -4,7 +4,6 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Web\Url; -use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Data\Filter\Filter; /** @@ -81,6 +80,7 @@ class Monitoring_CommentsController extends Controller public function removeAllAction() { $this->assertPermission('monitoring/command/comment/delete'); + $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index 566ad572c..4a19cac96 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -38,9 +38,7 @@ class DeleteDowntimesCommandForm extends CommandForm array( 'hidden', 'redirect', - array( - 'decorators' => array('ViewHelper') - ) + array('decorators' => array('ViewHelper')) ) )); return $this; From c6c78989a582293904c5742c214b4081e825fd63 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:02:34 +0200 Subject: [PATCH 178/298] Fix redirects after deleting a comment refs #8624 --- .../application/controllers/CommentController.php | 5 ++++- .../application/controllers/CommentsController.php | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index c97f12558..c3fcd18f8 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -64,12 +64,15 @@ class Monitoring_CommentController extends Controller */ public function showAction() { + $listCommentsLink = Url::fromPath('monitoring/list/comments') + ->setQueryString('comment_type=(comment|ack)'); + $this->view->comment = $this->comment; if ($this->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = $this->createDelCommentForm(); $this->view->delCommentForm->populate( array( - 'redirect' => Url::fromPath('monitoring/list/comments'), + 'redirect' => $listCommentsLink, 'comment_id' => $this->comment->id, 'comment_is_service' => isset($this->comment->service_description) ) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index dcd1523e8..64eeeb361 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -81,9 +81,8 @@ class Monitoring_CommentsController extends Controller { $this->assertPermission('monitoring/command/comment/delete'); - $this->view->comments = $this->comments; - $this->view->listAllLink = Url::fromPath('monitoring/list/comments') - ->setQueryString($this->filter->toQueryString()); + $listCommentsLink = Url::fromPath('monitoring/list/comments') + ->setQueryString('comment_type=(comment|ack)'); $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm->setTitle($this->view->translate('Remove all Comments')); $delCommentForm->addDescription(sprintf( @@ -91,8 +90,11 @@ class Monitoring_CommentsController extends Controller count($this->comments) )); $delCommentForm->setComments($this->comments) - ->setRedirectUrl(Url::fromPath('monitoring/list/comments')) - ->handleRequest(); + ->setRedirectUrl($listCommentsLink) + ->handleRequest(); $this->view->delCommentForm = $delCommentForm; + $this->view->comments = $this->comments; + $this->view->listAllLink = Url::fromPath('monitoring/list/comments') + ->setQueryString($this->filter->toQueryString()); } } From 9936df5157e5e701ea6c27eac465b7e5c721fbfa Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 7 May 2015 17:08:01 +0200 Subject: [PATCH 179/298] Fix current base version to v2.0.0-beta3 We can't really fix tag and release tarballs though. This is mainly for Jenkins... --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2f8540190..a00bf2444 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.0-beta2 +v2.0.0-beta3 From 891ce0fe57d8325e94987083eb7ad75aa0c750de Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 7 May 2015 17:19:00 +0200 Subject: [PATCH 180/298] UserTest: Fix wrong assert condition for wildcard --- test/php/library/Icinga/UserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/php/library/Icinga/UserTest.php b/test/php/library/Icinga/UserTest.php index ffdcbd905..dc55dc62d 100644 --- a/test/php/library/Icinga/UserTest.php +++ b/test/php/library/Icinga/UserTest.php @@ -73,7 +73,7 @@ class UserTest extends BaseTestCase $this->assertTrue($user->can('test/some/specific')); $this->assertTrue($user->can('test/more/everything')); $this->assertTrue($user->can('test/wildcard-with-wildcard/*')); - $this->assertTrue($user->can('test/wildcard/sub/sub')); + $this->assertTrue($user->can('test/wildcard-with-wildcard/sub/sub')); $this->assertFalse($user->can('not/test')); $this->assertFalse($user->can('test/some/not/so/specific')); $this->assertFalse($user->can('test/wildcard2/*')); From 83efc3a4a307158bcda000b071312eeea1c66d92 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:17:24 +0200 Subject: [PATCH 181/298] Conform to coding guidelines --- .../controllers/DowntimeController.php | 4 ++-- .../views/scripts/comment/show.phtml | 23 +++++++++++-------- .../Controller/MonitoredObjectController.php | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 1fed470fe..c06e0311d 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -82,7 +82,7 @@ class Monitoring_DowntimeController extends Controller 'label' => $this->translate('Downtime'), 'url' =>'monitoring/downtimes/show' ) - )->activate('downtime')->extend(new DashboardAction()); + )->activate('downtime')->extend(new DashboardAction()); } /** @@ -92,7 +92,7 @@ class Monitoring_DowntimeController extends Controller { $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; - $this->view->stateName = isset($this->downtime->service_description) ? + $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index 9010021c3..8216a9c70 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -18,11 +18,12 @@ icon('service', $this->translate('Service')); ?> link()->service( - $this->comment->service_description, - $this->comment->service_display_name, - $this->comment->host_name, - $this->comment->host_display_name - ); ?> + $this->comment->service_description, + $this->comment->service_display_name, + $this->comment->host_name, + $this->comment->host_display_name + ); + ?> translate('Host') ?>
translate('Expires') ?> comment->expiration ? sprintf( - $this->translate('This comment expires on %s at %s.'), - date('d.m.y', $this->comment->expiration), - date('H:i', $this->comment->expiration) - ) : $this->translate('This comment does not expire.'); ?> + $this->translate('This comment expires on %s at %s.'), + date('d.m.y', $this->comment->expiration), + date('H:i', $this->comment->expiration) + ) : $this->translate('This comment does not expire.'); + ?>
' . (string) $value . '' . (string) $value . '
+
@@ -23,57 +26,40 @@ if (count($hostgroups) === 0) { - - - services_critical_last_state_change_unhandled): ?> - + - services_unknown_last_state_change_unhandled): ?> - - services_warning_last_state_change_unhandled): ?> - - services_critical_last_state_change_handled): ?> - - services_unknown_last_state_change_handled): ?> - - services_warning_last_state_change_handled): ?> - - services_ok_last_state_change): ?> - - - - - + @@ -68,6 +69,17 @@ if (count($hostgroups) === 0) { array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $h->hostgroup_alias)) ); ?> + + @@ -80,6 +81,162 @@ if (count($hostgroups) === 0) { )) ); ?> +
translate('Last Problem'); ?> translate('Host Group'); ?>translate('Service States'); ?>
- translate('CRITICAL'); ?> + hosts_down_unhandled) { + $handled = false; + $state = Host::STATE_DOWN; + $lastStateChange = $h->hosts_down_last_state_change_unhandled; + } elseif ($h->hosts_unreachable_unhandled) { + $handled = false; + $state = Host::STATE_UNREACHABLE; + $lastStateChange = $h->hosts_unreachable_last_state_change_unhandled; + } else { + $handled = true; + if ($h->hosts_down_handled) { + $state = Host::STATE_DOWN; + $lastStateChange = $h->hosts_down_last_state_change_handled; + } elseif ($h->hosts_unreachable_handled) { + $state = Host::STATE_UNREACHABLE; + $lastStateChange = $h->hosts_unreachable_last_state_change_handled; + } elseif ($h->hosts_up) { + $state = Host::STATE_UP; + $lastStateChange = $h->hosts_up_last_state_change; + } else { + $state = Host::STATE_PENDING; + $lastStateChange = $h->hosts_pending_last_state_change; + } + } + ?> +
+
- prefixedTimeSince($h->services_critical_last_state_change_unhandled); ?> + prefixedTimeSince($lastStateChange); ?>
- translate('UNKNOWN'); ?> -
- prefixedTimeSince($h->services_unknown_last_state_change_unhandled); ?> -
- translate('WARNING'); ?> -
- prefixedTimeSince($h->services_warning_last_state_change_unhandled); ?> -
- translate('CRITICAL'); ?> -
- prefixedTimeSince($h->services_critical_last_state_change_handled); ?> -
- translate('UNKNOWN'); ?> -
- prefixedTimeSince($h->services_unknown_last_state_change_handled); ?> -
- translate('WARNING'); ?> -
- prefixedTimeSince($h->services_warning_last_state_change_handled); ?> -
- translate('OK'); ?> -
- prefixedTimeSince($h->services_ok_last_state_change); ?> -
- translate('PENDING'); ?> -
- prefixedTimeSince($h->services_pending_last_state_change); ?> -
qlink( $h->hostgroup_alias, @@ -93,7 +79,7 @@ if (count($hostgroups) === 0) { )) ); ?> + services_ok): ?> qlink( From 7e1f9f6dccc1085bc1066e6152e548d854050fac Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 17:48:34 +0200 Subject: [PATCH 202/298] Make ascending sort by host or service severity initiatable fixes #9059 --- .../library/Monitoring/DataView/HostStatus.php | 7 ++++--- .../library/Monitoring/DataView/ServiceStatus.php | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..a84098aa4 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -94,10 +94,11 @@ class HostStatus extends DataView ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', - 'host_last_state_change DESC', + 'host_severity', + 'host_last_state_change', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_address' => array( 'columns' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..4d4d617ab 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -130,19 +130,21 @@ class ServiceStatus extends DataView ), 'service_severity' => array( 'columns' => array( - 'service_severity DESC', - 'service_last_state_change DESC', + 'service_severity', + 'service_last_state_change', 'service_display_name ASC', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', - 'host_last_state_change DESC', + 'host_severity', + 'host_last_state_change', 'host_display_name ASC', 'service_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_display_name' => array( 'columns' => array( From ead0a642444c8718c3ca1475e205421a1f01239c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 18:10:18 +0200 Subject: [PATCH 203/298] GroupsummaryQuery: add column `hosts_total' refs #8054 --- .../library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 1 + modules/monitoring/library/Monitoring/DataView/Groupsummary.php | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index fd389562e..392c97538 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -11,6 +11,7 @@ class GroupSummaryQuery extends IdoQuery protected $columnMap = array( 'hoststatussummary' => array( + 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index d29c1c418..36174bfde 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -17,6 +17,7 @@ class Groupsummary extends DataView 'servicegroup_alias', 'hostgroup_name', 'hostgroup_alias', + 'hosts_total', 'hosts_up', 'hosts_unreachable', 'hosts_unreachable_handled', From e879ba445dc308c5524bb83e6cddb9c73b32071e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 18:15:04 +0200 Subject: [PATCH 204/298] List number of hosts in host groups refs #8054 --- .../application/controllers/ListController.php | 1 + .../application/views/scripts/list/hostgroups.phtml | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 948050db6..540f21bae 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -534,6 +534,7 @@ class Monitoring_ListController extends Controller 'hosts_unreachable_last_state_change_handled', 'hosts_down_last_state_change_unhandled', 'hosts_unreachable_last_state_change_unhandled', + 'hosts_total', 'services_ok', 'services_unknown_handled', 'services_unknown_unhandled', diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 90e96e660..89045d9ab 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -22,6 +22,7 @@ if (count($hostgroups) === 0) {
translate('Last Problem'); ?> translate('Host Group'); ?>translate('Total Hosts'); ?> translate('Total Services'); ?> translate('Service States'); ?>
+ qlink( + $h->hosts_total, + 'monitoring/list/hosts', + array('hostgroup_name' => $h->hostgroup_name), + array('title' => sprintf( + $this->translate('List all hosts in host group "%s"'), + $h->hostgroup_alias + )) + ); ?> + qlink( $h->services_total, From 149e893ecdb8fea16c225d5e95c4fb1f3f004747 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 10:54:30 +0200 Subject: [PATCH 205/298] Revert "Make ascending sort by host or service severity initiatable" This reverts commit 7e1f9f6dccc1085bc1066e6152e548d854050fac. --- .../library/Monitoring/DataView/HostStatus.php | 7 +++---- .../library/Monitoring/DataView/ServiceStatus.php | 14 ++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index a84098aa4..23df6d94a 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -94,11 +94,10 @@ class HostStatus extends DataView ), 'host_severity' => array( 'columns' => array( - 'host_severity', - 'host_last_state_change', + 'host_severity DESC', + 'host_last_state_change DESC', 'host_display_name ASC' - ), - 'order' => self::SORT_DESC + ) ), 'host_address' => array( 'columns' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index 4d4d617ab..b4f1038da 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -130,21 +130,19 @@ class ServiceStatus extends DataView ), 'service_severity' => array( 'columns' => array( - 'service_severity', - 'service_last_state_change', + 'service_severity DESC', + 'service_last_state_change DESC', 'service_display_name ASC', 'host_display_name ASC' - ), - 'order' => self::SORT_DESC + ) ), 'host_severity' => array( 'columns' => array( - 'host_severity', - 'host_last_state_change', + 'host_severity DESC', + 'host_last_state_change DESC', 'host_display_name ASC', 'service_display_name ASC' - ), - 'order' => self::SORT_DESC + ) ), 'host_display_name' => array( 'columns' => array( From 386d4db851aed056652d892d539de35b403c5062 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 May 2015 17:48:34 +0200 Subject: [PATCH 206/298] Make ascending sort by host or service severity initiatable fixes #9059 --- .../library/Monitoring/DataView/DataView.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index c9537eff8..be5862abe 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -238,11 +238,11 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable }; } - $order = $order === null ? (isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC) : $order; - $order = (strtoupper($order) === static::SORT_ASC) ? 'ASC' : 'DESC'; + $globalDefaultOrder = isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC; + $globalDefaultOrder = (strtoupper($globalDefaultOrder) === static::SORT_ASC) ? 'ASC' : 'DESC'; foreach ($sortColumns['columns'] as $column) { - list($column, $direction) = $this->query->splitOrder($column); + list($column, $specificDefaultOrder) = $this->query->splitOrder($column); if (! $this->isValidFilterTarget($column)) { throw new QueryException( mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), @@ -250,7 +250,10 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable get_class($this) ); } - $this->query->order($column, $direction !== null ? $direction : $order); + $this->query->order( + $column, + $order === null && $specificDefaultOrder !== null ? $specificDefaultOrder : $globalDefaultOrder + ); } $this->isSorted = true; return $this; From c7d1a7211f63510c0bb9f932f2bccbfdc4dfc705 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 15 May 2015 11:28:16 +0200 Subject: [PATCH 207/298] Show host states in host groups --- .../views/scripts/list/hostgroups.phtml | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 89045d9ab..23d031b3f 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -23,6 +23,7 @@ if (count($hostgroups) === 0) { translate('Last Problem'); ?> translate('Host Group'); ?> translate('Total Hosts'); ?>translate('Host States'); ?> translate('Total Services'); ?> translate('Service States'); ?> + hosts_up): ?> + + qlink( + $h->hosts_up, + 'monitoring/list/hosts', + array( + 'host_state' => 0, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state UP in the host group "%s"', + 'List %u hosts which are currently in state UP in the host group "%s"', + $h->hosts_up + ), + $h->hosts_up, + $h->hostgroup_alias + ) + ) + ); ?> + + + hosts_down_unhandled): ?> + + qlink( + $h->hosts_down_unhandled, + 'monitoring/list/hosts', + array( + 'host_state' => 1, + 'host_acknowledged' => 0, + 'host_in_downtime' => 0, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state DOWN in the host group "%s"', + 'List %u hosts which are currently in state DOWN in the host group "%s"', + $h->hosts_down_unhandled + ), + $h->hosts_down_unhandled, + $h->hostgroup_alias + ) + ) + ); ?> + + hosts_down_handled): ?> + + qlink( + $h->hosts_down_handled, + 'monitoring/list/hosts', + array( + 'host_state' => 1, + 'host_handled' => 1, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state DOWN (Acknowledged) in the host group "%s"', + 'List %u hosts which are currently in state DOWN (Acknowledged) in the host group "%s"', + $h->hosts_down_handled + ), + $h->hosts_down_handled, + $h->hostgroup_alias + ) + ) + ); ?> + + + hosts_down_unhandled): ?> + + + hosts_unreachable_unhandled): ?> + + qlink( + $h->hosts_unreachable_unhandled, + 'monitoring/list/hosts', + array( + 'host_state' => 2, + 'host_acknowledged' => 0, + 'host_in_downtime' => 0, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state UNREACHABLE in the host group "%s"', + 'List %u hosts which are currently in state UNREACHABLE in the host group "%s"', + $h->hosts_unreachable_unhandled + ), + $h->hosts_unreachable_unhandled, + $h->hostgroup_alias + ) + ) + ); ?> + + hosts_unreachable_handled): ?> + + qlink( + $h->hosts_unreachable_handled, + 'monitoring/list/hosts', + array( + 'host_state' => 2, + 'host_handled' => 1, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state UNREACHABLE (Acknowledged) in the host group "%s"', + 'List %u hosts which are currently in state UNREACHABLE (Acknowledged) in the host group "%s"', + $h->hosts_unreachable_handled + ), + $h->hosts_unreachable_handled, + $h->hostgroup_alias + ) + ) + ); ?> + + + hosts_unreachable_unhandled): ?> + + + hosts_pending): ?> + + qlink( + $h->hosts_pending, + 'monitoring/list/hosts', + array( + 'host_state' => 99, + 'hostgroup_name' => $h->hostgroup_name, + 'sort' => 'host_severity' + ), + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state PENDING in the host group "%s"', + 'List %u hosts which are currently in state PENDING in the host group "%s"', + $h->hosts_pending + ), + $h->hosts_pending, + $h->hostgroup_alias + ) + ) + ); ?> + + + qlink( $h->services_total, From 8b084733413b74131100abf6a31efc02793695c5 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 15 May 2015 12:34:59 +0200 Subject: [PATCH 208/298] Hostgroups view: reduce "Last Problem" column's width --- .../application/views/scripts/list/hostgroups.phtml | 2 +- public/css/icinga/main-content.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 23d031b3f..e75359b23 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -20,7 +20,7 @@ if (count($hostgroups) === 0) { ?> - + diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index b442723cb..59c7830da 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -169,6 +169,10 @@ table.benchmark { width: 96%; } +table.groupview th.state { + width: 9em; +} + .dashboard h1 { font-size: 1em; } From 1eb11625ef89b9659e9e4cc440e1247c18c93ffa Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 13:02:54 +0200 Subject: [PATCH 209/298] Add new FormNotification Decorator to render form notifications refs #9203 --- .../Web/Form/Decorator/FormNotifications.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 library/Icinga/Web/Form/Decorator/FormNotifications.php diff --git a/library/Icinga/Web/Form/Decorator/FormNotifications.php b/library/Icinga/Web/Form/Decorator/FormNotifications.php new file mode 100644 index 000000000..ed725e625 --- /dev/null +++ b/library/Icinga/Web/Form/Decorator/FormNotifications.php @@ -0,0 +1,95 @@ +getElement(); + if (! $form instanceof Form) { + return $content; + } + + $view = $form->getView(); + if ($view === null) { + return $content; + } + + $notifications = $this->recurseForm($form); + + if (empty($notifications)) { + return $content; + } + + $html = '
    '; + + asort($notifications); + foreach ($notifications as $message => $type) { + $html .= '
  • ' . $view->escape($message) . '
  • '; + } + + switch ($this->getPlacement()) { + case self::APPEND: + return $content . $html . '
'; + case self::PREPEND: + return $html . '' . $content; + } + } + + /** + * Recurse the given form and return the notifications for it and all of its subforms + * + * @param Form $form The form to recurse + * + * @return array + */ + protected function recurseForm(Form $form) + { + $notifications = $form->getNotifications(); + + foreach ($form->getSubForms() as $subForm) { + $notifications = $notifications + $this->recurseForm($subForm); + } + + return $notifications; + } + + /** + * Get the readable type name of the notification + * + * @param $type Type of the message + * + * @return string + */ + public static function getNotificationTypeName($type) + { + switch ($type) { + case Form::NOTIFICATION_ERROR: + return 'error'; + break; + case Form::NOTIFICATION_WARNING: + return 'warning'; + break; + case Form::NOTIFICATION_INFO: + return 'info'; + break; + default: + return 'unknown'; + } + } +} From 9f35db71bfa4645a186a22f7b7e3b1ae733e51a9 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 13:04:01 +0200 Subject: [PATCH 210/298] Form: Add typed notifications to the form refs #9203 --- library/Icinga/Web/Form.php | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index faf77770c..48f7acdb7 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -38,6 +38,28 @@ class Form extends Zend_Form */ const DEFAULT_SUFFIX = '_default'; + /** + * The type of the notification for the error + */ + const NOTIFICATION_ERROR = 0; + + /** + * The type of the notification for the warning + */ + const NOTIFICATION_WARNING = 2; + + /** + * The type of the notification for the info + */ + const NOTIFICATION_INFO = 4; + + /** + * The notifications of the form + * + * @var array + */ + protected $notifications = array(); + /** * Whether this form has been created * @@ -1009,6 +1031,7 @@ class Form extends Zend_Form } $this->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) + ->addDecorator('FormNotifications') ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) @@ -1208,4 +1231,57 @@ class Form extends Zend_Form throw new SecurityException('No permission for %s', $permission); } } + + /** + * Return all form notifications + * + * @return array + */ + public function getNotifications() + { + return $this->notifications; + } + + /** + * Add a typed message to the notifications + * + * @param string $message The message which would be displayed to the user + * + * @param int $type The type of the message notification + */ + public function addNotification($message, $type = self::NOTIFICATION_ERROR) + { + $this->notifications[$message] = $type; + $this->markAsError(); + } + + /** + * Add a error message to notifications + * + * @param string $message + */ + public function error($message) + { + $this->addNotification($message, $type = self::NOTIFICATION_ERROR); + } + + /** + * Add a warning message to notifications + * + * @param string $message + */ + public function warning($message) + { + $this->addNotification($message, $type = self::NOTIFICATION_WARNING); + } + + /** + * Add a info message to notifications + * + * @param string $message + */ + public function info($message) + { + $this->addNotification($message, $type = self::NOTIFICATION_INFO); + } } From 93470db81de5eeaf1360e4e36b356044dd611bcc Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 13:05:24 +0200 Subject: [PATCH 211/298] Add css styling for form notifications refs #9203 --- public/css/icinga/defaults.less | 3 +++ public/css/icinga/forms.less | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/public/css/icinga/defaults.less b/public/css/icinga/defaults.less index 3dc277300..e3e033eff 100644 --- a/public/css/icinga/defaults.less +++ b/public/css/icinga/defaults.less @@ -23,6 +23,9 @@ @colorUnreachableHandled: #cc77ff; @colorPending: #77aaff; @colorInvalid: #999; +@colorFormNotificationInfo: #77aaff; +@colorFormNotificationWarning: #ffaa44; +@colorFormNotificationError: #ff5566; /* Mixins */ diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 41525a4c7..85c7b20a9 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -165,6 +165,32 @@ form ul.form-errors { } } +form ul.form-notifications { + .non-list-like-list; + margin-bottom: 1em; + padding: 0em; + + li.info { + background: @colorFormNotificationInfo; + } + + li.warning { + background: @colorFormNotificationWarning; + } + + li.error { + background: @colorFormNotificationError; + } + + li { + color: white; + font-weight: bold; + line-height: 1.5em; + padding: 0.5em; + margin-bottom: 0.5em; + } +} + form div.element { margin: 0.5em 0; } From df7b56881fa061acd449fac6457000b2918a8b9a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 13:06:33 +0200 Subject: [PATCH 212/298] Add IDO instance validation refs #9203 --- .../application/forms/Config/BackendConfigForm.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 567f7a575..1380b416d 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -318,15 +318,15 @@ class BackendConfigForm extends ConfigForm if (count($instances) === 1) { return true; } elseif (count($instances) > 1) { - $form->addError( + $form->warning( $form->translate( - 'WARNING: IDO instance validation failed, because there are multiple instances available.' + 'IDO instance validation failed, because there are multiple instances available.' ) ); return false; } - $form->addError( + $form->error( $form->translate( 'IDO instance validation failed, because there is no IDO instance available.' ) From 19243e6885cabd31a86ba8d05be7a7da2857b8f6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 13:24:27 +0200 Subject: [PATCH 213/298] Add css cursor:pointer to buttons --- public/css/icinga/forms.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 85c7b20a9..c8b5df161 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -87,6 +87,10 @@ button::-moz-focus-inner { outline: 0; } +button { + cursor: pointer; +} + select::-moz-focus-inner { border: 0; outline: 0; From ad8903660ddd85fdc43cdc8182a1f65bef2bd54f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 10:56:33 +0200 Subject: [PATCH 214/298] Revert "SortBox::handleRequest(): set query order direction to asc if it's not given" This reverts commit 59753acece33c46fbd2070cf0e525343fa30caf6. --- library/Icinga/Web/Widget/SortBox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 895e9120c..022efdf32 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -114,7 +114,7 @@ class SortBox extends AbstractWidget $request = Icinga::app()->getFrontController()->getRequest(); } if ($sort = $request->getParam('sort')) { - $this->query->order($sort, $request->getParam('dir', 'asc')); + $this->query->order($sort, $request->getParam('dir')); } } return $this; From 3b7f27f614a0fb5e185eada48d1cb493c22cd8ff Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 10:56:52 +0200 Subject: [PATCH 215/298] Revert "ListController: set up sort control before paginating a query" This reverts commit ca79b020e30c5f039e7eb8c5cb75f797b8bf3a4d. --- .../controllers/ListController.php | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 948050db6..bec65ac9b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -97,13 +97,6 @@ class Monitoring_ListController extends Controller ), $this->extraColumns())); $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); - $this->setupSortControl(array( - 'host_severity' => $this->translate('Severity'), - 'host_state' => $this->translate('Current State'), - 'host_display_name' => $this->translate('Hostname'), - 'host_address' => $this->translate('Address'), - 'host_last_check' => $this->translate('Last Check') - ), $query); $this->view->hosts = $query->paginate(); $this->view->stats = $this->backend->select()->from('statusSummary', array( @@ -120,6 +113,13 @@ class Monitoring_ListController extends Controller $this->setupLimitControl(); $this->setupPaginationControl($this->view->hosts); + $this->setupSortControl(array( + 'host_severity' => $this->translate('Severity'), + 'host_state' => $this->translate('Current State'), + 'host_display_name' => $this->translate('Hostname'), + 'host_address' => $this->translate('Address'), + 'host_last_check' => $this->translate('Last Check') + ), $query); } /** @@ -181,6 +181,10 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('serviceStatus', $columns); $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); + $this->view->services = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->services); $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), @@ -192,10 +196,6 @@ class Monitoring_ListController extends Controller 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') ), $query); - $this->view->services = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->services); $this->view->stats = $this->backend->select()->from('statusSummary', array( 'services_total', @@ -246,6 +246,10 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); + $this->view->downtimes = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->downtimes); $this->setupSortControl(array( 'downtime_is_in_effect' => $this->translate('Is In Effect'), 'host_display_name' => $this->translate('Host'), @@ -258,10 +262,6 @@ class Monitoring_ListController extends Controller 'downtime_scheduled_end' => $this->translate('Scheduled End'), 'downtime_duration' => $this->translate('Duration') ), $query); - $this->view->downtimes = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->downtimes); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); @@ -292,13 +292,13 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->setupSortControl(array( - 'notification_start_time' => $this->translate('Notification Start') - ), $query); $this->view->notifications = $query->paginate(); $this->setupLimitControl(); $this->setupPaginationControl($this->view->notifications); + $this->setupSortControl(array( + 'notification_start_time' => $this->translate('Notification Start') + ), $query); } public function contactsAction() @@ -326,6 +326,10 @@ class Monitoring_ListController extends Controller 'contact_notify_host_downtime', )); $this->filterQuery($query); + $this->view->contacts = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->contacts); $this->setupSortControl(array( 'contact_name' => $this->translate('Name'), 'contact_alias' => $this->translate('Alias'), @@ -334,10 +338,6 @@ class Monitoring_ListController extends Controller 'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'), 'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod') ), $query); - $this->view->contacts = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->contacts); } public function eventgridAction() @@ -397,11 +397,6 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); - $this->setupSortControl(array( - 'contactgroup_name' => $this->translate('Contactgroup Name'), - 'contactgroup_alias' => $this->translate('Contactgroup Alias') - ), $query); - // Fetch and prepare all contact groups: $contactgroups = $query->getQuery()->fetchAll(); $groupData = array(); @@ -416,6 +411,11 @@ class Monitoring_ListController extends Controller } // TODO: Find a better naming $this->view->groupData = $groupData; + + $this->setupSortControl(array( + 'contactgroup_name' => $this->translate('Contactgroup Name'), + 'contactgroup_alias' => $this->translate('Contactgroup Alias') + ), $query); } public function commentsAction() @@ -438,6 +438,10 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); + $this->view->comments = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->comments); $this->setupSortControl( array( 'comment_timestamp' => $this->translate('Comment Timestamp'), @@ -448,10 +452,6 @@ class Monitoring_ListController extends Controller ), $query ); - $this->view->comments = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->comments); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = new DeleteCommentCommandForm(); @@ -498,6 +498,10 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); + $this->view->servicegroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->servicegroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'servicegroup_alias' => $this->translate('Service Group Name'), @@ -508,10 +512,6 @@ class Monitoring_ListController extends Controller 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') ), $query); - $this->view->servicegroups = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->servicegroups); } public function hostgroupsAction() @@ -555,6 +555,10 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); + $this->view->hostgroups = $query->paginate(); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->hostgroups); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), @@ -565,10 +569,6 @@ class Monitoring_ListController extends Controller 'services_warning' => $this->translate('Services WARNING'), 'services_pending' => $this->translate('Services PENDING') ), $query); - $this->view->hostgroups = $query->paginate(); - - $this->setupLimitControl(); - $this->setupPaginationControl($this->view->hostgroups); } public function eventhistoryAction() @@ -594,13 +594,13 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); - $this->setupSortControl(array( - 'timestamp' => $this->translate('Occurence') - ), $query); $this->view->history = $query->paginate(); $this->setupLimitControl(); $this->setupPaginationControl($this->view->history); + $this->setupSortControl(array( + 'timestamp' => $this->translate('Occurence') + ), $query); } public function servicegridAction() From e04655e8cfb2a1150c52a5b2c0a2ce4291c8e8b6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 12:33:41 +0200 Subject: [PATCH 216/298] Controller: Apply the user chosen sort rules when in compact view as well --- library/Icinga/Web/Controller.php | 42 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index b70dbd3fc..b223921a3 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -22,44 +22,56 @@ class Controller extends ModuleActionController public function init() { parent::init(); + $this->handleSortControlSubmit(); + } + /** + * Check whether the sort control has been submitted and redirect using GET parameters + */ + protected function handleSortControlSubmit() + { $request = $this->getRequest(); - $url = Url::fromRequest(); + if (! $request->isPost()) { + return; + } - if ($request->isPost() && ($sort = $request->getPost('sort'))) { + if (($sort = $request->getPost('sort'))) { + $url = Url::fromRequest(); $url->setParam('sort', $sort); - if ($dir = $request->getPost('dir')) { + if (($dir = $request->getPost('dir'))) { $url->setParam('dir', $dir); } else { $url->removeParam('dir'); } + $this->redirectNow($url); } } /** - * Create a SortBox widget at the `sortBox' view property + * Create a SortBox widget and apply its sort rules on the given query * - * In case the current view has been requested as compact this method does nothing. + * The widget is set on the `sortBox' view property only if the current view has not been requested as compact * * @param array $columns An array containing the sort columns, with the * submit value as the key and the label as the value - * @param Sortable $query Query to set on the newly created SortBox + * @param Sortable $query Query to apply the user chosen sort rules on * * @return $this */ protected function setupSortControl(array $columns, Sortable $query = null) { + $request = $this->getRequest(); + $sortBox = SortBox::create('sortbox-' . $request->getActionName(), $columns); + $sortBox->setRequest($request); + + if ($query) { + $sortBox->setQuery($query); + $sortBox->handleRequest($request); + } + if (! $this->view->compact) { - $req = $this->getRequest(); - $this->view->sortBox = $sortBox = SortBox::create( - 'sortbox-' . $req->getActionName(), - $columns - )->setRequest($req); - if ($query !== null) { - $sortBox->setQuery($query); - } - $sortBox->handleRequest(); + $this->view->sortBox = $sortBox; } return $this; From 3770741ba557ea1f96df30f51eeb69f4f886798b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 14:23:40 +0200 Subject: [PATCH 217/298] DataView: Implement QueryInterface An instance of DataView should implement the full interface, not only parts of it. --- .../library/Monitoring/DataView/DataView.php | 119 ++++++++++++++++-- 1 file changed, 112 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index be5862abe..0a47c0d3b 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -3,14 +3,11 @@ namespace Icinga\Module\Monitoring\DataView; -use Countable; +use Icinga\Data\QueryInterface; use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\FilterMatch; -use Icinga\Data\Browsable; use Icinga\Data\PivotTable; -use Icinga\Data\Sortable; use Icinga\Data\ConnectionInterface; -use Icinga\Data\Filterable; use Icinga\Exception\QueryException; use Icinga\Web\Request; use Icinga\Web\Url; @@ -19,12 +16,12 @@ use Icinga\Module\Monitoring\Backend\MonitoringBackend; /** * A read-only view of an underlying query */ -abstract class DataView implements Browsable, Countable, Filterable, Sortable +abstract class DataView implements QueryInterface, IteratorAggregate { /** * The query used to populate the view * - * @var \Icinga\Data\SimpleQuery + * @var QueryInterface */ protected $query; @@ -403,6 +400,114 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable */ public function count() { - return count($this->query); + return $this->query->count(); + } + + /** + * Set a limit count and offset + * + * @param int $count Number of rows to return + * @param int $offset Start returning after this many rows + * + * @return self + */ + public function limit($count = null, $offset = null) + { + $this->query->limit($count, $offset); + return $this; + } + + /** + * Whether a limit is set + * + * @return bool + */ + public function hasLimit() + { + return $this->query->hasLimit(); + } + + /** + * Get the limit if any + * + * @return int|null + */ + public function getLimit() + { + return $this->query->getLimit(); + } + + /** + * Whether an offset is set + * + * @return bool + */ + public function hasOffset() + { + return $this->query->hasOffset(); + } + + /** + * Get the offset if any + * + * @return int|null + */ + public function getOffset() + { + return $this->query->hasOffset(); + } + + /** + * Retrieve an array containing all rows of the result set + * + * @return array + */ + public function fetchAll() + { + return $this->getQuery()->fetchAll(); + } + + /** + * Fetch the first row of the result set + * + * @return mixed + */ + public function fetchRow() + { + return $this->getQuery()->fetchRow(); + } + + /** + * Fetch a column of all rows of the result set as an array + * + * @param int $columnIndex Index of the column to fetch + * + * @return array + */ + public function fetchColumn($columnIndex = 0) + { + return $this->getQuery()->fetchColumn($columnIndex); + } + + /** + * Fetch the first column of the first row of the result set + * + * @return string + */ + public function fetchOne() + { + return $this->getQuery()->fetchOne(); + } + + /** + * Fetch all rows of the result set as an array of key-value pairs + * + * The first column is the key, the second column is the value. + * + * @return array + */ + public function fetchPairs() + { + return $this->getQuery()->fetchPairs(); } } From ed5f646b6ff2bb4781f7360998dc6db45084fb0e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 14:26:00 +0200 Subject: [PATCH 218/298] SimpleQuery: Implement interface IteratorAggregate I'd like to foreach such. --- library/Icinga/Data/SimpleQuery.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Data/SimpleQuery.php b/library/Icinga/Data/SimpleQuery.php index 16f82cbe4..20d514ecf 100644 --- a/library/Icinga/Data/SimpleQuery.php +++ b/library/Icinga/Data/SimpleQuery.php @@ -4,13 +4,15 @@ namespace Icinga\Data; use Icinga\Application\Icinga; +use ArrayIterator; +use IteratorAggregate; use Icinga\Data\Filter\Filter; use Icinga\Web\Paginator\Adapter\QueryAdapter; use Zend_Paginator; use Exception; use Icinga\Exception\IcingaException; -class SimpleQuery implements QueryInterface, Queryable +class SimpleQuery implements QueryInterface, Queryable, IteratorAggregate { /** * Query data source @@ -91,6 +93,16 @@ class SimpleQuery implements QueryInterface, Queryable */ protected function init() {} + /** + * Return a iterable for this query's result + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->fetchAll()); + } + /** * Get the data source * From 5faebb4a88e40cb4c07c8de9f4b76098a3a1beee Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 14:26:32 +0200 Subject: [PATCH 219/298] DataView: Implement interface IteratorAggregate I'd like to foreach such. --- .../library/Monitoring/DataView/DataView.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 0a47c0d3b..6bed36fe1 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -3,6 +3,8 @@ namespace Icinga\Module\Monitoring\DataView; +use ArrayIterator; +use IteratorAggregate; use Icinga\Data\QueryInterface; use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\FilterMatch; @@ -56,6 +58,16 @@ abstract class DataView implements QueryInterface, IteratorAggregate { } + /** + * Return a iterator for all rows of the result set + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->fetchAll()); + } + /** * Get the query name this data view relies on * From fbf0ad4339a8736169cdaeabd850bacc9b78811f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 14:32:58 +0200 Subject: [PATCH 220/298] Drop interface Browsable We're not required to handle objects of Zend_Paginator in any way, so creating such as part of a query is not necessary since QueryAdapter accepts any instance of QueryInterface. (gets enforced in the near future) refs #8339 --- application/controllers/ConfigController.php | 3 +- application/controllers/ListController.php | 2 +- library/Icinga/Data/Browsable.php | 20 ----------- library/Icinga/Data/QueryInterface.php | 2 +- library/Icinga/Data/SimpleQuery.php | 33 ------------------- library/Icinga/File/Csv.php | 4 +-- .../controllers/AlertsummaryController.php | 4 +-- .../controllers/ListController.php | 18 +++++----- .../controllers/ShowController.php | 8 ++--- .../views/scripts/list/comments.phtml | 2 +- .../views/scripts/list/downtimes.phtml | 2 +- 11 files changed, 21 insertions(+), 77 deletions(-) delete mode 100644 library/Icinga/Data/Browsable.php diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 370b8f5d0..77b5b66d9 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -128,8 +128,7 @@ class ConfigController extends Controller $this->view->modules = Icinga::app()->getModuleManager()->select() ->from('modules') ->order('enabled', 'desc') - ->order('name') - ->paginate(); + ->order('name'); $this->setupLimitControl(); $this->setupPaginationControl($this->view->modules); // TODO: Not working diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index ca7265f0e..4271e385a 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -51,7 +51,7 @@ class ListController extends Controller . 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time . ' - (?[A-Za-z]+) - (?.*)(?!.)/msS' // loglevel, message ))); - $this->view->logData = $resource->select()->order('DESC')->paginate(); + $this->view->logData = $resource->select()->order('DESC'); $this->setupLimitControl(); $this->setupPaginationControl($this->view->logData); diff --git a/library/Icinga/Data/Browsable.php b/library/Icinga/Data/Browsable.php deleted file mode 100644 index a734a2680..000000000 --- a/library/Icinga/Data/Browsable.php +++ /dev/null @@ -1,20 +0,0 @@ -limitOffset; } - /** - * Paginate data - * - * Auto-detects pagination parameters from request when unset - * - * @param int $itemsPerPage Number of items per page - * @param int $pageNumber Current page number - * - * @return Zend_Paginator - */ - public function paginate($itemsPerPage = null, $pageNumber = null) - { - if ($itemsPerPage === null || $pageNumber === null) { - // Detect parameters from request - $request = Icinga::app()->getFrontController()->getRequest(); - if ($itemsPerPage === null) { - $itemsPerPage = $request->getParam('limit', 25); - } - if ($pageNumber === null) { - $pageNumber = $request->getParam('page', 0); - } - } - $this->limit($itemsPerPage, $pageNumber * $itemsPerPage); - $paginator = new Zend_Paginator(new QueryAdapter($this)); - $paginator->setItemCountPerPage($itemsPerPage); - $paginator->setCurrentPageNumber($pageNumber); - return $paginator; - } - /** * Retrieve an array containing all rows of the result set * diff --git a/library/Icinga/File/Csv.php b/library/Icinga/File/Csv.php index ee88262c3..5d9975bc7 100644 --- a/library/Icinga/File/Csv.php +++ b/library/Icinga/File/Csv.php @@ -3,15 +3,13 @@ namespace Icinga\File; -use Icinga\Data\Browsable; - class Csv { protected $query; protected function __construct() {} - public static function fromQuery(Browsable $query) + public static function fromQuery($query) { $csv = new Csv(); $csv->query = $query; diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index dcc805286..1dc3b137b 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -70,7 +70,7 @@ class Monitoring_AlertsummaryController extends Controller 'notification_state' ) ); - $this->view->notifications = $query->paginate(); + $this->view->notifications = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->notifications); @@ -493,7 +493,7 @@ class Monitoring_AlertsummaryController extends Controller $query->order('notification_start_time', 'desc'); - return $query->paginate(5); + return $query->limit(5); } /** diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index bec65ac9b..27f02f3f9 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -97,7 +97,7 @@ class Monitoring_ListController extends Controller ), $this->extraColumns())); $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); - $this->view->hosts = $query->paginate(); + $this->view->hosts = $query; $this->view->stats = $this->backend->select()->from('statusSummary', array( 'hosts_total', @@ -181,7 +181,7 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('serviceStatus', $columns); $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); - $this->view->services = $query->paginate(); + $this->view->services = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->services); @@ -246,7 +246,7 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->view->downtimes = $query->paginate(); + $this->view->downtimes = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->downtimes); @@ -292,7 +292,7 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->view->notifications = $query->paginate(); + $this->view->notifications = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->notifications); @@ -326,7 +326,7 @@ class Monitoring_ListController extends Controller 'contact_notify_host_downtime', )); $this->filterQuery($query); - $this->view->contacts = $query->paginate(); + $this->view->contacts = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->contacts); @@ -438,7 +438,7 @@ class Monitoring_ListController extends Controller 'service_display_name' )); $this->filterQuery($query); - $this->view->comments = $query->paginate(); + $this->view->comments = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->comments); @@ -498,7 +498,7 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); - $this->view->servicegroups = $query->paginate(); + $this->view->servicegroups = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->servicegroups); @@ -555,7 +555,7 @@ class Monitoring_ListController extends Controller // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); - $this->view->hostgroups = $query->paginate(); + $this->view->hostgroups = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->hostgroups); @@ -594,7 +594,7 @@ class Monitoring_ListController extends Controller )); $this->filterQuery($query); - $this->view->history = $query->paginate(); + $this->view->history = $query; $this->setupLimitControl(); $this->setupPaginationControl($this->view->history); diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index c1522d2a1..8edb2a437 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -70,12 +70,12 @@ class Monitoring_ShowController extends Controller { $this->getTabs()->activate('history'); $this->view->object->fetchEventHistory(); - $this->view->history = $this->view->object->eventhistory->getQuery()->paginate($this->params->get('limit', 50)); + $this->view->history = $this->view->object->eventhistory; $this->handleFormatRequest($this->view->object->eventhistory); $this->fetchHostStats(); $this->setupLimitControl(); - $this->setupPaginationControl($this->view->history); + $this->setupPaginationControl($this->view->history, 50); } public function servicesAction() @@ -154,7 +154,7 @@ class Monitoring_ShowController extends Controller 'command_name' ))->where('contact_id', $contact->contact_id); - $this->view->commands = $commands->paginate(); + $this->view->commands = $commands; $notifications = $this->backend->select()->from('notification', array( 'host_name', @@ -168,7 +168,7 @@ class Monitoring_ShowController extends Controller )); $notifications->where('contact_object_id', $contact->contact_object_id); - $this->view->notifications = $notifications->paginate(); + $this->view->notifications = $notifications; $this->setupLimitControl(); $this->setupPaginationControl($this->view->notifications); } diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index f05adff1f..f8c4383bd 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -5,7 +5,7 @@ render('list/components/selectioninfo.phtml'); ?>
- getTotalItemCount() ?> translate('Comments') ?>: + translate('Comments') ?>:
sortBox; ?> limiter; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 0d35b77cd..79a0e1b92 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -9,7 +9,7 @@ if (! $this->compact): ?> render('list/components/selectioninfo.phtml'); ?>
- getTotalItemCount() ?> translate('Downtimes') ?> + translate('Downtimes') ?>
sortBox; ?> limiter; ?> From 9a043386dee510e43b0463022c5eeb74222a9c40 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 14:36:13 +0200 Subject: [PATCH 221/298] Controller: Make setupSortControl creating a Zend_Paginator on its own We're accessing the url GET parameters `sort' and `dir' in a controller now. fixes #8339 --- library/Icinga/Web/Controller.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index b223921a3..4c68da0ff 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -4,10 +4,12 @@ namespace Icinga\Web; use Zend_Paginator; -use Icinga\Web\Controller\ModuleActionController; -use Icinga\Web\Widget\SortBox; -use Icinga\Web\Widget\Limiter; use Icinga\Data\Sortable; +use Icinga\Data\QueryInterface; +use Icinga\Web\Paginator\Adapter\QueryAdapter; +use Icinga\Web\Controller\ModuleActionController; +use Icinga\Web\Widget\Limiter; +use Icinga\Web\Widget\SortBox; /** * This is the controller all modules should inherit from @@ -94,17 +96,28 @@ class Controller extends ModuleActionController } /** - * Set the view property `paginator' to the given Zend_Paginator + * Apply the given page limit and number on the given query and setup a paginator for it * - * In case the current view has been requested as compact this method does nothing. + * The $itemsPerPage and $pageNumber parameters are only applied if not available in the current request. + * The paginator is set on the `paginator' view property only if the current view has not been requested as compact. * - * @param Zend_Paginator $paginator The Zend_Paginator for which to show a pagination control + * @param QueryInterface $query The query to create a paginator for + * @param int $itemsPerPage Number of items per page + * @param int $pageNumber Current page number * * @return $this */ - protected function setupPaginationControl(Zend_Paginator $paginator) + protected function setupPaginationControl(QueryInterface $query, $itemsPerPage = 25, $pageNumber = 0) { + $request = $this->getRequest(); + $limit = $request->getParam('limit', $itemsPerPage); + $page = $request->getParam('page', $pageNumber); + $query->limit($limit, $page * $limit); + if (! $this->view->compact) { + $paginator = new Zend_Paginator(new QueryAdapter($query)); + $paginator->setItemCountPerPage($limit); + $paginator->setCurrentPageNumber($page); $this->view->paginator = $paginator; } From 99c511eefdcf2beb727f94ccf35ebab742859dc7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 15:22:22 +0200 Subject: [PATCH 222/298] Limiter: Do not use a hardcoded default limit --- library/Icinga/Web/Controller.php | 9 ++++++--- library/Icinga/Web/Widget/Limiter.php | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 4c68da0ff..61e80173b 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -84,12 +84,15 @@ class Controller extends ModuleActionController * * In case the current view has been requested as compact this method does nothing. * + * @param int $itemsPerPage Default number of items per page + * * @return $this */ - protected function setupLimitControl() + protected function setupLimitControl($itemsPerPage = 25) { if (! $this->view->compact) { $this->view->limiter = new Limiter(); + $this->view->limiter->setDefaultLimit($itemsPerPage); } return $this; @@ -102,8 +105,8 @@ class Controller extends ModuleActionController * The paginator is set on the `paginator' view property only if the current view has not been requested as compact. * * @param QueryInterface $query The query to create a paginator for - * @param int $itemsPerPage Number of items per page - * @param int $pageNumber Current page number + * @param int $itemsPerPage Default number of items per page + * @param int $pageNumber Default page number * * @return $this */ diff --git a/library/Icinga/Web/Widget/Limiter.php b/library/Icinga/Web/Widget/Limiter.php index 9febf6f63..1c6c82f62 100644 --- a/library/Icinga/Web/Widget/Limiter.php +++ b/library/Icinga/Web/Widget/Limiter.php @@ -21,6 +21,8 @@ class Limiter extends AbstractWidget private $pages; + private $default; + public function setUrl(Url $url) { $this->url = $url; @@ -39,13 +41,19 @@ class Limiter extends AbstractWidget return $this; } + public function setDefaultLimit($limit) + { + $this->default = $limit; + return $this; + } + public function render() { if ($this->url === null) { $this->url = Url::fromRequest(); } - $currentLimit = (int) $this->url->getParam('limit', 25); // Default?? + $currentLimit = (int) $this->url->getParam('limit', $this->default); $availableLimits = array( 10 => '10', 25 => '25', From d0cc2ae7041d5834053cc6077f2118838669953f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 15 May 2015 15:23:49 +0200 Subject: [PATCH 223/298] ShowController: Use a default limit of 50 for an object's history listing refs #8337 --- modules/monitoring/application/controllers/ShowController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 8edb2a437..a8a4583d1 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -74,7 +74,7 @@ class Monitoring_ShowController extends Controller $this->handleFormatRequest($this->view->object->eventhistory); $this->fetchHostStats(); - $this->setupLimitControl(); + $this->setupLimitControl(50); $this->setupPaginationControl($this->view->history, 50); } From e6ba3d6470e87a90c4a73beccc14662122b84eed Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 15 May 2015 15:49:57 +0200 Subject: [PATCH 224/298] Add descriptive message to custom validations refs #9203 --- .../forms/Setup/IdoResourcePage.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index b856c590c..3f6bb1564 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -57,13 +57,19 @@ class IdoResourcePage extends Form if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { $configObject = new ConfigObject($this->getValues()); if (false === DbResourceForm::isValidResource($this, $configObject)) { - $this->addSkipValidationCheckbox(); + $this->addSkipValidationCheckbox($this->translate( + 'Check this to not to validate connectivity with the given database server' + )); return false; } elseif (false === BackendConfigForm::isValidIdoSchema($this, $configObject)) { - $this->addSkipValidationCheckbox(); + $this->addSkipValidationCheckbox($this->translate( + 'Check this to not to validate the ido schema' + )); return false; } elseif (false === BackendConfigForm::isValidIdoInstance($this, $configObject)) { - $this->addSkipValidationCheckbox(); + $this->addSkipValidationCheckbox($this->translate( + 'Check this to not to validate the ido instance' + )); return false; } } @@ -74,17 +80,21 @@ class IdoResourcePage extends Form /** * Add a checkbox to the form by which the user can skip the connection validation */ - protected function addSkipValidationCheckbox() + protected function addSkipValidationCheckbox($description = '') { + if (empty($description)) { + $description = $this->translate( + 'Proceed without any further (custom) validation' + ); + } + $this->addElement( 'checkbox', 'skip_validation', array( 'required' => true, 'label' => $this->translate('Skip Validation'), - 'description' => $this->translate( - 'Check this to not to validate connectivity with the given database server' - ) + 'description' => $description ) ); } From 58434d97438a19aafa33eee3f942c67436fe8b63 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 15 May 2015 17:01:28 +0200 Subject: [PATCH 225/298] ToggleInstanceFeaturesCommandForm::onSuccess(): show a notification for each feature about whether it has been enabled or disabled fixes #9023 --- .../Instance/ToggleInstanceFeaturesCommandForm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index ec58bb4b6..79d15f5c1 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -215,8 +215,14 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ->setFeature($feature) ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); + + if ($this->status->{$feature} != $enabled) { + Notification::success($enabled + ? $this->translate('Enabling feature..') + : $this->translate('Disabling feature..') + ); + } } - Notification::success($this->translate('Toggling feature..')); return true; } } From 533c980a2956890439014e7b92b9aae1de695362 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 15 May 2015 17:32:13 +0200 Subject: [PATCH 226/298] Show only three significant digits in check execution time fixes #8849 --- .../scripts/show/components/checkstatistics.phtml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index 2a4e4b033..b0699c799 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -68,7 +68,18 @@ if ($object->getType() === $object::TYPE_HOST) { check_execution_time): ?>
- + check_latency): ?> From 62d8c441f85a951bc51392748fd9db2764cd900d Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 18 May 2015 11:45:39 +0200 Subject: [PATCH 227/298] Add ServiceActionsHook refs #9284 --- .../controllers/HostController.php | 7 ++- .../controllers/ServiceController.php | 29 ++++++++++++ .../scripts/show/components/actions.phtml | 4 +- .../Web/Hook/ServiceActionsHook.php | 46 +++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index f820fc27f..7693023eb 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -49,6 +49,11 @@ class Monitoring_HostController extends MonitoredObjectController $this->getTabs()->activate('host'); } + /** + * Get host actions from hook + * + * @return array + */ protected function getHostActions() { $urls = array(); @@ -67,7 +72,7 @@ class Monitoring_HostController extends MonitoredObjectController */ public function showAction() { - $this->view->hostActions = $this->getHostActions(); + $this->view->actions = $this->getHostActions(); parent::showAction(); } diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 4df109b3e..e61c4685d 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommand use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController; +use Icinga\Web\Hook; class Monitoring_ServiceController extends MonitoredObjectController { @@ -48,6 +49,34 @@ class Monitoring_ServiceController extends MonitoredObjectController $this->getTabs()->activate('service'); } + /** + * Get service actions from hook + * + * @return array + */ + protected function getServiceActions() + { + $urls = array(); + + foreach (Hook::all('Monitoring\\ServiceActions') as $hook) { + foreach ($hook->getActionsForService($this->object) as $id => $url) { + $urls[$id] = $url; + } + } + + return $urls; + } + + /** + * Show a service + */ + public function showAction() + { + $this->view->actions = $this->getServiceActions(); + parent::showAction(); + } + + /** * Acknowledge a service problem */ diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index 2defd616d..0681d5d91 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -33,8 +33,8 @@ if ($object->action_url) { } } -if (isset($this->hostActions)) { - foreach ($this->hostActions as $id => $action) { +if (isset($this->actions)) { + foreach ($this->actions as $id => $action) { $links[] = sprintf($localLinkText, $action, $id); } } diff --git a/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php b/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php new file mode 100644 index 000000000..2df3c4f55 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Hook/ServiceActionsHook.php @@ -0,0 +1,46 @@ + url, where title will + * be used as link caption. Url should be an Icinga\Web\Url object when + * the link should point to an Icinga Web url - otherwise a string would + * be fine. + * + * Mixed example: + * + * return array( + * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($service->service_name), + * 'Logstash' => Url::fromPath( + * 'logstash/search/syslog', + * array('service' => $service->host_name) + * ) + * ); + * + * + * One might also provide ssh:// or rdp:// urls if equipped with fitting + * (safe) URL handlers for his browser(s). + * + * TODO: I'd love to see some kind of a Link/LinkSet object implemented + * for this and similar hooks. + * + * @param Service $service Monitoring service object + * + * @return array An array containing a list of service action links + */ + abstract public function getActionsForService(Service $service); +} From 4ff7d7a845156fcb38be17d230a2b130a9446bf2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 13:35:38 +0200 Subject: [PATCH 228/298] Don't parse $object->check_execution_time w/ regex as it's always a float (or null) --- .../scripts/show/components/checkstatistics.phtml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index b0699c799..18fbdb82f 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -68,17 +68,8 @@ if ($object->getType() === $object::TYPE_HOST) { check_execution_time): ?> - From fe2ee3617b3b482d8213ff72c1d19c569433e2c0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 13:56:35 +0200 Subject: [PATCH 229/298] Remove pie charts from multi-views refs #8565 --- .../controllers/HostsController.php | 5 ---- .../controllers/ServicesController.php | 27 ++----------------- .../partials/host/objects-header.phtml | 7 ----- .../partials/service/objects-header.phtml | 10 ------- 4 files changed, 2 insertions(+), 47 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 6c3c6850e..af29d3489 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -134,11 +134,6 @@ class Monitoring_HostsController extends Controller } $hostStates = (object)$this->hostList->getStateSummary(); - $this->view->hostStatesPieChart = InlinePie::createFromStateSummary( - $hostStates, - $this->translate('Host State'), - InlinePie::$colorsHostStatesHandledUnhandled - ); $this->setAutorefreshInterval(15); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1365fbb8a..17be9569f 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -92,17 +92,7 @@ class Monitoring_ServicesController extends Controller $this->view->objects = $this->serviceList; $this->view->stats = $this->serviceList->getServiceStateSummary(); $this->view->serviceStates = true; - $this->view->serviceStatesPieChart = InlinePie::createFromStateSummary( - $this->view->stats, - $this->translate('Service State'), - InlinePie::$colorsServiceStatesHandleUnhandled - ); $this->view->hostStates = $this->serviceList->getHostStateSummary(); - $this->view->hostStatesPieChart = InlinePie::createFromStateSummary( - $this->view->hostStates, - $this->translate('Service State'), - InlinePie::$colorsHostStatesHandledUnhandled - ); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } @@ -149,19 +139,6 @@ class Monitoring_ServicesController extends Controller $this->view->removeAckForm = $removeAckForm; } - $serviceStates = $this->serviceList->getServiceStateSummary(); - $this->view->serviceStatesPieChart = InlinePie::createFromStateSummary( - $serviceStates, - $this->translate('Service State'), - InlinePie::$colorsServiceStatesHandleUnhandled - ); - - $hostStates = $this->serviceList->getHostStateSummary(); - $this->view->hostStatesPieChart = InlinePie::createFromStateSummary( - $hostStates, - $this->translate('Host State'), - InlinePie::$colorsHostStatesHandledUnhandled - ); $this->setAutorefreshInterval(15); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); @@ -170,8 +147,8 @@ class Monitoring_ServicesController extends Controller ); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); - $this->view->stats = $serviceStates; - $this->view->hostStats = $hostStates; + $this->view->stats = $this->serviceList->getServiceStateSummary(); + $this->view->hostStats = $this->serviceList->getHostStateSummary(); $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $this->serviceList->getUnhandledObjects(); $this->view->problemObjects = $this->serviceList->getProblemObjects(); diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 5a54b6f11..ef48eefe0 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -5,11 +5,6 @@ $i = 0; ?> 0): ?> -
- translate('States:') ?> -   -
-

translate('Last Problem'); ?>translate('Last Problem'); ?> translate('Host Group'); ?> translate('Total Hosts'); ?> translate('Host States'); ?>
translate('Check execution time') ?>check_execution_time ?>scheck_execution_time, + $matches + )) { + printf('%.3f', (float) $matches[1]); + } else { + echo $object->check_execution_time; + } + ?>s
translate('Check execution time') ?>check_execution_time, - $matches - )) { - printf('%.3f', (float) $matches[1]); - } else { - echo $object->check_execution_time; - } + check_execution_time === null + ? '-' : round((float) $object->check_execution_time, 3) ?>s
@@ -40,7 +35,5 @@ $i = 0; ); ?> -

- diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index e0b330ece..7c707f0bf 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -4,15 +4,6 @@ use Icinga\Module\Monitoring\Object\Service; $i = 0; ?> 0): ?> -
- translate('Service states:') ?> -   -
-
- translate('Host states:') ?> -   -
-

@@ -41,5 +32,4 @@ $i = 0; ); ?> -

From 00bbb762a1b8b4611ffc1142acb9819a04ed43a1 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 14:03:10 +0200 Subject: [PATCH 230/298] Integrate comments and downtimes into MonitoredObjectsController Add option to list all related commends and downtimes into the specific hosts and serivces views. refs #8565 --- .../controllers/HostsController.php | 19 +++++++++++++++---- .../controllers/ServicesController.php | 9 +++++++-- .../library/Monitoring/Object/HostList.php | 13 +++++++++++++ .../library/Monitoring/Object/ObjectList.php | 10 ++++++++++ .../library/Monitoring/Object/ServiceList.php | 14 +++++++++++++- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index af29d3489..32916ba42 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -2,6 +2,7 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Data\Filter\Filter; +use Icinga\Data\Filter\FilterEqual; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; @@ -140,7 +141,6 @@ class Monitoring_HostsController extends Controller $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); - $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); $this->view->stats = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $this->hostList->getUnhandledObjects(); @@ -154,9 +154,20 @@ class Monitoring_HostsController extends Controller ->setQueryString($this->hostList->getProblemObjects()->objectsFilter()); $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects(); $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime(); - $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') - ->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter(array('host' => 'downtime_host'))); - + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts') + ->setQueryString( + $this->hostList + ->getObjectsInDowntime() + ->objectsFilter() + ->toQueryString() + ); + $this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString( + $this->hostList + ->objectsFilter() + ->andFilter(FilterEqual::where('downtime_objecttype', 'host')) + ->toQueryString() + ); $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments'); $this->view->baseFilter = $this->hostList->getFilter(); $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification'); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 17be9569f..583b03246 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -160,9 +160,14 @@ class Monitoring_ServicesController extends Controller ->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString()); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime(); - $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services') ->setQueryString($this->serviceList->getObjectsInDowntime() - ->objectsFilter(array('host' => 'downtime_host', 'service' => 'downtime_service'))->toQueryString()); + ->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString()); + $this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show') + ->setQueryString( + $this->serviceList->getObjectsInDowntime() + ->objectsFilter()->toQueryString() + ); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->baseFilter = $this->serviceList->getFilter(); diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index 48a7560b1..4236f94d8 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -86,4 +86,17 @@ class HostList extends ObjectList } return FilterOr::matchAny($filterExpression); } + + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select() + ->from('downtime') + ->applyFilter(clone $this->filter) + ->where('downtime_objecttype', 'host'); + } } diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 4f5ada43c..75fe1ba76 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -127,6 +127,16 @@ abstract class ObjectList implements Countable, IteratorAggregate return $this->backend->select()->from('comment')->applyFilter($this->filter); } + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select()->from('downtime')->applyFilter($this->filter); + } + /** * @return ObjectList */ diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index 379d8234c..5ae9b8193 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -134,5 +134,17 @@ class ServiceList extends ObjectList } return FilterOr::matchAny($filterExpression); } -} + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select() + ->from('downtime') + ->applyFilter(clone $this->filter) + ->where('downtime_objecttype', 'service'); + } +} From 4fbadaea2c2a7e998d017d318dbb65b1c3a5306a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 14:20:17 +0200 Subject: [PATCH 231/298] ToggleInstanceFeaturesCommandForm::createElements(): make form labels shorter refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 79d15f5c1..e26931f7b 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -85,7 +85,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, array( - 'label' => $this->translate('Active Host Checks Being Executed'), + 'label' => $this->translate('Active Host Checks'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, array( - 'label' => $this->translate('Active Service Checks Being Executed'), + 'label' => $this->translate('Active Service Checks'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -103,7 +103,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, array( - 'label' => $this->translate('Event Handlers Enabled'), + 'label' => $this->translate('Event Handlers'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -112,7 +112,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => $this->translate('Flap Detection Enabled'), + 'label' => $this->translate('Flap Detection'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -121,7 +121,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => $this->translate('Notifications Enabled'), + 'label' => $this->translate('Notifications'), 'autosubmit' => true, 'description' => $notificationDescription, 'decorators' => array( @@ -159,7 +159,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, array( - 'label' => $this->translate('Passive Host Checks Being Accepted'), + 'label' => $this->translate('Passive Host Checks'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -168,7 +168,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, array( - 'label' => $this->translate('Passive Service Checks Being Accepted'), + 'label' => $this->translate('Passive Service Checks'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) @@ -177,7 +177,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, array( - 'label' => $this->translate('Performance Data Being Processed'), + 'label' => $this->translate('Performance Data'), 'autosubmit' => true, 'disabled' => $toggleDisabled ) From e84491d438c36c4023665f7a5f15e28aa934a0c5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 14:49:06 +0200 Subject: [PATCH 232/298] Improve multi view layout refs #8565 --- .../views/scripts/comments/show.phtml | 2 +- .../views/scripts/hosts/show.phtml | 199 +++++++------- .../partials/host/objects-header.phtml | 14 +- .../partials/service/objects-header.phtml | 17 +- .../views/scripts/services/show.phtml | 253 +++++++++--------- public/css/icinga/monitoring-colors.less | 2 +- 6 files changed, 239 insertions(+), 248 deletions(-) diff --git a/modules/monitoring/application/views/scripts/comments/show.phtml b/modules/monitoring/application/views/scripts/comments/show.phtml index 6298749b2..f84f512b1 100644 --- a/modules/monitoring/application/views/scripts/comments/show.phtml +++ b/modules/monitoring/application/views/scripts/comments/show.phtml @@ -19,7 +19,7 @@
qlink( sprintf( - $this->translate('Remove all %d scheduled comments'), + $this->translate('Remove %d comments'), count($comments) ), $removeAllLink, diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index a5e1cff38..45bf19ebb 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -13,66 +13,61 @@ icon('reschedule') ?> translate('Commands') ?> + +

translatePlural( 'Issue commands to %s selected host:', 'Issue commands to all %s selected hosts:', count($objects) ), '' . count($objects) . '') ?> +

translate('No hosts found matching the filter'); ?> + -

-

- -
+
+ qlink( + $this->translate('Reschedule next checks'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?> -
- qlink( - $this->translate('Reschedule next checks'), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?> -
+
+ qlink( + $this->translate('Schedule downtimes'), + $downtimeAllLink, + null, + array('icon' => 'plug') + ); ?> -
- qlink( - $this->translate('Schedule downtimes'), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?> -
+
+ qlink( + $this->translate('Submit passive check results'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?> -
- qlink( - $this->translate('Submit passive check results'), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?> -
- -
- qlink( - $this->translate('Add comments'), - $addCommentLink, - null, - array('icon' => 'comment') - ); ?> -
+
+ qlink( + $this->translate('Add comments'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?> hasPermission('monitoring/command/send-custom-notification')): ?> -
qlink( +
+ qlink( sprintf($this->translate('Send a custom notification for all %u hosts'), $hostCount), $sendCustomNotificationLink, null, array('icon' => 'comment') - ); ?>
+ ); ?> -

-

icon('attention-alt') ?> translatePlural( @@ -92,16 +86,16 @@

- translatePlural( - 'There is %s problem, issue commands to the problematic host:', - 'There are %s problems, issue commands to the problematic hosts:', - $problemCount - ), - '' . $problemCount . '' - ); ?> - -

qlink( + translatePlural( + 'There is %s problem.', + 'There are %s problems.', + $problemCount + ), + '' . $problemCount . '' + ); ?> +

+ qlink( sprintf( $this->translatePlural( 'Schedule a downtime for %u problem host', @@ -113,13 +107,11 @@ $downtimeLink, null, array('icon' => 'plug') - ); ?>
- -

+ ); ?> -

+

translatePlural( 'There is %s unhandled problem host, issue commands to the problematic host:', @@ -128,8 +120,9 @@ ), '' . $unhandledCount . '' ); ?> +

-
qlink( + qlink( sprintf( $this->translatePlural( 'Schedule a downtime for %u unhandled problem host', @@ -141,10 +134,10 @@ $downtimeUnhandledLink, null, array('icon' => 'plug') - ); ?>
+ ); ?> - -
qlink( +
+ qlink( sprintf( $this->translatePlural( 'Acknowledge %u unhandled problem host', @@ -156,19 +149,16 @@ $acknowledgeUnhandledLink, null, array('icon' => 'ok') - ); ?>
-

+ ); ?> - -

0): ?>

icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

-

translatePlural( '%s Acknowledged Host Problem', '%s Acknowledged Host Problems', @@ -181,57 +171,60 @@

- 0): ?> + getScheduledDowntimes()) ?> -

icon('plug', $this->translate('Downtimes'))?> translate('Downtimes')?>

-

translatePlural( - '%s Host currently in downtime.', - '%s Hosts currently in downtime.', - $inDowntimeCount + +

icon('plug', $this->translate('Downtimes'))?> translate('Downtimes')?>

+ qlink( + sprintf( + $this->translatePlural( + '%s scheduled downtime', + '%s scheduled downtimes', + $scheduledDowntimeCount + ), + $scheduledDowntimeCount ), - '' . $inDowntimeCount . '' - ) ?> qlink( - $this->translate('List all'), - $inDowntimeLink, + $showDowntimesLink, null, array('data-base-target' => '_next') - ); ?> + );?> + translate('on all selected hosts.')) ?> -

+ 0): ?> +
+ qlink( + sprintf( + $this->translatePlural( + '%s host', + '%s hosts', + $inDowntimeCount + ), + $inDowntimeCount + ), + $inDowntimeLink, + null, + array('data-base-target' => '_next') + ); ?> + translate('are currently in downtime.') ?> + getComments())) > 0): ?>

icon('comment', $this->translate('Comments'))?> translate('Comments') ?>

-

- qlink( + sprintf( $this->translatePlural( - 'There is %s host comment.', - 'There are %s host comments.', + '%s comment', + '%s comments', $commentCount ), - '' . $commentCount . '' - ) ?> - - qlink( - $this->translate('List all'), - $commentsLink, - null, - array('data-base-target' => '_next') - ); ?> - -

- - + $commentCount + ), + $commentsLink, + null, + array('data-base-target' => '_next') + ); ?> + translate('on all selected hosts.') ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index ef48eefe0..17cf9f7fe 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -5,22 +5,22 @@ $i = 0; ?> 0): ?> -
- +
5) { + if (++ $i > 5) { continue; } ?> - - - + diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 7c707f0bf..e3c1227f3 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -4,20 +4,25 @@ use Icinga\Module\Monitoring\Object\Service; $i = 0; ?> 0): ?> -
host_state, true); ?>
hostFlags($host)) ?>escape($host->getName()); ?>escape($host->host_output) ?> + hostFlags($host)) ?> + escape($host->getName()); ?>
+ escape($host->host_output) ?> +
+
5) { + if (++ $i > 5) { continue; } ?> - - - - + diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 5159e65b3..9291f6ef3 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -17,62 +17,55 @@ translate('No services found matching the filter'); ?> +

translatePlural( 'Issue commands to %s selected service:', 'Issue commands to all %s selected services:', count($objects) ), '' . count($objects) . '') ?> +

+ +
+ qlink( + $this->translate('Reschedule next checks'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?> -

-

- -
+
+ qlink( + $this->translate('Schedule downtimes'), + $downtimeAllLink, + null, + array('icon' => 'plug') + ); ?> -
- qlink( - $this->translate('Reschedule next checks'), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?> -
+
+ qlink( + $this->translate('Submit passive check results'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?> -
- qlink( - $this->translate('Schedule downtimes'), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?> -
- -
- qlink( - $this->translate('Submit passive check results'), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?> -
- -
- qlink( - $this->translate('Add comments'), - $addCommentLink, - null, - array('icon' => 'comment') - ); ?> -
+
+ qlink( + $this->translate('Add comments'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?> hasPermission('monitoring/command/send-custom-notification')): ?> -
qlink( +
+ qlink( sprintf($this->translate('Send a custom notification for all %u services'), $serviceCount), $sendCustomNotificationLink, null, array('icon' => 'comment') - ); ?>
+ ); ?> -

- translatePlural( + 'There is %s problem, issue commands to the problem service', + 'There are %s problems, issue commands to the problem services', + $problemCount + ), + '' . $problemCount . '' + ); ?> +

+ qlink( + sprintf( $this->translatePlural( - 'There is %s problem, issue commands to the problem service', - 'There are %s problems, issue commands to the problem services', + 'Schedule a downtime for %s problem service', + 'Schedule downtimes for %s problem services', $problemCount ), - '' . $problemCount . '' - ); ?> - -
- qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %s problem service', - 'Schedule downtimes for %s problem services', - $problemCount - ), - $problemCount - ), - $downtimeLink, - null, - array('icon' => 'plug') - ); ?> -
+ $problemCount + ), + $downtimeLink, + null, + array('icon' => 'plug') + ); ?> -

translate('There are %s unhandled problems. ' . +

+ translate('There are %s unhandled problem services. ' . 'Issue commands to the problematic services:'), '' . $unhandledCount . '') ?> -

- qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %u unhandled service problem', - 'Schedule a downtime for %u unhandled service problems', - $unhandledCount - ), - $unhandledCount - ), - $downtimeUnhandledLink, - null, - array('icon' => 'plug') - ); ?> -
-
qlink( - sprintf( - $this->translatePlural( - 'Acknowledge %u unhandled service problem', - 'Acknowledge %u unhandled service problems', - $unhandledCount - ), +

+ qlink( + sprintf( + $this->translatePlural( + 'Schedule a downtime for %u unhandled problem service', + 'Schedule a downtime for %u unhandled problem services', $unhandledCount ), - $acknowledgeUnhandledLink, - null, - array('icon' => 'ok') - ); ?>
-

+ $unhandledCount + ), + $downtimeUnhandledLink, + null, + array('icon' => 'plug') + ); ?> + +
+ qlink( + sprintf( + $this->translatePlural( + 'Acknowledge %u unhandled problem service', + 'Acknowledge %u unhandled problem services', + $unhandledCount + ), + $unhandledCount + ), + $acknowledgeUnhandledLink, + null, + array('icon' => 'ok') + ); ?> @@ -167,55 +159,56 @@

+ getScheduledDowntimes()) ?> - 0 /*&& $auth->hasPermission('monitoring/command/comment/delete')*/): ?> -

icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

-

translatePlural( - '%s service currently in downtime.', - '%s services currently in downtime.', - $inDowntimeCount - ), '' . $inDowntimeCount . '') ?> + +

icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

+ qlink( + sprintf( + $this->translatePlural( + '%s scheduled downtime', + '%s scheduled downtimes', + $scheduledDowntimeCount + ), + $scheduledDowntimeCount + ), + $showDowntimesLink, + null, + array('data-base-target' => '_next') + );?> + translate('on all selected services.')) ?> + 0): ?> +
qlink( - $this->translate('List all'), + sprintf($this->translatePlural( + '%s service', + '%s services', + $inDowntimeCount + ), $inDowntimeCount), $inDowntimeLink, null, array('data-base-target' => '_next') );?> -

+ translate('are currently in downtime.')) ?> + - -getComments()) ?> - 0): ?> -

icon('comment') ?> translate('Comments') ?>

-

translatePlural( - 'There is %s comment.', - 'There are %s comments.', - $commentCount - ), '' . $commentCount . ''); - ?> - qlink( - $this->translate('List all'), - $commentsLink, - null, - array('data-base-target' => '_next') - ); ?> -

- - - - - + array('data-base-target' => '_next') + ); ?> + translate('on all selected services.') ?> + diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 3078fdec7..4902bebb1 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -944,7 +944,7 @@ table.statesummary { } td { - font-size: 0.85em; + font-size: 0.9em; line-height: 1.2em; padding-left: 0.2em; margin: 0; From 729fb9a4d16d5667910bbc59350b8c2eb0dcb8af Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 14:51:22 +0200 Subject: [PATCH 233/298] ToggleInstanceFeaturesCommandForm::onSuccess(): notifications: show which feature has been enabled or disabled refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index e26931f7b..50970df0c 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -209,6 +209,50 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm public function onSuccess() { $this->assertPermission('monitoring/command/feature/instance'); + + $notifications = array( + ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS => array( + $this->translate('Enabling active host checks...'), + $this->translate('Disabling active host checks...') + ), + ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS => array( + $this->translate('Enabling active service checks...'), + $this->translate('Disabling active service checks...') + ), + ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS => array( + $this->translate('Enabling event handlers...'), + $this->translate('Disabling event handlers...') + ), + ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION => array( + $this->translate('Enabling flap detection...'), + $this->translate('Disabling flap detection...') + ), + ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS => array( + $this->translate('Enabling notifications...'), + $this->translate('Disabling notifications...') + ), + ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING => array( + $this->translate('Enabling obsessing over hosts...'), + $this->translate('Disabling obsessing over hosts...') + ), + ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING => array( + $this->translate('Enabling obsessing over services...'), + $this->translate('Disabling obsessing over services...') + ), + ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS => array( + $this->translate('Enabling passive host checks...'), + $this->translate('Disabling passive host checks...') + ), + ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS => array( + $this->translate('Enabling passive service checks...'), + $this->translate('Disabling passive service checks...') + ), + ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA => array( + $this->translate('Enabling performance data...'), + $this->translate('Disabling performance data...') + ) + ); + foreach ($this->getValues() as $feature => $enabled) { $toggleFeature = new ToggleInstanceFeatureCommand(); $toggleFeature @@ -216,10 +260,9 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); - if ($this->status->{$feature} != $enabled) { - Notification::success($enabled - ? $this->translate('Enabling feature..') - : $this->translate('Disabling feature..') + if ((bool) $this->status->{$feature} !== (bool) $enabled) { + Notification::success( + $notifications[$feature][$enabled ? 0 : 1] ); } } From 342a8a39d103c2d49bb32e8f9bd3f9f5ac389bcc Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 14:58:51 +0200 Subject: [PATCH 234/298] Fix state summary in multi views refs #8565 --- .../views/scripts/list/components/hostssummary.phtml | 4 ++-- .../views/scripts/list/components/servicesummary.phtml | 2 +- .../views/scripts/partials/service/objects-header.phtml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml index 3ecb2279a..a21a6c9ea 100644 --- a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml @@ -14,7 +14,7 @@ function urlAddFilterOptional($url, $filter, $optional) { $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; $selfUrl = 'monitoring/list/hosts'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>

compact ? ' data-base-target="col1"' : ''; ?>> +?>
compact ? ' data-base-target="col1"' : ''; ?>> translate('%s hosts:'), $this->stats->hosts_total); ?> stats->hosts_up): ?> @@ -67,7 +67,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); $this->stats->hosts_down_handled, urlAddFilterOptional( $selfUrl, - Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 1)), + Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 0)), $this->baseFilter ), null, diff --git a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml index 76a51de92..97d5f9fdf 100644 --- a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml @@ -16,7 +16,7 @@ $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; $selfUrl = 'monitoring/list/services'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>
compact ? ' data-base-target="col1"' : ''; ?>> +?>
compact ? ' data-base-target="col1"' : ''; ?>> translate('%s services:'), $this->stats->services_total); ?> stats->services_ok): ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index e3c1227f3..c51861f03 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Object\Service; $i = 0; ?> 0): ?> -
service_state, true); ?>
serviceFlags($service)) ?>escape($service->getName()); ?>escape($service->getHost()->getName()); ?>escape($service->service_output) ?> + serviceFlags($service)) ?> + + escape($service->getName()); ?> + translate('on') ?> + escape($service->getHost()->getName()); ?>
+
+ escape($service->service_output) ?> +
+
Date: Mon, 18 May 2015 15:18:26 +0200 Subject: [PATCH 235/298] ToggleObjectFeaturesCommandForm::onSuccess(): show a notification for each feature about whether it has been enabled or disabled refs #9023 --- .../ToggleObjectFeaturesCommandForm.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 34fbb4c2c..85a6ae3fd 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -117,6 +117,34 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm public function onSuccess() { $this->assertPermission('monitoring/command/feature/object'); + + $notifications = array( + ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array( + $this->translate('Enabling active checks...'), + $this->translate('Disabling active checks...') + ), + ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => array( + $this->translate('Enabling passive checks...'), + $this->translate('Disabling passive checks...') + ), + ToggleObjectFeatureCommand::FEATURE_OBSESSING => array( + $this->translate('Enabling obsessing...'), + $this->translate('Disabling obsessing...') + ), + ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array( + $this->translate('Enabling notifications...'), + $this->translate('Disabling notifications...') + ), + ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array( + $this->translate('Enabling event handler...'), + $this->translate('Disabling event handler...') + ), + ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => array( + $this->translate('Enabling flap detection...'), + $this->translate('Disabling flap detection...') + ) + ); + foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ foreach ($this->getValues() as $feature => $enabled) { @@ -127,10 +155,13 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ->setObject($object) ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); + + Notification::success( + $notifications[$feature][$enabled ? 0 : 1] + ); } } } - Notification::success($this->translate('Toggling feature..')); return true; } } From c3129890aae2d3316d9737dd364195339a8972f9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 15:22:10 +0200 Subject: [PATCH 236/298] Improve multi-view tabs Display the current object count next to the tab title, to clarify that those views display a summary of multiple items. Only display the current tab for hosts or services, to avoid confusion. refs #8565 --- .../controllers/HostsController.php | 19 +++---------------- .../controllers/ServicesController.php | 19 +++---------------- .../library/Monitoring/Object/HostList.php | 2 +- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 32916ba42..5a734cbbe 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -15,7 +15,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; use Icinga\Web\Widget\Tabextension\DashboardAction; class Monitoring_HostsController extends Controller @@ -42,24 +41,12 @@ class Monitoring_HostsController extends Controller $this->translate('Show summarized information for %u hosts'), count($this->hostList) ), - 'label' => $this->translate('Hosts'), + 'label' => sprintf($this->translate('Hosts (%d)'), count($this->hostList)), 'url' => Url::fromRequest(), 'icon' => 'host' ) - )->extend(new DashboardAction()); - - $this->getTabs()->add( - 'services', - array( - 'title' => sprintf( - $this->translate('Show summarized information for related services') - ), - 'label' => $this->translate('Services'), - 'url' => Url::fromPath('monitoring/services/show')->setParams(Url::fromRequest()->getParams()), - 'icon' => 'services' - ) - )->activate('show'); - + )->extend(new DashboardAction())->activate('show'); + $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts')->setQueryString($filterString); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 583b03246..83b1b5dd5 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -15,7 +15,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; use Icinga\Web\Widget\Tabextension\DashboardAction; class Monitoring_ServicesController extends Controller @@ -34,18 +33,6 @@ class Monitoring_ServicesController extends Controller $this->serviceList = $serviceList; $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services'); - $this->getTabs()->add( - 'hosts', - array( - 'title' => sprintf( - $this->translate('Show summarized information for hosts') - ), - 'label' => $this->translate('Hosts'), - 'url' => Url::fromPath('monitoring/hosts/show')->setParams(Url::fromRequest()->getParams()), - 'icon' => 'host' - ) - )->extend(new DashboardAction()); - $this->getTabs()->add( 'show', array( @@ -53,11 +40,11 @@ class Monitoring_ServicesController extends Controller $this->translate('Show summarized information for %u services'), count($this->serviceList) ), - 'label' => $this->translate('Services'), + 'label' => sprintf($this->translate('Services (%d)'), count($this->serviceList)), 'url' => Url::fromRequest(), - 'icon' => 'services' + 'icon' => 'services' ) - )->activate('show'); + )->extend(new DashboardAction())->activate('show'); } protected function handleCommandForm(ObjectsCommandForm $form) diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index 4236f94d8..2aa5bb04f 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -76,7 +76,7 @@ class HostList extends ObjectList /** * Returns a Filter that matches all hosts in this list * - * @return array An + * @return Filter */ public function objectsFilter($columns = array('host' => 'host')) { From 1f20ba1bc63ad40913a91231fbacaa4184a4c25c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 15:48:04 +0200 Subject: [PATCH 237/298] Fix state summary base target in multi views refs #8565 --- modules/monitoring/application/views/scripts/hosts/show.phtml | 2 +- .../views/scripts/list/components/hostssummary.phtml | 2 +- .../views/scripts/list/components/servicesummary.phtml | 2 +- .../monitoring/application/views/scripts/services/show.phtml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 45bf19ebb..6b4ed4ca3 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,4 +1,4 @@ -
+
compact): ?> diff --git a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml index a21a6c9ea..d6166a52d 100644 --- a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml @@ -14,7 +14,7 @@ function urlAddFilterOptional($url, $filter, $optional) { $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; $selfUrl = 'monitoring/list/hosts'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>
compact ? ' data-base-target="col1"' : ''; ?>> +?>
compact ? ' data-base-target="col1"' : ''; ?>> translate('%s hosts:'), $this->stats->hosts_total); ?> stats->hosts_up): ?> diff --git a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml index 97d5f9fdf..76a51de92 100644 --- a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml @@ -16,7 +16,7 @@ $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; $selfUrl = 'monitoring/list/services'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>
compact ? ' data-base-target="col1"' : ''; ?>> +?>
compact ? ' data-base-target="col1"' : ''; ?>> translate('%s services:'), $this->stats->services_total); ?> stats->services_ok): ?> diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 9291f6ef3..429f43ea6 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,4 +1,4 @@ -
+
compact): ?> From 7caba93a28c972585bafaaa0fa7dc59da59758e3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 16:03:15 +0200 Subject: [PATCH 238/298] Replace `...' w/ `..' refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 40 +++++++++---------- .../ToggleObjectFeaturesCommandForm.php | 24 +++++------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 50970df0c..9ef90718f 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -212,44 +212,44 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm $notifications = array( ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS => array( - $this->translate('Enabling active host checks...'), - $this->translate('Disabling active host checks...') + $this->translate('Enabling active host checks..'), + $this->translate('Disabling active host checks..') ), ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS => array( - $this->translate('Enabling active service checks...'), - $this->translate('Disabling active service checks...') + $this->translate('Enabling active service checks..'), + $this->translate('Disabling active service checks..') ), ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS => array( - $this->translate('Enabling event handlers...'), - $this->translate('Disabling event handlers...') + $this->translate('Enabling event handlers..'), + $this->translate('Disabling event handlers..') ), ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION => array( - $this->translate('Enabling flap detection...'), - $this->translate('Disabling flap detection...') + $this->translate('Enabling flap detection..'), + $this->translate('Disabling flap detection..') ), ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS => array( - $this->translate('Enabling notifications...'), - $this->translate('Disabling notifications...') + $this->translate('Enabling notifications..'), + $this->translate('Disabling notifications..') ), ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING => array( - $this->translate('Enabling obsessing over hosts...'), - $this->translate('Disabling obsessing over hosts...') + $this->translate('Enabling obsessing over hosts..'), + $this->translate('Disabling obsessing over hosts..') ), ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING => array( - $this->translate('Enabling obsessing over services...'), - $this->translate('Disabling obsessing over services...') + $this->translate('Enabling obsessing over services..'), + $this->translate('Disabling obsessing over services..') ), ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS => array( - $this->translate('Enabling passive host checks...'), - $this->translate('Disabling passive host checks...') + $this->translate('Enabling passive host checks..'), + $this->translate('Disabling passive host checks..') ), ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS => array( - $this->translate('Enabling passive service checks...'), - $this->translate('Disabling passive service checks...') + $this->translate('Enabling passive service checks..'), + $this->translate('Disabling passive service checks..') ), ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA => array( - $this->translate('Enabling performance data...'), - $this->translate('Disabling performance data...') + $this->translate('Enabling performance data..'), + $this->translate('Disabling performance data..') ) ); diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 85a6ae3fd..ad6196d44 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -120,28 +120,28 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm $notifications = array( ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array( - $this->translate('Enabling active checks...'), - $this->translate('Disabling active checks...') + $this->translate('Enabling active checks..'), + $this->translate('Disabling active checks..') ), ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => array( - $this->translate('Enabling passive checks...'), - $this->translate('Disabling passive checks...') + $this->translate('Enabling passive checks..'), + $this->translate('Disabling passive checks..') ), ToggleObjectFeatureCommand::FEATURE_OBSESSING => array( - $this->translate('Enabling obsessing...'), - $this->translate('Disabling obsessing...') + $this->translate('Enabling obsessing..'), + $this->translate('Disabling obsessing..') ), ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array( - $this->translate('Enabling notifications...'), - $this->translate('Disabling notifications...') + $this->translate('Enabling notifications..'), + $this->translate('Disabling notifications..') ), ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array( - $this->translate('Enabling event handler...'), - $this->translate('Disabling event handler...') + $this->translate('Enabling event handler..'), + $this->translate('Disabling event handler..') ), ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => array( - $this->translate('Enabling flap detection...'), - $this->translate('Disabling flap detection...') + $this->translate('Enabling flap detection..'), + $this->translate('Disabling flap detection..') ) ); From 0bde465295e765e295b29304b737ee2f833a5e13 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 16:29:33 +0200 Subject: [PATCH 239/298] Rename ::extraColumns() to ::addColumns() refs #4498 --- .../monitoring/application/controllers/ListController.php | 8 ++++---- .../monitoring/application/views/scripts/list/hosts.phtml | 2 +- .../application/views/scripts/list/services.phtml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 27f02f3f9..5be9fcd09 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -94,7 +94,7 @@ class Monitoring_ListController extends Controller 'host_passive_checks_enabled', 'host_current_check_attempt', 'host_max_check_attempts' - ), $this->extraColumns())); + ), $this->addColumns())); $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); $this->view->hosts = $query; @@ -177,7 +177,7 @@ class Monitoring_ListController extends Controller 'service_passive_checks_enabled', 'current_check_attempt' => 'service_current_check_attempt', 'max_check_attempts' => 'service_max_check_attempts' - ), $this->extraColumns()); + ), $this->addColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); @@ -644,7 +644,7 @@ class Monitoring_ListController extends Controller return $query; } - protected function extraColumns() + protected function addColumns() { $columns = preg_split( '~,~', @@ -652,7 +652,7 @@ class Monitoring_ListController extends Controller -1, PREG_SPLIT_NO_EMPTY ); - $this->view->extraColumns = $columns; + $this->view->addColumns = $columns; return $columns; } diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 196279b04..89c2e7d26 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -92,7 +92,7 @@ if (count($hosts) === 0) {

escape($this->ellipsis($host->host_output, 10000)) ?>

- extraColumns as $col): ?> + addColumns as $col): ?>
diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 63d9076c3..12ba232cc 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -81,7 +81,7 @@ if (count($services) === 0) { ); ?>

escape($this->ellipsis($service->service_output, 10000)); ?>

-extraColumns as $col): ?> +addColumns as $col): ?> From 94555d7998c6f0e3c0378b8e2f555307b810ac6a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 18 May 2015 17:13:46 +0200 Subject: [PATCH 240/298] Streamline layout of all multi-views Fix small inconsistencies between layout of downtime, comment, service and host multi-views. --- .../application/controllers/CommentsController.php | 4 ++-- .../controllers/DowntimesController.php | 4 ++-- .../application/controllers/HostsController.php | 2 +- .../application/controllers/ServicesController.php | 2 +- .../application/views/scripts/comments/show.phtml | 11 +---------- .../application/views/scripts/downtimes/show.phtml | 13 ++----------- .../application/views/scripts/hosts/show.phtml | 4 ++-- .../scripts/partials/comment/comments-header.phtml | 6 ++++-- .../partials/downtime/downtimes-header.phtml | 8 +++++--- .../scripts/partials/host/objects-header.phtml | 11 ++++++++--- .../scripts/partials/service/objects-header.phtml | 14 +++++++++----- .../application/views/scripts/services/show.phtml | 2 +- public/css/icinga/layout-structure.less | 3 ++- public/css/icinga/monitoring-colors.less | 5 ----- 14 files changed, 40 insertions(+), 49 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index e9a885dbe..e1092b033 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -55,8 +55,8 @@ class Monitoring_CommentsController extends Controller 'title' => $this->translate( 'Display detailed information about multiple comments.' ), - 'icon' => 'comment', - 'label' => $this->translate('Comments'), + 'icon' => 'comment', + 'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)), 'url' =>'monitoring/comments/show' ) )->activate('comments'); diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 49424ed3a..4ba872bbd 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -75,8 +75,8 @@ class Monitoring_DowntimesController extends Controller 'title' => $this->translate( 'Display detailed information about multiple downtimes.' ), - 'icon' => 'plug', - 'label' => $this->translate('Downtimes'), + 'icon' => 'plug', + 'label' => $this->translate('Downtimes') . sprintf(' (%d)', count($this->downtimes)), 'url' =>'monitoring/downtimes/show' ) )->activate('downtimes'); diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 5a734cbbe..45eca1135 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -41,7 +41,7 @@ class Monitoring_HostsController extends Controller $this->translate('Show summarized information for %u hosts'), count($this->hostList) ), - 'label' => sprintf($this->translate('Hosts (%d)'), count($this->hostList)), + 'label' => $this->translate('Hosts') . sprintf(' (%d)', count($this->hostList)), 'url' => Url::fromRequest(), 'icon' => 'host' ) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 83b1b5dd5..f4ee73cf5 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -40,7 +40,7 @@ class Monitoring_ServicesController extends Controller $this->translate('Show summarized information for %u services'), count($this->serviceList) ), - 'label' => sprintf($this->translate('Services (%d)'), count($this->serviceList)), + 'label' => $this->translate('Services') . sprintf(' (%d)', count($this->serviceList)), 'url' => Url::fromRequest(), 'icon' => 'services' ) diff --git a/modules/monitoring/application/views/scripts/comments/show.phtml b/modules/monitoring/application/views/scripts/comments/show.phtml index f84f512b1..4f9c64d47 100644 --- a/modules/monitoring/application/views/scripts/comments/show.phtml +++ b/modules/monitoring/application/views/scripts/comments/show.phtml @@ -8,15 +8,8 @@ -
+

icon('reschedule') ?> translate('Commands') ?>

-

- translate('Issue commands to all %s selected comments.'), - '' . count($comments) . '' - ) - ?> -

qlink( sprintf( $this->translate('Remove %d comments'), @@ -29,6 +22,4 @@ 'title' => $this->translate('Remove all selected comments.') ) ) ?> -
-

diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index 35edc04f4..1c508bbc9 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -7,15 +7,8 @@ render('partials/downtime/downtimes-header.phtml'); ?>

-
-

icon('reschedule') ?> translate('Commands') ?>

-

- translate('Issue commands to all %s selected downtimes.'), - '' . count($downtimes) . '' - ) - ?> -

+
+

icon('reschedule') ?> translate('Commands') ?>

qlink( sprintf( $this->translate('Remove all %d scheduled downtimes'), @@ -28,6 +21,4 @@ 'title' => $this->translate('Remove all selected downtimes.') ) ) ?> -
-

diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 6b4ed4ca3..6bbb3c80d 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,7 +8,7 @@
-
+

icon('reschedule') ?> translate('Commands') ?> @@ -165,7 +165,7 @@ $acknowledgedCount ), '' . $acknowledgedCount . '' - ); ?>

+ ); ?>

diff --git a/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml index 4ec725549..7e2a5d87c 100644 --- a/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/comment/comments-header.phtml @@ -18,13 +18,15 @@
escape($host->$col) ?>
escape($service->$col) ?>

+ 5): ?> qlink( - sprintf($this->translate('List all %d comments …'), count($comments)), + sprintf($this->translate('show all %d comments'), $i), $listAllLink, null, array( - 'title' => $this->translate('List all'), + 'icon' => $i > 5 ? 'down-open' : '', 'data-base-target' => "_next" ) ) ?> +

diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml index 54cd0210c..5518e5022 100644 --- a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml @@ -79,14 +79,16 @@
-

+

+ 5): ?> qlink( - sprintf($this->translate('List all %d downtimes …'), count($downtimes)), + sprintf($this->translate('show all %d downtimes'), $i), $listAllLink, null, array( - 'title' => $this->translate('List all'), + 'icon' => $i > 5 ? 'down-open' : '', 'data-base-target' => "_next" ) ) ?> +

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 17cf9f7fe..d59479e07 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -25,15 +25,20 @@ $i = 0;
-
+
+ 5): ?> qlink( - sprintf($this->translate('list all %d hosts ...'), $i), + sprintf($this->translate('show all %d hosts'), $i), $listAllLink, null, - array('data-base-target' => '_next') + array( + 'icon' => 'down-open', + 'data-base-target' => '_next' + ) ); ?> +
diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index c51861f03..0d3d4840d 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -27,14 +27,18 @@ $i = 0;
-
- qlink( - sprintf($this->translate('List all %d services ...'), $i), +
+ 5): ?> + qlink( + sprintf($this->translate('show all %d services'), $i), $listAllLink, null, - array('data-base-target' => '_next') + array( + 'icon' => 'down-open', + 'data-base-target' => '_next' + ) ); ?> +
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 429f43ea6..746e24871 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -8,7 +8,7 @@ render('partials/service/objects-header.phtml'); ?>
-
+

icon('reschedule') ?> translate('Commands') ?> diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index 63be9f546..3a8713a38 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -373,6 +373,7 @@ html { width: 1px; } -.no-padding-top { +.multi-commands { padding-top: 0em; + font-size: 0.9em; } diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 4902bebb1..ba0877232 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -933,11 +933,6 @@ table.statesummary { width: auto; border-collapse: separate; - td { - padding: 0em 0.4em 0em 0.4em; - line-height: 1.2em; - } - tr.state td.state { width: auto; font-weight: bold; From d539a0e0174143471afa73dbd9f802281e67224b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 10:11:54 +0200 Subject: [PATCH 241/298] Add PHPDoc to ::addColumns() refs #4498 --- .../monitoring/application/controllers/ListController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 5be9fcd09..0ab1192f7 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -644,6 +644,12 @@ class Monitoring_ListController extends Controller return $query; } + /** + * Get columns to be added from URL parameter 'addColumns' + * and assign to $this->view->addColumns (as array) + * + * @return array + */ protected function addColumns() { $columns = preg_split( From 1ce9900c8675cbd5b818dcf3d16993996e069236 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 11:11:43 +0200 Subject: [PATCH 242/298] Add PHPDoc to ::setSearchColumns() --- library/Icinga/Web/Widget/FilterEditor.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index a362d1014..83f5f2955 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -76,6 +76,11 @@ class FilterEditor extends AbstractWidget return $this->filter; } + /** + * Set columns to search in + * + * @param array $searchColumns + */ public function setSearchColumns(array $searchColumns) { $this->searchColumns = $searchColumns; From 4f4d7ccba206ed2e5c30b79797204eb1a91d230a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 12:55:40 +0200 Subject: [PATCH 243/298] Correct PHPDoc of ::setSearchColumns() --- library/Icinga/Web/Widget/FilterEditor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 83f5f2955..40953a518 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -80,6 +80,8 @@ class FilterEditor extends AbstractWidget * Set columns to search in * * @param array $searchColumns + * + * @return $this */ public function setSearchColumns(array $searchColumns) { From afe07f48148c6ab0ee3742c00f320090946b6303 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 13:42:57 +0200 Subject: [PATCH 244/298] Revert "Hostgroups view: reduce "Last Problem" column's width" This reverts commit 8b084733413b74131100abf6a31efc02793695c5. Common table style is subject of #8935. refs #8054 --- .../application/views/scripts/list/hostgroups.phtml | 2 +- public/css/icinga/main-content.less | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index e75359b23..23d031b3f 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -20,7 +20,7 @@ if (count($hostgroups) === 0) { ?> - + diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 59c7830da..b442723cb 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -169,10 +169,6 @@ table.benchmark { width: 96%; } -table.groupview th.state { - width: 9em; -} - .dashboard h1 { font-size: 1em; } From 73e8c51fd1e7a0814fb28b938f50642e8f3aca8d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 19 May 2015 12:21:32 +0200 Subject: [PATCH 245/298] Ldap\Query: Remove method paginate() --- library/Icinga/Protocol/Ldap/Query.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index f82a40511..004c2e43e 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -281,31 +281,6 @@ class Query return $this->sort_columns; } - /** - * Return a pagination adapter for the current query - * - * @return \Zend_Paginator - */ - public function paginate($limit = null, $page = null) - { - if ($page === null || $limit === null) { - $request = \Zend_Controller_Front::getInstance()->getRequest(); - if ($page === null) { - $page = $request->getParam('page', 0); - } - if ($limit === null) { - $limit = $request->getParam('limit', 20); - } - } - $paginator = new \Zend_Paginator( - // TODO: Adapter doesn't fit yet: - new \Icinga\Web\Paginator\Adapter\QueryAdapter($this) - ); - $paginator->setItemCountPerPage($limit); - $paginator->setCurrentPageNumber($page); - return $paginator; - } - /** * Add a filter expression to this query * From a629adb4483d3391b930ff19ae27deeaea709ccd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 19 May 2015 12:21:44 +0200 Subject: [PATCH 246/298] DataView: Remove method paginate() --- .../library/Monitoring/DataView/DataView.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 6bed36fe1..f39f1d96d 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -389,22 +389,6 @@ abstract class DataView implements QueryInterface, IteratorAggregate return $this; } - /** - * Paginate data - * - * @param int $itemsPerPage Number of items per page - * @param int $pageNumber Current page number - * - * @return Zend_Paginator - */ - public function paginate($itemsPerPage = null, $pageNumber = null) - { - if (! $this->isSorted) { - $this->order(); - } - return $this->query->paginate($itemsPerPage, $pageNumber); - } - /** * Count result set * From 4cedfce07fc8b54f74ae7912ce8a04d3320ce85a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 19 May 2015 12:22:20 +0200 Subject: [PATCH 247/298] DataView: Fix that method getOffset() calls parent::hasOffset() --- modules/monitoring/library/Monitoring/DataView/DataView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index f39f1d96d..8212d7bb7 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -450,7 +450,7 @@ abstract class DataView implements QueryInterface, IteratorAggregate */ public function getOffset() { - return $this->query->hasOffset(); + return $this->query->getOffset(); } /** From bd7c7f963663cc570f378f395863d99e9a1c3d7d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 19 May 2015 13:57:11 +0200 Subject: [PATCH 248/298] Introduce widget Paginator This does not support custom scrolling styles as of now. Custom view scripts are supported though. In case Paginator::getPages() does not suffice, feel free to improve this. --- library/Icinga/Web/Controller.php | 10 +- library/Icinga/Web/Widget/Paginator.php | 168 ++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 library/Icinga/Web/Widget/Paginator.php diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 61e80173b..9acf17469 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -3,12 +3,11 @@ namespace Icinga\Web; -use Zend_Paginator; use Icinga\Data\Sortable; use Icinga\Data\QueryInterface; -use Icinga\Web\Paginator\Adapter\QueryAdapter; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Widget\Limiter; +use Icinga\Web\Widget\Paginator; use Icinga\Web\Widget\SortBox; /** @@ -115,12 +114,11 @@ class Controller extends ModuleActionController $request = $this->getRequest(); $limit = $request->getParam('limit', $itemsPerPage); $page = $request->getParam('page', $pageNumber); - $query->limit($limit, $page * $limit); + $query->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); if (! $this->view->compact) { - $paginator = new Zend_Paginator(new QueryAdapter($query)); - $paginator->setItemCountPerPage($limit); - $paginator->setCurrentPageNumber($page); + $paginator = new Paginator(); + $paginator->setQuery($query); $this->view->paginator = $paginator; } diff --git a/library/Icinga/Web/Widget/Paginator.php b/library/Icinga/Web/Widget/Paginator.php new file mode 100644 index 000000000..dc014e371 --- /dev/null +++ b/library/Icinga/Web/Widget/Paginator.php @@ -0,0 +1,168 @@ +query = $query; + return $this; + } + + /** + * Set the view script to use + * + * @param string|array $script + * + * @return $this + */ + public function setViewScript($script) + { + $this->viewScript = $script; + return $this; + } + + /** + * Render this paginator + */ + public function render() + { + if ($this->query === null) { + throw new ProgrammingError('Need a query to create the paginator widget for'); + } + + $itemCountPerPage = $this->query->getLimit(); + if (! $itemCountPerPage) { + return ''; // No pagination required + } + + $totalItemCount = count($this->query); + $pageCount = (int) ceil($totalItemCount / $itemCountPerPage); + $currentPage = $this->query->hasOffset() ? ($this->query->getOffset() / $itemCountPerPage) + 1 : 1; + $pagesInRange = $this->getPages($pageCount, $currentPage); + $variables = array( + 'totalItemCount' => $totalItemCount, + 'pageCount' => $pageCount, + 'itemCountPerPage' => $itemCountPerPage, + 'first' => 1, + 'current' => $currentPage, + 'last' => $pageCount, + 'pagesInRange' => $pagesInRange, + 'firstPageInRange' => min($pagesInRange), + 'lastPageInRange' => max($pagesInRange) + ); + + if ($currentPage > 1) { + $variables['previous'] = $currentPage - 1; + } + + if ($currentPage < $pageCount) { + $variables['next'] = $currentPage + 1; + } + + if (is_array($this->viewScript)) { + if ($this->viewScript[1] !== null) { + return $this->view()->partial($this->viewScript[0], $this->viewScript[1], $variables); + } + + return $this->view()->partial($this->viewScript[0], $variables); + } + + return $this->view()->partial($this->viewScript, $variables); + } + + /** + * Returns an array of "local" pages given the page count and current page number + * + * @return array + */ + protected function getPages($pageCount, $currentPage) + { + $range = array(); + + if ($pageCount < 10) { + // Show all pages if we have less than 10 + for ($i = 1; $i < 10; $i++) { + if ($i > $pageCount) { + break; + } + + $range[$i] = $i; + } + } else { + // More than 10 pages: + foreach (array(1, 2) as $i) { + $range[$i] = $i; + } + + if ($currentPage < 6 ) { + // We are on page 1-5 from + for ($i = 1; $i <= 7; $i++) { + $range[$i] = $i; + } + } else { + // Current page > 5 + $range[] = '...'; + + if (($pageCount - $currentPage) < 5) { + // Less than 5 pages left + $start = 5 - ($pageCount - $currentPage); + } else { + $start = 1; + } + + for ($i = $currentPage - $start; $i < ($currentPage + (4 - $start)); $i++) { + if ($i > $pageCount) { + break; + } + + $range[$i] = $i; + } + } + + if ($currentPage < ($pageCount - 2)) { + $range[] = '...'; + } + + foreach (array($pageCount - 1, $pageCount) as $i) { + $range[$i] = $i; + } + + } + + if (empty($range)) { + $range[] = 1; + } + + return $range; + } +} From 85dd496d35970ccf64acefed1b24c92d210eb8e1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 13:29:21 +0200 Subject: [PATCH 249/298] Add parameter $searchColumns to ::filterQuery() refs #8241 --- .../application/controllers/ListController.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 0ab1192f7..6c685f34a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -12,6 +12,7 @@ use Icinga\Web\Widget\Tabs; use Icinga\Data\Filter\Filter; use Icinga\Web\Widget; use Icinga\Module\Monitoring\Forms\StatehistoryForm; +use Icinga\Data\Filterable; class Monitoring_ListController extends Controller { @@ -625,7 +626,15 @@ class Monitoring_ListController extends Controller $this->view->verticalPaginator = $pivot->paginateYAxis(); } - protected function filterQuery($query) + /** + * Apply filters on a query + * + * @param Filterable $query The query to apply filters on + * @param array $searchColumns Columns to search in + * + * @return Filterable $query + */ + protected function filterQuery(Filterable $query, array $searchColumns = null) { $editor = Widget::create('filterEditor') ->setQuery($query) @@ -633,8 +642,11 @@ class Monitoring_ListController extends Controller 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' ) - ->ignoreParams('page') - ->handleRequest($this->getRequest()); + ->ignoreParams('page'); + if ($searchColumns !== null) { + $editor->setSearchColumns($searchColumns); + } + $editor->handleRequest($this->getRequest()); $query->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); From a2b262eab173ed8c8f18c8f239b918aa56cf6eb2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 13:58:08 +0200 Subject: [PATCH 250/298] Take display_name into account when searching for host and service names refs #8241 --- .../monitoring/application/controllers/ListController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 6c685f34a..a793f2a0a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -96,7 +96,7 @@ class Monitoring_ListController extends Controller 'host_current_check_attempt', 'host_max_check_attempts' ), $this->addColumns())); - $this->filterQuery($query); + $this->filterQuery($query, array('host', 'host_display_name')); $this->applyRestriction('monitoring/hosts/filter', $query); $this->view->hosts = $query; @@ -180,7 +180,7 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->addColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query); + $this->filterQuery($query, array('service', 'service_display_name')); $this->applyRestriction('monitoring/services/filter', $query); $this->view->services = $query; @@ -498,7 +498,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query); + $this->filterQuery($query, array('servicegroup', 'servicegroup_alias')); $this->view->servicegroups = $query; $this->setupLimitControl(); @@ -555,7 +555,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query); + $this->filterQuery($query, array('hostgroup', 'hostgroup_alias')); $this->view->hostgroups = $query; $this->setupLimitControl(); From 94bdb8b4b072c9fadac77830325f727a14f93f85 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 19 May 2015 16:35:44 +0200 Subject: [PATCH 251/298] Abort pending AJAX requests before page unload Abort all pending requests before the page unload, to avoid confusing error messages during page reloads. Avoid rendering the site unusable in cases where the site is still being used after the beforeunload event. fixes #7759 --- public/js/icinga/events.js | 13 +++++++++++-- public/js/icinga/loader.js | 14 ++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index cc927feb6..d458ab7fc 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -100,7 +100,7 @@ // Destroy Icinga, clean up and interrupt pending requests on unload $( window ).on('unload', { self: this }, this.onUnload); - $( window ).on('beforeunload', { self: this }, this.onUnload); + $( window ).on('beforeunload', { self: this }, this.onBeforeUnload); // We catch scroll events in our containers $('.container').on('scroll', { self: this }, this.icinga.events.onContainerScroll); @@ -153,6 +153,15 @@ icinga.destroy(); }, + onBeforeUnload: function (event) { + var icinga = event.data.self.icinga; + + // Browsers may call the error handler on all pending AJAX requests, when the page is reloaded, + // which could in turn cause needless error messages to show up in the frontend until the page is loaded. + // To circumvent this cancel all pending requests. + icinga.loader.cancelRequests(); + }, + /** * A scroll event happened in one of our containers */ @@ -560,7 +569,7 @@ $(window).off('resize', this.onWindowResize); $(window).off('load', this.onLoad); $(window).off('unload', this.onUnload); - $(window).off('beforeunload', this.onUnload); + $(window).off('beforeunload', this.onBeforeUnload); $(document).off('scroll', '.container', this.onContainerScroll); $(document).off('click', 'a', this.linkClicked); $(document).off('click', 'table.action tr[href]', this.rowSelected); diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 99667ac1c..e01e03cec 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -793,16 +793,22 @@ }, /** - * On shutdown we kill all pending requests + * Cancel and dereference all pending requests and dereference this object */ destroy: function() { + this.icinga.loader.cancelRequests(); + this.icinga = null; + this.requests = {}; + }, + + /** + * Cancel all pendings ajax requests + */ + cancelRequests: function() { $.each(this.requests, function(id, request) { request.abort(); }); - this.icinga = null; - this.requests = {}; } - }; }(Icinga, jQuery)); From 54207d34275fc1bfed0adc31365c00fc98645be0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 19 May 2015 17:05:04 +0200 Subject: [PATCH 252/298] Revert "Abort pending AJAX requests before page unload" This reverts commit 94bdb8b4b072c9fadac77830325f727a14f93f85. After the patch, Firefox shows an error message on each reload for an unknown reason. refs #7759 --- public/js/icinga/events.js | 13 ++----------- public/js/icinga/loader.js | 14 ++++---------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index d458ab7fc..cc927feb6 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -100,7 +100,7 @@ // Destroy Icinga, clean up and interrupt pending requests on unload $( window ).on('unload', { self: this }, this.onUnload); - $( window ).on('beforeunload', { self: this }, this.onBeforeUnload); + $( window ).on('beforeunload', { self: this }, this.onUnload); // We catch scroll events in our containers $('.container').on('scroll', { self: this }, this.icinga.events.onContainerScroll); @@ -153,15 +153,6 @@ icinga.destroy(); }, - onBeforeUnload: function (event) { - var icinga = event.data.self.icinga; - - // Browsers may call the error handler on all pending AJAX requests, when the page is reloaded, - // which could in turn cause needless error messages to show up in the frontend until the page is loaded. - // To circumvent this cancel all pending requests. - icinga.loader.cancelRequests(); - }, - /** * A scroll event happened in one of our containers */ @@ -569,7 +560,7 @@ $(window).off('resize', this.onWindowResize); $(window).off('load', this.onLoad); $(window).off('unload', this.onUnload); - $(window).off('beforeunload', this.onBeforeUnload); + $(window).off('beforeunload', this.onUnload); $(document).off('scroll', '.container', this.onContainerScroll); $(document).off('click', 'a', this.linkClicked); $(document).off('click', 'table.action tr[href]', this.rowSelected); diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index e01e03cec..99667ac1c 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -793,22 +793,16 @@ }, /** - * Cancel and dereference all pending requests and dereference this object + * On shutdown we kill all pending requests */ destroy: function() { - this.icinga.loader.cancelRequests(); - this.icinga = null; - this.requests = {}; - }, - - /** - * Cancel all pendings ajax requests - */ - cancelRequests: function() { $.each(this.requests, function(id, request) { request.abort(); }); + this.icinga = null; + this.requests = {}; } + }; }(Icinga, jQuery)); From b1b2e3fc21f3a66cc5b30dc8ab6b72359df48253 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 17:13:46 +0200 Subject: [PATCH 253/298] Revert "Merge branch 'bugfix/Take-display_name-into-account-when-searching-for-host-and-service-names-8241'" This reverts commit 75b004dc429a3ef32b113ebd0fb3791896ebf89b, reversing changes made to bd7c7f963663cc570f378f395863d99e9a1c3d7d. --- .../controllers/ListController.php | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 656b59032..92c42d4ad 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -12,7 +12,6 @@ use Icinga\Web\Widget\Tabs; use Icinga\Data\Filter\Filter; use Icinga\Web\Widget; use Icinga\Module\Monitoring\Forms\StatehistoryForm; -use Icinga\Data\Filterable; class Monitoring_ListController extends Controller { @@ -96,7 +95,7 @@ class Monitoring_ListController extends Controller 'host_current_check_attempt', 'host_max_check_attempts' ), $this->addColumns())); - $this->filterQuery($query, array('host', 'host_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); $this->view->hosts = $query; @@ -180,7 +179,7 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->addColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query, array('service', 'service_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); $this->view->services = $query; @@ -498,7 +497,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('servicegroup', 'servicegroup_alias')); + $this->filterQuery($query); $this->view->servicegroups = $query; $this->setupLimitControl(); @@ -556,7 +555,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('hostgroup', 'hostgroup_alias')); + $this->filterQuery($query); $this->view->hostgroups = $query; $this->setupLimitControl(); @@ -627,15 +626,7 @@ class Monitoring_ListController extends Controller $this->view->verticalPaginator = $pivot->paginateYAxis(); } - /** - * Apply filters on a query - * - * @param Filterable $query The query to apply filters on - * @param array $searchColumns Columns to search in - * - * @return Filterable $query - */ - protected function filterQuery(Filterable $query, array $searchColumns = null) + protected function filterQuery($query) { $editor = Widget::create('filterEditor') ->setQuery($query) @@ -643,11 +634,8 @@ class Monitoring_ListController extends Controller 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' ) - ->ignoreParams('page'); - if ($searchColumns !== null) { - $editor->setSearchColumns($searchColumns); - } - $editor->handleRequest($this->getRequest()); + ->ignoreParams('page') + ->handleRequest($this->getRequest()); $query->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); From 3243f9a65a45ba080ce36ff652bf02a6cf5a1f1f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 15:26:21 +0200 Subject: [PATCH 254/298] Don't handle the case $this->searchColumns === null for actions in which ::setSearchColumns() is called refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 24 +--------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 40953a518..fb346b573 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -217,29 +217,7 @@ class FilterEditor extends AbstractWidget if ($search !== null) { if ($this->searchColumns === null) { if (strpos($search, '=') === false) { - // TODO: Ask the view for (multiple) search columns - switch($request->getActionName()) { - case 'services': - $searchCol = 'service'; - break; - case 'hosts': - $searchCol = 'host'; - break; - case 'hostgroups': - $searchCol = 'hostgroup'; - break; - case 'servicegroups': - $searchCol = 'servicegroup'; - break; - default: - $searchCol = null; - } - - if ($searchCol === null) { - throw new Exception('Cannot search here'); - } - $search = ltrim($search); - $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); + throw new Exception('Cannot search here'); } else { list($k, $v) = preg_split('/=/', $search); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v)); From 36713fb519f38cd2071fb0a001dad444f1c83db7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 15:43:47 +0200 Subject: [PATCH 255/298] Rename parameter $query of ::filterQuery() to $dataView refs #8241 --- .../controllers/ListController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a793f2a0a..df5a10dee 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -13,6 +13,7 @@ use Icinga\Data\Filter\Filter; use Icinga\Web\Widget; use Icinga\Module\Monitoring\Forms\StatehistoryForm; use Icinga\Data\Filterable; +use Icinga\Module\Monitoring\DataView\DataView; class Monitoring_ListController extends Controller { @@ -627,17 +628,17 @@ class Monitoring_ListController extends Controller } /** - * Apply filters on a query + * Apply filters on a DataView * - * @param Filterable $query The query to apply filters on - * @param array $searchColumns Columns to search in + * @param DataView $dataView The DataView to apply filters on + * @param array $searchColumns Columns to search in * - * @return Filterable $query + * @return DataView $dataView */ - protected function filterQuery(Filterable $query, array $searchColumns = null) + protected function filterQuery(DataView $dataView, array $searchColumns = null) { $editor = Widget::create('filterEditor') - ->setQuery($query) + ->setQuery($dataView) ->preserveParams( 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' @@ -647,13 +648,13 @@ class Monitoring_ListController extends Controller $editor->setSearchColumns($searchColumns); } $editor->handleRequest($this->getRequest()); - $query->applyFilter($editor->getFilter()); + $dataView->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); $this->view->filter = $editor->getFilter(); - $this->handleFormatRequest($query); - return $query; + $this->handleFormatRequest($dataView); + return $dataView; } /** From cc050ed696fc73ebb4d344bbd1e5f679a18e5e71 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 16:28:07 +0200 Subject: [PATCH 256/298] Display an error notification rather than throwing an exception refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index fb346b573..07640872b 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -10,6 +10,7 @@ use Icinga\Data\Filter\FilterOr; use Icinga\Web\Url; use Icinga\Application\Icinga; use Icinga\Exception\ProgrammingError; +use Icinga\Web\Notification; use Exception; /** @@ -217,7 +218,8 @@ class FilterEditor extends AbstractWidget if ($search !== null) { if ($this->searchColumns === null) { if (strpos($search, '=') === false) { - throw new Exception('Cannot search here'); + Notification::error(mt('monitoring', 'Cannot search here')); + return $this; } else { list($k, $v) = preg_split('/=/', $search); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v)); From 2ed1d6c66b0f1975b9cdbe8b74e28958a3764ff7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 16:37:39 +0200 Subject: [PATCH 257/298] Implement ::getSearchColumns() refs #8241 --- .../library/Monitoring/DataView/DataView.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 8212d7bb7..6456fa203 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -378,6 +378,16 @@ abstract class DataView implements QueryInterface, IteratorAggregate return $this; } + /** + * Get the view's search columns + * + * @return string[] + */ + public function getSearchColumns() + { + return array(); + } + /** * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing * column validation. From c0cf6e4918af12905b197b46fb418be5cb8c8bcb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 19 May 2015 18:08:26 +0200 Subject: [PATCH 258/298] Display icon_images in all host and service detail views refs #8665 --- .../application/controllers/HostsController.php | 2 ++ .../application/controllers/ServicesController.php | 2 ++ .../scripts/partials/host/object-header.phtml | 3 +++ .../scripts/partials/host/objects-header.phtml | 3 +++ .../scripts/partials/service/object-header.phtml | 14 ++++++++++---- .../scripts/partials/service/objects-header.phtml | 3 +++ .../monitoring/library/Monitoring/Object/Host.php | 1 + .../library/Monitoring/Object/Service.php | 2 ++ 8 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 45eca1135..ac55ade9b 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -53,6 +53,7 @@ class Monitoring_HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $this->hostList->setColumns(array( + 'host_icon_image', 'host_name', 'host_state', 'host_problem', @@ -94,6 +95,7 @@ class Monitoring_HostsController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; $this->hostList->setColumns(array( + 'host_icon_image', 'host_name', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index f4ee73cf5..ca9788ff2 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -55,6 +55,7 @@ class Monitoring_ServicesController extends Controller 'host_state', 'host_problem', 'host_handled', + 'service_icon_image', 'service_description', 'service_state', 'service_problem', @@ -98,6 +99,7 @@ class Monitoring_ServicesController extends Controller 'host_state', 'host_problem', 'host_handled', + 'service_icon_image', 'service_output', 'service_description', 'service_state', diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 0efedf328..127f492e6 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -9,6 +9,9 @@ use Icinga\Module\Monitoring\Object\Host; prefixedTimeSince($object->host_last_state_change, true); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 45111fe1e..b50aff9bc 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -10,7 +10,10 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->host_last_state_change, true); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 0d3d4840d..fe1e4b16a 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -16,6 +16,9 @@ $i = 0; -
translate('Last Problem'); ?>translate('Last Problem'); ?> translate('Host Group'); ?> translate('Total Hosts'); ?> translate('Host States'); ?> + host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> + icon($this->resolveMacros($object->host_icon_image, $object)) ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index d59479e07..b6856609c 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -18,6 +18,9 @@ $i = 0; host_state, true); ?>
hostFlags($host)) ?> + host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> + icon($this->resolveMacros($host->host_icon_image, $host)) ?> + escape($host->getName()); ?>
escape($host->host_output) ?>
- escape($object->host_display_name); ?> + host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> + icon($this->resolveMacros($object->host_icon_image, $object)) ?> + + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -27,10 +30,13 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->service_last_state_change, true); ?> + service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)): ?> + icon($this->resolveMacros($object->service_icon_image, $object)) ?> + translate('Service'); ?>: escape($object->service_display_name); ?> - service_display_name !== $object->service_description): ?> - (escape($object->service_description); ?>) - + service_display_name !== $object->service_description): ?> + (escape($object->service_description); ?>) + render('partials/service/statusicons.phtml'); ?>
service_state, true); ?>
serviceFlags($service)) ?> + service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> + icon($this->resolveMacros($service->service_icon_image, $service)) ?> + escape($service->getName()); ?> translate('on') ?> diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 342e78812..2c01fe0eb 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -89,6 +89,7 @@ class Host extends MonitoredObject protected function getDataView() { $columns = array( + 'host_icon_image', 'host_acknowledged', 'host_action_url', 'host_active_checks_enabled', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 7c22ae57d..fec5de238 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -106,6 +106,7 @@ class Service extends MonitoredObject protected function getDataView() { return $this->backend->select()->from('serviceStatus', array( + 'host_icon_image', 'host_acknowledged', 'host_active_checks_enabled', 'host_address', @@ -118,6 +119,7 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_state', + 'service_icon_image', 'service_acknowledged', 'service_action_url', 'service_active_checks_enabled', From 6ba07b089ddd7b9c76730455a60e2733784bdcbe Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 17:31:17 +0200 Subject: [PATCH 259/298] Implement and use Hostgroupsummary and Servicegroupsummary refs #8241 --- .../application/controllers/ChartController.php | 4 ++-- .../application/controllers/ListController.php | 4 ++-- .../library/Monitoring/DataView/Groupsummary.php | 5 ----- .../library/Monitoring/DataView/Hostgroupsummary.php | 12 ++++++++++++ .../Monitoring/DataView/Servicegroupsummary.php | 12 ++++++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php create mode 100644 modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 39f60c304..d2e9f990c 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -163,7 +163,7 @@ class Monitoring_ChartController extends Controller public function hostgroupAction() { $query = $this->backend->select()->from( - 'groupsummary', + 'hostgroupsummary', array( 'hostgroup', 'hosts_up', @@ -194,7 +194,7 @@ class Monitoring_ChartController extends Controller public function servicegroupAction() { $query = $this->backend->select()->from( - 'groupsummary', + 'servicegroupsummary', array( 'servicegroup', 'services_ok', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index df5a10dee..01e2adc44 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -470,7 +470,7 @@ class Monitoring_ListController extends Controller ); $this->setAutorefreshInterval(12); - $query = $this->backend->select()->from('groupsummary', array( + $query = $this->backend->select()->from('servicegroupsummary', array( 'servicegroup_name', 'servicegroup_alias', 'hosts_up', @@ -521,7 +521,7 @@ class Monitoring_ListController extends Controller $this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups')); $this->setAutorefreshInterval(12); - $query = $this->backend->select()->from('groupsummary', array( + $query = $this->backend->select()->from('hostgroupsummary', array( 'hostgroup_name', 'hostgroup_alias', 'hosts_up', diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index d29c1c418..f823d00a4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -64,9 +64,4 @@ class Groupsummary extends DataView ) ); } - - public function getFilterColumns() - { - return array('hostgroup', 'servicegroup'); - } } diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php new file mode 100644 index 000000000..ba8e49987 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -0,0 +1,12 @@ + Date: Tue, 19 May 2015 17:50:07 +0200 Subject: [PATCH 260/298] Override ::getSearchColumns() refs #8241 --- .../monitoring/library/Monitoring/DataView/HostStatus.php | 8 ++++++++ .../library/Monitoring/DataView/Hostgroupsummary.php | 8 ++++++++ .../library/Monitoring/DataView/ServiceStatus.php | 8 ++++++++ .../library/Monitoring/DataView/Servicegroupsummary.php | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..eebe496a5 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -125,4 +125,12 @@ class HostStatus extends DataView } return parent::isValidFilterTarget($column); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('host', 'host_display_name'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index ba8e49987..b923b49e4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -9,4 +9,12 @@ class Hostgroupsummary extends Groupsummary { return array('hostgroup'); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('hostgroup', 'hostgroup_alias'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..ff57266a3 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -183,4 +183,12 @@ class ServiceStatus extends DataView } return parent::isValidFilterTarget($column); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('service', 'service_display_name'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 550f8744c..f21f49d3e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -9,4 +9,12 @@ class Servicegroupsummary extends Groupsummary { return array('servicegroup'); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('servicegroup', 'servicegroup_alias'); + } } From 0b937c86dc6e4956857cc2e812c72cf50976960a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 18:00:47 +0200 Subject: [PATCH 261/298] Get columns for FilterEditor::setSearchColumns() from DataView::getSearchColumns() refs #8241 --- .../controllers/ListController.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 01e2adc44..59fcd6f85 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -97,7 +97,7 @@ class Monitoring_ListController extends Controller 'host_current_check_attempt', 'host_max_check_attempts' ), $this->addColumns())); - $this->filterQuery($query, array('host', 'host_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); $this->view->hosts = $query; @@ -181,7 +181,7 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->addColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query, array('service', 'service_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); $this->view->services = $query; @@ -499,7 +499,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('servicegroup', 'servicegroup_alias')); + $this->filterQuery($query); $this->view->servicegroups = $query; $this->setupLimitControl(); @@ -556,7 +556,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('hostgroup', 'hostgroup_alias')); + $this->filterQuery($query); $this->view->hostgroups = $query; $this->setupLimitControl(); @@ -631,11 +631,10 @@ class Monitoring_ListController extends Controller * Apply filters on a DataView * * @param DataView $dataView The DataView to apply filters on - * @param array $searchColumns Columns to search in * * @return DataView $dataView */ - protected function filterQuery(DataView $dataView, array $searchColumns = null) + protected function filterQuery(DataView $dataView) { $editor = Widget::create('filterEditor') ->setQuery($dataView) @@ -643,11 +642,9 @@ class Monitoring_ListController extends Controller 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' ) - ->ignoreParams('page'); - if ($searchColumns !== null) { - $editor->setSearchColumns($searchColumns); - } - $editor->handleRequest($this->getRequest()); + ->ignoreParams('page') + ->setSearchColumns($dataView->getSearchColumns()) + ->handleRequest($this->getRequest()); $dataView->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); From 3a2238f737ca228a21d5a9225924a909f8658c5d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:12:18 +0200 Subject: [PATCH 262/298] Rename UrlParams::req() to ::getRequired() req() seems mysterious :) --- library/Icinga/Web/UrlParams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/UrlParams.php b/library/Icinga/Web/UrlParams.php index e25fa7e6c..df5162459 100644 --- a/library/Icinga/Web/UrlParams.php +++ b/library/Icinga/Web/UrlParams.php @@ -54,7 +54,7 @@ class UrlParams * * @throws MissingParameterException If the parameter was not given */ - public function req($name, $strict = true) + public function getRequired($name, $strict = true) { if ($this->has($name)) { $value = $this->get($name); From 3d1c3609c026b6f24c68230f236a7f01168d1a58 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:21:53 +0200 Subject: [PATCH 263/298] lib: Add UrlParams::shiftRequired() --- library/Icinga/Web/UrlParams.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/library/Icinga/Web/UrlParams.php b/library/Icinga/Web/UrlParams.php index df5162459..d97f83b39 100644 --- a/library/Icinga/Web/UrlParams.php +++ b/library/Icinga/Web/UrlParams.php @@ -138,6 +138,30 @@ class UrlParams return $ret; } + /** + * Require and remove a parameter + * + * @param string $name Name of the parameter + * @param bool $strict Whether the parameter's value must not be the empty string + * + * @return mixed + * + * @throws MissingParameterException If the parameter was not given + */ + public function shiftRequired($name, $strict = true) + { + if ($this->has($name)) { + $value = $this->get($name); + if (! $strict || strlen($value) > 0) { + $this->shift($name); + return $value; + } + } + $e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name); + $e->setParameter($name); + throw $e; + } + public function addEncoded($param, $value = true) { $this->params[] = array($param, $this->cleanupValue($value)); From ccaebd1d73e8ad7195e98ad159422c79da92f5bd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:22:23 +0200 Subject: [PATCH 264/298] cli: Rename Params::req() to ::getRequired() --- library/Icinga/Cli/Params.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Cli/Params.php b/library/Icinga/Cli/Params.php index 507c50e3b..d51e912e2 100644 --- a/library/Icinga/Cli/Params.php +++ b/library/Icinga/Cli/Params.php @@ -167,7 +167,7 @@ class Params * * @throws MissingParameterException If the parameter was not given */ - public function req($name, $strict = true) + public function getRequired($name, $strict = true) { if ($this->has($name)) { $value = $this->get($name); From 338fad5da95bbe4c5513ac899bf9b96a3f127aa4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:23:37 +0200 Subject: [PATCH 265/298] cli: Add Params::shiftRequired() --- library/Icinga/Cli/Params.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/library/Icinga/Cli/Params.php b/library/Icinga/Cli/Params.php index d51e912e2..9e30cf19e 100644 --- a/library/Icinga/Cli/Params.php +++ b/library/Icinga/Cli/Params.php @@ -258,6 +258,30 @@ class Params return $result; } + /** + * Require and remove a parameter + * + * @param string $name Name of the parameter + * @param bool $strict Whether the parameter's value must not be the empty string + * + * @return mixed + * + * @throws MissingParameterException If the parameter was not given + */ + public function shiftRequired($name, $strict = true) + { + if ($this->has($name)) { + $value = $this->get($name); + if (! $strict || strlen($value) > 0) { + $this->shift($name); + return $value; + } + } + $e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name); + $e->setParameter($name); + throw $e; + } + /** * Put the given value onto the argument stack * From 5a69c26d2cd3667ee7c4d535a92e11c4e261af21 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:24:05 +0200 Subject: [PATCH 266/298] Fix typo in PHPDoc of ConfirmRemovalForm::init() --- application/forms/ConfirmRemovalForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/ConfirmRemovalForm.php b/application/forms/ConfirmRemovalForm.php index 985413907..5d9ca86b4 100644 --- a/application/forms/ConfirmRemovalForm.php +++ b/application/forms/ConfirmRemovalForm.php @@ -11,7 +11,7 @@ use Icinga\Web\Form; class ConfirmRemovalForm extends Form { /** - * Initalize this form + * Initialize this form */ public function init() { From bd54784496d4d522d4693d3246d9f5e2d7ed19f3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:25:48 +0200 Subject: [PATCH 267/298] Don't override submit label in the ConfirmRemovalForm --- application/forms/ConfirmRemovalForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/ConfirmRemovalForm.php b/application/forms/ConfirmRemovalForm.php index 5d9ca86b4..357928cd0 100644 --- a/application/forms/ConfirmRemovalForm.php +++ b/application/forms/ConfirmRemovalForm.php @@ -16,6 +16,6 @@ class ConfirmRemovalForm extends Form public function init() { $this->setName('form_confirm_removal'); - $this->setSubmitLabel($this->translate('Confirm Removal')); + $this->getSubmitLabel() ?: $this->setSubmitLabel($this->translate('Confirm Removal')); } } From 902c00e836fad029ee2279f1712e31abf382779a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:29:34 +0200 Subject: [PATCH 268/298] lib: Introduce Controller::httpNotFound() Many actions require loading specific objects from database or any other storage. If the object isn't found, Controller::httpNotFound($message) should be used for immediately returning w/ HTTP 404. --- library/Icinga/Web/Controller.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 9acf17469..0975d4c13 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -3,6 +3,7 @@ namespace Icinga\Web; +use Zend_Controller_Action_Exception; use Icinga\Data\Sortable; use Icinga\Data\QueryInterface; use Icinga\Web\Controller\ModuleActionController; @@ -49,6 +50,18 @@ class Controller extends ModuleActionController } } + /** + * Immediately respond w/ HTTP 404 + * + * @param $message + * + * @throws Zend_Controller_Action_Exception + */ + public function httpNotFound($message) + { + throw new Zend_Controller_Action_Exception($message, 404); + } + /** * Create a SortBox widget and apply its sort rules on the given query * From 9b4f08eb433879f520dc7f93a4e205ae9bc631b5 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 20 May 2015 10:43:54 +0200 Subject: [PATCH 269/298] Implement classes HostgroupsummaryQuery and ServicegroupsummaryQuery Without this the Hostgroupsummary and Servicegroupsummary DataViews would not work refs #8241 --- .../Backend/Ido/Query/HostgroupsummaryQuery.php | 8 ++++++++ .../Backend/Ido/Query/ServicegroupsummaryQuery.php | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicegroupsummaryQuery.php diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php new file mode 100644 index 000000000..5711b88f5 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php @@ -0,0 +1,8 @@ + Date: Wed, 20 May 2015 13:48:51 +0200 Subject: [PATCH 270/298] Don't let a long plugin output make the whole container horizontally scrollable fixes #8941 --- public/css/icinga/monitoring-colors.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index ba0877232..020db57cd 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -23,7 +23,7 @@ table.action { border-collapse: separate; border-spacing: 1px; width: 100%; - table-layout: fixed; + table-layout: fixed !important; margin: 0; color: @colorTextDefault; } From 2493535ac77c1dac21549a240176191d18a58116 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:29:45 +0200 Subject: [PATCH 271/298] Revert "Implement classes HostgroupsummaryQuery and ServicegroupsummaryQuery" This reverts commit 9b4f08eb433879f520dc7f93a4e205ae9bc631b5. There's DataView::getQueryName() for this. refs #8241 --- .../Backend/Ido/Query/HostgroupsummaryQuery.php | 8 -------- .../Backend/Ido/Query/ServicegroupsummaryQuery.php | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php delete mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicegroupsummaryQuery.php diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php deleted file mode 100644 index 5711b88f5..000000000 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php +++ /dev/null @@ -1,8 +0,0 @@ - Date: Wed, 20 May 2015 15:37:24 +0200 Subject: [PATCH 272/298] monitoring: Use the groupsummary query for the host group summary view refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index b923b49e4..5383aae82 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -17,4 +17,12 @@ class Hostgroupsummary extends Groupsummary { return array('hostgroup', 'hostgroup_alias'); } + + /** + * {@inheritdoc} + */ + public static function getQueryName() + { + return 'groupsummary'; + } } From 5efbad3a714b9c4424796b0408874b662b479186 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:38:48 +0200 Subject: [PATCH 273/298] monitoring: Don't sort the host group summary by service severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 59fcd6f85..5905e77a2 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -553,7 +553,7 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - ))->order('services_severity')->order('hostgroup_alias'); + ))->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); From d379b27c245523a39813f8c06bb025fc87175518 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:40:49 +0200 Subject: [PATCH 274/298] monitoring: Hostgroupsummary must not extend Groupsummary which is subject to remove refs #8241 --- .../Monitoring/DataView/Hostgroupsummary.php | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 5383aae82..e4d91b74d 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -3,8 +3,46 @@ namespace Icinga\Module\Monitoring\DataView; -class Hostgroupsummary extends Groupsummary +/** + * Data view for the host group summary + */ +class Hostgroupsummary extends DataView { + /** + * {@inheritdoc} + */ + public function getColumns() + { + return array( + 'hostgroup_alias', + 'hostgroup_name', + 'hosts_down_handled', + 'hosts_down_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_down_unhandled', + 'hosts_pending', + 'hosts_pending_last_state_change', + 'hosts_unreachable_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_unreachable_last_state_change_unhandled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'hosts_up_last_state_change', + 'services_critical_handled', + 'services_critical_unhandled', + 'services_ok', + 'services_pending', + 'services_total', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_unhandled' + ); + } + + /** + * {@inheritdoc} + */ public function getFilterColumns() { return array('hostgroup'); From 2dc6d5467d68a02dd0ae38bf80f4f3aeef2b41d0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:06:45 +0200 Subject: [PATCH 275/298] monitoring: Don't select unnecessary columns in the host group summary refs #8241 --- .../controllers/ListController.php | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 5905e77a2..536fa3ecf 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -522,37 +522,29 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('hostgroupsummary', array( - 'hostgroup_name', 'hostgroup_alias', - 'hosts_up', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', + 'hostgroup_name', 'hosts_down_handled', + 'hosts_down_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', 'hosts_down_unhandled', 'hosts_pending', - 'hosts_up_last_state_change', 'hosts_pending_last_state_change', - 'hosts_down_last_state_change_handled', + 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', - 'hosts_down_last_state_change_unhandled', 'hosts_unreachable_last_state_change_unhandled', - 'services_ok', - 'services_unknown_handled', - 'services_unknown_unhandled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'hosts_up_last_state_change', 'services_critical_handled', 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', + 'services_ok', 'services_pending', - 'services_ok_last_state_change', - 'services_pending_last_state_change', - 'services_warning_last_state_change_handled', - 'services_critical_last_state_change_handled', - 'services_unknown_last_state_change_handled', - 'services_warning_last_state_change_unhandled', - 'services_critical_last_state_change_unhandled', - 'services_unknown_last_state_change_unhandled', - 'services_total' + 'services_total', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_unhandled' ))->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. From a9d6a949571b0951595aa4ec2121e95281300510 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:09:30 +0200 Subject: [PATCH 276/298] monitoring: Use the groupsummary query for the service group summary view refs #8241 --- .../Monitoring/DataView/Servicegroupsummary.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index f21f49d3e..1b96e0788 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -5,11 +5,22 @@ namespace Icinga\Module\Monitoring\DataView; class Servicegroupsummary extends Groupsummary { + /** + * {@inheritdoc} + */ public function getFilterColumns() { return array('servicegroup'); } + /** + * {@inheritdoc} + */ + public static function getQueryName() + { + return 'groupsummary'; + } + /** * {@inheritdoc} */ From f9952cf231253af8c0e96d973a1a2fb1ab845958 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:15:38 +0200 Subject: [PATCH 277/298] monitoring: Don't sort the service group summary by service severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 536fa3ecf..8e45f497e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -496,7 +496,7 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - ))->order('services_severity')->order('servicegroup_alias'); + ))->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); From 80b174f526538d2fc28cf3a01d18a6c6bc90184a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:16:21 +0200 Subject: [PATCH 278/298] monitoring: Servicegroupsummary must not extend Groupsummary which is subject to remove refs #8241 --- .../DataView/Servicegroupsummary.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 1b96e0788..3633248f4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -3,8 +3,42 @@ namespace Icinga\Module\Monitoring\DataView; -class Servicegroupsummary extends Groupsummary +class Servicegroupsummary extends DataView { + /** + * {@inheritdoc} + */ + public function getColumns() + { + return array( + 'hosts_down_handled', + 'hosts_down_unhandled', + 'hosts_pending', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'servicegroup_alias', + 'servicegroup_name', + 'services_critical_handled', + 'services_critical_last_state_change_handled', + 'services_critical_last_state_change_unhandled', + 'services_critical_unhandled', + 'services_ok', + 'services_ok_last_state_change', + 'services_pending', + 'services_pending_last_state_change', + 'services_total', + 'services_unknown_handled', + 'services_unknown_last_state_change_handled', + 'services_unknown_last_state_change_unhandled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_last_state_change_handled', + 'services_warning_last_state_change_unhandled', + 'services_warning_unhandled' + ); + } + /** * {@inheritdoc} */ From cfb819ec61bf398333a2b41eb4693421ab8661d5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 17:03:23 +0200 Subject: [PATCH 279/298] monitoring: Add missing column to the host group summary data view refs #8241 --- .../monitoring/library/Monitoring/DataView/Hostgroupsummary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index e4d91b74d..81725595a 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -22,6 +22,7 @@ class Hostgroupsummary extends DataView 'hosts_down_unhandled', 'hosts_pending', 'hosts_pending_last_state_change', + 'hosts_total', 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', 'hosts_unreachable_last_state_change_unhandled', From ce463d16ef1f5c5737aa74e38de0d954ea92ce65 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:19:58 +0200 Subject: [PATCH 280/298] Reorder group summary query's columns by name refs #8241 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 392c97538..3418e1b2f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -5,12 +5,19 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; use Zend_Db_Select; +/** + * Query for host and service group summaries + */ class GroupSummaryQuery extends IdoQuery { - protected $useSubqueryCount = true; - + /** + * {@inheritdoc} + */ protected $columnMap = array( 'hoststatussummary' => array( + 'hostgroup' => 'hostgroup', + 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup_name' => 'hostgroup_name', 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', @@ -18,46 +25,51 @@ class GroupSummaryQuery extends IdoQuery 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', - 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)', 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', - 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', - 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', - 'hostgroup_name' => 'hostgroup_name', - 'hostgroup_alias' => 'hostgroup_alias', - 'hostgroup' => 'hostgroup' + 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' ), 'servicestatussummary' => array( - 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', - 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', - 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', - 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', - 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'servicegroup' => 'servicegroup', + 'servicegroup_alias' => 'servicegroup_alias', + 'servicegroup_name' => 'servicegroup_name', 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_critical_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', + 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', + 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', + 'services_ok_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)', + 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', + 'services_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)', + 'services_severity' => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)', + 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', 'services_unknown' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 THEN 1 ELSE 0 END)', 'services_unknown_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', - 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_severity' => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)', - 'services_ok_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)', - 'services_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)', - 'services_warning_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', - 'services_critical_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', - 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'servicegroup_name' => 'servicegroup_name', - 'servicegroup_alias' => 'servicegroup_alias', - 'servicegroup' => 'servicegroup' + 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', + 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_warning_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', + 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', + 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)' ) ); + /** + * {@inheritdoc} + */ + protected $useSubqueryCount = true; + + /** + * {@inheritdoc} + */ protected function joinBaseTables() { $columns = array( @@ -79,11 +91,11 @@ class GroupSummaryQuery extends IdoQuery $hosts = $this->createSubQuery( 'Hoststatus', $columns + array( - 'state' => 'host_state', - 'acknowledged' => 'host_acknowledged', - 'in_downtime' => 'host_in_downtime', - 'state_change' => 'host_last_state_change', - 'severity' => 'host_severity' + 'state' => 'host_state', + 'acknowledged' => 'host_acknowledged', + 'in_downtime' => 'host_in_downtime', + 'state_change' => 'host_last_state_change', + 'severity' => 'host_severity' ) ); if (in_array('servicegroup_name', $this->desiredColumns)) { @@ -101,11 +113,11 @@ class GroupSummaryQuery extends IdoQuery $services = $this->createSubQuery( 'Status', $columns + array( - 'state' => 'service_state', - 'acknowledged' => 'service_acknowledged', - 'in_downtime' => 'service_in_downtime', - 'state_change' => 'service_last_state_change', - 'severity' => 'service_severity' + 'state' => 'service_state', + 'acknowledged' => 'service_acknowledged', + 'in_downtime' => 'service_in_downtime', + 'state_change' => 'service_last_state_change', + 'severity' => 'service_severity' ) ); $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); From bbed2cffae334d95301f12b9d8c91fdf8aec0bb4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:23:55 +0200 Subject: [PATCH 281/298] monitoring: Add column hosts_severity to the group summary query refs #8241 --- .../library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 3418e1b2f..df1a38d88 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -18,7 +18,6 @@ class GroupSummaryQuery extends IdoQuery 'hostgroup' => 'hostgroup', 'hostgroup_alias' => 'hostgroup_alias', 'hostgroup_name' => 'hostgroup_name', - 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', @@ -30,6 +29,8 @@ class GroupSummaryQuery extends IdoQuery 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', + 'hosts_severity' => 'MAX(CASE WHEN object_type = \'host\' THEN severity ELSE 0 END)', + 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' From 37abc724de21b38f4f1156ae2ba36cb9dc51c449 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:24:31 +0200 Subject: [PATCH 282/298] monitoring: Let the host group summary provide the column hosts_severity refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 81725595a..a2c1dfd7a 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -22,6 +22,7 @@ class Hostgroupsummary extends DataView 'hosts_down_unhandled', 'hosts_pending', 'hosts_pending_last_state_change', + 'hosts_severity', 'hosts_total', 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', @@ -52,16 +53,16 @@ class Hostgroupsummary extends DataView /** * {@inheritdoc} */ - public function getSearchColumns() + public static function getQueryName() { - return array('hostgroup', 'hostgroup_alias'); + return 'groupsummary'; } /** * {@inheritdoc} */ - public static function getQueryName() + public function getSearchColumns() { - return 'groupsummary'; + return array('hostgroup', 'hostgroup_alias'); } } From a52264aa3212c6f61c1391676230ba254a999783 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:26:10 +0200 Subject: [PATCH 283/298] monitoring: Sort by hosts_severity when sorting the host group summary by severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 5e05de83b..a21edbbda 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -554,7 +554,7 @@ class Monitoring_ListController extends Controller $this->setupLimitControl(); $this->setupPaginationControl($this->view->hostgroups); $this->setupSortControl(array( - 'services_severity' => $this->translate('Severity'), + 'hosts_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), 'services_total' => $this->translate('Total Services'), 'services_ok' => $this->translate('Services OK'), From ee6c669441ce8a8d34a269a8f7c7dfc76efaafda Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 21 May 2015 11:40:08 +0200 Subject: [PATCH 284/298] Deduplicate code and fix layout Move icon rendering code into a separate for better maintainabillity. refs #8665 --- .../controllers/ServicesController.php | 2 + .../application/views/helpers/IconImage.php | 46 +++++++++++++++++++ .../views/scripts/list/hosts.phtml | 6 +-- .../views/scripts/list/services.phtml | 6 +-- .../scripts/partials/host/object-header.phtml | 6 +-- .../partials/host/objects-header.phtml | 4 +- .../partials/service/object-header.phtml | 8 +--- .../partials/service/objects-header.phtml | 4 +- 8 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 modules/monitoring/application/views/helpers/IconImage.php diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index ca9788ff2..6877aca02 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -50,6 +50,7 @@ class Monitoring_ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $this->serviceList->setColumns(array( + 'host_icon_image', 'host_name', 'host_output', 'host_state', @@ -94,6 +95,7 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; $this->serviceList->setColumns(array( + 'host_icon_image', 'host_name', 'host_output', 'host_state', diff --git a/modules/monitoring/application/views/helpers/IconImage.php b/modules/monitoring/application/views/helpers/IconImage.php new file mode 100644 index 000000000..2ed3b1d25 --- /dev/null +++ b/modules/monitoring/application/views/helpers/IconImage.php @@ -0,0 +1,46 @@ +host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)) { + return $this->view->icon($this->view->resolveMacros($object->host_icon_image, $object)); + } + return ''; + } + + /** + * Display the image_icon of a MonitoredObject + * + * @param MonitoredObject|stdClass $object The host or service + * @return string + */ + public function service($object) + { + if ($object->service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)) { + return $this->view->icon($this->view->resolveMacros($object->service_icon_image, $object)); + } + return ''; + } +} diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 89c2e7d26..a83f3bb8a 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -52,9 +52,7 @@ if (count($hosts) === 0) { - host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> - icon($this->resolveMacros($host->host_icon_image, $host)) ?> - + iconImage()->host($host) ?> hostFlags($host)) ?> qlink( $host->host_display_name, @@ -75,7 +73,7 @@ if (count($hosts) === 0) { 'host' => $host->host_name, 'service_problem' => 1, 'service_handled' => 0 - ), + ), array( 'style' => 'font-weight: normal', 'title' => sprintf( diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 12ba232cc..964a0e982 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -58,12 +58,8 @@ if (count($services) === 0) {
perfdata($service->service_perfdata, true, 8) ?>
- + iconImage()->service($service) ?> serviceFlags($service)); ?> - - service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> - icon($this->resolveMacros($service->service_icon_image, $service)) ?> - qlink( $service->service_display_name, $serviceLink, diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 127f492e6..ed7edae79 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -9,9 +9,7 @@ use Icinga\Module\Monitoring\Object\Host; prefixedTimeSince($object->host_last_state_change, true); ?>
- host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> - icon($this->resolveMacros($object->host_icon_image, $object)) ?> - + iconImage()->host($object) ?> escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -23,4 +21,4 @@ use Icinga\Module\Monitoring\Object\Host; render('partials/host/statusicons.phtml'); ?>
\ No newline at end of file +

diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index b6856609c..bce62db6b 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -17,10 +17,8 @@ $i = 0;
host_state, true); ?>
+ iconImage()->host($host) ?> hostFlags($host)) ?> - host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> - icon($this->resolveMacros($host->host_icon_image, $host)) ?> - escape($host->getName()); ?>
escape($host->host_output) ?>
- host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> - icon($this->resolveMacros($object->host_icon_image, $object)) ?> - + iconImage()->service($object) ?> escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -30,9 +28,7 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->service_last_state_change, true); ?> - service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)): ?> - icon($this->resolveMacros($object->service_icon_image, $object)) ?> - + iconImage()->host($object) ?> translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index fe1e4b16a..176c43d92 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -15,10 +15,8 @@ $i = 0;
service_state, true); ?>
+ iconImage()->service($service) ?> serviceFlags($service)) ?> - service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> - icon($this->resolveMacros($service->service_icon_image, $service)) ?> - escape($service->getName()); ?> translate('on') ?> From 82f9425b904f8567b373b56056669c32806fa6af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:01:58 +0200 Subject: [PATCH 285/298] Revert "Make ascending sort by host or service severity initiatable" This reverts commit 386d4db851aed056652d892d539de35b403c5062. The commit introduced the bug that changing the sort direction no longer changed the sort direction :) refs #9059 --- .../library/Monitoring/DataView/DataView.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 8212d7bb7..5175c4481 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -247,11 +247,11 @@ abstract class DataView implements QueryInterface, IteratorAggregate }; } - $globalDefaultOrder = isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC; - $globalDefaultOrder = (strtoupper($globalDefaultOrder) === static::SORT_ASC) ? 'ASC' : 'DESC'; + $order = $order === null ? (isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC) : $order; + $order = (strtoupper($order) === static::SORT_ASC) ? 'ASC' : 'DESC'; foreach ($sortColumns['columns'] as $column) { - list($column, $specificDefaultOrder) = $this->query->splitOrder($column); + list($column, $direction) = $this->query->splitOrder($column); if (! $this->isValidFilterTarget($column)) { throw new QueryException( mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), @@ -259,10 +259,7 @@ abstract class DataView implements QueryInterface, IteratorAggregate get_class($this) ); } - $this->query->order( - $column, - $order === null && $specificDefaultOrder !== null ? $specificDefaultOrder : $globalDefaultOrder - ); + $this->query->order($column, $direction !== null ? $direction : $order); } $this->isSorted = true; return $this; From 195275a716be571bb2c94cf868c3f7364fe0ecfb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:17:25 +0200 Subject: [PATCH 286/298] monitoring: Don't hardcode sort direction of the severity columns fixes #9059 --- .../library/Monitoring/DataView/HostStatus.php | 5 +++-- .../library/Monitoring/DataView/ServiceStatus.php | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..31daabf65 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -94,10 +94,11 @@ class HostStatus extends DataView ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', + 'host_severity', 'host_last_state_change DESC', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_address' => array( 'columns' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..40096ee02 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -130,19 +130,21 @@ class ServiceStatus extends DataView ), 'service_severity' => array( 'columns' => array( - 'service_severity DESC', + 'service_severity', 'service_last_state_change DESC', 'service_display_name ASC', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', + 'host_severity', 'host_last_state_change DESC', 'host_display_name ASC', 'service_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_display_name' => array( 'columns' => array( From 58b3192ce3a48193b78736356d8b23254e10ee77 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:26:27 +0200 Subject: [PATCH 287/298] monitoring: Add sort rules to the host group summary refs #8241 --- .../Monitoring/DataView/Hostgroupsummary.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index a2c1dfd7a..0a5ec184e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -65,4 +65,30 @@ class Hostgroupsummary extends DataView { return array('hostgroup', 'hostgroup_alias'); } + + /** + * {@inheritdoc} + */ + public function getSortRules() + { + return array( + 'hostgroup_alias' => array( + 'order' => self::SORT_ASC + ), + 'hosts_severity' => array( + 'columns' => array( + 'hosts_severity', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_DESC + ), + 'hosts_total' => array( + 'columns' => array( + 'hosts_total', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_ASC + ) + ); + } } From 4b9f7eb910b7ffab89b4810b3d4e3922f5c92ba3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:36:05 +0200 Subject: [PATCH 288/298] monitoring: Default to the sort rules of the host group summary refs #8241 --- modules/monitoring/application/controllers/ListController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a21edbbda..d3d573389 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -545,9 +545,7 @@ class Monitoring_ListController extends Controller 'services_unknown_unhandled', 'services_warning_handled', 'services_warning_unhandled' - ))->order('hostgroup_alias'); - // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and - // service groups. We should separate them. + )); $this->filterQuery($query); $this->view->hostgroups = $query; From 73eb8cc805617e84dd4797369a4abd22e1e38b9a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:37:53 +0200 Subject: [PATCH 289/298] monitoring: Add sort rule for total services to the host group summary refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 0a5ec184e..63c04df79 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -88,6 +88,13 @@ class Hostgroupsummary extends DataView 'hostgroup_alias ASC' ), 'order' => self::SORT_ASC + ), + 'services_total' => array( + 'columns' => array( + 'services_total', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_ASC ) ); } From 89bac33595ec22c417472f7fbe0ac44bf541ff7d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:38:20 +0200 Subject: [PATCH 290/298] monitoring: Fix sort control columns for the host group summary refs #8241 --- .../monitoring/application/controllers/ListController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index d3d573389..be3139b72 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -554,12 +554,8 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'hosts_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), - 'services_total' => $this->translate('Total Services'), - 'services_ok' => $this->translate('Services OK'), - 'services_unknown' => $this->translate('Services UNKNOWN'), - 'services_critical' => $this->translate('Services CRITICAL'), - 'services_warning' => $this->translate('Services WARNING'), - 'services_pending' => $this->translate('Services PENDING') + 'hosts_total' => $this->translate('Total Hosts'), + 'services_total' => $this->translate('Total Services') ), $query); } From e7396ea49cb853348e2d638816a58e55f84bff6f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:38:58 +0200 Subject: [PATCH 291/298] monitoring: Add services_severity to the service group summary data view refs #8241 --- .../library/Monitoring/DataView/Servicegroupsummary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 3633248f4..c9f60f75c 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -27,6 +27,7 @@ class Servicegroupsummary extends DataView 'services_ok_last_state_change', 'services_pending', 'services_pending_last_state_change', + 'services_severity', 'services_total', 'services_unknown_handled', 'services_unknown_last_state_change_handled', From 1a1f93db23d1b27907add455a3f8a75ff2c21fc4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:41:29 +0200 Subject: [PATCH 292/298] monitoring: Add sort rules to the service group summary refs #8241 --- .../DataView/Servicegroupsummary.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index c9f60f75c..11d6ec07e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -63,4 +63,30 @@ class Servicegroupsummary extends DataView { return array('servicegroup', 'servicegroup_alias'); } + + /** + * {@inheritdoc} + */ + public function getSortRules() + { + return array( + 'servicegroup_alias' => array( + 'order' => self::SORT_ASC + ), + 'services_severity' => array( + 'columns' => array( + 'services_severity', + 'servicegroup_alias ASC' + ), + 'order' => self::SORT_DESC + ), + 'services_total' => array( + 'columns' => array( + 'services_total', + 'servicegroup_alias ASC' + ), + 'order' => self::SORT_ASC + ) + ); + } } From 0db7cfca885ae7cc0da78cd8574e28547a292328 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:41:59 +0200 Subject: [PATCH 293/298] monitoring: Default to the sort rules of the service group summary refs #8241 --- .../controllers/ListController.php | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index be3139b72..dc82fcf65 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -470,34 +470,32 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('servicegroupsummary', array( - 'servicegroup_name', - 'servicegroup_alias', - 'hosts_up', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', - 'services_ok', - 'services_unknown_handled', - 'services_unknown_unhandled', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'servicegroup_alias', + 'servicegroup_name', 'services_critical_handled', - 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', - 'services_pending', - 'services_ok_last_state_change', - 'services_pending_last_state_change', - 'services_warning_last_state_change_handled', 'services_critical_last_state_change_handled', - 'services_unknown_last_state_change_handled', - 'services_warning_last_state_change_unhandled', 'services_critical_last_state_change_unhandled', + 'services_critical_unhandled', + 'services_ok', + 'services_ok_last_state_change', + 'services_pending', + 'services_pending_last_state_change', + 'services_total', + 'services_unknown_handled', + 'services_unknown_last_state_change_handled', 'services_unknown_last_state_change_unhandled', - 'services_total' - ))->order('servicegroup_alias'); - // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and - // service groups. We should separate them. + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_last_state_change_handled', + 'services_warning_last_state_change_unhandled', + 'services_warning_unhandled' + )); $this->filterQuery($query); $this->view->servicegroups = $query; From e0c6ce58c393ca47327cfde1232b7796dc303db8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:42:53 +0200 Subject: [PATCH 294/298] monitoring: Fix sort control columns for the service group summary refs #8241 --- .../monitoring/application/controllers/ListController.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index dc82fcf65..c08acf2ad 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -504,12 +504,7 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'servicegroup_alias' => $this->translate('Service Group Name'), - 'services_total' => $this->translate('Total Services'), - 'services_ok' => $this->translate('Services OK'), - 'services_unknown' => $this->translate('Services UNKNOWN'), - 'services_critical' => $this->translate('Services CRITICAL'), - 'services_warning' => $this->translate('Services WARNING'), - 'services_pending' => $this->translate('Services PENDING') + 'services_total' => $this->translate('Total Services') ), $query); } From ad5ab16b3f175a6e93553551f03c4c438b2e1710 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:43:27 +0200 Subject: [PATCH 295/298] monitoring: Drop the Groupsummary data view We have Hostgroupsummary and Servicegroupsummary now. refs #8241 --- .../Monitoring/DataView/Groupsummary.php | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/DataView/Groupsummary.php diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php deleted file mode 100644 index d27bf9ee8..000000000 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ /dev/null @@ -1,68 +0,0 @@ - array( - 'columns' => array('services_severity'), - 'order' => self::SORT_DESC - ) - ); - } -} From 0c72686ba12dd280d86aee849a2f6e3199195791 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:46:47 +0200 Subject: [PATCH 296/298] monitoring: Make display_name columns case insensitive The display_name columns should be case insenstive because we now support them when searching. refs #8241 --- .../library/Monitoring/Backend/Ido/Query/HoststatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 23a8b585a..5d32550e7 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -11,7 +11,7 @@ class HoststatusQuery extends IdoQuery 'hosts' => array( 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_name' => 'ho.name1 COLLATE latin1_general_ci', - 'host_display_name' => 'h.display_name', + 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 17a12259e..a070c983c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -36,7 +36,7 @@ class StatusQuery extends IdoQuery 'hosts' => array( 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_name' => 'ho.name1', - 'host_display_name' => 'h.display_name', + 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', @@ -174,7 +174,7 @@ class StatusQuery extends IdoQuery 'service_host_name' => 'so.name1', 'service' => 'so.name2 COLLATE latin1_general_ci', 'service_description' => 'so.name2', - 'service_display_name' => 's.display_name', + 'service_display_name' => 's.display_name COLLATE latin1_general_ci', 'service_icon_image' => 's.icon_image', 'service_action_url' => 's.action_url', 'service_notes_url' => 's.notes_url', From 57328aa6ed5f2e1b1d173430eb7cc44f1fda9040 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 13:58:54 +0200 Subject: [PATCH 297/298] monitoring: Make host group and service group alias columns case insensitive The alias columns should be case insenstive because we now support them when searching. refs #8241 --- .../Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 8 ++++---- .../Monitoring/Backend/Ido/Query/HoststatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index df1a38d88..da33c2bc6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -15,8 +15,8 @@ class GroupSummaryQuery extends IdoQuery */ protected $columnMap = array( 'hoststatussummary' => array( - 'hostgroup' => 'hostgroup', - 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup' => 'hostgroup COLLATE latin1_general_ci', + 'hostgroup_alias' => 'hostgroup_alias COLLATE latin1_general_ci', 'hostgroup_name' => 'hostgroup_name', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', @@ -36,8 +36,8 @@ class GroupSummaryQuery extends IdoQuery 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' ), 'servicestatussummary' => array( - 'servicegroup' => 'servicegroup', - 'servicegroup_alias' => 'servicegroup_alias', + 'servicegroup' => 'servicegroup COLLATE latin1_general_ci', + 'servicegroup_alias' => 'servicegroup_alias COLLATE latin1_general_ci', 'servicegroup_name' => 'servicegroup_name', 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 5d32550e7..ec9e6bd32 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -85,7 +85,7 @@ class HoststatusQuery extends IdoQuery 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup_name' => 'hgo.name1', - 'hostgroup_alias' => 'hg.alias' + 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci' ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index a070c983c..84a7b64f1 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -162,12 +162,12 @@ class StatusQuery extends IdoQuery 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup_name' => 'hgo.name1', - 'hostgroup_alias' => 'hg.alias' + 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci' ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', 'servicegroup_name' => 'sgo.name1', - 'servicegroup_alias' => 'sg.alias' + 'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci' ), 'services' => array( 'service_host' => 'so.name1 COLLATE latin1_general_ci', From c47465a7329afaa32f57dd51103298b5057f4e71 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 14:04:04 +0200 Subject: [PATCH 298/298] lib/filter: Fix check against unset search columns refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 07640872b..2d64e4c2b 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -216,7 +216,7 @@ class FilterEditor extends AbstractWidget $filter = $this->getFilter(); if ($search !== null) { - if ($this->searchColumns === null) { + if (empty($this->searchColumns)) { if (strpos($search, '=') === false) { Notification::error(mt('monitoring', 'Cannot search here')); return $this;