Add actual links and buttons to the multi-views

refs #3788
This commit is contained in:
Matthias Jentsch 2013-10-18 09:59:06 +02:00
parent 4133d0093d
commit 9cba03b017
9 changed files with 206 additions and 56 deletions

View File

@ -27,13 +27,13 @@
// {{{ICINGA_LICENSE_HEADER}}}
use \Icinga\Web\Form;
use \Icinga\Web\Controller\ActionController;
use \Icinga\Module\Monitoring\Backend;
use \Icinga\Module\Monitoring\Object\Host;
use \Icinga\Module\Monitoring\Object\Service;
use \Icinga\Module\Monitoring\Form\Command\MultiCommandFlagForm;
use \Icinga\Module\Monitoring\DataView\HostAndServiceStatus as HostAndServiceStatusView;
use \Icinga\Module\Monitoring\DataView\Comment as CommentView;
use \Icinga\Web\Controller\ActionController;
/**
* Displays aggregations collections of multiple objects.
@ -43,7 +43,6 @@ class Monitoring_MultiController extends ActionController
public function init()
{
$this->view->queries = $this->getDetailQueries();
$this->view->wildcard = false;
$this->backend = Backend::createBackend($this->_getParam('backend'));
}
@ -87,7 +86,7 @@ class Monitoring_MultiController extends ActionController
}
$this->view->objects = $this->view->hosts = $hosts;
$this->view->comments = isset($comments) ? $comments : $this->getComments($hosts);
$this->view->hostnames = $this->getHostnames($hosts);
$this->view->hostnames = $this->getProperties($hosts, 'host_name');
$this->view->downtimes = $this->getDowntimes($hosts);
$this->view->errors = $errors;
@ -108,7 +107,11 @@ class Monitoring_MultiController extends ActionController
$unique = array();
foreach ($values as $value)
{
$unique[$value->{$key}] = null;
if (is_array($value)) {
$unique[$value[$key]] = $value[$key];
} else {
$unique[$value->{$key}] = $value->{$key};
}
}
return $unique;
}
@ -117,16 +120,16 @@ class Monitoring_MultiController extends ActionController
{
$unique = array();
foreach ($objects as $object) {
$unique = array_merge($this->getUniqueValues($object->comments, 'comment_id'));
$unique = array_merge($unique, $this->getUniqueValues($object->comments, 'comment_internal_id'));
}
return array_keys($unique);
}
private function getHostnames($objects)
private function getProperties($objects, $property)
{
$objectnames = array();
foreach ($objects as $object) {
$objectnames[] = $object->host_name;
$objectnames[] = $object->{$property};
}
return $objectnames;
}
@ -190,7 +193,8 @@ class Monitoring_MultiController extends ActionController
}
$this->view->objects = $this->view->services = $services;
$this->view->comments = isset($comments) ? $comments : $this->getComments($services);
$this->view->hostnames = $this->getHostnames($services);
$this->view->hostnames = $this->getProperties($services, 'host_name');
$this->view->servicenames = $this->getProperties($services, 'service_description');
$this->view->downtimes = $this->getDowntimes($services);
$this->view->errors = $errors;

View File

@ -12,7 +12,7 @@ $viewHelper = $this->getHelper('MonitoringState');
<h1>Comments</h1>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="multi">
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="single">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?>

View File

@ -1,24 +1,64 @@
<div class="panel panel-default ">
<div class="panel-heading">
<span> {{COMMENT_ICON}} Comments </span>
<span> 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 class="panel-row">
<?php if (count($comments) > 0) { ?>
<a href=" <?=
$this->href(
'monitoring/list/comments',
array(
'comment_id' => implode(',', $this->comments)
)
);
?>">
<?= count($comments);?> comments in the selected items.
</a>
<a href="<?=
$this->href(
'monitoring/command/removecomment',
$this->target
);
?>" class="button btn-common btn-small input-sm pull-right">
<i class="icinga-icon-remove"></i>
</a>
<?php } else { ?>
0 comments in the selected items.
<?php } ?>
</div>
<div class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/sendcustomnotification',
$this->target
);
?>" class="button btn-cta btn-common btn-wide">
Add Comments
</a>
</div>
<div class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/sendcustomnotification',
$this->target
);
?>" class="button btn-cta btn-common btn-half-left">
Send Notifications
</a>
<a href="<?=
$this->href(
'monitoring/command/delaynotification',
$this->target
);
?>" class="button btn-cta btn-common btn-half-right">
Delay Notifications
</a>
</div>
</div>
</div>

View File

@ -1,20 +1,37 @@
<div class="panel panel-default">
<div class="panel-heading">
{{DOWNTIME_ICON}} Downtimes
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 class="panel-row">
<?php if (count($downtimes) > 0) { ?>
<a href="
<?= $this->href(
'monitoring/list/downtimes',
array()
);?>
">
<?= count($downtimes); ?> Selected items are currently in downtime.
</a>
<a href="<?=
$this->href(
'monitoring/command/removedowntime',
$this->target
);
?>" class="button btn-common btn-small input-sm pull-right">
<i class="icinga-icon-remove"></i>
</a>
<?php } else { ?>
0 Selected items are currently in downtime.
<?php } ?>
</div>
<a href="<?=
$this->href(
'monitoring/command/removedowntime',
$target
);
?>" class="button btn-cta btn-common btn-wide">
Remove Acknowledgements
</a>
</div>
</div>

View File

@ -1,9 +1,67 @@
<?php
/** @var Zend_View_Helper_CommandForm $cf */
$cf = $this->getHelper('CommandForm');
$servicequery = isset($this->servicequery) ? $this->servicequery : '';
?>
<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 class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/reschedulenextcheck',
$this->target
);
?>" class="button btn-cta btn-half-left">
Recheck
</a>
<a href="<?=
$this->href(
'monitoring/command/reschedulenextcheck',
$this->target
);
?>" class="button btn-cta btn-half-right">
Reschedule
</a>
</div>
<div class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/acknowledgeproblem',
$this->target
);
?>" class="button btn-cta btn-wide">
Acknowledge Problems
</a>
</div>
<div class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/scheduledowntimes',
$this->target
);
?>" class="button btn-cta btn-common btn-wide">
Schedule Downtimes
</a>
</div>
<div class="panel-row">
<a href="<?=
$this->href(
'monitoring/command/submitpassivecheckresult',
$this->target
);
?>" class="button btn-cta btn-common btn-wide">
Submit Passive Checkresults
</a>
</div>
<div>
<ul class="list-inline">
<?php

