Implement new layout for host multi-view

refs #8543
This commit is contained in:
Matthias Jentsch 2015-03-06 12:31:34 +01:00
parent f425704305
commit 71534369ef
3 changed files with 297 additions and 90 deletions

View File

@ -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
*/

View File

@ -1,116 +1,224 @@
<?php
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
?>
<div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs; ?>
<?php endif ?>
<h1>
<?= $this->qlink(
sprintf($this->translate('%d Hosts Selected'), count($objects)),
$listAllLink
); ?>
</h1>
<?= $this->render('partials/host/objects-header.phtml'); ?>
</div>
<div class="content">
<h3>
<?= $this->icon('reschedule') ?>
<?= $this->translate('Commands') ?>
</h3>
<?= sprintf(t('Issue commands on all %d selected services:'), count($objects)) ?>
<?php if (($hostCount = count($objects)) === 0): ?>
<?= $this->translate('No hosts matching the filter'); ?>
<?php else: ?>
<h3><?= sprintf($this->translatePlural('%u Host', '%u Hosts', $hostCount), $hostCount); ?></h3>
<div><?= $this->qlink(
sprintf($this->translate('List all %u hosts'), $hostCount),
$listAllLink
); ?></div>
<p>
<div>
<?= $checkNowForm; ?>
</div>
<div><?= $this->qlink(
sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount),
$rescheduleAllLink,
null,
array('icon' => 'reschedule')
); ?></div>
<div><?= $this->qlink(
sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount),
$downtimeAllLink,
null,
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount),
$processCheckResultAllLink,
null,
array('icon' => 'reply')
); ?></div>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div>
<h3><?= sprintf(
$this->translatePlural(
'%u Unhandled Host Problem',
'%u Unhandled Host Problems',
$unhandledCount
),
$unhandledCount
); ?></h3>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled host problem',
'Schedule a downtime for %u unhandled host problems',
$unhandledCount
),
$unhandledCount
),
$downtimeUnhandledLink,
<?= $this->qlink(
$this->translate('Reschedule the next check'),
$rescheduleAllLink,
null,
array('icon' => 'reschedule')
); ?>
</div>
<div>
<?= $this->qlink(
$this->translate('Schedule a downtime'),
$downtimeAllLink,
null,
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled host problem',
'Acknowledge %u unhandled host problems',
); ?>
</div>
<div>
<?= $this->qlink(
$this->translate('Submit a passive check result'),
$processCheckResultAllLink,
null,
array('icon' => 'reply')
); ?>
</div>
<div>
<?= $this->qlink(
$this->translate('Add a comment'),
$addCommentLink,
null,
array('icon' => 'comment')
); ?>
</div>
</p>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div>
<h3>
<?= $this->icon('attention-alt') ?>
<?= $this->translatePlural(
'Unhandled Problem',
'Unhandled Problems',
$unhandledCount
) ?>
</h3>
<p>
<?= sprintf(
t('There are %s unhandled problems. Issue commands to the problematic hosts.'),
'<span class="badge badge-critical">' . $unhandledCount . '</span>'
) ?>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u host',
'Schedule a downtime for %u hosts',
$unhandledCount
),
$unhandledCount
),
$downtimeUnhandledLink,
null,
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled host',
'Acknowledge %u unhandled hosts',
$unhandledCount
),
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?></div>
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?></div>
</p>
</div>
<?php endif ?>
<?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?>
<div>
<h2><?= sprintf(
<h3><?= $this->icon('ok', $this->translate('Acknowledgements')) ?> <?= $this->translate('Acknowledgements') ?></h3>
<p><?= sprintf(
$this->translatePlural(
'%u Acknowledged Host Problem',
'%u Acknowledged Host Problems',
$acknowledgedCount
),
$acknowledgedCount
); ?></h2>
); ?></p>
<?= $removeAckForm ?>
</div>
<?php endif ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<h2><?= $this->qlink(
sprintf(
<h3><?= $this->translate('Downtimes') ?></h3>
<p><?= sprintf(
$this->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')
); ?></h2>
) ?> <?= $this->qlink(
$this->translate('Alle anzeigen'),
$inDowntimeLink,
null
); ?>
</p>
<?php endif ?>
<?php if (($commentCount = count($objects->getComments())) > 0): ?>
<h2><?= $this->qlink(
sprintf(
<h3> <?= $this->translate('Comments') ?></h3>
<p>
<?= sprintf(
$this->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')
); ?></h2>
) ?>
<?= $this->qlink(
$this->translate('List all'),
$commentsLink,
null
); ?>
</p>
<table>
<?php foreach ($objects as $service): ?>
<?php $service->fetchComments(); ?>
<?php foreach ($service->comments as $comment): ?>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?php
$delCommentForm = new DeleteCommentCommandForm();
$delCommentForm->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;
?>
(<?= ucfirst($comment->type) ?>):
</td>
<td style="padding-left: .5em;">
<?= nl2br($comment->comment) ?>
</td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</table>
<!--
<p>
<div><?= $this->qlink(
$this->translate('Remove all'),
$deleteCommentLink,
null,
array('icon' => 'trash')
); ?></div>
</p>
-->
<?php endif ?>
<?php endif ?>
</div>

View File

@ -1,16 +1,91 @@
<?php if (! $this->compact): ?>
<?= $tabs; ?>
<?php endif ?>
<?php
use Icinga\Module\Monitoring\Object\Host;
?>
<?php
$i = 0;
$hidden = array();
$hiddenRich = array();
?>
<?php if (($hostCount = count($objects)) > 0): ?>
<div class="hbox-item">
<h1 tabindex="-1">
<?= sprintf($this->translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?>
</h1>
</div>
<div class="hbox-item" style="font-size: 14px">
<?php foreach (array_filter($hostStates) as $text => $count): ?>
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
<?php endforeach ?>
</div>
<p>
<table class="state statesummary">
<thead>
<tr>
<th></th>
<th></th>
<th><?= $this->icon('host'); ?> <?= $this->translate('Host'); ?></th>
<th class="collapse"><?= $this->translate('Output'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($objects as $host): /** @var Host $host */ ?>
<?php
$i++;
if ($i > 5) {
$desc = $host->getName();
$hidden[] = $desc;
$hiddenRich[] = sprintf("<div class='color-box badge-%s'></div>%s", $host->getStateText($host->host_state) ,$desc);
continue;
}
?>
<tr class="state <?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
<td class="state"><?= Host::getStateText($host->host_state, true); ?><br /></td>
<td>
<?php if (!$host->host_handled && $host->host_state > 0): ?>
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
<?php endif ?>
<?php if ($host->host_acknowledged && !$host->host_in_downtime): ?>
<?= $this->icon('ok', $this->translate('Acknowledged') . (
$host->host_last_ack ? ': ' . $host->host_last_ack : ''
)) ?>
<?php endif ?>
<?php if ($host->host_is_flapping): ?>
<?= $this->icon('flapping', $this->translate('Flapping')) ?>
<?php endif ?>
<?php if (!$host->host_notifications_enabled): ?>
<?= $this->icon('bell-off-empty', $this->translate('Notifications Disabled')) ?>
<?php endif ?>
<?php if ($host->host_in_downtime): ?>
<?= $this->icon('plug', $this->translate('In Downtime')) ?>
<?php endif ?>
<?php if (isset($host->host_last_comment) && $host->host_last_comment !== null): ?>
<?= $this->icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?>
<?php endif ?>
</td>
<td><?= $this->escape($host->getName()); ?></td>
<td><p class="pluginoutput"><?= $this->escape($host->host_output) ?></p></td>
</tr>
<?php endforeach ?>
<?php if (count($hidden)): ?>
<tr>
<td>
<div class="selection-info" data-title-rich="<span align='left'><?= join('<br>', $hiddenRich) ?></span>"
title="<?= join(', ', $hidden) ?>">
<?= sprintf(t('%d more ...'), count($hidden)) ?>
</div>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
</p>
<?php endif ?>