From f57731abf206bf3030a7a95a9019aa398c3dea2e Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Mon, 3 Dec 2018 19:03:24 +0100 Subject: [locationinfo] add new settings for panels (counter, updaterate) - setting: consider only clients in roomplaner, instead of ip range - add option to set update rate in summary panels - directly initialize when mode is "only calendar" - Set counter to "-" if room has ongoing event - fix some spelling / unused code --- modules-available/locationinfo/api.inc.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'modules-available/locationinfo/api.inc.php') diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index ad71de8b..c33c528e 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -7,7 +7,7 @@ HandleParameters(); /** - * Handles the API paramenters. + * Handles the API parameters. */ function HandleParameters() { @@ -20,7 +20,7 @@ function HandleParameters() } elseif ($get === "machines") { $locationIds = LocationInfo::getLocationsOr404($uuid); $output = array(); - InfoPanel::appendMachineData($output, $locationIds, false); + InfoPanel::appendMachineData($output, $locationIds, true); $output = array_values($output); } elseif ($get === "config") { $type = InfoPanel::getConfig($uuid, $output); @@ -30,7 +30,7 @@ function HandleParameters() } } elseif ($get === "pcstates") { $locationIds = LocationInfo::getLocationsOr404($uuid); - $output = getPcStates($locationIds); + $output = getPcStates($locationIds, $uuid); } elseif ($get === "locationtree") { $locationIds = LocationInfo::getLocationsOr404($uuid); $output = getLocationTree($locationIds); @@ -84,7 +84,7 @@ function getLastChangeTs($paneluuid) * @param int[] $idList list of the location ids. * @return array aggregated PC states */ -function getPcStates($idList) +function getPcStates($idList, $paneluuid) { $pcStates = array(); foreach ($idList as $id) { @@ -99,13 +99,24 @@ function getPcStates($idList) } $locationInfoList = array(); - InfoPanel::appendMachineData($locationInfoList, $idList); + InfoPanel::appendMachineData($locationInfoList, $idList, true); + + $panel = Database::queryFirst('SELECT paneluuid, panelconfig FROM locationinfo_panel WHERE paneluuid = :paneluuid', + compact('paneluuid')); + $config = json_decode($panel['panelconfig'], true); + foreach ($locationInfoList as $locationInfo) { $id = $locationInfo['id']; foreach ($locationInfo['machines'] as $pc) { $key = strtolower($pc['pcState']); if (isset($pcStates[$id][$key])) { - $pcStates[$id][$key]++; + if ($config['roomplaner']) { + if (isset($pc['x']) && isset($pc['y'])) { + $pcStates[$id][$key]++; + } + } else { + $pcStates[$id][$key]++; + } } } } -- cgit v1.2.3-55-g7522