monitoring: Rewrite service-grid view script

refs #9538
This commit is contained in:
Eric Lippmann 2015-08-25 14:55:02 +02:00
parent bf7d1ba878
commit c5fe641c43

View File

@ -12,19 +12,14 @@ if (! $this->compact): ?>
<?php endif ?> <?php endif ?>
<div class="content" data-base-target="_next"> <div class="content" data-base-target="_next">
<?php <?php
$hasHeader = false;
$pivotData = $this->pivot->toArray();
if (empty($pivotData)) { if (empty($pivotData)) {
echo $this->translate('No services found matching the filter') . '</div>'; echo $this->translate('No services found matching the filter') . '</div>';
return; return;
} }
$hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ')'; $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ')';
?> ?>
<table class="pivot servicestates">
<?php foreach ($pivotData as $hostName => $services): ?> <table class="service-grid-table">
<?php if (!$hasHeader): ?>
<thead> <thead>
<tr> <tr>
<th><?= $this->partial( <th><?= $this->partial(
@ -35,59 +30,54 @@ $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . '
'yAxisPaginator' => $verticalPaginator 'yAxisPaginator' => $verticalPaginator
) )
); ?></th> ); ?></th>
<th colspan="<?= count($services); ?>"> <?php foreach ($pivotHeader['cols'] as $serviceDescription => $serviceDisplayName): ?>
<div> <th class="rotate-45"><div><span><?= $this->qlink(
<?php $this->ellipsis($serviceDisplayName, 18),
$serviceDescriptions = array_keys($services);
$serviceFilter = '(service_description=' . implode('|service_description=', $serviceDescriptions) . ')';
foreach ($serviceDescriptions as $serviceDescription): ?>
<span>
<?= $this->qlink(
'<abbr>' . $this->ellipsis($serviceDescription, 18) . '</abbr>',
'monitoring/list/services?' . $hostFilter, 'monitoring/list/services?' . $hostFilter,
array( array('service_description' => $serviceDescription),
'service_description' => $serviceDescription array('title' => sprintf(
), $this->translate('List all services with the name "%s" on all reported hosts'),
array( $serviceDisplayName
'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $serviceDescription) )),
),
false false
); ?> ) ?></span></div></th>
</span>
<?php endforeach ?> <?php endforeach ?>
</div>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $hasHeader = true; ?> <?php foreach ($pivotHeader['rows'] as $hostName => $hostDisplayName): ?>
<?php endif ?>
<tr> <tr>
<th> <th><?php
<?= $this->qlink( $services = $pivotData[$hostName];
$hostName, $serviceFilter = '(service_description=' . implode('|service_description=', array_keys($services)) . ')';
echo $this->qlink(
$hostDisplayName,
'monitoring/list/services?' . $serviceFilter, 'monitoring/list/services?' . $serviceFilter,
array('host' => $hostName), array('host_name' => $hostName),
array('title' => sprintf($this->translate('List all reported services on host %s'), $hostName)) array('title' => sprintf($this->translate('List all reported services on host %s'), $hostDisplayName))
); ?> );
</th> ?></th>
<?php foreach ($services as $service): ?> <?php foreach (array_keys($pivotHeader['cols']) as $serviceDescription): ?>
<?php if ($service !== null): ?>
<td> <td>
<span class="sr-only" id="<?= $service->host_name . '_' . $service->service_description . '_desc'; ?>"> <?php
<?= $this->escape($service->service_output); ?> $service = $pivotData[$hostName][$serviceDescription];
if ($service === null): ?>
<span aria-hidden="true">&middot;</span>
<?php continue; endif ?>
<?php $ariaDescribedById = $this->protectId($service->host_name . '_' . $service->service_description . '_desc') ?>
<span class="sr-only" id="<?= $ariaDescribedById ?>">
<?= $this->escape($service->service_output) ?>
</span> </span>
<?= $this->qlink( <?= $this->qlink(
'', '',
'monitoring/show/service', 'monitoring/show/service',
array( array(
'host' => $service->host_name, 'host' => $hostName,
'service' => $service->service_description 'service' => $serviceDescription
), ),
array( array(
'aria-describedby' => $service->host_name . '_' . $service->service_description . '_desc', 'aria-describedby' => $ariaDescribedById,
'class' => 'state_' . Service::getStateText($service->service_state). ($service->service_handled ? ' handled' : ''), 'class' => 'bg-state-' . Service::getStateText($service->service_state) . ($service->service_handled ? ' handled' : ''),
'title' => $this->escape($service->service_output), 'title' => $this->escape($service->service_output),
'aria-label' => sprintf( 'aria-label' => sprintf(
$this->translate('Show detailed information for service %s on host %s'), $this->translate('Show detailed information for service %s on host %s'),
@ -97,9 +87,6 @@ foreach ($serviceDescriptions as $serviceDescription): ?>
) )
); ?> ); ?>
</td> </td>
<?php else: ?>
<td><span aria-hidden="true">&middot;</span></td>
<?php endif ?>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>