summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/pages/list.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-18 16:15:18 +0100
committerSimon Rettberg2023-01-18 16:15:18 +0100
commit89d952f7e9475d79c9e9a46e78e84bd63978dd04 (patch)
tree5a15c3994ae8dcb5c061b3cf28a27f6337cdd5cc /modules-available/statistics/pages/list.inc.php
parent[dnbd3] Extend timeout for inactive graph (diff)
downloadslx-admin-89d952f7e9475d79c9e9a46e78e84bd63978dd04.tar.gz
slx-admin-89d952f7e9475d79c9e9a46e78e84bd63978dd04.tar.xz
slx-admin-89d952f7e9475d79c9e9a46e78e84bd63978dd04.zip
[statistics] Listview: Display roomlayout and unique properties in a sidebar
.... if viewport is wide enouh, it will be a sidebar, otherwise, it will be displayed above the actual list.
Diffstat (limited to 'modules-available/statistics/pages/list.inc.php')
-rw-r--r--modules-available/statistics/pages/list.inc.php47
1 files changed, 46 insertions, 1 deletions
diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php
index db5f262a..2c49c525 100644
--- a/modules-available/statistics/pages/list.inc.php
+++ b/modules-available/statistics/pages/list.inc.php
@@ -25,7 +25,7 @@ class SubPage
/**
* @param \StatisticsFilterSet $filterSet
*/
- private static function showMachineList($filterSet)
+ private static function showMachineList(StatisticsFilterSet $filterSet)
{
Module::isAvailable('js_stupidtable');
$filterSet->makeFragments($where, $join, $args);
@@ -77,6 +77,7 @@ class SubPage
$detailsAllowedLocations = User::getAllowedLocations("machine.view-details");
$location = self::buildLocationLookup();
$rows = [];
+ $colValCount = []; // Count unique values for several columns
foreach ($allRows as &$row) {
$row['link_details'] = in_array($row['locationid'], $detailsAllowedLocations);
//$row['firstseen'] = Util::prettyTime($row['firstseen']);
@@ -145,8 +146,40 @@ class SubPage
if ($row['locationid'] > 0) {
$row['location'] = $location[$row['locationid']];
}
+ foreach (['locationid', 'cpumodel', 'nic-speed_s', 'gbram', 'gbtmp'] as $key) {
+ if (!isset($colValCount[$key][$row[$key]])) {
+ $colValCount[$key][$row[$key]] = [];
+ }
+ $colValCount[$key][$row[$key]][] = $row['machineuuid'];
+ }
$rows[] =& $row;
}
+ $roomsvg = null;
+ if (count($colValCount['locationid']) === 1 && ($lid = array_key_first($colValCount['locationid']))
+ && Module::isAvailable('roomplanner')) {
+ $roomsvg = PvsGenerator::generateSvg($lid, false, 0, 1, true, $colValCount['locationid'][$lid]);
+ }
+ $side = [];
+ foreach (['locationid', 'cpumodel', 'nic-speed_s', 'gbram', 'gbtmp'] as $key) {
+ if (count($colValCount[$key]) === 1) {
+ $val = array_key_first($colValCount[$key]);
+ switch ($key) {
+ case 'locationid':
+ $val = $location[$val]['name'];
+ break;
+ case 'gbram':
+ $val .= ' GiB RAM';
+ break;
+ case 'gbtmp':
+ $val .= ' GiB ID-44';
+ break;
+ case 'nic-speed_s':
+ $val .= ' MBit/s';
+ break;
+ }
+ $side[] = $val;
+ }
+ }
$data = array(
'rowCount' => count($rows),
'rows' => $rows,
@@ -160,6 +193,8 @@ class SubPage
'canWol' => !empty($wolAllowedLocations),
'canExec' => !empty($execAllowedLocations),
'canBenchmark' => !empty($benchmarkAllowedLocations),
+ 'roomsvg' => $roomsvg,
+ 'sidebar' => $side,
);
Render::addTemplate('clientlist', $data);
}
@@ -175,3 +210,13 @@ class SubPage
}
}
+
+// Remove when we require >= 7.3.0
+if (!function_exists('array_key_first')) {
+ function array_key_first(array $arr) {
+ foreach($arr as $key => $unused) {
+ return $key;
+ }
+ return NULL;
+ }
+} \ No newline at end of file