Merge branch 'bugfix/remove-not-working-components-4583'

fixes #4583
This commit is contained in:
Marius Hein 2013-08-20 15:50:10 +02:00
commit 1bd35ff734
13 changed files with 84 additions and 461 deletions

View File

@ -1,27 +1,28 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner ">
<ul class="nav pull-left">
<li style="float:left"><a href="<?= $this->baseUrl('/') ?>" class="brand" style="margin-left:0px;">Icinga</a></li>
</ul>
<?php if ($this->auth()->isAuthenticated()): ?>
<ul class="nav pull-right" >
<li>
<form class="navbar-search" style="padding-top:0.2em">
<input type="text" class="search-query" placeholder="Search" style="padding-top:0.3em">
</form>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?=
$this->escape($this->auth()->getUser()->getUsername())
?> <i class="icon-user icon-white" style="margin-top:0.2em"></i>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><?= $this->qlink($this->translate('Preferences'), 'preference') ?></li>
<li><?= $this->qlink($this->translate('Logout'), 'authentication/logout') ?></li>
<div class="navbar-inner ">
<ul class="nav pull-left">
<li style="float:left"><a href="<?= $this->baseUrl('/') ?>" class="brand" style="margin-left:0px;">Icinga</a></li>
</ul>
</li>
</ul>
<?php endif ?>
</div>
<?php if ($this->auth()->isAuthenticated()): ?>
<ul class="nav pull-right" >
<!-- Remove component as of #4583 since it's not working-->
<!-- <li>-->
<!-- <form class="navbar-search" style="padding-top:0.2em">-->
<!-- <input type="text" class="search-query" placeholder="Search" style="padding-top:0.3em">-->
<!-- </form>-->
<!-- </li>-->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<?= $this->escape($this->auth()->getUser()->getUsername()); ?>
<i class="icon-user icon-white" style="margin-top:0.2em"></i>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><?= $this->qlink($this->translate('Preferences'), 'preference'); ?></li>
<li><?= $this->qlink($this->translate('Logout'), 'authentication/logout'); ?></li>
</ul>
</li>
</ul>
<?php endif ?>
</div>
</div>

View File

@ -1,14 +1,18 @@
[menu]
Issues.title = "Issues" ; Extended version
Issues.route = "/monitoring/list/services?problems=1&sort=severity" ; Explicit route
Issues.key = "issues" ; When this key is set in the controller, the item is active
;Remove component as of #4583 since it's not working
;Issues.title = "Issues" ; Extended version
;Issues.route = "/monitoring/list/services?problems=1&sort=severity" ; Explicit route
;Issues.key = "issues" ; When this key is set in the controller, the item is active
Changes.title = "Recent Changes"
Changes.route = "/monitoring/list/services?sort=service_last_state_change"
_1 = 1 ;Spacer after this section
;Remove component as of #4583 since it's not working
;Changes.title = "Recent Changes"
;Changes.route = "/monitoring/list/services?sort=service_last_state_change"
;_1 = 1 ;Spacer after this section
Hosts = "/monitoring/list/hosts"
Services = "/monitoring/list/services"
Downtimes = "/monitoring/list/downtimes"
Notifications = "/monitoring/list/notifications"
Summaries = "/monitoring/summary/group/by/hostgroup"
;Remove component as of #4583 since it's not working
;Summaries = "/monitoring/summary/group/by/hostgroup"

View File

