From 7c7b4a928d7e09ecff190e10cd2f6945b67eafdf Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 May 2018 13:42:57 +0200 Subject: [PATCH 1/7] joystickPagination: Add small control to flip axes Don't know if that's the final solution. There's probably a better (more visible) one. refs #2640 --- .../views/scripts/joystickPagination.phtml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index 9549fc2b0..134796b79 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -10,6 +10,15 @@ $showText = $this->translate('%s: Show %s %u to %u out of %u', 'pagination.joyst $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); +$flipUrl = Url::fromRequest(); +$flipUrl->setParam('flipped', (int) ! $flipUrl->getParam('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'))))); +} + $totalYAxisPages = $yAxisPaginator->count(); $currentYAxisPage = $yAxisPaginator->getCurrentPageNumber(); $prevYAxisPage = $currentYAxisPage > 1 ? $currentYAxisPage - 1 : null; @@ -79,7 +88,20 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : icon('left-open'); ?> + flippable): ?> + qlink( + '', + $flipUrl, + null, + array( + 'icon' => 'arrows-cw', + 'data-base-target' => '_self', + 'title' => $this->translate('Flip grid axes') + ) + ) ?> +   + qlink( From 9ce5e2aa6071fcd12fbd6162f0039abeb53bf575 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 May 2018 13:44:13 +0200 Subject: [PATCH 2/7] list/servicegrid: Allow to flip the grid's axes Still missing: * Flipped quick search columns * Non-hardcoded axis labels Probably make this a dedicated view? refs #2640 --- .../views/scripts/joystickPagination.phtml | 6 +++- .../controllers/ListController.php | 33 +++++++++++++------ .../views/scripts/list/servicegrid.phtml | 1 + 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index 134796b79..cd2555c47 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -11,7 +11,11 @@ $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); $flipUrl = Url::fromRequest(); -$flipUrl->setParam('flipped', (int) ! $flipUrl->getParam('flipped')); +if ($flipUrl->hasParam('flipped')) { + $flipUrl->remove('flipped'); +} else { + $flipUrl->setParam('flipped'); +} if ($flipUrl->hasParam('page')) { $flipUrl->setParam('page', implode(',', array_reverse(explode(',', $flipUrl->getParam('page'))))); } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index da2058173..171a10427 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -589,15 +589,27 @@ class ListController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $this->filterQuery($query); $filter = (bool) $this->params->shift('problems', false) ? Filter::where('service_problem', 1) : null; - $pivot = $query - ->pivot( - 'service_description', - 'host_name', - $filter, - $filter ? clone $filter : null - ) - ->setXAxisHeader('service_display_name') - ->setYAxisHeader('host_display_name'); + if ($this->params->has('flipped')) { + $pivot = $query + ->pivot( + 'host_name', + 'service_description', + $filter, + $filter ? clone $filter : null + ) + ->setYAxisHeader('service_display_name') + ->setXAxisHeader('host_display_name'); + } else { + $pivot = $query + ->pivot( + 'service_description', + 'host_name', + $filter, + $filter ? clone $filter : null + ) + ->setXAxisHeader('service_display_name') + ->setYAxisHeader('host_display_name'); + } $this->setupSortControl(array( 'host_display_name' => $this->translate('Hostname'), 'service_display_name' => $this->translate('Service Name') @@ -622,7 +634,8 @@ class ListController extends Controller 'format', // handleFormatRequest() 'stateType', // hostsAction() and servicesAction() 'addColumns', // addColumns() - 'problems' // servicegridAction() + 'problems', // servicegridAction() + 'flipped' // servicegridAction() )); $this->handleFormatRequest($dataView); return $dataView; diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 0e50855b5..59bc196e9 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -27,6 +27,7 @@ foreach ($pivotData as $hostName => $_) { 'joystickPagination.phtml', 'default', array( + 'flippable' => true, 'xAxisPaginator' => $horizontalPaginator, 'yAxisPaginator' => $verticalPaginator ) From e6cb82b34b96b22a2a2b87ba9dd7ed400ce3e347 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 May 2018 13:46:07 +0200 Subject: [PATCH 3/7] list/servicegrid: Push sort control to the right That's where all of our sort controls are located. Confuses users like me otherwise and violates one of the basic ui design principles.. refs #2640 --- .../application/views/scripts/list/servicegrid.phtml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 59bc196e9..92cce9364 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -6,7 +6,9 @@ use Icinga\Web\Url; if (! $this->compact): ?>
tabs ?> - sortBox ?> +
+ sortBox ?> +
filterEditor ?>
From 589d1bb75cb9ce39049b3dc2e3eaeffa14690d0a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 3 May 2018 09:34:36 +0200 Subject: [PATCH 4/7] list/servicegrid: Use a different view script when axes are flipped refs #2640 --- .../controllers/ListController.php | 3 + .../scripts/list/servicegrid-flipped.phtml | 143 ++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 171a10427..900062764 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -619,6 +619,9 @@ class ListController extends Controller list($pivotData, $pivotHeader) = $pivot->toArray(); $this->view->pivotData = $pivotData; $this->view->pivotHeader = $pivotHeader; + if ($this->params->get('flipped')) { + $this->render('servicegrid-flipped'); + } } /** diff --git a/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml b/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml new file mode 100644 index 000000000..777fdc890 --- /dev/null +++ b/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml @@ -0,0 +1,143 @@ +compact): ?> +
+ tabs ?> +
+ sortBox ?> +
+ filterEditor ?> +
+ +
+ +

translate('No services found matching the filter.') ?>

+
+ $_) { + $serviceFilter->orFilter(Filter::where('service_description', $serviceDescription)); +} +?> + + + + + $hostAlias): ?> + + + + + + + + $serviceDisplayName): ?> + + + + + + compact && $this->horizontalPaginator->getPages()->pageCount > 1): ?> + + + + + compact && $this->verticalPaginator->getPages()->pageCount > 1): ?> + + + + + +
partial( + 'joystickPagination.phtml', + 'default', + array( + 'flippable' => true, + 'xAxisPaginator' => $horizontalPaginator, + 'yAxisPaginator' => $verticalPaginator + ) + ) ?>
qlink( + $this->ellipsis($hostAlias, 18), + Url::fromPath('monitoring/list/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 + ) ?>
$_) { + $hostFilter->orFilter(Filter::where('host_name', $hostName)); + } + echo $this->qlink( + $serviceDisplayName, + Url::fromPath('monitoring/list/services')->addFilter( + Filter::matchAll($hostFilter, Filter::where('service_description', $serviceDescription)) + ), + null, + array('title' => sprintf( + $this->translate('List all services with the name "%s" on all reported hosts'), + $serviceDisplayName + )) + ); + ?> + + + protectId($service->host_name . '_' . $service->service_description . '_desc') ?> + + escape($service->service_output) ?> + + qlink( + '', + 'monitoring/service/show', + array( + 'host' => $hostName, + 'service' => $serviceDescription + ), + array( + 'aria-describedby' => $ariaDescribedById, + 'aria-label' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $service->service_display_name, + $service->host_display_name + ), + 'class' => 'service-grid-link state-' . Service::getStateText($service->service_state) . ($service->service_handled ? ' handled' : ''), + 'title' => $service->service_output + ) + ) ?> + + qlink( + $this->translate('Load more'), + Url::fromRequest(), + array( + 'limit' => ($this->horizontalPaginator->getItemCountPerPage() + 20) + . ',' + . $this->verticalPaginator->getItemCountPerPage() + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> + +
+ qlink( + $this->translate('Load more'), + Url::fromRequest(), + array( + 'limit' => $this->horizontalPaginator->getItemCountPerPage() + . ',' + . ($this->verticalPaginator->getItemCountPerPage() + 20) + ), + array( + 'class' => 'action-link', + 'data-base-target' => '_self' + ) + ) ?> +
+ From bc398bc8dfca4c9d24d003c848a0061f6ff0007b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 3 May 2018 10:34:05 +0200 Subject: [PATCH 5/7] list/servicegrid: Increase joystick size to make it more apparent Also increases x-axis label length by 30% since we're now showing hostnames which are usually longer than service descriptions. Also this makes room for actually being able to increase the joystick size. refs #2640 --- .../application/views/scripts/list/servicegrid-flipped.phtml | 2 +- .../application/views/scripts/list/servicegrid.phtml | 2 +- modules/monitoring/public/css/service-grid.less | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml b/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml index 777fdc890..59378152d 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid-flipped.phtml @@ -36,7 +36,7 @@ foreach ($pivotData as $serviceDescription => $_) { ) ?> $hostAlias): ?>
qlink( - $this->ellipsis($hostAlias, 18), + $this->ellipsis($hostAlias, 24), Url::fromPath('monitoring/list/services')->addFilter( Filter::matchAll($serviceFilter, Filter::where('host_name', $hostName)) ), diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 92cce9364..e1c3cf942 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -36,7 +36,7 @@ foreach ($pivotData as $hostName => $_) { ) ?> $serviceDisplayName): ?>
qlink( - $this->ellipsis($serviceDisplayName, 18), + $this->ellipsis($serviceDisplayName, 24), Url::fromPath('monitoring/list/services')->addFilter( Filter::matchAll($hostFilter, Filter::where('service_description', $serviceDescription)) ), diff --git a/modules/monitoring/public/css/service-grid.less b/modules/monitoring/public/css/service-grid.less index 49409524a..57ead0b32 100644 --- a/modules/monitoring/public/css/service-grid.less +++ b/modules/monitoring/public/css/service-grid.less @@ -12,10 +12,10 @@ } .rotate-45 { - height: 6em; + height: 8em; div { - .transform(translate(0.4em, 2.1em) rotate(315deg)); + .transform(translate(0.4em, 2.8em) rotate(315deg)); width: 1.5em; } } @@ -30,6 +30,7 @@ .joystick-pagination { margin: 0 auto; + font-size: 130%; a { color: @text-color; From 568d473c401cb463cb7c5f1e4a860e7bc10f0d98 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 7 May 2018 14:10:03 +0200 Subject: [PATCH 6/7] joystickPagination: Show the pagination even if there's nothing to page refs #2640 --- application/views/scripts/joystickPagination.phtml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index cd2555c47..ae3e157bb 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -2,10 +2,6 @@ use Icinga\Web\Url; -if ($xAxisPaginator->count() <= 1 && $yAxisPaginator->count() <= 1) { - return; // Display this pagination only if there are multiple pages -} - $showText = $this->translate('%s: Show %s %u to %u out of %u', 'pagination.joystick'); $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); From 9b76ff55395e85177c2f0a0418f6e3355c7f353d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 7 May 2018 14:14:34 +0200 Subject: [PATCH 7/7] servicegrid: Properly handle `?flipped=0` refs #2640 --- application/views/scripts/joystickPagination.phtml | 2 +- modules/monitoring/application/controllers/ListController.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index ae3e157bb..a8c24c9f6 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -7,7 +7,7 @@ $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); $flipUrl = Url::fromRequest(); -if ($flipUrl->hasParam('flipped')) { +if ($flipUrl->getParam('flipped')) { $flipUrl->remove('flipped'); } else { $flipUrl->setParam('flipped'); diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 900062764..90d1dcf99 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -589,7 +589,7 @@ class ListController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $this->filterQuery($query); $filter = (bool) $this->params->shift('problems', false) ? Filter::where('service_problem', 1) : null; - if ($this->params->has('flipped')) { + if ($this->params->get('flipped', false)) { $pivot = $query ->pivot( 'host_name', @@ -619,7 +619,7 @@ class ListController extends Controller list($pivotData, $pivotHeader) = $pivot->toArray(); $this->view->pivotData = $pivotData; $this->view->pivotHeader = $pivotHeader; - if ($this->params->get('flipped')) { + if ($this->params->get('flipped', false)) { $this->render('servicegrid-flipped'); } }