From 9ce5e2aa6071fcd12fbd6162f0039abeb53bf575 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 May 2018 13:44:13 +0200 Subject: [PATCH] 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 )