diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
commit | a0901c4b7f2db488cb4fb3be2dd921a0308f4659 (patch) | |
tree | fafb393cf330a60df129ff10d0059eb7b14052a7 /application/views | |
parent | Initial commit. (diff) | |
download | icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.tar.xz icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/views')
-rw-r--r-- | application/views/scripts/joystickPagination-icingadb.phtml | 162 | ||||
-rw-r--r-- | application/views/scripts/services/grid-flipped.phtml | 148 | ||||
-rw-r--r-- | application/views/scripts/services/grid.phtml | 149 |
3 files changed, 459 insertions, 0 deletions
diff --git a/application/views/scripts/joystickPagination-icingadb.phtml b/application/views/scripts/joystickPagination-icingadb.phtml new file mode 100644 index 0000000..e5d2ac4 --- /dev/null +++ b/application/views/scripts/joystickPagination-icingadb.phtml @@ -0,0 +1,162 @@ +<?php + +use Icinga\Web\Url; + +$showText = $this->translate('%s: Show %s %u to %u out of %u', 'pagination.joystick'); +$flipUrl = clone $baseUrl; +if ($flipUrl->getParam('flipped')) { + $flipUrl->remove('flipped'); +} else { + $flipUrl->setParam('flipped'); +} +if ($flipUrl->hasParam('page')) { + $flipUrl->setParam('page', implode(',', array_reverse(explode(',', $flipUrl->getParam('page'))))); +} +if ($flipUrl->hasParam('limit')) { + $flipUrl->setParam('limit', implode(',', array_reverse(explode(',', $flipUrl->getParam('limit'))))); +} +$yAxisItemCountPerPage = $yAxisPaginator->getLimit(); +$yAxisTotalItem = $yAxisPaginator->count(); +$totalYAxisPages = ceil($yAxisTotalItem / $yAxisItemCountPerPage); +$currentYAxisPage = round($yAxisPaginator->getOffset() / $yAxisItemCountPerPage) + 1; +$prevYAxisPage = $currentYAxisPage > 1 ? $currentYAxisPage - 1 : null; +$nextYAxisPage = $currentYAxisPage < $totalYAxisPages ? $currentYAxisPage + 1 : null; + +$xAxisItemCountPerPage = $xAxisPaginator->getLimit(); +$xAxisTotalItem = $xAxisPaginator->count(); +$totalXAxisPages = ceil($xAxisTotalItem / $xAxisItemCountPerPage); +$currentXAxisPage = round($xAxisPaginator->getOffset() / $xAxisItemCountPerPage) + 1; +$prevXAxisPage = $currentXAxisPage > 1 ? $currentXAxisPage - 1 : null; +$nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : null; + +?> + +<table class="joystick-pagination"> + <tbody> + <tr> + <td> </td> + <td> + <?php if ($prevYAxisPage): ?> + <?= $this->qlink( + '', + $baseUrl, + array( + 'page' => $currentXAxisPage . ',' . $prevYAxisPage + ), + array( + 'icon' => 'up-open', + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('Y-Axis', 'pagination.joystick'), + $this->translate('hosts', 'pagination.joystick'), + ($prevYAxisPage - 1) * $xAxisItemCountPerPage + 1, + $prevYAxisPage * $xAxisItemCountPerPage, + $yAxisTotalItem + ) + ) + ); ?> + <?php else: ?> + <?= $this->icon('up-open'); ?> + <?php endif ?> + </td> + <td> </td> + </tr> + <tr> + <td> + <?php if ($prevXAxisPage): ?> + <?= $this->qlink( + '', + $baseUrl, + array( + 'page' => $prevXAxisPage . ',' . $currentYAxisPage + ), + array( + 'icon' => 'left-open', + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('X-Axis', 'pagination.joystick'), + $this->translate('services', 'pagination.joystick'), + ($prevXAxisPage - 1) * $xAxisItemCountPerPage + 1, + $prevXAxisPage * $xAxisItemCountPerPage, + $xAxisTotalItem + ) + ) + ); ?> + <?php else: ?> + <?= $this->icon('left-open'); ?> + <?php endif ?> + </td> + <?php if ($this->flippable): ?> + <td><?= $this->qlink( + '', + $flipUrl, + null, + array( + 'icon' => 'arrows-cw', + 'data-base-target' => '_self', + 'title' => $this->translate('Flip grid axes') + ) + ) ?></td> + <?php else: ?> + <td> </td> + <?php endif ?> + <td> + <?php if ($nextXAxisPage): ?> + <?= $this->qlink( + '', + $baseUrl, + array( + 'page' => $nextXAxisPage . ',' . $currentYAxisPage + ), + array( + 'icon' => 'right-open', + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('X-Axis', 'pagination.joystick'), + $this->translate('services', 'pagination.joystick'), + $currentXAxisPage * $xAxisItemCountPerPage + 1, + $nextXAxisPage === $totalXAxisPages ? $xAxisItemCountPerPage : $nextXAxisPage * $xAxisItemCountPerPage, + $xAxisTotalItem + ) + ), + false + ); ?> + <?php else: ?> + <?= $this->icon('right-open'); ?> + <?php endif ?> + </td> + </tr> + <tr> + <td> </td> + <td> + <?php if ($nextYAxisPage): ?> + <?= $this->qlink( + '', + $baseUrl, + array( + 'page' => $currentXAxisPage . ',' . $nextYAxisPage + ), + array( + 'icon' => 'down-open', + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('Y-Axis', 'pagination.joystick'), + $this->translate('hosts', 'pagination.joystick'), + $currentYAxisPage * $yAxisItemCountPerPage + 1, + $nextYAxisPage === $totalYAxisPages ? $yAxisItemCountPerPage : $nextYAxisPage * $yAxisItemCountPerPage, + $yAxisTotalItem + ) + ) + ); ?> + <?php else: ?> + <?= $this->icon('down-open'); ?> + <?php endif ?> + </td> + <td> </td> + </tr> + </tbody> +</table> diff --git a/application/views/scripts/services/grid-flipped.phtml b/application/views/scripts/services/grid-flipped.phtml new file mode 100644 index 0000000..f186fda --- /dev/null +++ b/application/views/scripts/services/grid-flipped.phtml @@ -0,0 +1,148 @@ +<?php +use Icinga\Data\Filter\Filter; +use Icinga\Module\Icingadb\Common\ServiceStates; +use Icinga\Web\Url; + +if (! $this->compact): ?> + <?= $this->controls ?> +<?php endif ?> +<div class="content" data-base-target="_next" id="<?= $this->protectId('content') ?>"> + <?php if (empty($pivotData)): ?> + <div class="item-list"> + <div class="empty-state"><?= $this->translate('No services found matching the filter.') ?></div> + </div> +</div> +<?php return; endif; +$serviceFilter = Filter::matchAny(); +foreach ($pivotData as $serviceDescription => $_) { + $serviceFilter->orFilter(Filter::where('service.name', $serviceDescription)); +} +?> +<table class="service-grid-table"> + <thead> + <tr> + <th><?= $this->partial( + 'joystickPagination-icingadb.phtml', + 'default', + array( + 'flippable' => true, + 'baseUrl' => $baseUrl, + 'xAxisPaginator' => $horizontalPaginator, + 'yAxisPaginator' => $verticalPaginator + ) + ) ?></th> + <?php foreach ($pivotHeader['cols'] as $hostName => $hostAlias): ?> + <th class="rotate-45"><div><span><?= $this->qlink( + $this->ellipsis($hostAlias, 24), + Url::fromPath('icingadb/services')->addFilter( + Filter::matchAll($serviceFilter, Filter::where('host.name', $hostName)) + ), + null, + array('title' => sprintf($this->translate('List all reported services on host %s'), $hostAlias)), + false + ) ?></span></div></th> + <?php endforeach ?> + </tr> + </thead> + <tbody> + + <?php $i = 0 ?> + <?php foreach ($pivotHeader['rows'] as $serviceDescription => $serviceDisplayName): ?> + <tr> + <th><?php + $hostFilter = Filter::matchAny(); + foreach ($pivotData[$serviceDescription] as $hostName => $_) { + $hostFilter->orFilter(Filter::where('host.name', $hostName)); + } + echo $this->qlink( + $serviceDisplayName, + Url::fromPath('icingadb/services')->addFilter( + Filter::matchAll($hostFilter, Filter::where('service.name', $serviceDescription)) + ), + null, + array('title' => sprintf( + $this->translate('List all services with the name "%s" on all reported hosts'), + $serviceDisplayName + )) + ); + ?></th> + <?php foreach (array_keys($pivotHeader['cols']) as $hostName): ?> + <td><?php + $service = $pivotData[$serviceDescription][$hostName]; + if ($service === null): ?> + <span aria-hidden="true">·</span> + <?php continue; endif ?> + <?php $ariaDescribedById = $this->protectId($service->host_name . '_' . $service->name . '_desc') ?> + <span class="sr-only" id="<?= $ariaDescribedById ?>"> + <?= $this->escape($service->state->output) ?> + </span> + <?= $this->qlink( + '', + 'icingadb/services', + array( + 'host.name' => $hostName, + 'name' => $serviceDescription + ), + array( + 'aria-describedby' => $ariaDescribedById, + 'aria-label' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $service->display_name, + $service->host_display_name + ), + 'class' => 'service-grid-link state-' . $service->state->getStateText() . ($service->state->is_handled ? ' handled' : ''), + 'title' => $service->state->output + ) + ) ?> + </td> + <?php endforeach ?> + <?php + $horizontalItemsPerPage = $this->horizontalPaginator->getLimit(); + $horizontalTotalPages = ceil($this->horizontalPaginator->count() / $horizontalItemsPerPage); + + + $verticalItemsPerPage = $this->verticalPaginator->getLimit(); + $verticalTotalPages = ceil($this->verticalPaginator->count() / $verticalItemsPerPage); + + if (! $this->compact && $horizontalTotalPages > 1): ?> + <td> + <?php $expandLink = $this->qlink( + $this->translate('Load more'), + $baseUrl, + array( + 'limit' => ($horizontalItemsPerPage + 20) + . ',' + . $verticalItemsPerPage + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> + <?= ++$i === (int) ceil(count($pivotHeader['rows']) / 2) ? $expandLink : '' ?> + </td> + <?php endif ?> + </tr> + <?php endforeach ?> + <?php if (! $this->compact && $verticalTotalPages > 1): ?> + <tr> + <td colspan="<?= count($pivotHeader['cols']) + 1?>" class="service-grid-table-more"> + <?php echo $this->qlink( + $this->translate('Load more'), + $baseUrl, + array( + 'limit' => $horizontalItemsPerPage + . ',' + . ($verticalItemsPerPage + 20) + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> + </td> + </tr> + <?php endif ?> + </tbody> +</table> +</div> diff --git a/application/views/scripts/services/grid.phtml b/application/views/scripts/services/grid.phtml new file mode 100644 index 0000000..560f7c0 --- /dev/null +++ b/application/views/scripts/services/grid.phtml @@ -0,0 +1,149 @@ +<?php +use Icinga\Data\Filter\Filter; +use Icinga\Module\Icingadb\Common\ServiceStates; +use Icinga\Web\Url; + +if (! $this->compact): ?> + <?= $this->controls ?> +<?php endif ?> +<div class="content" data-base-target="_next" id="<?= $this->protectId('content') ?>"> +<?php if (empty($pivotData)): ?> + <div class="item-list"> + <div class="empty-state"><?= $this->translate('No services found matching the filter.') ?></div> + </div> +</div> +<?php return; endif; +$hostFilter = Filter::matchAny(); +foreach ($pivotData as $hostName => $_) { + $hostFilter->orFilter(Filter::where('host.name', $hostName)); +} +?> + <table class="service-grid-table"> + <thead> + <tr> + <th><?= $this->partial( + 'joystickPagination-icingadb.phtml', + 'default', + array( + 'flippable' => true, + 'baseUrl' => $baseUrl, + 'xAxisPaginator' => $horizontalPaginator, + 'yAxisPaginator' => $verticalPaginator + ) + ); ?></th> + <?php foreach ($pivotHeader['cols'] as $serviceDescription => $serviceDisplayName):?> + <th class="rotate-45"><div><span><?= $this->qlink( + $this->ellipsis($serviceDisplayName, 24), + Url::fromPath('icingadb/services')->addFilter( + Filter::matchAll($hostFilter, Filter::where('service.name', $serviceDescription)) + ), + null, + array('title' => sprintf( + $this->translate('List all services with the name "%s" on all reported hosts'), + $serviceDisplayName + )), + false + ) ?></span></div></th> + <?php endforeach ?> + </tr> + </thead> + <tbody> + + <?php $i = 0 ?> + <?php foreach ($pivotHeader['rows'] as $hostName => $hostDisplayName): ?> + <tr> + <th><?php + $serviceFilter = Filter::matchAny(); + foreach ($pivotData[$hostName] as $serviceName => $_) { + $serviceFilter->orFilter(Filter::where('service.name', $serviceName)); + } + echo $this->qlink( + $hostDisplayName, + Url::fromPath('icingadb/services')->addFilter( + Filter::matchAll($serviceFilter, Filter::where('host.name', $hostName)) + ), + null, + array('title' => sprintf($this->translate('List all reported services on host %s'), $hostDisplayName)) + ); + ?></th> + <?php foreach (array_keys($pivotHeader['cols']) as $serviceDescription): ?> + <td> + <?php + $service = $pivotData[$hostName][$serviceDescription]; + if ($service === null): ?> + <span aria-hidden="true">·</span> + <?php continue; endif ?> + <?php + $ariaDescribedById = $this->protectId($service->host_name . '_' . $service->name . '_desc') ?> + <span class="sr-only" id="<?= $ariaDescribedById ?>"> + <?= $this->escape($service->state->output) ?> + </span> + <?= $this->qlink( + '', + 'icingadb/service', + array( + 'host.name' => $hostName, + 'name' => $serviceDescription + ), + array( + 'aria-describedby' => $ariaDescribedById, + 'aria-label' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $service->display_name, + $service->host_display_name + ), + 'class' => 'service-grid-link state-' . $service->state->getStateText() . ($service->state->is_handled ? ' handled' : ''), + 'title' => $service->state->output + ) + ) ?> + </td> + <?php endforeach ?> + <?php + $horizontalItemsPerPage = $this->horizontalPaginator->getLimit(); + $horizontalTotalPages = ceil($this->horizontalPaginator->count() / $horizontalItemsPerPage); + + + $verticalItemsPerPage = $this->verticalPaginator->getLimit(); + $verticalTotalPages = ceil($this->verticalPaginator->count() / $verticalItemsPerPage); + + if (! $this->compact && $horizontalTotalPages > 1): ?> + <td> + <?php $expandLink = $this->qlink( + $this->translate('Load more'), + $baseUrl, + array( + 'limit' => ( + $horizontalItemsPerPage + 20) . ',' + . $verticalItemsPerPage + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> + <?= ++$i === (int) (count($pivotHeader['rows']) / 2) ? $expandLink : '' ?> + </td> + <?php endif ?> + </tr> + <?php endforeach ?> + <?php if (! $this->compact && $verticalTotalPages > 1): ?> + <tr> + <td colspan="<?= count($pivotHeader['cols']) + 1?>" class="service-grid-table-more"> + <?php echo $this->qlink( + $this->translate('Load more'), + $baseUrl, + array( + 'limit' => $horizontalItemsPerPage . ',' . + ($verticalItemsPerPage + 20) + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> + </td> + </tr> + <?php endif ?> + </tbody> + </table> +</div> |