diff options
author | Simon Rettberg | 2017-05-11 16:38:53 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-05-11 16:38:53 +0200 |
commit | 01112d0cbb9c919b972c96c270ee561783c4df77 (patch) | |
tree | 17a8792ce4ab2da2d7509922a0600103abd35e7f /modules-available/locationinfo/api.inc.php | |
parent | [sysconfig] Remove redundant/dead code (diff) | |
download | slx-admin-01112d0cbb9c919b972c96c270ee561783c4df77.tar.gz slx-admin-01112d0cbb9c919b972c96c270ee561783c4df77.tar.xz slx-admin-01112d0cbb9c919b972c96c270ee561783c4df77.zip |
[locationinfo] Tweak and clean up overview panel
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
-rw-r--r-- | modules-available/locationinfo/api.inc.php | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index c93783ec..945c4c92 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -274,32 +274,32 @@ function defaultConfig() * Gets the pc states of the given locations. * * @param int[] $idList list of the location ids. - * @return string PC state JSON + * @return array aggregated PC states */ function getPcStates($idList) { $pcStates = array(); - - $locationInfoList = getLocationInfo($idList); - foreach ($locationInfoList as $locationInfo) { - $result = array( - 'id' => $locationInfo['id'], + foreach ($idList as $id) { + $pcStates[$id] = array( + 'id' => $id, 'idle' => 0, 'occupied' => 0, 'off' => 0, 'broken' => 0, ); - + } + $locationInfoList = getLocationInfo($idList); + foreach ($locationInfoList as $locationInfo) { + $id = $locationInfo['id']; foreach ($locationInfo['computer'] as $computer) { $key = strtolower($computer['pcState']); - if (isset($result[$key])) { - $result[$key]++; + if (isset($pcStates[$id][$key])) { + $pcStates[$id][$key]++; } } - - $pcStates[] = $result; } - return $pcStates; + + return array_values($pcStates); } /** @@ -310,6 +310,9 @@ function getPcStates($idList) */ function getLocationTree($idList) { + if (in_array(0, $idList)) { + return array_values(Location::getTree()); + } $locations = Location::getTree(); $ret = findLocations($locations, $idList); |