summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/pages/locations.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2020-05-19 15:37:44 +0200
committerSimon Rettberg2020-07-30 13:25:36 +0200
commit259b1c8bbb3617c65a9ed073ed340acade32c543 (patch)
tree2690c6669bce6c55c5d49ef99e57333fe6d9b254 /modules-available/locations/pages/locations.inc.php
parent[locationinfo] Make colors for idle clients more distinct from offline (diff)
downloadslx-admin-259b1c8bbb3617c65a9ed073ed340acade32c543.tar.gz
slx-admin-259b1c8bbb3617c65a9ed073ed340acade32c543.tar.xz
slx-admin-259b1c8bbb3617c65a9ed073ed340acade32c543.zip
[locations] Show colored bars for used/idle/offline in overview
Diffstat (limited to 'modules-available/locations/pages/locations.inc.php')
-rw-r--r--modules-available/locations/pages/locations.inc.php16
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),