diff options
author | Simon Rettberg | 2023-02-28 11:07:30 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-02-28 11:07:30 +0100 |
commit | c8c07db57da7f7aec01c209aed82297cd321bbec (patch) | |
tree | 26c8905d0d742870200dc5eab148143576a3daac /modules-available/statistics/pages | |
parent | [dozmod] Try to avoid race condition, output slow dmsd download (diff) | |
download | slx-admin-c8c07db57da7f7aec01c209aed82297cd321bbec.tar.gz slx-admin-c8c07db57da7f7aec01c209aed82297cd321bbec.tar.xz slx-admin-c8c07db57da7f7aec01c209aed82297cd321bbec.zip |
[statistics] Fix warning on empty list; add comments
Diffstat (limited to 'modules-available/statistics/pages')
-rw-r--r-- | modules-available/statistics/pages/list.inc.php | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index 2c49c525..12689e97 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -118,6 +118,7 @@ class SubPage if (isset($row['data']) && !$row['data']) { $row['nohdd'] = true; } + // Shorten CPU names a bit for prettier display in small column $row['cpumodel'] = preg_replace('/\(R\)|\(TM\)|\bintel\b|\bamd\b|\bcpu\b|dual-core|\bdual\s+core\b|\bdual\b|\bprocessor\b/i', ' ', $row['cpumodel']); if (!empty($row['rmmodule'])) { $data = RunMode::getRunMode($row['machineuuid'], RunMode::DATA_STRINGS); @@ -154,30 +155,36 @@ class SubPage } $rows[] =& $row; } + // Now if all machines are from the same location, try to load the roomplan + // Also, collect all properties that are the same across all machines for display in the sidebar $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; + if (!empty($rows) && !empty($colValCount)) { + 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]); + } + // Handle our selected attributes + foreach (['locationid', 'cpumodel', 'nic-speed_s', 'gbram', 'gbtmp'] as $key) { + if (count($colValCount[$key]) === 1) { + $val = array_key_first($colValCount[$key]); + // Suffixes are not localized, but hopefully generic enough for now + 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; } - $side[] = $val; } } $data = array( @@ -199,7 +206,7 @@ class SubPage Render::addTemplate('clientlist', $data); } - private static function buildLocationLookup() + private static function buildLocationLookup(): array { $ret = []; $i = 0; |