Merge branch 'bugfix/monitoring-remove-services-tab-7998'

fixes #7998
This commit is contained in:
Eric Lippmann 2015-06-05 15:28:39 +02:00
commit 3e29046f56
7 changed files with 67 additions and 117 deletions

View File

@ -133,6 +133,8 @@ class Monitoring_HostsController extends Controller
$this->view->objects = $this->hostList;
$this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
$this->view->problemObjects = $this->hostList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')
->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')
->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')

View File

@ -78,20 +78,6 @@ class Monitoring_ShowController extends Controller
$this->setupPaginationControl($this->view->history, 50);
}
public function servicesAction()
{
$this->setAutorefreshInterval(15);
$this->getTabs()->activate('services');
$this->_setParam('service', '');
// TODO: This used to be a hack and still is. Modifying query string here.
$_SERVER['QUERY_STRING'] = (string) $this->params->without('service')->set('limit', '');
$this->view->services = $this->view->action('services', 'list', 'monitoring', array(
'view' => 'compact',
'sort' => 'service_description',
));
$this->fetchHostStats();
}
protected function fetchHostStats()
{
$this->view->stats = $this->backend->select()->from('statusSummary', array(
@ -228,19 +214,6 @@ class Monitoring_ShowController extends Controller
)
);
}
$tabs->add(
'services',
array(
'title' => sprintf(
$this->translate('List all services on host %s'),
$isService ? $object->getHost()->getName() : $object->getName()
),
'label' => $this->translate('Services'),
'icon' => 'services',
'url' => 'monitoring/show/services',
'urlParams' => $params,
)
);
if ($this->backend->hasQuery('eventHistory')) {
$tabs->add(
'history',

View File

@ -69,7 +69,7 @@ if (count($hosts) === 0) {
$this->translatePlural('%u unhandled service', '%u unhandled services', $host->host_unhandled_services),
$host->host_unhandled_services
),
'monitoring/show/services',
'monitoring/list/services',
array(
'host' => $host->host_name,
'service_problem' => 1,

View File

@ -67,7 +67,7 @@ foreach ($serviceDescriptions as $service_description): ?>
<th>
<?= $this->qlink(
$host_name,
'monitoring/show/services?' . $serviceFilter,
'monitoring/list/services?' . $serviceFilter,
array('host' => $host_name),
array('title' => sprintf($this->translate('List all reported services on host %s'), $host_name))
); ?>

View File

@ -12,8 +12,7 @@ function urlAddFilterOptional($url, $filter, $optional) {
return $url->setQueryString($f->toQueryString());
}
$selfUrl = Url::fromPath('monitoring/show/services', array('host' => $object->host_name));
$currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
$selfUrl = Url::fromPath('monitoring/list/services', array('host' => $object->host_name));
?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>>
<?php if ($object->stats->services_total): ?>
<?= $this->qlink(
@ -27,15 +26,18 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
),
$selfUrl,
null,
array('title' => sprintf(
$this->translatePlural(
'List all %u service on host %s',
'List all %u services on host %s',
$object->stats->services_total
array(
'title' => sprintf(
$this->translatePlural(
'List all %u service on host %s',
'List all %u services on host %s',
$object->stats->services_total
),
$object->stats->services_total,
$object->host_name
),
$object->stats->services_total,
$object->host_name
))
'data-base-target' => '_next'
)
); ?>
<?php else: ?>
<?= $this->translate('No services configured on this host'); ?>
@ -43,20 +45,23 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
<span class="badges">
<?php if ($object->stats->services_ok): ?>
<span class="state ok<?= $currentUrl === $selfUrl->with('service_state', 0)->getRelativeUrl() ? ' active' : ''; ?>">
<span class="state ok">
<?= $this->qlink(
$object->stats->services_ok,
$selfUrl,
array('service_state' => 0),
array('title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state OK on host %s',
'List %u services which are currently in state OK on host %s',
$object->stats->services_ok
array(
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state OK on host %s',
'List %u services which are currently in state OK on host %s',
$object->stats->services_ok
),
$object->stats->services_ok,
$object->host_name
),
$object->stats->services_ok,
$object->host_name
))
'data-base-target' => '_next'
)
); ?>
</span>
<?php endif ?>
@ -68,61 +73,49 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
$unhandled = $pre . '_unhandled';
$paramsHandled = array('service_state' => $stateId, 'service_handled' => 1);
$paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0);
if ($object->stats->$unhandled) {
$compareUrl = $selfUrl->with($paramsUnhandled)->getRelativeUrl();
} else {
$compareUrl = $selfUrl->with($paramsHandled)->getRelativeUrl();
}
if ($compareUrl === $currentUrl) {
$active = ' active';
} else {
$active = '';
}
echo '<span class="state ' . $state . $active . ($object->stats->$unhandled ? '' : ' handled') . '">';
echo '<span class="state ' . $state . ($object->stats->$unhandled ? '' : ' handled') . '">';
if ($object->stats->$unhandled) {
echo $this->qlink(
$object->stats->$unhandled,
$selfUrl,
$paramsUnhandled,
array('title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state %s on host %s',
'List %u services which are currently in state %s on host %s',
$object->stats->$unhandled
array(
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state %s on host %s',
'List %u services which are currently in state %s on host %s',
$object->stats->$unhandled
),
$object->stats->$unhandled,
Service::getStateText($stateId, true),
$object->host_name
),
$object->stats->$unhandled,
Service::getStateText($stateId, true),
$object->host_name
))
'data-base-target' => '_next'
)
);
}
if ($object->stats->$handled) {
if ($selfUrl->with($paramsHandled)->getRelativeUrl() === $currentUrl) {
$active = ' active';
} else {
$active = '';
}
if ($object->stats->$unhandled) {
echo '<span class="state handled ' . $state . $active . '">';
echo '<span class="state handled ' . $state . '">';
}
echo $this->qlink(
$object->stats->$handled,
$selfUrl,
$paramsHandled,
array('title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state %s (Acknowledged) on host %s',
'List %u services which are currently in state %s (Acknowledged) on host %s',
$object->stats->$handled
array(
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state %s (Acknowledged) on host %s',
'List %u services which are currently in state %s (Acknowledged) on host %s',
$object->stats->$handled
),
$object->stats->$handled,
Service::getStateText($stateId, true),
$object->host_name
),
$object->stats->$handled,
Service::getStateText($stateId, true),
$object->host_name
))
'data-base-target' => '_next'
)
);
if ($object->stats->$unhandled) {
echo "</span>\n";
@ -133,20 +126,23 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
}
?>
<?php if ($object->stats->services_pending): ?>
<span class="state pending<?= $currentUrl === $selfUrl->with('service_state', 99)->getRelativeUrl() ? ' active' : ''; ?>">
<span class="state pending">
<?= $this->qlink(
$object->stats->services_pending,
$selfUrl,
array('service_state' => 99),
array('title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state PENDING on host %s',
'List %u services which are currently in state PENDING on host %s',
$object->stats->services_pending
array(
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state PENDING on host %s',
'List %u services which are currently in state PENDING on host %s',
$object->stats->services_pending
),
$object->stats->services_pending,
$object->host_name
),
$object->stats->services_pending,
$object->host_name
))
'data-base-target' => '_next'
)
) ?>
</span>
<?php endif ?>

View File

@ -1,8 +0,0 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/host/object-header.phtml') ?>
<?= $this->render('partials/host/servicesummary.phtml') ?>
</div>
<?= $services ?>

View File

@ -181,19 +181,6 @@ abstract class MonitoredObjectController extends Controller
)
);
}
$tabs->add(
'services',
array(
'title' => sprintf(
$this->translate('List all services on host %s'),
$isService ? $object->getHost()->getName() : $object->getName()
),
'label' => $this->translate('Services'),
'icon' => 'services',
'url' => 'monitoring/show/services',
'urlParams' => $params
)
);
if ($this->backend->hasQuery('eventHistory')) {
$tabs->add(
'history',