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
This commit is contained in:
Johannes Meyer 2018-05-02 13:44:13 +02:00
parent 7c7b4a928d
commit 9ce5e2aa60
3 changed files with 29 additions and 11 deletions

View File

@ -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')))));
}

View File

@ -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;

View File

@ -27,6 +27,7 @@ foreach ($pivotData as $hostName => $_) {
'joystickPagination.phtml',
'default',
array(
'flippable' => true,
'xAxisPaginator' => $horizontalPaginator,
'yAxisPaginator' => $verticalPaginator
)