Change Multi-Views to a new layout

Add more detailed information about the current selection

refs #3788
This commit is contained in:
Matthias Jentsch 2013-10-15 17:52:30 +02:00
parent 8c416a51ce
commit df0cb01a27
10 changed files with 229 additions and 84 deletions

View File

@ -45,54 +45,68 @@ class Monitoring_MultiController extends ActionController
public function hostAction()
{
$hosts = array();
$warnings = array();
$hostnames = array();
$comments = array();
$downtimes = array();
$errors = array();
foreach ($this->view->queries as $index => $query) {
if (array_key_exists('host', $query)) {
$host = Host::fetch($this->backend, $query['host']);
$host->prefetch();
$hosts[] = $host;
} else {
$warnings[] = 'Query ' . $index . ' misses property host.';
if (!array_key_exists('host', $query)) {
$errors[] = 'Query ' . $index . ' misses property host.';
continue;
}
$host = Host::fetch($this->backend, $query['host']);
foreach ($host->comments as $comment) {
$comments[$comment->comment_id] = null;
}
if ($host->host_in_downtime) {
$downtimes[] += $host->host_in_downtime;
}
$hostnames[] = $host->host_name;
$hosts[] = $host;
}
$this->view->commands = array(
'host' => array(
),
'service' => array(
),
'notification' => array(
),
''
);
$this->view->objects = $this->view->hosts = $hosts;
$this->view->warnings = $warnings;
$this->view->comments = array_keys($comments);
$this->view->hostnames = $hostnames;
$this->view->downtimes = $downtimes;
$this->view->errors = $errors;
}
public function serviceAction()
{
$services = array();
$warnings = array();
$comments = array();
$downtimes = array();
$errors = array();
foreach ($this->view->queries as $index => $query) {
if (!array_key_exists('host', $query)) {
$warnings[] = 'Query ' . $index . ' misses property host.';
$errors[] = 'Query ' . $index . ' misses property host.';
continue;
}
if (!array_key_exists('service', $query)) {
$warnings[] = 'Query ' . $index . ' misses property service.';
$errors[] = 'Query ' . $index . ' misses property service.';
continue;
}
$service = Service::fetch($this->backend, $query['host'], $query['service']);
$service->prefetch();
$services[] = $service;
}
$service = Service::fetch($this->backend, $query['host'], $query['service']);
foreach ($service->comments as $comment) {
$comments[$comment->comment_id] = null;
}
if ($service->service_in_downtime) {
$downtimes[] += $service->service_in_downtime;
}
$hostnames[] = $service->host_name;
$services[] = $service;
}
$this->view->objects = $this->view->services = $services;
$this->view->warnings = $warnings;
$this->view->comments = array_keys($comments);
$this->view->downtimes = $downtimes;
$this->view->errors = $errors;
}
public function notificationAction()
@ -102,7 +116,7 @@ class Monitoring_MultiController extends ActionController
public function historyAction()
{
}
/**

View File

@ -0,0 +1,15 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: mjentsch
* Date: 15.10.13
* Time: 17:47
* To change this template use File | Settings | File Templates.
*/
namespace Icinga\Module\Monitoring\Form\Command;
class MultiFlagForm extends Form {
}

View File