@ -26,21 +26,25 @@
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Web\Hook;
use Icinga\File\Csv;
use Monitoring\Backend;
use Icinga\Application\Benchmark;
use Icinga\Web\Widget\Tabextension\OutputFormat;
use Icinga\Web\Widget\Tabextension\DashboardAction;
use Icinga\Web\Widget\Tabextension\BasketAction;
use \Icinga\Application\Benchmark;
use \Icinga\Data\Db\Query;
use \Icinga\File\Csv;
use \Icinga\Web\Controller\ModuleActionController;
use \Icinga\Web\Hook;
use \Icinga\Web\Widget\Tabextension\BasketAction;
use \Icinga\Web\Widget\Tabextension\DashboardAction;
use \Icinga\Web\Widget\Tabextension\OutputFormat;
use \Icinga\Web\Widget\Tabs;
use \Monitoring\Backend;
class Monitoring_ListController extends ModuleActionController
{
/**
* The backend used for this controller
*
* @var \Icinga\Backend
* @var Backend
*/
protected $backend;
@ -48,9 +52,9 @@ class Monitoring_ListController extends ModuleActionController
* Set to a string containing the compact layout name to use when
* 'compact' is set as the layout parameter, otherwise null
*
* @var string|null
* @var string
*/
private $compactView = null;
private $compactView;
/**
* Retrieve backend and hooks for this controller
@ -101,8 +105,7 @@ class Monitoring_ListController extends ModuleActionController
*/
public function servicesAction()
{
$state_type = $this->_getParam('_statetype', 'soft');
if ($state_type = 'soft') {
if ($this->_getParam('_statetype', 'soft') === 'soft') {
$state_column = 'service_state';
$state_change_column = 'service_last_state_change';
} else {
@ -111,7 +114,6 @@ class Monitoring_ListController extends ModuleActionController
}
$this->compactView = "services-compact";
$this->view->services = $this->query('status', array(
'host_name',
'host_state',
@ -143,50 +145,7 @@ class Monitoring_ListController extends ModuleActionController
}
/**
* Display hostgroup list
*
* @TODO Implement hostgroup overview (feature #4184)
*/
public function hostgroupsAction()
{
$this->view->hostgroups = $this->backend->select()
->from('hostgroup', array(
'hostgroup_name',
'hostgroup_alias',
))->applyRequest($this->_request);
}
/**
* Display servicegroup list
*
* @TODO Implement servicegroup overview (feature #4185)
*/
public function servicegroupsAction()
{
$this->view->servicegroups = $this->backend->select()
->from('servicegroup', array(
'servicegroup_name',
'servicegroup_alias',
))->applyRequest($this->_request);
}
/**
* Display contactgroups overview
*
*
*/
public function contactgroupsAction()
{
$this->view->contactgroups = $this->backend->select()
->from('contactgroup', array(
'contactgroup_name',
'contactgroup_alias',
))->applyRequest($this->_request);
}
/**
* Fetch the current downtimes and put them into the view
* property 'downtimes'
* Fetch the current downtimes and put them into the view property `downtimes`
*/
public function downtimesAction()
{
@ -239,7 +198,15 @@ class Monitoring_ListController extends ModuleActionController
$this->inheritCurrentSortColumn();
}
protected function query($view, $columns)
/**
* Create query
*
* @param string $view
* @param array $columns
*
* @return Query
*/
private function query($view, $columns)
{
$extra = preg_split(
'~,~',
@ -259,9 +226,9 @@ class Monitoring_ListController extends ModuleActionController
/**
* Handle the 'format' and 'view' parameter
*
* @param \Icinga\Data\Db\Query $query The current query
* @param Query $query The current query
*/
protected function handleFormatRequest($query)
private function handleFormatRequest($query)
{
if ($this->compactView !== null && ($this->_getParam('view', false) === 'compact')) {
$this->_helper->viewRenderer($this->compactView);
@ -292,63 +259,17 @@ class Monitoring_ListController extends ModuleActionController
*
* @return Tabs
*/
protected function createTabs()
private function createTabs()
{
$tabs = $this->getTabs();
$tabs->extend(new OutputFormat())
->extend(new DashboardAction())
->extend(new BasketAction());
$tabs->add('services', array(
'title' => 'All services',
'icon' => 'img/classic/service.png',
'url' => 'monitoring/list/services',
));
$tabs->add('hosts', array(
'title' => 'All hosts',
'icon' => 'img/classic/server.png',
'url' => 'monitoring/list/hosts',
));
$tabs->add('downtimes', array(
'title' => 'Downtimes',
'usePost' => true,
'icon' => 'img/classic/downtime.gif',
'url' => 'monitoring/list/downtimes',
));
$tabs->add('notifications', array(
'title' => 'Notifications',
'icon' => 'img/classic/alarm-clock.png',
'url' => 'monitoring/list/notifications'
));
/*
$tabs->add('hostgroups', array(
'title' => 'Hostgroups',
'icon' => 'img/classic/servers-network.png',
'url' => 'monitoring/list/hostgroups',
));
$tabs->add('servicegroups', array(
'title' => 'Servicegroups',
'icon' => 'img/classic/servers-network.png',
'url' => 'monitoring/list/servicegroups',
));
$tabs->add('contacts', array(
'title' => 'Contacts',
'icon' => 'img/classic/servers-network.png',
'url' => 'monitoring/list/contacts',
));
$tabs->add('contactgroups', array(
'title' => 'Contactgroups',
'icon' => 'img/classic/servers-network.png',
'url' => 'monitoring/list/contactgroups',
));
*/
}
/**
* Let the current response inherit the used sort column by applying it to the
* view property 'sort'
* Let the current response inherit the used sort column by applying it to the view property `sort`
*/
private function inheritCurrentSortColumn()
{

View File

@ -1,94 +0,0 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Backend;
class Monitoring_SummaryController extends ModuleActionController
{
protected $backend;
protected $host;
protected $service;
public function init()
{
$this->backend = Backend::getInstance($this->_getParam('backend'));
$this->view->tabs = $this->getTabs();
}
protected function createTabs()
{
$tabs = $this->getTabs();
$tabs->add('hostgroup', array(
'title' => 'Hostgroups',
'url' => 'monitoring/summary/group',
'urlParams' => array('by' => 'hostgroup'),
));
$tabs->add('servicegroup', array(
'title' => 'Servicegroups',
'url' => 'monitoring/summary/group',
'urlParams' => array('by' => 'servicegroup'),
));
$tabs->activate($this->_getParam('by', 'hostgroup'));
return $tabs;
}
public function historyAction()
{
$this->_helper->viewRenderer('history');
}
public function groupAction()
{
if ($this->_getParam('by') === 'servicegroup') {
$view = 'servicegroupsummary';
} else {
$view = 'hostgroupsummary';
}
if (! $this->backend->hasView($view)) {
$this->view->backend = $this->backend;
$this->view->view_name = $view;
$this->_helper->viewRenderer('backend-is-missing');
return;
}
$this->view->preserve = array(
'problems' => $this->_getParam('problems') ? 'true' : 'false',
'search' => $this->_getParam('search')
);
$query = $this->backend->select()->from($view);
$query->where('problems', $this->_getParam('problems') ? 'true' : 'false');
//$query->where('ss.current_state > 0');
$query->where('search', $this->_getParam('search'));
// echo '<pre>' . $query->dump() . '</pre>'; exit;
$this->view->summary = $query->paginate();
}
}
// @codingStandardsIgnoreEnd

View File

@ -1,5 +0,0 @@
<?= $this->tabs->render($this); ?>
<pre>
<?= $this->escape(print_r($this->contactgroups->fetchAll(), 1)) ?>
</pre>

View File

@ -41,7 +41,6 @@ $downtimes = $downtimes->fetchAll();
'downtime_duration' => 'Duration',
)
) ?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<?=

View File

@ -1,5 +0,0 @@
<?= $this->tabs->render($this); ?>
<pre>
<?= $this->escape(print_r($this->hostgroups->fetchAll(), 1)) ?>
</pre>

View File

@ -20,7 +20,6 @@ $trimArea = $this->getHelper('Trim');
'host_name' => 'Host',
)
) ?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>

View File

@ -23,7 +23,6 @@ $formatter = $this->getHelper('MonitoringProperties');
)
);
?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>

View File

@ -1,5 +0,0 @@
<?= $this->tabs->render($this); ?>
<pre>
<?= $this->escape(print_r($this->servicegroups->fetchAll(), 1)) ?>
</pre>

View File

@ -11,29 +11,6 @@ $trimArea = $this->getHelper('Trim');
</div>
<?php return; endif ?>
<form method="get" action="<?= $this->qUrl(
'monitoring/list/services?' . http_build_query($this->services->getAppliedFilter()->toParams()),
array()
);
?>">
Sort by <?= $this->formSelect(
'sort',
$this->sort,
array('class' => 'autosubmit'),
array(
'service_severity' => 'Severity',
'service_last_state_change' => 'Last state change',
'service_last_time_unknown' => 'Last UNKNOWN',
'service_last_time_critical' => 'Last CRITICAL',
'service_last_time_warning' => 'Last WARNING',
'service_last_time_ok' => 'Last OK',
'service_description' => 'Service',
)
) ?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<?= $this->paginationControl($paginator, null, null, array('preserve' => $this->preserve)) ?>
<table class="statustable action services">

View File

@ -33,7 +33,6 @@ $trimArea = $this->getHelper('Trim');
'service_description' => 'Service',
)
) ?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<?= $this->paginationControl($paginator, null, null, array('preserve' => $this->preserve)) ?>

