summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/locations/pages/locations.inc.php16
-rw-r--r--modules-available/locations/style.css5
-rw-r--r--modules-available/locations/templates/locations.html14
3 files changed, 22 insertions, 13 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),
diff --git a/modules-available/locations/style.css b/modules-available/locations/style.css
index 042ac4d1..19950a38 100644
--- a/modules-available/locations/style.css
+++ b/modules-available/locations/style.css
@@ -12,3 +12,8 @@ table.locations tbody td:nth-of-type(even) {
pointer-events: none;
opacity: 0.6;
}
+
+.load-col {
+ text-align: right;
+ text-shadow: 1px 1px #fff;
+} \ No newline at end of file
diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html
index e2224bc0..7adfe2fc 100644
--- a/modules-available/locations/templates/locations.html
+++ b/modules-available/locations/templates/locations.html
@@ -71,10 +71,10 @@
</span>
{{/havestatistics}}
</td>
- <td class="text-nowrap" align="right">
- {{#havestatistics}}
- {{clientLoad}}
- {{/havestatistics}}
+ <td class="text-nowrap load-col" {{#clientCount}} style="background:linear-gradient(to right, #f97, #f97 {{clientLoad}}%, #6fa {{clientLoad}}%, #6fa {{clientIdle}}%, #eee {{clientIdle}}%)"{{/clientCount}}>
+ {{#clientCount}}
+ {{clientLoad}}&thinsp;%
+ {{/clientCount}}
</td>
<td class="text-nowrap {{overriddenClass}}">
{{#havebaseconfig}}
@@ -125,8 +125,10 @@
</a>
<span style="display:inline-block;width:5ex"></span>
</td>
- <td class="text-nowrap" align="right">
- {{unassignedLoad}}
+ <td class="text-nowrap load-col"{{#unassignedCount}} style="background:linear-gradient(to right, #f97, #f97 {{unassignedLoad}}%, #6fa {{unassignedLoad}}%, #6fa {{unassignedIdle}}%, #eee {{unassignedIdle}}%)"{{/unassignedCount}}>
+ {{#unassignedCount}}
+ {{unassignedLoad}}&thinsp;%
+ {{/unassignedCount}}
</td>
<td>
{{#unassignedOverrides}}