View File

@ -1,10 +1,13 @@
<?php
$this->is_service = false;
$this->hostquery = implode($this->hostnames, ',');
$this->target = array(
'host' => $this->hostquery
);
?>
<div class="panel panel-default">
<div class="panel panel-heading">
{{HOST_ICON}}
<h1> Hosts </h1>
</div>

View File

@ -1,5 +1,11 @@
<?php
$this->is_service = true;
$this->hostquery = implode($this->hostnames, ',');
$this->servicequery = implode($this->servicenames, ',');
$this->target = array(
'host' => $this->hostquery,
'service' => $this->servicequery
);
?>
<div class="panel-heading">

View File

@ -209,4 +209,4 @@
</div>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -77,7 +77,7 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) {
var controlForms;
/**
* Handles a multi-selection of rows
* Handles multi-selection
*
* @type {TableMultiSelection}
*/
@ -135,6 +135,15 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) {
}
};
/**
* Show a 'hand' to indicate that the row is selectable,
* when hovering.
*/
this.showMousePointerOnRow = function(domContext) {
domContext = domContext || contentNode;
$('tbody tr', domContext).css('cursor' ,'pointer');
}
/**
* Activate a hover effect on all table rows, to indicate that
* this table row is clickable.
@ -295,6 +304,27 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) {
Container.getDetailContainer().registerOnUpdate(this.syncSelectionWithDetail.bind(this));
};
/**
* Init all objects responsible for selection handling
*
* - Indicate selection by showing active and hovered rows
* - Handle click-events according to the selection mode
* - Create and follow links according to the row content
*/
this.initRowSelection = function() {
selectionMode = gridDomNode.data('icinga-grid-selection-type');
if (selectionMode === 'multi' || selectionMode === 'single') {
// indicate selectable rows
this.showMousePointerOnRow();
this.activateRowHovering();
selection = new TableMultiSelection(
contentNode,
Container.getDetailContainer().getContainerHref()
);
}
this.registerTableLinks();
}
/**
* Create this component, setup listeners and behaviour
*/
@ -303,16 +333,8 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) {
this.container.removeDefaultLoadIndicator();
controlForms = determineControlForms();
contentNode = determineContentTable();
selectionMode = gridDomNode.data('icinga-grid-selection-type');
if (selectionMode === 'multi' || selectionMode === 'single') {
this.activateRowHovering();
selection = new TableMultiSelection(
contentNode,
Container.getDetailContainer().getContainerHref()
);
}
this.initRowSelection();
this.registerControls();
this.registerTableLinks();
this.registerHistoryChanges();
};