diff options
author | Simon Rettberg | 2020-05-19 15:37:44 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-05-19 15:37:44 +0200 |
commit | c2e20fb1b18119eb98052661bbefae88f045b0cc (patch) | |
tree | 54d8b0600504119603fb4b286bcd60e00db04ebe /modules-available/locations/pages | |
parent | [locationinfo] Make colors for idle clients more distinct from offline (diff) | |
download | slx-admin-c2e20fb1b18119eb98052661bbefae88f045b0cc.tar.gz slx-admin-c2e20fb1b18119eb98052661bbefae88f045b0cc.tar.xz slx-admin-c2e20fb1b18119eb98052661bbefae88f045b0cc.zip |
[locations] Show colored bars for used/idle/offline in overview
Diffstat (limited to 'modules-available/locations/pages')
-rw-r--r-- | modules-available/locations/pages/locations.inc.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/modules-available/locations/pages/locations.inc.php b/modules-available/locations/pages/locations.inc.php index 54f44554..8afb454a 100644 --- a/modules-available/locations/pages/locations.inc.php +++ b/modules-available/locations/pages/locations.inc.php @@ -90,8 +90,7 @@ class SubPage unset($locationList[0]); // Statistics: Count machines for each subnet $unassigned = false; - $unassignedLoad = 0; - $unassignedOverrides = 0; + $unassignedIdle = $unassignedLoad = $unassignedOverrides = 0; $allowedLocationIds = User::getAllowedLocations("location.view"); foreach (array_keys($locationList) as $lid) { @@ -119,16 +118,19 @@ class SubPage if (in_array(0, $allowedLocationIds)) { $extra = ' OR locationid IS NULL'; } - $res = Database::simpleQuery("SELECT m.locationid, Count(*) AS cnt, Sum(If(m.state = 'OCCUPIED', 1, 0)) AS used + $res = Database::simpleQuery("SELECT m.locationid, Count(*) AS cnt, + Sum(If(m.state = 'OCCUPIED', 1, 0)) AS used, Sum(If(m.state = 'IDLE', 1, 0)) AS idle FROM machine m WHERE (locationid IN (:allowedLocationIds) $extra) GROUP BY locationid", compact('allowedLocationIds')); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { $locId = (int)$row['locationid']; if (isset($locationList[$locId])) { $locationList[$locId]['clientCount'] = $row['cnt']; - $locationList[$locId]['clientLoad'] = round(100 * $row['used'] / $row['cnt']) . ' %'; + $locationList[$locId]['clientLoad'] = round(100 * $row['used'] / $row['cnt']); + $locationList[$locId]['clientIdle'] = round(100 * ($row['used'] + $row['idle']) / $row['cnt']); } else { $unassigned += $row['cnt']; $unassignedLoad += $row['used']; + $unassignedIdle += $row['idle']; } } $res = Database::simpleQuery("SELECT m.locationid, Count(DISTINCT sm.machineuuid) AS cnt FROM setting_machine sm @@ -149,8 +151,7 @@ class SubPage $loc['clientCountSum'] = 0; } if (!isset($loc['clientCount'])) { - $loc['clientCount'] = 0; - $loc['clientLoad'] = '0%'; + $loc['clientCount'] = $loc['clientIdle'] = $loc['clientLoad'] = 0; } $loc['clientCountSum'] += $loc['clientCount']; foreach ($loc['parents'] as $pid) { @@ -233,7 +234,8 @@ class SubPage 'overlapOther' => $overlapOther, 'mismatchMachines' => $mismatchMachines, 'unassignedCount' => $unassigned, - 'unassignedLoad' => ($unassigned ? (round(($unassignedLoad / $unassigned) * 100) . ' %') : ''), + 'unassignedLoad' => ($unassigned ? (round(($unassignedLoad / $unassigned) * 100)) : ''), + 'unassignedIdle' => ($unassigned ? (round((($unassignedLoad + $unassignedIdle) / $unassigned) * 100)) : ''), 'unassignedOverrides' => $unassignedOverrides, 'defaultConfig' => $defaultConfig, 'addAllowedList' => array_values($addAllowedList), |