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 | |
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')
-rw-r--r-- | modules-available/statistics/pages/list.inc.php | 47 | ||||
-rw-r--r-- | modules-available/statistics/pages/machine.inc.php | 4 | ||||
-rw-r--r-- | modules-available/statistics/style.css | 22 | ||||
-rw-r--r-- | modules-available/statistics/templates/clientlist.html | 12 | ||||
-rw-r--r-- | modules-available/statistics/templates/machine-main.html | 11 |
5 files changed, 89 insertions, 7 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)) { diff --git a/modules-available/statistics/style.css b/modules-available/statistics/style.css index 7e1539ec..7bd60b44 100644 --- a/modules-available/statistics/style.css +++ b/modules-available/statistics/style.css @@ -93,3 +93,25 @@ 50% { background: #f2dede } 100% { background: unset } } + +.slx-right { + float: right; +} +@media (min-width: 1650px) { + .slx-right { + position: fixed; + right: 10px; + display: block; + min-width: 140px; + width: calc(100vw - 1550px); + float: none !important; + } +} + +.infobox { + border: 1px solid #aaa; + background: #eee; + border-radius: 3px; + margin: 3px auto; + padding: 0 2px; +}
\ No newline at end of file diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html index 714fdfc0..d0e330e8 100644 --- a/modules-available/statistics/templates/clientlist.html +++ b/modules-available/statistics/templates/clientlist.html @@ -1,7 +1,15 @@ -<button class="pull-right btn btn-default" type="button" data-toggle="modal" - data-target="#column-selector">{{lang_selectColumns}}</button> +<div class="slx-right"> + {{{roomsvg}}} + {{#sidebar}} + <div class="infobox">{{.}}</div> + {{/sidebar}} +</div> <h2>{{lang_clientList}} ({{rowCount}})</h2> +<button class="btn btn-default" type="button" data-toggle="modal" + data-target="#column-selector">{{lang_selectColumns}}</button> + +<div class="clearfix"></div> <form method="post" action="?do=statistics" id="list-form"> <input type="hidden" name="token" value="{{token}}"> diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html index cba9c62a..be32f9c7 100644 --- a/modules-available/statistics/templates/machine-main.html +++ b/modules-available/statistics/templates/machine-main.html @@ -104,19 +104,22 @@ </td> </tr> {{/modeid}} - {{#hasroomplan}} + {{#roomsvg}} <tr> <td class="text-nowrap"> {{lang_roomplan}} </td> <td> + <div> + {{{roomsvg}}} + </div> <a href="?do=roomplanner&locationid={{locationid}}" target="_blank" - onclick="window.open(this.href, '_blank', 'toolbar=0,scrollbars,resizable');return false"> - <img src="api.php?do=roomplanner&show=svg&locationid={{locationid}}&machineuuid={{machineuuid}}&fallback=1"/> + onclick="window.open(this.href, '_blank', 'toolbar=0,scrollbars,resizable');return false"> + {{lang_edit}} </a> </td> </tr> - {{/hasroomplan}} + {{/roomsvg}} {{#rebootcontrol}} <tr> <td class="text-nowrap"> |