@ -28,6 +28,8 @@
/**
* Class Zend_View_Helper_CommandButton
*
* TODO: Check if it should eventually be implement as a widget
*/
class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
@ -64,6 +66,17 @@ class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
const CMD_DELAY_NOTIFICATION = 28;
const CMD_REMOVE_DOWNTIME = 29;
/**
* Render the given command-button
*
* @param $command The command constant, for example CommandButton::CMD_DISABLE_ACTIVE_CHECKS
* @param $href The href that should be executed when clicking this button.
*/
private function render($command, $href) {
$cmd = $this->commandInformation[$command];
}
/**
* Information about interface commands
*
@ -85,14 +98,15 @@ class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
*/
private static $commandInformation = array(
self::CMD_DISABLE_ACTIVE_CHECKS => array(
'Disable Active Checks For This %s', // Long description (mandatory)
'Disable Active Checks', // Short description (mandatory)
'', // Icon anything (optional)
'' // Button css cls (optional)
'Disable Active Checks For This %s',
'Disable Active Checks',
'',
''
),
self::CMD_ENABLE_ACTIVE_CHECKS => array(
'Enable Active Checks For This %s',
'Enable Active Checks',
'',
''
),
self::CMD_RESCHEDULE_NEXT_CHECK => array(
@ -104,66 +118,79 @@ class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
self::CMD_SUBMIT_PASSIVE_CHECK_RESULT => array(
'Submit Passive Check Result',
'Submit Check Result',
'',
''
),
self::CMD_STOP_OBSESSING => array(
'Stop Obsessing Over This %s',
'Stop Obsessing',
'',
''
),
self::CMD_START_OBSESSING => array(
'Start Obsessing Over This %s',
'Start Obsessing',
'',
''
),
self::CMD_STOP_ACCEPTING_PASSIVE_CHECKS => array(
'Stop Accepting Passive Checks For This %s',
'Stop Passive Checks',
'',
''
),
self::CMD_START_ACCEPTING_PASSIVE_CHECKS => array(
'Start Accepting Passive Checks For This %s',
'Start Passive Checks',
'',
''
),
self::CMD_DISABLE_NOTIFICATIONS => array(
'Disable Notifications For This %s',
'Disable Notifications',
'',
''
),
self::CMD_ENABLE_NOTIFICATIONS => array(
'Enable Notifications For This %s',
'Enable Notifications',
'',
''
),
self::CMD_SEND_CUSTOM_NOTIFICATION => array(
'Send Custom %s Notification',
'Send Notification',
'',
''
),
self::CMD_SCHEDULE_DOWNTIME => array(
'Schedule Downtime For This %s',
'Schedule Downtime',
'',
''
),
self::CMD_SCHEDULE_DOWNTIMES_TO_ALL => array(
'Schedule Downtime For This %s And All Services',
'Schedule Services Downtime',
'',
''
),
self::CMD_REMOVE_DOWNTIMES_FROM_ALL => array(
'Remove Downtime(s) For This %s And All Services',
'Remove Downtime(s)',
'',
''
),
self::CMD_DISABLE_NOTIFICATIONS_FOR_ALL => array(
'Disable Notification For All Service On This %s',
'Disable Service Notifications',
'',
''
),
self::CMD_ENABLE_NOTIFICATIONS_FOR_ALL => array(
'Enable Notification For All Service On This %s',
'Enable Service Notifications',
'',
''
),
self::CMD_RESCHEDULE_NEXT_CHECK_TO_ALL => array(
@ -175,36 +202,43 @@ class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
self::CMD_DISABLE_ACTIVE_CHECKS_FOR_ALL => array(
'Disable Checks For All Services On This %s',
'Disable Service Checks',
'',
''
),
self::CMD_ENABLE_ACTIVE_CHECKS_FOR_ALL => array(
'Enable Checks For All Services On This %s',
'Enable Service Checks',
'',
''
),
self::CMD_DISABLE_EVENT_HANDLER => array(
'Disable Event Handler For This %s',
'Disable Event Handler',
'',
''
),
self::CMD_ENABLE_EVENT_HANDLER => array(
'Enable Event Handler For This %s',
'Enable Event Handler',
'',
''
),
self::CMD_DISABLE_FLAP_DETECTION => array(
'Disable Flap Detection For This %s',
'Disable Flap Detection',
'',
''
),
self::CMD_ENABLE_FLAP_DETECTION => array(
'Enable Flap Detection For This %s',
'Enable Flap Detection',
'',
''
),
self::CMD_ADD_COMMENT => array(
'Add New %s Comment',
'Add Comment',
'',
''
),
self::CMD_RESET_ATTRIBUTES => array(
@ -228,7 +262,8 @@ class Zend_View_Helper_CommandButton extends Zend_View_Helper_Abstracts {
self::CMD_DELAY_NOTIFICATION => array(
'Delay Next %s Notification',
'Delay Notification',
'',
''
),
)
);
}

View File

@ -1 +1,24 @@
<?php
<div class="panel panel-default ">
<div class="panel-heading">
<span> {{COMMENT_ICON}} Comments </span>
</div>
<div class="panel-body">
<a href=" <?=
$this->href(
'monitoring/list/comments',
array(
'comment_id' => implode(',', $comments)
)
);
?>">
<?= count($comments);?> comments are present in the selected items.
</a>
<div>
{{REMOVE_COMMENTS_BUTTON}}
{{ADD_COMMENT_BUTTON}}
{{SEND_NOTIFICATION_BUTTON}}
{{DELAY_NOTIFICATION_BUTTON}}
</div>
</div>
</div>

View File

@ -0,0 +1,15 @@
<div class="panel panel-default ">
<div class="panel-heading">
<span> Configuration </span>
</div>
<div class="panel-body">
Change settings:
<form>
Active Checks {{CHECKBOX}}
Passive Checks {{CHECKBOX}}
Flap Detection {{CHECKBOX}}
</form>
</div>
</div>

View File

@ -0,0 +1,20 @@
<div class="panel panel-default">
<div class="panel-heading">
{{DOWNTIME_ICON}} Downtimes
</div>
<div class="panel-body">
<a href="
<?= $this->href(
'monitoring/list/downtimes',
array()
);?>
">
<?= count($downtimes); ?> Selected items are currently in downtime.
</a>
<div>
{{REMOVE_DOWNTIME_BUTTON}}
{{REMOVE_ACKNOWLEDGEMENTS_BUTTON}}
</div>
</div>
</div>

View File

@ -1,8 +1,50 @@
<div class="panel panel-default">
<div class="panel-heading">
<span>Execute commands for all <?= count($objects) ?> object(s) </span>
</div>
<div class="panel-body">
<?= $this->monitoringCommands($objects, \Icinga\Module\Monitoring\Command\Meta::TYPE_FULL); ?>
</div>
<h4> Selected <?= count($objects) ?> objects. </h4>
<a href="#">{{RECHECK_BUTTON}}</a>
<a href="#">{{RESCHEDULE_BUTTON}}</a>
<a href="#">{{ACKNOWLEDGE_PROBLEMS_BUTTON}}</a>
<a href="#">{{SCHEDULE_DOWNTIMES}}</a>
<a href="#">{{SUBMIT_PASSIVE_CHECK_RESULTS}}</a>
<div>
<ul class="list-inline">
<?php
for ($i = 0; $i < count($objects) && $i < 10; $i++) {
$object = $objects[$i];
?>
<li>
<a href="<?php
if ($this->is_service) {
echo $this->href(
'monitoring/show/service',
array(
'host' => $object->host_name,
'service' => $object->service_description
)
);
} else {
echo $this->href(
'monitoring/show/host', array('host' => $object->host_name)
);
}?>" >
<?= $object->host_name; ?>
<?= isset($object->service_description) ? $object->service_description : '' ?>
</a>
</li>
<?php } ?>
</ul>
<?php if (count($objects) > 10) {
if (!$this->is_service) {
?>
<a href="
<?= $this->href('monitoring/list/hosts', array(
'host' => implode(',', $hostnames)
)
);?>">
<?php } else { ?>
<a href="
<?= $this->href('monitoring/list/services', array(
)
);?>">
<?php } ?>
and <?= count($objects) - 10 ?> more ... </a>
<?php } ?>
</div>

View File

@ -1,12 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
{{HOST_ICON}} <h1>Selected <?= count($objects) ?> hosts </h1>
</div>
<div class="panel-body">
<?php foreach($objects as $host) { ?>
<?php } ?>
</div>
</div>
<?= $this->render('multi/components/summary.phtml') ?>

View File

@ -1,21 +1,18 @@
<?php
$this->is_service = false;
?>
<div class="panel panel-default">
<div class="panel-heading">
{{HOST_ICON}} <h1>Selected <?= count($objects) ?> hosts </h1>
<div class="panel panel-heading">
{{HOST_ICON}}
<h1> Hosts </h1>
</div>
<div class="panel-body">
<ul>
<?php foreach($this->hosts as $host) { ?>
<li>
<a href="<?= $this->href(
'monitoring/show/host',
array('host' => $host->host_name)
);?>">
<?= $host->host_name ?>
</a>
</li>
<?php } ?>
</ul>
<div class="panel panel-body">
<?= $this->render('multi/components/summary.phtml'); ?>
</div>
</div>
<?= $this->render('multi/components/summary.phtml') ?>
<?= $this->render('multi/components/downtimes.phtml'); ?>
<?= $this->render('multi/components/comments.phtml'); ?>
<?= $this->render('multi/components/configuration.phtml'); ?>

View File

@ -1,22 +1,18 @@
<?php
$this->is_service = true;
?>
<div class="panel panel-default">
<div class="panel-heading">
{{SERVICE_ICON}} <h1>Selected <?= count($objects) ?> services </h1>
{{SERVICE_ICON}}
<h1> Services </h1>
</div>
<div class="panel-body">
<?php foreach($this->services as $service) { ?>
<li>
<a href="<?= $this->href(
'monitoring/show/service',
array(
'host' => $service->host_name,
'service' => $service->service_description
)
);?>">
<?= $service->host_name ?> <?= $service->service_description ?>
</a>
</li>
<?php } ?>
<?= $this->render('multi/components/summary.phtml'); ?>
</div>
</div>
<?= $this->render('multi/components/summary.phtml') ?>
<?= $this->render('multi/components/downtimes.phtml'); ?>
<?= $this->render('multi/components/comments.phtml'); ?>
<?= $this->render('multi/components/configuration.phtml'); ?>