From 379331896f4b696e9cd5be53a81e998619aedd11 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: Set severity as default sort --- application/controllers/HostgroupsController.php | 5 ++--- application/controllers/HostsController.php | 6 +++++- application/controllers/ServicegroupsController.php | 5 +---- application/controllers/ServicesController.php | 6 +++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/application/controllers/HostgroupsController.php b/application/controllers/HostgroupsController.php index 700c6fd74..93d90fb13 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,10 +52,10 @@ 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, [ diff --git a/application/controllers/HostsController.php b/application/controllers/HostsController.php index fff7139a2..cd2f884f4 100644 --- a/application/controllers/HostsController.php +++ b/application/controllers/HostsController.php @@ -50,6 +50,8 @@ 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, [ @@ -57,8 +59,10 @@ public function indexAction() 'host.state.severity desc,host.state.last_state_change desc' => t('Severity'), '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..d9be5340a 100644 --- a/application/controllers/ServicegroupsController.php +++ b/application/controllers/ServicegroupsController.php @@ -40,10 +40,7 @@ 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, diff --git a/application/controllers/ServicesController.php b/application/controllers/ServicesController.php index c39f8b5de..926b79156 100644 --- a/application/controllers/ServicesController.php +++ b/application/controllers/ServicesController.php @@ -60,6 +60,8 @@ 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, [ @@ -68,8 +70,10 @@ public function indexAction() '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);