diff options
author | Simon Rettberg | 2023-01-18 16:15:18 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-01-18 16:15:18 +0100 |
commit | 89d952f7e9475d79c9e9a46e78e84bd63978dd04 (patch) | |
tree | 5a15c3994ae8dcb5c061b3cf28a27f6337cdd5cc /modules-available/statistics/pages | |
parent | [dnbd3] Extend timeout for inactive graph (diff) | |
download | slx-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')
-rw-r--r-- | modules-available/statistics/pages/list.inc.php | 47 | ||||
-rw-r--r-- | modules-available/statistics/pages/machine.inc.php | 4 |
2 files changed, 50 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 diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php index f9724b5c..1b93584e 100644 --- a/modules-available/statistics/pages/machine.inc.php +++ b/modules-available/statistics/pages/machine.inc.php @@ -71,6 +71,10 @@ class SubPage } $locations = Location::getLocationRootChain($client['locationid']); } + if ($client['locationid'] && $client['hasroomplan'] && Module::isAvailable('roomplanner')) { + $client['roomsvg'] = PvsGenerator::generateSvg($client['locationid'], $client['machineuuid'], + 0, 1, true); + } User::assertPermission('machine.view-details', (int)$client['locationid']); // Hack: Get raw collected data if (Request::get('raw', false)) { |