Merge branch 'feature/show-icon-images-in-detail-view-8665'

fixes #8665
This commit is contained in:
Matthias Jentsch 2015-05-21 11:42:57 +02:00
commit 87a46ea5b1
11 changed files with 68 additions and 14 deletions

View File

@ -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',

View File

@ -50,11 +50,13 @@ class Monitoring_ServicesController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->serviceList->setColumns(array(
'host_icon_image',
'host_name',
'host_output',
'host_state',
'host_problem',
'host_handled',
'service_icon_image',
'service_description',
'service_state',
'service_problem',
@ -93,11 +95,13 @@ class Monitoring_ServicesController extends Controller
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$this->serviceList->setColumns(array(
'host_icon_image',
'host_name',
'host_output',
'host_state',
'host_problem',
'host_handled',
'service_icon_image',
'service_output',
'service_description',
'service_state',

View File

@ -0,0 +1,46 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
/**
* Generate icons to describe a given hosts state
*/
class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract
{
/**
* Create dispatch instance
*
* @return \Zend_View_Helper_IconImage
*/
public function iconImage()
{
return $this;
}
/**
* Display the image_icon of a MonitoredObject
*
* @param MonitoredObject|stdClass $object The host or service
* @return string
*/
public function host($object)
{
if ($object->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 '';
}
}

View File

@ -52,9 +52,7 @@ if (count($hosts) === 0) {
<!-- Host / Status / Output -->
<td>
<?php if ($host->host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?>
<?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?>
<?php endif ?>
<?= $this->iconImage()->host($host) ?>
<?= implode(' ', $this->hostFlags($host)) ?>
<?= $this->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(

View File

@ -58,12 +58,8 @@ if (count($services) === 0) {
<td>
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?> </div>
<?= $this->iconImage()->service($service) ?>
<?= implode(' ', $this->serviceFlags($service)); ?>
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?php endif ?>
<?= $this->qlink(
$service->service_display_name,
$serviceLink,

View File

@ -9,6 +9,7 @@ use Icinga\Module\Monitoring\Object\Host;
<?= $this->prefixedTimeSince($object->host_last_state_change, true); ?>
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>

View File

@ -17,6 +17,7 @@ $i = 0;
<tr class="state <?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
<td class="state"><?= 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) ?>

View File

@ -10,7 +10,8 @@ use Icinga\Module\Monitoring\Object\Service;
<?= $this->prefixedTimeSince($object->host_last_state_change, true); ?>
</td>
<td>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<?= $this->iconImage()->service($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
@ -27,10 +28,11 @@ use Icinga\Module\Monitoring\Object\Service;
<?= $this->prefixedTimeSince($object->service_last_state_change, true); ?>
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->translate('Service'); ?>: <?= $this->escape($object->service_display_name); ?></strong>
<?php if ($object->service_display_name !== $object->service_description): ?>
<small>(<?= $this->escape($object->service_description); ?>)</small>
<?php endif ?>
<?php if ($object->service_display_name !== $object->service_description): ?>
<small>(<?= $this->escape($object->service_description); ?>)</small>
<?php endif ?>
<?= $this->render('partials/service/statusicons.phtml'); ?>
</td>
</tr>

View File

@ -15,6 +15,7 @@ $i = 0;
<tr class="state <?= Service::getStateText($service->service_state); ?><?= $service->service_handled ? ' handled' : '' ?>">
<td class="state"><?= Service::getStateText($service->service_state, true); ?><br /></td>
<td>
<?= $this->iconImage()->service($service) ?>
<?= implode(' ', $this->serviceFlags($service)) ?>
<b>
<?= $this->escape($service->getName()); ?>

View File

@ -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',

View File

@ -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',