View File

@ -1,167 +0,0 @@
<? if (! $this->compact): ?>
<?= $this->tabs ?>
<? endif ?>
<? if (empty($this->summary)): ?>
There are no such services right now
<? else: ?>
<?php
$now = time();
?>
<? if (! $this->compact && $this->summary instanceof \Zend_Paginator): ?>
<?= $this->paginationControl($this->summary, null, null, array('preserve' => $this->preserve)); ?>
<? endif ?>
<table class="pivot action">
<thead>
<tr>
<!-- <th style="width: 6em;">&nbsp;</th>-->
<th style="text-align: left;">&nbsp;</th>
<th style="width: 5em;">Critical</th>
<th style="width: 5em;">Unknown</th>
<th style="width: 5em;">Warning</th>
<? if (! $this->compact): ?> <th style="width: 9%;">OK</th><? endif ?>
</tr>
</thead>
<tbody>
<? foreach ($this->summary as $row): ?>
<?php
$class_ok = '';
$class_warning = '';
$class_critical = '';
$class_unknown = '';
$html_ok = '-';
$html_warning = '-';
$html_critical = '-';
$html_unknown = '-';
$name_class = null;
if ($row->critical > 0) {
$class_critical = 'critical';
$html_critical = $row->critical;
if ($row->critical_ack + $row->critical_dt > 0) {
$html_critical = sprintf(
'%s <span class="critical handled">(%s/%s)</span>',
$row->critical,
$row->critical_ack,
$row->critical_dt
);
}
if ($name_class === null) $name_class = 'critical';
} elseif ($row->critical_dt + $row->critical_ack > 0) {
$class_critical = 'critical handled';
$html_critical = sprintf(
'%s / %s',
$row->critical_ack,
$row->critical_dt
);
if ($name_class === null) $name_class = 'critical handled';
}
if ($row->unknown > 0) {
$class_unknown = 'unknown';
$html_unknown = $row->unknown;
if ($row->unknown_ack + $row->unknown_dt > 0) {
$html_unknown .= sprintf(
' <span class="unknown handled">(%s/%s)</span>',
$row->unknown,
$row->unknown_ack,
$row->unknown_dt
);
}
if ($name_class === null) $name_class = 'unknown';
} elseif ($row->unknown_dt + $row->unknown_ack > 0) {
$class_unknown = 'unknown handled';
$html_unknown = sprintf(
'%s / %s',
$row->unknown_ack,
$row->unknown_dt
);
if ($name_class === null) $name_class = 'unknown handled';
}
if ($row->warning > 0) {
$class_warning = 'warning';
$html_warning = $row->warning;
if ($row->warning_ack + $row->warning_dt > 0) {
$html_warning .= sprintf(
' <span class="warning handled">(%s/%s)</span>',
$row->warning,
$row->warning_ack,
$row->warning_dt
);
}
if ($name_class === null) $name_class = 'warning';
} elseif ($row->warning_dt + $row->warning_ack > 0) {
$class_warning = 'warning handled';
$html_warning = sprintf(
'%s / %s',
$row->warning_ack,
$row->warning_dt
);
if ($name_class === null) $name_class = 'warning handled';
}
if ($row->ok > 0) {
$class_ok = 'ok';
if (isset($row->hostgroup_name)) {
$html_ok = $this->qlink($row->ok, 'monitoring/list/services', array(
'hostgroups' => $row->hostgroup_name
));
} else {
$html_ok = $this->qlink($row->ok, 'monitoring/list/services', array(
'servicegroups' => $row->servicegroup_name
));
}
if ($name_class === null) $name_class = 'ok';
}
if (isset($row->hostgroup_name)) {
if ($name_class === 'ok') {
$name_html = $this->qlink($row->hostgroup_name, 'monitoring/list/services', array(
'hostgroups' => $row->hostgroup_name
));
} else {
$name_html = $this->qlink($row->hostgroup_name, 'monitoring/list/services', array(
'hostgroups' => $row->hostgroup_name,
'problems' => '1',
'sort' => 'severity'
));
}
} else {
if ($name_class === 'ok') {
$name_html = $this->qlink($row->servicegroup_name, 'monitoring/list/services', array(
'servicegroups' => $row->servicegroup_name
));
} else {
$name_html = $this->qlink($row->servicegroup_name, 'monitoring/list/services', array(
'servicegroups' => $row->servicegroup_name,
'problems' => '1',
'sort' => 'severity'
));
}
}
?>
<tr>
<!-- <td class="<?= $name_class ?>"><? if ($row->last_state_change + 600 > $now): ?>
<blink><?= $this->timeSince($row->last_state_change) ?></blink>
<? else: ?>
<?= $this->timeSince($row->last_state_change) ?>
<? endif ?></td>-->
<td style="text-align: left;"><?= $name_html ?></td>
<td class="<?= $class_critical ?>"><?= $html_critical ?></td>
<td class="<?= $class_unknown ?>"><?= $html_unknown ?></td>
<td class="<?= $class_warning ?>"><?= $html_warning ?></td>
<? if (! $this->compact): ?><td class="ok"><?= $html_ok ?></td><? endif ?>
</tr>
<? endforeach ?>
</tbody>
</table>
<? endif ?>
<? if ($this->compact): ?><a href="<?= $this->baseUrl('monitoring/summary/group') ?>">more</a><? endif ?>