From 5f19ec1b2e5d02325268da114ca903f5d140bf80 Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@netways.de>
Date: Fri, 17 Apr 2015 16:13:22 +0200
Subject: [PATCH] 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 @@
 <?php
-
 use Icinga\Module\Monitoring\Object\Host;
 use Icinga\Module\Monitoring\Object\Service;
 
-?>
-
-<?php if (false === $this->compact): ?>
+if (! $this->compact): ?>
 <div class="controls">
-  <?= $this->tabs->render($this); ?>
-  <div style="margin: 1em" class="dontprint">
-    <?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
-    <?php if (! $this->filterEditor): ?>
-        <?= $this->filterPreview ?>
-    <?php endif; ?>
-  </div>
-  <?= $this->widget('limiter', array('url' => $this->url, 'max' => $downtimes->count())); ?>
-  <?= $this->paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?>
+  <?= $this->tabs; ?>
+  <?= $this->sortBox; ?>
+  <?= $this->limiter; ?>
+  <?= $this->paginator; ?>
+  <?= $this->filterEditor; ?>
 </div>
 <?php endif ?>
-
 <div class="content">
-<?= $this->filterEditor ?>
-<?php if (count($downtimes) === 0): ?>
-  <?= $this->translate('No active downtimes'); ?>
-</div>
-<?php return; endif ?>
+<?php
+
+if (count($downtimes) === 0) {
+    echo $this->translate('No downtimes found matching the filter') . '</div>';
+    return;
+}
+?>
 
   <table data-base-target="_next" class="action">
     <tbody>