From f5260ab67219a48bdc97aa7ffab5c1ed5845f2f5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 16 Apr 2020 12:32:43 +0200 Subject: [statistics] Make sort order in client list match the location tree It's still not showing the actual tree, but sorting is the same as the location list now, but obviously skipping locations where no clients match the display filter. --- modules-available/statistics/pages/list.inc.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'modules-available/statistics/pages') diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index 97133aa2..4df60044 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -63,6 +63,7 @@ class SubPage $execAllowedLocations = User::getAllowedLocations('.rebootcontrol.action.exec'); // Only make client clickable if user is allowed to view details page $detailsAllowedLocations = User::getAllowedLocations("machine.view-details"); + $location = self::buildLocationLookup(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($singleMachine === 'none') { $singleMachine = $row['machineuuid']; @@ -107,7 +108,9 @@ class SubPage } } $row['state_' . $row['state']] = true; - $row['locationname'] = Location::getName($row['locationid']); + if ($row['locationid'] > 0) { + $row['location'] = $location[$row['locationid']]; + } $rows[] = $row; } if ($singleMachine !== false && $singleMachine !== 'none') { @@ -134,4 +137,14 @@ class SubPage Render::addTemplate('clientlist', $data); } + private static function buildLocationLookup() + { + $ret = []; + $i = 0; + foreach (Location::getLocationsAssoc() as $lid => $data) { + $ret[$lid] = ['sort' => ++$i, 'name' => $data['locationname']]; + } + return $ret; + } + } -- cgit v1.2.3-55-g7522