From 317bb2485612af590f1c4b031062c5c596f75258 Mon Sep 17 00:00:00 2001
From: Eric Lippmann <eric.lippmann@netways.de>
Date: Tue, 10 Nov 2015 16:54:02 +0100
Subject: [PATCH] monitoring: Reduce header size for multiple selected hosts

refs #5543
---
 .../controllers/HostsController.php           | 41 ++++------
 .../partials/host/objects-header.phtml        | 81 +++++++++----------
 2 files changed, 53 insertions(+), 69 deletions(-)

diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php
index bffbecc05..487f7246b 100644
--- a/modules/monitoring/application/controllers/HostsController.php
+++ b/modules/monitoring/application/controllers/HostsController.php
@@ -52,21 +52,18 @@ class HostsController extends Controller
     protected function handleCommandForm(ObjectsCommandForm $form)
     {
         $this->hostList->setColumns(array(
-            'host_icon_image',
-            'host_icon_image_alt',
-            'host_name',
-            'host_address',
-            'host_address6',
-            'host_state',
-            'host_problem',
-            'host_handled',
             'host_acknowledged',
+            'host_active_checks_enabled',
+            'host_display_name',
+            'host_handled',
             'host_in_downtime',
             'host_is_flapping',
-            'host_output',
+            'host_last_state_change',
+            'host_name',
             'host_notifications_enabled',
-            'host_active_checks_enabled',
-            'host_passive_checks_enabled'
+            'host_passive_checks_enabled',
+            'host_problem',
+            'host_state'
         ));
 
         $form
@@ -90,24 +87,18 @@ class HostsController extends Controller
             ->handleRequest();
         $this->view->checkNowForm = $checkNowForm;
         $this->hostList->setColumns(array(
-            'host_icon_image',
-            'host_icon_image_alt',
-            'host_name',
-            'host_address',
-            'host_address6',
-            'host_state',
-            'host_problem',
-            'host_handled',
             'host_acknowledged',
+            'host_active_checks_enabled',
+            'host_display_name',
+            'host_handled',
             'host_in_downtime',
             'host_is_flapping',
-            'host_output',
+            'host_last_state_change',
+            'host_name',
             'host_notifications_enabled',
-            'host_active_checks_enabled',
-            'host_passive_checks_enabled'
-            /*'host_event_handler_enabled',
-            'host_flap_detection_enabled',
-            'host_obsessing'*/
+            'host_passive_checks_enabled',
+            'host_problem',
+            'host_state'
         ));
 
         $acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
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 0a3fdbaf6..720e2de40 100644
--- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml
+++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml
@@ -1,48 +1,41 @@
 <?php
 use Icinga\Module\Monitoring\Object\Host;
 
-$i = 0;
-?>
-
-<?php if (($hostCount = count($objects)) > 0): ?>
-    <table class="action state statesummary">
-        <tbody>
-        <?php foreach ($objects as $host): /** @var Host $host */ ?>
-            <?php
-            if (++ $i > 5) {
-                continue;
-            }
-            ?>
-
-            <tr>
-                <td class="state-col state-<?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
-                    <?= Host::getStateText($host->host_state, true); ?>
-                    <br />
-                </td>
-                <td>
-                <?= $this->iconImage()->host($host) ?>
-                <?= implode(' ', $this->hostFlags($host)) ?>
-                <b><?= $this->escape($host->getName()); ?></b><br>
-                <?= $this->escape($host->host_output) ?>
-                </td>
-            </tr>
-        <?php endforeach ?>
-    </tbody>
-    </table>
-    <div class="hbox-item multi-commands">
-        <?php if ($i > 5): ?>
-        <?=
-        $this->qlink(
-            sprintf($this->translate('show all %d hosts'), $i),
-            $listAllLink,
-            null,
-            array(
-                'icon' => 'down-open',
-                'data-base-target' => '_next'
-            )
-        );
-        ?>
-        <?php endif ?>
-    </div>
+if (! ($hostCount = count($objects))): return; endif ?>
+<table class="state-table">
+<tbody>
+<?php foreach ($objects as $i => $host): /** @var Host $host */
+    if ($i === 5) {
+        break;
+    } ?>
+    <tr>
+        <td class="state-col state-<?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
+            <span class="sr-only"><?= Host::getStateText($host->host_state) ?></span>
+            <div class="state-meta">
+                <?= $this->timeSince($host->host_last_state_change, $this->compact) ?>
+            </div>
+        </td>
+        <td>
+            <?= $this->link()->host(
+                $host->host_name,
+                $host->host_display_name
+            ) ?>
+            <?= implode(' ', $this->hostFlags($host)) ?>
+        </td>
+    </tr>
+<?php endforeach ?>
+</tbody>
+</table>
+<?php if ($hostCount > 5): ?>
+<div class="hosts-link">
+    <?= $this->qlink(
+        sprintf($this->translate('List all %d hosts'), $hostCount),
+        $this->url()->setPath('monitoring/list/hosts'),
+        null,
+        array(
+            'data-base-target'  => '_next',
+            'icon'              => 'forward'
+        )
+    ) ?>
+</div>
 <?php endif ?>
-