diff options
author | Michael Scherle | 2017-03-22 16:55:32 +0100 |
---|---|---|
committer | Michael Scherle | 2017-03-22 16:55:32 +0100 |
commit | f5f0104684168e185d585c3db65242aafaf3ac60 (patch) | |
tree | 767584495d5fa3e87f638fb78ac259459c52641e /modules-available | |
parent | frontend: fixed roomupdate & removed 10 sec delay (diff) | |
parent | Locationinfo: Added Comments to the functions. (diff) | |
download | slx-admin-f5f0104684168e185d585c3db65242aafaf3ac60.tar.gz slx-admin-f5f0104684168e185d585c3db65242aafaf3ac60.tar.xz slx-admin-f5f0104684168e185d585c3db65242aafaf3ac60.zip |
Merge branch 'location-info-panel' of git.openslx.org:openslx-ng/slx-admin into location-info-panel
Diffstat (limited to 'modules-available')
12 files changed, 855 insertions, 298 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 7ad83067..55f21e55 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -2,6 +2,9 @@ HandleParameters(); +/** + * Handles the API paramenters. + */ function HandleParameters() { @@ -36,6 +39,12 @@ function HandleParameters() } } +/** + * Filters the id list. Removes Double / non-int / hidden rooms. + * + * @param $roomids Array of the room ids. + * @return array The filtered array of the room ids. + */ function filterIdList($roomids) { $idList = explode(',', $roomids); @@ -46,6 +55,12 @@ function filterIdList($roomids) return $filteredIdList; } +/** + * Filters the hidden rooms from an array. + * + * @param $idArray Id list + * @return array Filtered id list + */ function filterHiddenRoom($idArray) { $filteredArray = array(); @@ -67,7 +82,13 @@ function filterHiddenRoom($idArray) } // ########## <Roominfo> ########## - +/** + * Gets the room info of the given rooms. + * + * @param $idList Array list of ids. + * @param bool $coords Defines if coords should be included or not. + * @return string Roominfo JSON + */ function getRoomInfo($idList, $coords = false) { @@ -125,7 +146,12 @@ function getRoomInfo($idList, $coords = false) // ########## </Roominfo> ########### // ########## <Openingtime> ########## - +/** + * Gets the Opening time of the given locations. + * + * @param $idList Array list of locations + * @return string Opening times JSON + */ function getOpeningTime($idList) { $dbresult = array(); @@ -172,7 +198,12 @@ function getOpeningTime($idList) return json_encode($finalArray, true); } -// Format the openingtime in the frontend needed format. +/** + * Format the openingtime in the frontend needed format. + * + * @param $openingtime The opening time in the db saved format. + * @return mixed The opening time in the frontend needed format. + */ function formatOpeningtime($openingtime) { $weekarray = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); @@ -202,6 +233,12 @@ function formatOpeningtime($openingtime) return $result; } +/** + * Recursively gets the opening time from the parent location. + * + * @param $locationID Id of the location you want to get the parent opening time. + * @return array|mixed The opening time from the parent location. + */ function getOpeningTimesFromParent($locationID) { // Get parent location id. @@ -223,6 +260,11 @@ function getOpeningTimesFromParent($locationID) } } +/** + * Creates the basic opening time where everything is closed. + * + * @return array Basic opening time. + */ function createBasicClosingTime() { $weekarray = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); @@ -241,7 +283,11 @@ function createBasicClosingTime() } // ########## </Openingtime> ########## - +/** + * Gets the config of the location. + * + * @param $locationID ID of the location + */ function getConfig($locationID) { $dbresult = Database::queryFirst("SELECT l.locationname, li.config, li.serverroomid, s.servertype, s.serverurl FROM `location_info` AS li @@ -266,6 +312,12 @@ function getConfig($locationID) } } +/** + * Gets the pc states of the given locations. + * + * @param $idList Array list of the location ids. + * @return string PC state JSON + */ function getPcStates($idList) { $pcStates = array(); @@ -299,6 +351,12 @@ function getPcStates($idList) return json_encode($pcStates); } +/** + * Gets the room tree of the given locations. + * + * @param $idList Array list of the locations. + * @return string Room tree JSON. + */ function getRoomTree($idList) { $roomTree = array(); @@ -318,6 +376,13 @@ function getRoomTree($idList) return json_encode($roomTree); } +/** + * Recursively gets the Childs of a location. + * + * @param $id Location id you want all childs from. + * @param $filteredIdList Pointer to the filtered list to avoid double ids. + * @return array List with all the Childs. + */ function getChildsRecursive($id, &$filteredIdList) { $dbquery = Database::simpleQuery("SELECT locationid, locationname FROM `location` WHERE parentlocationid=:locationID", array('locationID' => $id)); @@ -344,6 +409,12 @@ function getChildsRecursive($id, &$filteredIdList) } // ########## <Calendar> ########### +/** + * Gets the calendar of the given ids. + * + * @param $idList Array list with the location ids. + * @return string Calendar JSON. + */ function getCalendar($idList) { $serverList = array(); diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php index a1566229..83e4febd 100644 --- a/modules-available/locationinfo/inc/coursebackend.inc.php +++ b/modules-available/locationinfo/inc/coursebackend.inc.php @@ -12,8 +12,10 @@ abstract class CourseBackend /** * @var array list of known backends - * $error boolean true if there was an error - * $errormsg string with the error message + * @var boolean true if there was an error + * @var string with the error message + * @var int as internal serverID + * @var string url of the service */ private static $backendTypes = false; public $error; @@ -81,11 +83,6 @@ abstract class CourseBackend return self::$backendTypes[$moduleType]; } - - /* - * TODO: Insert required methods here - */ - /** * @return string return display name of backend */ @@ -93,7 +90,7 @@ abstract class CourseBackend /** - * @returns array with parameter name as key and type as value + * @returns array with parameter name as key and and an array with type, help text and mask as value */ public abstract function getCredentials(); @@ -106,10 +103,10 @@ abstract class CourseBackend * uses json to setCredentials, the json must follow the form given in * getCredentials * - * @param string $data array with the credentials + * @param array $data with the credentials * @param string $url address of the server * @param int $serverID ID of the server - * @returns void + * @returns bool if the credentials were in the correct format */ public abstract function setCredentials($data, $url, $serverID); @@ -127,7 +124,7 @@ abstract class CourseBackend /** * Internal version of fetch, to be overridden by subclasses. * - * @param $roomIds + * @param $roomIds array with local ID as key and serverID as value * @return array a multidimensional array that uses the roomID as key * and has the schedules as string in the value */ @@ -136,9 +133,8 @@ abstract class CourseBackend /** * Method for fetching the schedule of the given rooms on a server. * - * @param int $roomId int of room ID to fetch - * @param int $serverid id of the server - * @return string|bool some jsonstring as result, or false on error + * @param array $roomId array of room ID to fetch + * @return array|bool array containing the timetables as value and roomid as key as result, or false on error */ public final function fetchSchedule($roomIDs) { @@ -148,13 +144,14 @@ abstract class CourseBackend $dbquery1 = Database::simpleQuery($q); $result = []; $sRoomIDs = []; + $newResult = []; foreach ($dbquery1->fetchAll(PDO::FETCH_ASSOC) as $row) { $sRoomID = $row['serverroomid']; $lastUpdate = $row['lastcalendarupdate']; $calendar = $row['calendar']; //Check if in cache if lastUpdate is null then it is interpreted as 1970 - if (strtotime($lastUpdate) > strtotime("-" . $this->getCacheTime() . "seconds") && $this->getCacheTime() > 0) { - $result[$row['locationid']] = json_decode($calendar); + if ($lastUpdate > strtotime("-" . $this->getCacheTime() . "seconds")) { + $newResult[$row['locationid']] = json_decode($calendar); } else { $sRoomIDs[$row['locationid']] = $sRoomID; } @@ -176,7 +173,7 @@ abstract class CourseBackend if ($results === false) { return false; } - $newResult = []; + foreach ($sRoomIDs as $location => $serverRoom) { $newResult[$location] = $results[$serverRoom]; } @@ -205,5 +202,59 @@ abstract class CourseBackend } return false; } + /** + * Query path in array-representation of XML document. + * e.g. 'path/syntax/foo/wanteditem' + * This works for intermediate nodes (that have more children) + * and leaf nodes. The result is always an array on success, or + * false if not found. + */ + function getAttributes($array, $path) + { + if (!is_array($path)) { + // Convert 'path/syntax/foo/wanteditem' to array for further processing and recursive calls + $path = explode('/', $path); + } + do { + // Get next element from array, loop to ignore empty elements (so double slashes in the path are allowed) + $element = array_shift($path); + } while (empty($element) && !empty($path)); + if (!isset($array[$element])) { + // Current path element does not exist - error + return false; + } + if (empty($path)) { + // Path is now empty which means we're at 'wanteditem' from out example above + if (!is_array($array[$element]) || !isset($array[$element][0])) { + // If it's a leaf node of the array, wrap it in plain array, so the function will + // always return an array on success + return array($array[$element]); + } + // 'wanteditem' is not a unique leaf node, return as is + // This means it's either a plain array, in case there are multiple 'wanteditem' elements on the same level + // or it's an associative array if 'wanteditem' has any sub-nodes + return $array[$element]; + } + // Recurse + if (!is_array($array[$element])) { + // We're in the middle of the requested path, but the current element is already a leaf node with no + // children - error + return false; + } + if (isset($array[$element][0])) { + // The currently handled element of the path exists multiple times on the current level, so it is + // wrapped in a plain array - recurse into each one of them and merge the results + $return = []; + foreach ($array[$element] as $item) { + $test = $this->getAttributes($item, $path); + If(gettype($test) == "array" ){ + $return = array_merge($return, $test); + } + } + return $return; + } + // Unique non-leaf node - simple recursion + return $this->getAttributes($array[$element], $path); + } } diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php index e857a26b..85d834ff 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php @@ -20,7 +20,7 @@ class Coursebackend_Davinci extends CourseBackend public function checkConnection() { if ($this->location != "") { - $this->fetchArray('B206'); + $this->fetchSchedulesInternal(['B206']); return !$this->error; } $this->error = true; @@ -49,21 +49,28 @@ class Coursebackend_Davinci extends CourseBackend return 0; } + /** + * @param $response xml document + * @return bool|array array representation of the xml if possible + */ private function toArray($response) { - try { $cleanresponse = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response); $xml = new SimpleXMLElement($cleanresponse); $array = json_decode(json_encode((array)$xml), true); } catch (Exception $exception) { $this->error = true; - $this->errormsg = "url did not send a xml"; + $this->errormsg = "url did not answer with a xml, maybe the url is wrong or the room is wrong"; $array = false; } return $array; } + /** + * @param $roomId string name of the room + * @return array|bool if successful the arrayrepresentation of the timetable + */ private function fetchArray($roomId) { $startDate = new DateTime('monday this week'); @@ -97,18 +104,17 @@ class Coursebackend_Davinci extends CourseBackend public function fetchSchedulesInternal($roomIds) { $schedules = []; - foreach ($roomIds as $sroomId) { $return = $this->fetchArray($sroomId); if ($return === false) { return false; - } elseif (!isset($return['Lessons']['Lesson'])) { + } + $lessons = $this->getAttributes($return,'Lessons/Lesson'); + if (!$lessons) { $this->error = true; $this->errormsg = "url send a xml in a wrong format"; return false; } - $lessons = $return['Lessons']['Lesson']; - $timetable = []; foreach ($lessons as $lesson) { $date = $lesson['Date']; @@ -127,6 +133,7 @@ class Coursebackend_Davinci extends CourseBackend } $schedules[$sroomId] = $timetable; } + error_log('123'.json_encode($schedules)); return $schedules; } } diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 0d057bee..b250d114 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -6,23 +6,23 @@ class CourseBackend_HisInOne extends CourseBackend private $password; private $open; - //Sets the location and the login information of this client - public function setCredentials($data, $location, $serverID) + + public function setCredentials($data, $url, $serverID) { if (array_key_exists('password', $data) && array_key_exists('username', $data) && array_key_exists('role', $data) && isset($data['open'])) { $this->error = false; $this->password = $data['password']; $this->username = $data['username'] . "\t" . $data['role']; $this->open = $data['open']; - if ($location == "") { + if ($url == "") { $this->error = true; $this->errormsg = "No url is given"; return !$this->error; } if ($this->open) { - $this->location = $location . "/qisserver/services2/OpenCourseService"; + $this->location = $url . "/qisserver/services2/OpenCourseService"; } else { - $this->location = $location . "/qisserver/services2/CourseService"; + $this->location = $url . "/qisserver/services2/CourseService"; } $this->serverID = $serverID; } else { @@ -37,23 +37,25 @@ class CourseBackend_HisInOne extends CourseBackend public function checkConnection() { - if ($this->location =="") { + if ($this->location == "") { $this->error = true; $this->errormsg = "Credentials are not set"; } - $this->findUnit(42); + $this->fetchSchedulesInternal([190=>190]); return !$this->error; } - //Cache the timetables for 30 minutes ttables older than 60 are not refreshed - + /** + * @param $roomID int + * @return array|bool if successful an array with the subjectIDs that take place in the room + */ public function findUnit($roomID) { $termYear = date('Y'); - $termType = date('n'); - if ($termType > 3 && $termType < 10) { + $termType1 = date('n'); + if ($termType1 > 3 && $termType1 < 10) { $termType = 2; - } elseif ($termType > 10) { + } elseif ($termType1 > 10) { $termType = 1; $termYear = $termYear + 1; } else { @@ -96,17 +98,14 @@ class CourseBackend_HisInOne extends CourseBackend $this->error = true; $this->errormsg = $response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring']; return false; - } - elseif ($this->open && isset($response2['soapenvBody']['hisfindUnitResponse']['hisunits']['hisunit'])) { - $units = $response2['soapenvBody']['hisfindUnitResponse']['hisunits']['hisunit']; + } elseif ($this->open) { + $units = $this->getAttributes($response2,'soapenvBody/hisfindUnitResponse/hisunits/hisunit'); foreach ($units as $unit) { $id[] = $unit['hisid']; } - } elseif (!$this->open && isset($response2['soapenvBody']['hisfindUnitResponse']['hisunitIds'])) { - if(isset($response2['soapenvBody']['hisfindUnitResponse']['hisunitIds']['hisid'])){ - $id = $response2['soapenvBody']['hisfindUnitResponse']['hisunitIds']['hisid']; - } - } else { + } elseif (!$this->open) { + $id = $this->getAttributes($response2,'soapenvBody/hisfindUnitResponse/hisunitIds/hisid'); + } else { $this->error = true; $this->errormsg = "url send a xml in a wrong format"; $id = false; @@ -114,8 +113,10 @@ class CourseBackend_HisInOne extends CourseBackend return $id; } - //ttables older than 60 minutes are not refreshed - + /** + * @param $doc DOMDocument + * @return DOMElement + */ private function getHeader($doc) { $header = $doc->createElement('SOAP-ENV:Header'); @@ -136,6 +137,11 @@ class CourseBackend_HisInOne extends CourseBackend return $header; } + /** + * @param $request string with xml SOAP request + * @param $action string with the name of the SOAP action + * @return bool|string if successful the answer xml from the SOAP server + */ private function __doRequest($request, $action) { $header = array( @@ -172,6 +178,10 @@ class CourseBackend_HisInOne extends CourseBackend return $output; } + /** + * @param $response xml document + * @return bool|array array representation of the xml if possible + */ private function toArray($response) { try { @@ -186,22 +196,20 @@ class CourseBackend_HisInOne extends CourseBackend return $array; } - //Contstructs the Soap Header $doc is a DOMDocument this returns a DOMElement + public function getCacheTime() { return 30 * 60; } - //returns the IDs in an array for a given roomID or false if there was an error + public function getRefreshTime() { return 60 * 60; } - //This function sends a Soaprequest with the eventID and returns an array which contains much - // informations, like start and enddates for events and their name. It returns false if there was an error public function getDisplayName() { @@ -209,20 +217,17 @@ class CourseBackend_HisInOne extends CourseBackend } - //Makes a SOAP-Request as a normal POST - public function getCredentials() { - $credentials = ["username" => "string", "role" => "string", "password" => "string", "open" => "bool"]; + $credentials = ["username" => ["string", "Name used to identify on HisInOne", false], "role" =>["string", "Role used to identify on HisInOne", false], "password" => ["string", "Password for the username on HisInOne", true], "open" => ["bool", "If checked the opencourseservice interface is used", false]]; return $credentials; } - //this function transforms a xml string into an array or return false if there was an error public function fetchSchedulesInternal($param) { - if(empty($param)){ + if (empty($param)) { $this->error = true; $this->errormsg = 'No roomid was given'; } @@ -231,7 +236,7 @@ class CourseBackend_HisInOne extends CourseBackend $eventIDs = []; foreach ($param as $ID) { $unitID = $this->findUnit($ID); - if ($unitID === false) { + if ($unitID == false) { return false; } $eventIDs = array_merge($eventIDs, $unitID); @@ -240,8 +245,8 @@ class CourseBackend_HisInOne extends CourseBackend return false; } } - if(empty($eventIDs)){ - foreach ($param as $room){ + if (empty($eventIDs)) { + foreach ($param as $room) { $tTables[$room] = []; } return $tTables; @@ -260,54 +265,24 @@ class CourseBackend_HisInOne extends CourseBackend $timetable = array(); //Here I go over the soapresponse foreach ($events as $event) { - if(empty($event['hisunit']['hisplanelements']['hisplanelement'][0]['hisdefaulttext'])){ - $this->error = true; - $this->errormsg = "url returns a wrong xml"; - return false; + $name = $this->getAttributes($event,'/hisunit/hisdefaulttext'); + if($name==false){ + //if HisInOne has no default text then there is no name + $name = ['']; } - $title = $event['hisunit']['hisplanelements']['hisplanelement'][0]['hisdefaulttext']; - foreach ($event as $subject) { - $units = $subject['hisplanelements']['hisplanelement']; - foreach ($units as $unit) { - $pdates = $unit['hisplannedDates']['hisplannedDate']; - //there seems to be a bug that gives more than one individualDates in plannedDate - //this construction catches it - if (array_key_exists('hisindividualDates', $pdates)) { - $dates = $pdates['hisindividualDates']['hisindividualDate']; - foreach ($dates as $date) { - $roomID = $date['hisroomId']; - $datum = $date['hisexecutiondate']; - if (intval($roomID) == $room && in_array($datum, $currentWeek)) { - $startTime = $date['hisstarttime']; - $endTime = $date['hisendtime']; - $json = array( - 'title' => $title, - 'start' => $datum . " " . $startTime, - 'end' => $datum . " " . $endTime - ); - array_push($timetable, $json); - } - } - } else { - foreach ($pdates as $dates2) { - $dates = $dates2['hisindividualDates']['hisindividualDate']; - foreach ($dates as $date) { - $roomID = $date['hisroomId']; - $datum = $date['hisexecutiondate']; - if (intval($roomID) == $room && in_array($datum, $currentWeek)) { - - $startTime = $date['hisstarttime']; - $endTime = $date['hisendtime']; - $json = array( - 'title' => $title, - 'start' => $datum . " " . $startTime, - 'end' => $datum . " " . $endTime - ); - array_push($timetable, $json); - } - } - } - } + $dates = $this->getAttributes($event,'/hisunit/hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); + foreach ($dates as $date) { + $roomID =$this->getAttributes($date,'/hisroomId')[0]; + $datum = $this->getAttributes($date,'/hisexecutiondate')[0]; + if (intval($roomID) == $room && in_array($datum, $currentWeek)) { + $startTime = $this->getAttributes($date,'hisstarttime')[0]; + $endTime = $this->getAttributes($date,'hisendtime')[0]; + $json = array( + 'title' => $name[0], + 'start' => $datum . " " . $startTime, + 'end' => $datum . " " . $endTime + ); + array_push($timetable, $json); } } } @@ -316,8 +291,11 @@ class CourseBackend_HisInOne extends CourseBackend return $tTables; } - //Request for a timetable with roomids as array it will be boolean false if there was an error + /** + * @param $unit int ID of the subject in HisInOne database + * @return bool|array false if there was an error otherwise an array with the information about the subject + */ public function readUnit($unit) { $doc = new DOMDocument('1.0', 'utf-8'); @@ -348,21 +326,25 @@ class CourseBackend_HisInOne extends CourseBackend if ($response2 != false) { if (isset($response2['soapenvBody']['soapenvFault'])) { $this->error = true; - $this->errormsg = $response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring']; + $this->errormsg = 'SOAP-Fault'.$response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring']; return false; } elseif (isset($response2['soapenvBody']['hisreadUnitResponse'])) { $this->error = false; $response3 = $response2['soapenvBody']['hisreadUnitResponse']; + $this->errormsg = ''; return $response3; } else { $this->error = true; - $this->errormsg = "url send a xml in a wrong format"; + $this->errormsg = "wrong url or the url send a xml in the wrong format"; return false; } } return false; } + /** + * @return array with days of the current week in datetime format + */ private function getCurrentWeekDates() { $DateArray = array(); diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 02a7e2c1..4e2ea8aa 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -3,6 +3,12 @@ class LocationInfo { + /** + * Gets the pc data and returns it's state. + * + * @param $pc The pc data from the db. Array('logintime' =>, 'lastseen' =>, 'lastboot' =>) + * @return int pc state + */ public static function getPcState($pc) { /* pcState: diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 75a945ce..973509da 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -4,7 +4,7 @@ "lang_locationID": "ID", "lang_locationIsHidden": "Versteckt", "lang_locationIsHidden_title": "Wenn aktiv, dann liefert die API keine Informationen über diesen Raum.", - "lang_locationInUse": "In Benutzung / Gesamt", + "lang_locationInUse": "Rechner", "lang_locationSettings": "Einstellungen", "lang_locationConfig": "Config", "lang_pcID": "ID", @@ -28,37 +28,47 @@ "lang_sunday": "Sonntag", "lang_expertMode": "Experten Modus", "lang_expertMode_title": "Ermöglicht es dir Öffnungzeiten für jeden Tag zu Setzen.", + "lang_nameTooltip": "Legt den Namen des Servers fest.", + "lang_urlTooltip": "Server URL über den das backend versucht Kalender-daten zu holen.", + "lang_typeTooltip": "Legt fest um welchen Typ von Server es sich handelt.", "lang_language": "Sprache", - "lang_languageEn": "en", - "lang_languageDe": "de", - "lang_languagePt": "pt", + "lang_languageEn": "Englisch", + "lang_languageDe": "Deutsch", + "lang_languagePt": "Portugiesisch", + "lang_languageTooltip": "Die Sprache, welche vom Frontend benutzt wird.", "lang_mode": "Modus", "lang_mode1": "Kalender & Raum", "lang_mode2": "Kalender", "lang_mode3": "Raum", "lang_mode4": "Wechselnd", - "lang_ecoMode": "Eco modus (e-ink)", - "lang_daysToShow": "Tage im Kalender", - "lang_daysToShowTooltip": "[1-7] Zeigt die gewünschte Anzahl an Tagen im Kalender an.", - "lang_scale": "Skalierung", - "lang_scaleTooltip": "[10-90] Skaliert die Kalender breite in modus 1", + "lang_modeTooltip": "Die Anzeigemodi, welche das frontend unterstützt.", + "lang_ecoMode": "E-Ink modus", + "lang_ecoTooltip": "Anstelle der Farb-basierten PC-Status Bilder, werden Symbol-basierte PC Bilder verwendet.", + "lang_daysToShow": "Tage", + "lang_daysToShowTooltip": "Legt die gewünschte Anzahl an Tagen im Kalender fest.", + "lang_scale": "Kalender breite", + "lang_scaleTooltip": "[10-90] Legt die Kalenderbreite fest. (In Prozent)", "lang_switchTime": "Wechsel Zeit", - "lang_switchTimeTooltip": "[1-120] Die Zeit die vergeht bis ein wechsel erfolgt in modus 4 (in sekunden)", + "lang_switchTimeTooltip": "[1-120] Legt die Zeit fest, die vergeht bis ein wechsel erfolgt (in sekunden)", "lang_rotation": "Rotation", "lang_rotation0": "0°", "lang_rotation1": "90° ⟲", "lang_rotation2": "180°", "lang_rotation3": "90° ⟳", - "lang_vertical": "Vertikal", - "lang_calupdate": "Kalenderabfragrate", - "lang_calupdateTooltip": "Zeit nachdem der Kalender geupdated wird (in minutes)", - "lang_roomupdate": "Raumabfragrate", + "lang_rotationTooltip": "Rotiert den Raum.", + "lang_vertical": "Vertikaler Modus", + "lang_verticalTooltip": "Legt fest, ob der Kalender und der Raum übereinander angezeigt werden soll.", + "lang_updateRates": "Anfragraten", + "lang_calendar": "Kalender", + "lang_calupdateTooltip": "Zeit nachdem der Kalender geupdated wird (in minuten)", + "lang_room": "Raum", "lang_roomupdateTooltip": "Zeit nachder die Pcs geupdated werden (in sekunden)", - "lang_configupdate": "Einstellungsabfragrate", + "lang_config": "Einstellungen", "lang_configupdateTooltip": "Zeit nachder die Einstellungen geupdated werden (in minuten)", "lang_min": "min", "lang_sec": "sec", - "lang_autoScale": "Auto skalierung", + "lang_autoScale": "Auto Tage", + "lang_autoscaleTooltip": "Berechnet sich die optimale anzahl an Tagen, anhand der Bildschirmbreite, die der Kalender anzeigt.", "lang_deleteConfirmation": "Bist du sicher?", "lang_addServer": "Server", "lang_addServer_title": "Server hinzufügen", @@ -71,10 +81,14 @@ "lang_serverID": "Server ID", "lang_sID": "sID", "lang_server": "Server", - "lang_serverRoomId": "Server: Raum ID", + "lang_serverTooltip": "Legt fest, von welchem Server die Kalender Daten bezogen werden.", + "lang_roomId": "Raum ID", + "lang_roomIdTooltip": "Die ID vom Raum, welche der Server braucht, um die Kalender Daten abzurufen.", "lang_credentials": "Anmeldung", "lang_refresh_title": "Überprüft ob die Serververbindung gültig ist.", "lang_delete": "Löschen", "lang_refresh": "Aktualisieren", - "lang_general": "Allgemein" + "lang_general": "Allgemein", + "lang_server": "Server", + "lang_display": "Anzeige" } diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index ec0bae12..b7de3131 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -5,7 +5,7 @@ "lang_locationID": "ID", "lang_locationIsHidden": "Hidden", "lang_locationIsHidden_title": "If checked the API doesn't return information about the room.", - "lang_locationInUse": "In use / total", + "lang_locationInUse": "Clients", "lang_locationSettings": "Settings", "lang_locationConfig": "Config", @@ -33,37 +33,47 @@ "lang_expertMode": "Expert mode", "lang_expertMode_title": "Allows you to set openingtimes for every day.", + "lang_nameTooltip": "Defines the name of the server.", + "lang_urlTooltip": "Server URL on which the backend trys to get the calendar data from.", + "lang_typeTooltip": "Defines on which type of server you want to connect to.", "lang_language": "Language", - "lang_languageEn": "en", - "lang_languageDe": "de", - "lang_languagePt": "pt", + "lang_languageEn": "English", + "lang_languageDe": "German", + "lang_languagePt": "Portugues", + "lang_languageTooltip": "The language the frontend uses.", "lang_mode": "Mode", "lang_mode1": "Calendar & Room", "lang_mode2": "Calendar", "lang_mode3": "Room", "lang_mode4": "Switching", - "lang_ecoMode": "Eco mode (e-ink)", - "lang_daysToShow": "Days to show", - "lang_daysToShowTooltip": "[1-7] Sets how many days the calendar shows", - "lang_scale": "Scale", - "lang_scaleTooltip": "[10-90] scales the calendar width in mode 1", + "lang_modeTooltip": "The display modes the frontend supports.", + "lang_ecoMode": "E-Ink mode", + "lang_ecoTooltip": "Symbolic based pc state pictures are used instead of the colour base ones.", + "lang_daysToShow": "Days", + "lang_daysToShowTooltip": "Defines the amount of days to show in the calendar", + "lang_scale": "Calendar width", + "lang_scaleTooltip": "[10-90] Defines the calendar width. (in percent)", "lang_switchTime": "Switchtime", - "lang_switchTimeTooltip": "[1-120] Sets the time between switching in mode 4 (in seconds)", + "lang_switchTimeTooltip": "[1-120] Sets the time between switching (in seconds)", "lang_rotation": "Rotation", "lang_rotation0": "0°", "lang_rotation1": "90° ⟲", "lang_rotation2": "180°", "lang_rotation3": "90° ⟳", - "lang_vertical": "Vertical", - "lang_calupdate": "Calendar update rate", + "lang_rotationTooltip": "Rotates the room.", + "lang_vertical": "Vertical mode", + "lang_verticalTooltip": "Defines whether the room and calendar are shown above each other.", + "lang_updateRates": "Update rates", + "lang_calendar": "Calendar", "lang_calupdateTooltip": "Time the calender querys for updates (in minutes)", - "lang_roomupdate": "Room update rate", + "lang_room": "Room", "lang_roomupdateTooltip": "Time the PCs in the room gets updated (in seconds)", - "lang_configupdate": "Config update", + "lang_config": "Config", "lang_configupdateTooltip": "Time interval the config gets updated (in minutes)", "lang_min": "min", "lang_sec": "sec", - "lang_autoScale": "Auto scale", + "lang_autoScale": "Auto Days", + "lang_autoscaleTooltip": "Calculates the optimum amount of days to show from the display width.", "lang_deleteConfirmation": "Are you sure?", "lang_addServer": "Server", "lang_addServer_title": "Add server", @@ -76,10 +86,15 @@ "lang_serverID": "Server ID", "lang_sID": "sID", "lang_server": "Server", - "lang_serverRoomId": "Server: Room ID", + "lang_serverTooltip": "Defines from which server the room queries the calendar data.", + "lang_roomId": "Room ID", + "lang_roomIdTooltip": "The ID of the room the server needs, for querying the calendar data.", "lang_credentials": "Login", "lang_refresh_title": "Checks if the server connection is valid.", "lang_delete": "Delete", "lang_refresh": "Refresh", - "lang_general": "General" + "lang_general": "General", + + "lang_server": "Server", + "lang_display": "Display" } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index ec024f48..6490e722 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -62,6 +62,9 @@ class Page_LocationInfo extends Page } + /** + * Updates the server in the db. + */ private function updateServer() { $id = Request::post('id', 0, 'int'); if ($id == 0) { @@ -76,11 +79,17 @@ class Page_LocationInfo extends Page $this->checkConnection(); } + /** + * Deletes the server from the db. + */ private function deleteServer() { $id = Request::post('id', 0, 'int'); Database::exec("DELETE FROM `setting_location_info` WHERE serverid=:id", array('id' => $id)); } + /** + * Updated the config in the db. + */ private function updateConfig() { $result = array(); @@ -101,6 +110,10 @@ class Page_LocationInfo extends Page $serverid = Request::post('serverid', 0, 'int'); $serverroomid = Request::post('serverroomid','', 'string'); + error_log("eco: " . $result['eco']); + error_log("vertical: " . $result['vertical']); + error_log("scaledaysauto: " . $result['scaledaysauto']); + Database::exec("INSERT INTO `location_info` (locationid, serverid, serverroomid, config) VALUES (:id, :serverid, :serverroomid, :config) ON DUPLICATE KEY UPDATE config=:config, serverid=:serverid, serverroomid=:serverroomid", array('id' => $locationid, 'config' => json_encode($result, true), 'serverid' => $serverid, 'serverroomid' => $serverroomid)); @@ -109,6 +122,9 @@ class Page_LocationInfo extends Page Util::redirect('?do=locationinfo'); } + /** + * Updates the server settings in the db. + */ private function updateServerSettings() { $serverid = Request::post('id', -1, 'int'); $servername = Request::post('name', 'unnamed', 'string'); @@ -139,6 +155,9 @@ class Page_LocationInfo extends Page } } + /** + * Updates the opening time in the db from the expert mode. + */ private function updateOpeningTimeExpert() { $days = Request::post('days'); @@ -223,6 +242,9 @@ class Page_LocationInfo extends Page Util::redirect('?do=locationinfo'); } + /** + * Updates the opening time in the db from the easy mode. + */ private function updateOpeningTimeEasy() { $locationid = Request::post('id', 0, 'int'); $openingtime = Request::post('openingtime'); @@ -251,6 +273,11 @@ class Page_LocationInfo extends Page Util::redirect('?do=locationinfo'); } + /** + * Checks if the server connection to a backend is valid. + * + * @param int $id Server id which connection should be checked. + */ private function checkConnection($id = 0) { $serverid = Request::post('id', 0, 'int'); if ($id != 0) { @@ -277,6 +304,12 @@ class Page_LocationInfo extends Page } } + /** + * Sets the new hidden value and checks childs and parents. + * + * @param $id The location id which was toggled + * @param $val The hidden value true / false + */ protected function toggleHidden($id, $val) { Database::exec("INSERT INTO `location_info` (locationid, hidden) VALUES (:id, :hidden) ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $id, 'hidden' => $val)); @@ -285,6 +318,12 @@ class Page_LocationInfo extends Page } + /** + * Recursivly sets all hidden values to all childs. + * + * @param $id The location id which childs should be checked + * @param $val The hidden value + */ protected function checkChildRecursive($id, $val) { $dbquery = Database::simpleQuery("SELECT locationid FROM `location` WHERE parentlocationid = :locationid", array('locationid' => $id)); $childs = array(); @@ -299,6 +338,11 @@ class Page_LocationInfo extends Page } } + /** + * Recursively check all parent locations and updates the hidden values if necessary + * + * @param $id The id of the location which was toggled. + */ protected function checkParentRecursive($id) { $dbquery = Database::simpleQuery("SELECT parentlocationid FROM `location` WHERE locationid = :locationid", array('locationid' => $id)); $parent = 0; @@ -331,7 +375,9 @@ class Page_LocationInfo extends Page } } -// Loads the Infoscreen pange in the admin-panel and passes all needed information. + /** + * Loads the Infoscreen page in the admin-panel and passes all needed information. + */ protected function getInfoScreenTable() { // Get a table with the needed location info. name, id, hidden, pcState (Count of pcs that are in use), total pcs @@ -440,6 +486,11 @@ class Page_LocationInfo extends Page } } + /** + * Ajax the server settings. + * + * @param $id Serverid + */ private function ajaxServerSettings($id) { $dbresult = Database::queryFirst('SELECT servername, serverurl, servertype, credentials FROM `setting_location_info` WHERE serverid = :id', array('id' => $id)); @@ -510,6 +561,11 @@ class Page_LocationInfo extends Page echo Render::parse('server-settings', array('id' => $id, 'name' => $dbresult['servername'], 'url' => $dbresult['serverurl'], 'servertype' => $dbresult['servertype'], 'backendList' => array_values($serverBackends))); } + /** + * Ajax the time table + * + * @param $id id of the location + */ private function ajaxTimeTable($id) { $array = array(); $dbquery = Database::simpleQuery("SELECT openingtime FROM `location_info` WHERE locationid = :id", array('id' => $id)); @@ -551,6 +607,12 @@ class Page_LocationInfo extends Page } } + /** + * Checks if easymode or expert mode is active. + * + * @param $array Array of the saved openingtimes. + * @return bool True if easy mode, false if expert mode + */ private function isEasyMode($array) { if(count($array[0]) == 3) { if ($array[0][0]['days'] == array ("Monday","Tuesday","Wednesday","Thursday","Friday") @@ -566,6 +628,11 @@ class Page_LocationInfo extends Page } } + /** + * Ajax the config of a location. + * + * @param $id Location ID + */ private function ajaxConfig($id) { $array = array(); diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html index 3168c6a2..adce047b 100644 --- a/modules-available/locationinfo/templates/config.html +++ b/modules-available/locationinfo/templates/config.html @@ -4,105 +4,269 @@ <input type="hidden" name="action" value="updateConfig"> <input type="hidden" name="id" value="{{id}}"> - - <div style="float: left;"> - <Label>{{lang_server}}</Label><br> - <select name="serverid"> - {{#serverlist}} - <option id="serverOption-{{sid}}" value="{{sid}}">{{sname}}</option> - {{/serverlist}} - </select> - </div> - - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_serverRoomId}}</Label><br> - <input name="serverroomid" id="serverroomid" value="{{serverroomid}}" - style="width: 250px; text-align: center;"> - </div> - - - <br><br><br><br> - - <div style="float: left;"> - <Label>{{lang_language}}</Label><br> - <select name="language"> - <option value="en" id="en">{{lang_languageEn}}</option> - <option value="de" id="de">{{lang_languageDe}}</option> - <option value="pt" id="pt">{{lang_languagePt}}</option> - </select> - </div> - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_mode}}</Label><br> - <select name="mode" onchange="vertical_cb(this.value);"> - <option value="1" id="mode1">{{lang_mode1}}</option> - <option value="2" id="mode2">{{lang_mode2}}</option> - <option value="3" id="mode3">{{lang_mode3}}</option> - <option value="4" id="mode4">{{lang_mode4}}</option> - </select> - </div> - <div style="float: left; margin-left: 15px;"> - <input name="vertical" id="cb_vertical" type="checkbox"/> {{lang_vertical}}<br> - <input name="eco" id="cb_eco" type="checkbox"/> {{lang_ecoMode}}<br> - <input name="autoscale" id="cb_autoScale" type="checkbox"/> {{lang_autoScale}} - </div> - - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_daysToShowTooltip}}">{{lang_daysToShow}}</Label><br> - <select name="daystoshow"> - <option value="1" id="day1">1</option> - <option value="2" id="day2">2</option> - <option value="3" id="day3">3</option> - <option value="4" id="day4">4</option> - <option value="5" id="day5">5</option> - <option value="6" id="day6">6</option> - <option value="7" id="day7">7</option> - </select> - </div> - - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_rotation}}</Label><br> - <select name="rotation"> - <option value="0" id="rotation0">{{lang_rotation0}}</option> - <option value="3" id="rotation3">{{lang_rotation3}}</option> - <option value="2" id="rotation2">{{lang_rotation2}}</option> - <option value="1" id="rotation1">{{lang_rotation1}}</option> - </select> - </div> - - <br><br><br><br> - - <Label data-toggle="tooltip" title="{{lang_scaleTooltip}}">{{lang_scale}}</Label><br> - <span id="scale">50 %</span><input name="scale" id="sl_scale" type="range" step="1" min="10" max="90" value="50" - style="width: 300px;" oninput="showScaleValue(this.value)"/> - - <br><br> - - <Label data-toggle="tooltip" title="{{lang_switchTimeTooltip}}">{{lang_switchTime}}</Label><br> - <span id="switch">20 {{lang_sec}}</span><input name="switchtime" id="sl_switch" type="range" step="1" min="1" - max="120" value="20" style="width: 300px;" - oninput="showSwitchValue(this.value)"/> - - <br><br> - - <div> - <div style="float: left;"> - <Label data-toggle="tooltip" title="{{lang_calupdateTooltip}}">{{lang_calupdate}}</Label><br> - <input id="updateCalendar" name="calupdate" type="number" style="width: 50px; text-align: center;" min="0" - max="1440"/> {{lang_min}} - </div> - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_roomupdateTooltip}}">{{lang_roomupdate}}</Label><br> - <input id="updateRoom" name="roomupdate" type="number" style="width: 50px; text-align: center;" min="0" - max="86400"/> {{lang_sec}} - </div> - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_configupdateTooltip}}">{{lang_configupdate}}</Label><br> - <input id="updateConfig" name="configupdate" type="number" style="width: 50px; text-align: center;" min="0" - max="1440"/> {{lang_min}} - </div> - </div> - - <br><br><br><br> + <div class="panel panel-default"> + <div class="panel-heading">{{lang_server}}</div> + <div class="panel-body"> + <div class="list-group"> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_server}}</label> + </div> + <div class="col-md-7"> + <select class="form-control" name="serverid"> + {{#serverlist}} + <option id="serverOption-{{sid}}" value="{{sid}}">{{sname}}</option> + {{/serverlist}} + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-server" title="{{lang_serverTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_roomId}}</label> + </div> + <div class="col-md-7"> + <input class="form-control" name="serverroomid" id="serverroomid" value="{{serverroomid}}"> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-roomId" title="{{lang_roomIdTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + </div> + </div> + </div> + + <div class="panel panel-default"> + <div class="panel-heading">{{lang_display}}</div> + <div class="panel-body"> + <div class="list-group"> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_language}}</label> + </div> + <div class="col-md-7"> + <select class="form-control" name="language"> + <option value="en" id="en">{{lang_languageEn}}</option> + <option value="de" id="de">{{lang_languageDe}}</option> + <option value="pt" id="pt">{{lang_languagePt}}</option> + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-language" title="{{lang_languageTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_mode}}</label> + </div> + <div class="col-md-7"> + <select class="form-control" name="mode" onchange="modeChange(this.value);"> + <option value="1" id="mode1">{{lang_mode1}}</option> + <option value="2" id="mode2">{{lang_mode2}}</option> + <option value="3" id="mode3">{{lang_mode3}}</option> + <option value="4" id="mode4">{{lang_mode4}}</option> + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-mode" title="{{lang_modeTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3"> + <label>{{lang_ecoMode}}</label> + </div> + <div class="col-md-7"> + <input type="hidden" name="eco" value="{{eco}}" id="cb_input_eco"/> + <input class="bs-switch" id="cb_eco" type="checkbox"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-eco" title="{{lang_ecoTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + </div> + </div> + </div> + + + <div class="panel panel-default" id="extra-div"> + <div class="panel-heading">{{lang_mode}}</div> + <div class="panel-body"> + <div class="list-group"> + + <div class="list-group-item" id="item-vertical"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_vertical}}</label> + </div> + <div class="col-md-7" > + <input type="hidden" name="vertical" value="{{vertical}}" id="cb_input_vertical"/> + <input class="bs-switch" id="cb_vertical" type="checkbox"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-vertical" title="{{lang_verticalTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item" id="item-autoscale"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_autoScale}}</label> + </div> + <div class="col-md-7" > + <input type="hidden" name="autoscale" value="{{scaledaysauto}}" id="cb_input_autoScale"/> + <input class="bs-switch" id="cb_autoScale" type="checkbox"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-autoscale" title="{{lang_autoscaleTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item" id="item-daystoshow"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_daysToShow}}</label> + </div> + <div class="col-md-7" > + <select class="form-control" name="daystoshow"> + <option value="1" id="day1">1</option> + <option value="2" id="day2">2</option> + <option value="3" id="day3">3</option> + <option value="4" id="day4">4</option> + <option value="5" id="day5">5</option> + <option value="6" id="day6">6</option> + <option value="7" id="day7">7</option> + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-daystoshow" title="{{lang_daysToShowTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item" id="item-rotation"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_rotation}}</label> + </div> + <div class="col-md-7"> + <select class="form-control" name="rotation"> + <option value="0" id="rotation0">{{lang_rotation0}}</option> + <option value="3" id="rotation3">{{lang_rotation3}}</option> + <option value="2" id="rotation2">{{lang_rotation2}}</option> + <option value="1" id="rotation1">{{lang_rotation1}}</option> + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-rotation" title="{{lang_rotationTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item" id="item-scale"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_scale}}</label> + </div> + <div class="col-md-7" > + <span id="scale">50 %</span> + <input name="scale" id="sl_scale" type="range" step="1" min="10" max="90" value="50" oninput="showScaleValue(this.value)"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-scale" title="{{lang_scaleTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item" id="item-switchtime"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_switchTime}}</label> + </div> + <div class="col-md-7" > + <span id="switch">20 {{lang_sec}}</span> + <input name="switchtime" id="sl_switch" type="range" step="1" min="1" max="120" value="20" oninput="showSwitchValue(this.value)"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-switchtime" title="{{lang_switchTimeTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + </div> + </div> + </div> + + <div class="panel panel-default"> + <div class="panel-heading">{{lang_updateRates}}</div> + <div class="panel-body"> + <div class="list-group"> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_calendar}}</label> + </div> + <div class="col-md-7" > + <input class="form-control" id="updateCalendar" name="calupdate" type="number" min="0" max="1440"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-updatecalendar" title="{{lang_calupdateTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_room}}</label> + </div> + <div class="col-md-7" > + <input class="form-control" id="updateRoom" name="roomupdate" type="number" min="0" max="86400"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-updateroom" title="{{lang_roomupdateTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + <div class="list-group-item"> + <div class="row"> + <div class="col-md-3" > + <label>{{lang_config}}</label> + </div> + <div class="col-md-7" > + <input class="form-control" id="updateConfig" name="configupdate" type="number" min="0" max="1440"/> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-updateconfig" title="{{lang_configupdateTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> + </div> + </div> + + </div> + </div> + </div> <button type="submit" class="btn btn-primary">{{lang_save}}</button> @@ -110,8 +274,35 @@ </div> <script type="text/javascript"> + + var autoscale = '{{scaledaysauto}}'; + initBootstrap(); loadValues(); + /** + * Initialize the bootstrap elements. + */ + function initBootstrap() { + // Init Bootstrap stuff. + $('#help-updateroom').tooltip(); + $('#help-updateconfig').tooltip(); + $('#help-updatecalendar').tooltip(); + $('#help-daystoshow').tooltip(); + $('#help-rotation').tooltip(); + $('#help-server').tooltip(); + $('#help-roomId').tooltip(); + $('#help-language').tooltip(); + $('#help-mode').tooltip(); + $('#help-eco').tooltip(); + $('#help-vertical').tooltip(); + $('#help-autoscale').tooltip(); + $('#help-scale').tooltip(); + $('#help-switchtime').tooltip(); + } + + /** + * Loads the Values in the config form elements. + */ function loadValues() { $("#{{language}}").attr("selected", "selected"); @@ -122,17 +313,44 @@ mode = $("#mode1"); } mode.attr("selected", "selected"); - vertical_cb(mode.val()); - if ('{{vertical}}' == true) { - $("#cb_vertical").prop("checked", true); - } - if ('{{eco}}' == true) { - $("#cb_eco").prop("checked", true); - } - if ('{{scaledaysauto}}' == true) { - $("#cb_autoScale").prop("checked", true); - } + $('#cb_vertical').bootstrapSwitch({ + state: '{{vertical}}', + size: 'small' + }); + $('#cb_vertical').on('switchChange.bootstrapSwitch', function(e, value) { + if (value) { + $('#cb_input_vertical').val(1); + } else { + $('#cb_input_vertical').val(0); + } + }); + + $('#cb_eco').bootstrapSwitch({ + state: '{{eco}}', + size: 'small' + }); + $('#cb_eco').on('switchChange.bootstrapSwitch', function(e, value) { + if (value) { + $('#cb_input_eco').val(1); + } else { + $('#cb_input_eco').val(0); + } + }); + + $('#cb_autoScale').bootstrapSwitch({ + state: '{{scaledaysauto}}', + size: 'small' + }); + + $('#cb_autoScale').on('switchChange.bootstrapSwitch', function(e, value) { + if (value) { + $('#cb_input_autoScale').val(1); + } else { + $('#cb_input_autoScale').val(0); + } + autoScaleChange(value); + }); var day = $("#{{daystoshow}}"); if (!day.length) { @@ -177,23 +395,72 @@ configupdate = 180; } $("#updateConfig").attr("value", configupdate); + + modeChange(mode.val()); } + /** + * Updates the value from the scale slider. + * + * @param newValue The new value the scale slider was set to. + */ function showScaleValue(newValue) { $("#scale").text(newValue + " %"); } + /** + * Updates the value from the switchtime slider. + * + * @param newValue The new value the switchtime slider was set to. + */ function showSwitchValue(newValue) { $("#switch").text(newValue + " " + '{{lang_sec}}'); } - function vertical_cb(value) { - var cb = $("#cb_vertical"); - if (value == 1) { - cb.prop("disabled", false); + /** + * If the mode was changed the mode settings have to be adjusted. + * + * @param value The new mode that was set. 1-4 + */ + function modeChange(value) { + $('#item-vertical').hide(); + $('#item-autoscale').hide(); + $('#item-daystoshow').hide(); + $('#item-rotation').hide(); + $('#item-scale').hide(); + $('#item-switchtime').hide(); + + autoScaleChange(autoscale); + + if (value == "1") { + $('#item-vertical').show(); + $('#item-autoscale').show(); + $('#item-rotation').show(); + $('#item-scale').show(); + } else if (value == "2"){ + $('#item-autoscale').show(); + } else if (value == "3"){ + $('#item-rotation').show(); + $('#item-daystoshow').hide(); + } else if (value == "4"){ + $('#item-autoscale').show(); + $('#item-rotation').show(); + $('#item-switchtime').show(); + } + } + + /** + * If the auto scale changes the days to show must be shown / hided + * + * @param value The new value of the autoscale switch. + */ + function autoScaleChange(value) { + autoscale = value; + if (value) { + $('#item-daystoshow').hide(); } else { - cb.prop("disabled", true); - cb.prop("checked", false); + $('#item-daystoshow').show(); } } + </script> diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html index d494ebdc..f14faa23 100644 --- a/modules-available/locationinfo/templates/location-info.html +++ b/modules-available/locationinfo/templates/location-info.html @@ -95,11 +95,11 @@ } cb.addEventListener("click", function() { cbClick(this, {{locationid}}); }); </script> - <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" - onclick="loadTimeModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-time"></span>{{lang_openingTime}}</a> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" style="width: 100%" + onclick="loadTimeModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-time"></span></a> </td> - <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" - onclick="loadConfigModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-cog"></span>{{lang_locationSettings}}</a> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" style="width: 100%;" + onclick="loadConfigModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-cog"></span></a> </td> </tr> @@ -123,6 +123,12 @@ <script type="text/javascript"> var lastPcSubTable = false; + /** + * Sets the checkbox value and calls the php hide action. + * + * @param cb The checkbox which was clicked. + * @param locID the locationID of the checkbox. + */ function cbClick(cb, locID) { var value; @@ -134,6 +140,12 @@ window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value; } + /** + * Loads the settings modal of a server. + * + * @param serverid The id of the server. + * @param servername The name of the server. + */ function loadSettingsModal(serverid, servername) { $('#myModalHeader').text("{{lang_locationSettings}}").css("font-weight", "Bold"); @@ -141,6 +153,12 @@ $('#myModalBody').load("?do=locationinfo&action=serverSettings&id=" + serverid); } + /** + * Load a opening time modal of a location. + * + * @param locationId The id of the location. + * @param locationName The name of the location. + */ function loadTimeModal(locationId, locationName) { $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight", "Bold"); @@ -149,9 +167,10 @@ } /** + * Loads the config modal of a location. * - * @param locationId - * @param locationName + * @param locationId The id of the location + * @param locationName the name of the location */ function loadConfigModal(locationId, locationName) { $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight", "Bold"); @@ -167,6 +186,11 @@ var preEditPassword; var preEditType; + /** + * Deletes a server. + * + * @param id The serverid + */ function deleteButtonClick(id) { var del = confirm("{{lang_deleteConfirmation}}"); if (del == true) { @@ -175,12 +199,20 @@ } } + /** + * Calls the checkConnection php function to check a server connection. + * + * @param id The id of the server. + */ function refreshButtonClick(id) { $('#refresh-btn-animate-' + id).addClass('glyphicon-refresh-animate'); $('#serverFormAction-' + id).val("checkConnection"); $('#submit-serverForm-' + id).trigger("click"); } + /** + * Loads a new / empty server settings modal. + */ function addServer() { loadSettingsModal(0, ''); } diff --git a/modules-available/locationinfo/templates/server-settings.html b/modules-available/locationinfo/templates/server-settings.html index b42f4c15..641873ef 100644 --- a/modules-available/locationinfo/templates/server-settings.html +++ b/modules-available/locationinfo/templates/server-settings.html @@ -15,9 +15,12 @@ <div class="col-md-3" > <label>{{lang_locationName}}</label> </div> - <div class="col-md-8"> + <div class="col-md-7"> <input required class="form-control" id="input-name-{{id}}" name="name" type="text" value="{{name}}"></input> </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-name" title="{{lang_nameTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> </div> </div> @@ -26,9 +29,12 @@ <div class="col-md-3"> <label>{{lang_serverUrl}}</label> </div> - <div class="col-md-8"> + <div class="col-md-7"> <input required class="form-control" id="input-url-{{id}}" name="url" type="text" value="{{url}}" ></input> </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-url" title="{{lang_urlTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> + </div> </div> </div> @@ -37,14 +43,15 @@ <div class="col-md-3"> <label>{{lang_serverType}}</label> </div> - <div class="col-md-8"> - - <select class="form-control" id="input-type-{{id}}" name="type" value="{{typ}}" onchange="servertype_changed(this.value);"> + <div class="col-md-7"> + <select class="form-control" id="input-type-{{id}}" name="type" value="{{typ}}" onchange="servertype_changed(this.value);"> {{#backendList}} - <option id="{{typ}}" value="{{typ}}" {{#active}}selected{{/active}}>{{display}} + <option id="{{typ}}" value="{{typ}}" {{#active}}selected{{/active}}>{{display}} {{/backendList}} - </select> - + </select> + </div> + <div class="col-md-2"> + <a class="btn btn-default" id="help-type" title="{{lang_typeTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></a> </div> </div> </div> @@ -71,8 +78,25 @@ if (type == "") { type = $('#input-type-{{id}}').val(); } + loadCredentials(); - function loadCredentials() { + initalizeBootstrap(); + + /** + * Initialize the bootstrap elements. + */ + function initalizeBootstrap() { + $('#help-name').tooltip(); + $('#help-url').tooltip(); + $('#help-type').tooltip(); + } + + /** + * Loads the dynamic credentials forms. + * + * @param {bool} useValue If false the form elements will be empty. Default = true. + */ + function loadCredentials(useValue = true) { // {{name}} name of auth {{type}} type of auth (string, int etc.) {{value}} value from the db {{#backendList}} if (type == "{{typ}}") { @@ -81,33 +105,44 @@ if ("{{type}}" == "string") { $("#credentials-list").append('<div class="list-group-item"><div class="row">\ - <div class="col-md-3"><label title="{{title}}">{{name}}</label></div>\ - <div class="col-md-8">\ - <input required class="form-control" {{#mask}}type="password"{{/mask}}{{^mask}}type="text"{{/mask}} name="{{uid}}" value="{{value}}" form="settingsForm">\ - </div></div></div>'); + <div class="col-md-3"><label>{{name}}</label></div>\ + <div class="col-md-7">\ + <input required class="form-control" id="input-{{uid}}" {{#mask}}type="password"{{/mask}}{{^mask}}type="text"{{/mask}} name="{{uid}}" value="{{value}}" form="settingsForm"></div>\ + <div class="col-md-2"><a class="btn btn-default" id="help-{{uid}}" title="{{title}}"><span class="glyphicon glyphicon-question-sign"></span></a></div>\ + </div></div>'); } else if ("{{type}}" == "int") { $("#credentials-list").append('<div class="list-group-item"><div class="row">\ - <div class="col-md-3"><label title="{{title}}">{{name}}</label></div>\ - <div class="col-md-8">\ - <input required class="form-control" {{#mask}}type="password" pattern="[0-9]*"{{/mask}}{{^mask}}type="number"{{/mask}} name="{{uid}}" value="{{value}}" form="settingsForm">\ - </div></div></div>'); + <div class="col-md-3"><label>{{name}}</label></div>\ + <div class="col-md-7">\ + <input required class="form-control" id="input-{{uid}}" {{#mask}}type="password" pattern="[0-9]*"{{/mask}}{{^mask}}type="number"{{/mask}} name="{{uid}}" value="{{value}}" form="settingsForm"></div>\ + <div class="col-md-2"><a class="btn btn-default" id="help-{{uid}}" title="{{title}}"><span class="glyphicon glyphicon-question-sign"></span></a></div>\ + </div></div>'); } else if ("{{type}}" == "bool") { $("#credentials-list").append('<div class="list-group-item"><div class="row">\ - <div class="col-md-3"><label title="{{title}}">{{name}}</label></div>\ - <div class="col-md-8">\ - <input class="bs-switch" id="bs-{{uid}}" type="checkbox" name="{{uid}}" value="true" form="settingsForm" {{#value}}checked{{/value}}>\ - </div></div></div>'); - $('#bs-{{uid}}').bootstrapSwitch(); + <div class="col-md-3"><label>{{name}}</label></div>\ + <div class="col-md-7">\ + <input class="bs-switch" id="input-{{uid}}" type="checkbox" name="{{uid}}" value="true" form="settingsForm" {{#value}}checked{{/value}}></div>\ + <div class="col-md-2"><a class="btn btn-default" id="help-{{uid}}" title="{{title}}"><span class="glyphicon glyphicon-question-sign"></span></a></div>\ + </div></div>'); + $('#bs-{{uid}}').bootstrapSwitch({ + size: "small" + }); } else if ("{{type}}" == "array") { $("#credentials-list").append('<div class="list-group-item"><div class="row">\ - <div class="col-md-3"><label title="{{title}}">{{name}}</label></div>\ - <div class="col-md-8">\ - <select class="form-control" name="{{uid}}" form="settingsForm">\ + <div class="col-md-3"><label>{{name}}</label></div>\ + <div class="col-md-7">\ + <select class="form-control" id="input-{{uid}}" name="{{uid}}" form="settingsForm">\ {{#array}}\ <option value="{{option}}" {{#active}}selected{{/active}}>{{option}}</option>\ {{/array}}\ - </select>\ - </div></div></div>'); + </select></div>\ + <div class="col-md-2"><a class="btn btn-default" id="help-{{uid}}" title="{{title}}"><span class="glyphicon glyphicon-question-sign"></span></a></div>\ + </div></div>'); + } + + $('#help-{{uid}}').tooltip(); + if (!useValue) { + $('#input-{{uid}}').val(""); } {{/credentials}} {{^credentials}} @@ -118,11 +153,16 @@ } + /** + * After the servertype switch changed, the new credentials needs to be loaded. + * + * @param {string} value The new type of the server which credentials needs to be loaded. + */ function servertype_changed(value) { type = value; $('#credentials-div').fadeOut('fast', function() { $('#credentials-list').empty(); - loadCredentials(); + loadCredentials(false); }); } diff --git a/modules-available/locationinfo/templates/timetable.html b/modules-available/locationinfo/templates/timetable.html index 78d13e29..7143facd 100644 --- a/modules-available/locationinfo/templates/timetable.html +++ b/modules-available/locationinfo/templates/timetable.html @@ -146,6 +146,9 @@ } }); + /** + * Sets the timepicker element. + */ function setTimepicker() { $('.timepicker2').timepicker({ minuteStep: 1, @@ -157,6 +160,9 @@ }); } + /** + * Adds a new opening time to the table in expert mode. + */ function newOpeningTime() { $('#lastOpenTimesTableElement').before('<tr>\ <td>\ @@ -172,7 +178,6 @@ <input type="hidden" name="days[]" value="-">\ </td>\ <td>\ - \ <div class="input-group bootstrap-timepicker">\ <span class="input-group-addon">\ <span class="glyphicon glyphicon-time"></span>\ |