From deea667624529789c25b926b86389a84c4cb6cdb Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Thu, 9 Jan 2025 15:47:55 +0100 Subject: [PATCH] Host/Service/Hostgroup/Servicegroup: Use severity as default sort order --- application/controllers/HostgroupsController.php | 7 +++---- application/controllers/HostsController.php | 9 +++++++-- application/controllers/ServicegroupsController.php | 7 ++----- application/controllers/ServicesController.php | 8 ++++++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/application/controllers/HostgroupsController.php b/application/controllers/HostgroupsController.php index 700c6fd74..fd6db6810 100644 --- a/application/controllers/HostgroupsController.php +++ b/application/controllers/HostgroupsController.php @@ -40,7 +40,6 @@ public function indexAction() $paginationControl = $this->createPaginationControl($hostgroups); $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl); - $defaultSort = null; if ($viewModeSwitcher->getViewMode() === 'grid') { $hostgroups->without([ 'services_critical_handled', @@ -53,15 +52,15 @@ public function indexAction() 'services_warning_handled', 'services_warning_unhandled', ]); - - $defaultSort = ['hosts_severity DESC', 'display_name']; } + $defaultSort = ['hosts_severity DESC', 'display_name']; + $sortControl = $this->createSortControl( $hostgroups, [ - 'display_name' => t('Name'), 'hosts_severity desc, display_name' => t('Severity'), + 'display_name' => t('Name'), 'hosts_total desc' => t('Total Hosts'), ], $defaultSort diff --git a/application/controllers/HostsController.php b/application/controllers/HostsController.php index fff7139a2..c07e30dae 100644 --- a/application/controllers/HostsController.php +++ b/application/controllers/HostsController.php @@ -50,15 +50,20 @@ public function indexAction() $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($hosts); + + $defaultSort = ['host.state.severity DESC', 'host.state.last_state_change DESC']; + $sortControl = $this->createSortControl( $hosts, [ - 'host.display_name' => t('Name'), 'host.state.severity desc,host.state.last_state_change desc' => t('Severity'), + 'host.display_name' => t('Name'), 'host.state.soft_state' => t('Current State'), 'host.state.last_state_change desc' => t('Last State Change') - ] + ], + $defaultSort ); + $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl); $columns = $this->createColumnControl($hosts, $viewModeSwitcher); diff --git a/application/controllers/ServicegroupsController.php b/application/controllers/ServicegroupsController.php index 299d001b8..3aff53cb8 100644 --- a/application/controllers/ServicegroupsController.php +++ b/application/controllers/ServicegroupsController.php @@ -40,16 +40,13 @@ public function indexAction() $paginationControl = $this->createPaginationControl($servicegroups); $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl); - $defaultSort = null; - if ($viewModeSwitcher->getViewMode() === 'grid') { - $defaultSort = ['services_severity DESC', 'display_name']; - } + $defaultSort = ['services_severity DESC', 'display_name']; $sortControl = $this->createSortControl( $servicegroups, [ - 'display_name' => t('Name'), 'services_severity desc, display_name' => t('Severity'), + 'display_name' => t('Name'), 'services_total desc' => t('Total Services') ], $defaultSort diff --git a/application/controllers/ServicesController.php b/application/controllers/ServicesController.php index c39f8b5de..b66da4d09 100644 --- a/application/controllers/ServicesController.php +++ b/application/controllers/ServicesController.php @@ -60,16 +60,20 @@ public function indexAction() $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($services); + + $defaultSort = ['service.state.severity DESC', 'service.state.last_state_change Desc']; $sortControl = $this->createSortControl( $services, [ - 'service.display_name' => t('Name'), 'service.state.severity desc,service.state.last_state_change desc' => t('Severity'), + 'service.display_name' => t('Name'), 'service.state.soft_state' => t('Current State'), 'service.state.last_state_change desc' => t('Last State Change'), 'host.display_name' => t('Host') - ] + ], + $defaultSort ); + $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl); $columns = $this->createColumnControl($services, $viewModeSwitcher);