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
1 changed files with 68 additions and 81 deletions

View File

@ -12,97 +12,84 @@ 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): ?>
<?php if (!$hasHeader): ?>
<thead>
<tr>
<th><?= $this->partial(
'joystickPagination.phtml',
'default',
array(
'xAxisPaginator' => $horizontalPaginator,
'yAxisPaginator' => $verticalPaginator
)
); ?></th>
<th colspan="<?= count($services); ?>">
<div>
<?php
$serviceDescriptions = array_keys($services);
$serviceFilter = '(service_description=' . implode('|service_description=', $serviceDescriptions) . ')';
foreach ($serviceDescriptions as $serviceDescription): ?> <table class="service-grid-table">
<span> <thead>
<?= $this->qlink( <tr>
'<abbr>' . $this->ellipsis($serviceDescription, 18) . '</abbr>', <th><?= $this->partial(
'joystickPagination.phtml',
'default',
array(
'xAxisPaginator' => $horizontalPaginator,
'yAxisPaginator' => $verticalPaginator
)
); ?></th>
<?php foreach ($pivotHeader['cols'] as $serviceDescription => $serviceDisplayName): ?>
<th class="rotate-45"><div><span><?= $this->qlink(
$this->ellipsis($serviceDisplayName, 18),
'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 ?> </tr>
</div>
</th>
</tr>
</thead> </thead>
<tbody> <tbody>
<?php $hasHeader = true; ?> <?php foreach ($pivotHeader['rows'] as $hostName => $hostDisplayName): ?>
<?php endif ?> <tr>
<tr> <th><?php
<th> $services = $pivotData[$hostName];
<?= $this->qlink( $serviceFilter = '(service_description=' . implode('|service_description=', array_keys($services)) . ')';
$hostName, echo $this->qlink(
'monitoring/list/services?' . $serviceFilter, $hostDisplayName,
array('host' => $hostName), 'monitoring/list/services?' . $serviceFilter,
array('title' => sprintf($this->translate('List all reported services on host %s'), $hostName)) array('host_name' => $hostName),
); ?> array('title' => sprintf($this->translate('List all reported services on host %s'), $hostDisplayName))
</th> );
<?php foreach ($services as $service): ?> ?></th>
<?php if ($service !== null): ?> <?php foreach (array_keys($pivotHeader['cols']) as $serviceDescription): ?>
<td> <td>
<span class="sr-only" id="<?= $service->host_name . '_' . $service->service_description . '_desc'; ?>"> <?php
<?= $this->escape($service->service_output); ?> $service = $pivotData[$hostName][$serviceDescription];
</span> if ($service === null): ?>
<?= $this->qlink( <span aria-hidden="true">&middot;</span>
'', <?php continue; endif ?>
'monitoring/show/service', <?php $ariaDescribedById = $this->protectId($service->host_name . '_' . $service->service_description . '_desc') ?>
array( <span class="sr-only" id="<?= $ariaDescribedById ?>">
'host' => $service->host_name, <?= $this->escape($service->service_output) ?>
'service' => $service->service_description </span>
), <?= $this->qlink(
array( '',
'aria-describedby' => $service->host_name . '_' . $service->service_description . '_desc', 'monitoring/show/service',
'class' => 'state_' . Service::getStateText($service->service_state). ($service->service_handled ? ' handled' : ''), array(
'title' => $this->escape($service->service_output), 'host' => $hostName,
'aria-label' => sprintf( 'service' => $serviceDescription
$this->translate('Show detailed information for service %s on host %s'), ),
$service->service_display_name, array(
$service->host_display_name 'aria-describedby' => $ariaDescribedById,
) 'class' => 'bg-state-' . Service::getStateText($service->service_state) . ($service->service_handled ? ' handled' : ''),
) 'title' => $this->escape($service->service_output),
); ?> 'aria-label' => sprintf(
</td> $this->translate('Show detailed information for service %s on host %s'),
<?php else: ?> $service->service_display_name,
<td><span aria-hidden="true">&middot;</span></td> $service->host_display_name
<?php endif ?> )
<?php endforeach ?> )
</tr> ); ?>
<?php endforeach ?> </td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>