From 0085d9309252fc1eec276b6eb05f271a140bee5d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 13 Jun 2017 18:32:23 +0200 Subject: [locationinfo] slxadmin part done, todo: frontend+api --- modules-available/locationinfo/api.inc.php | 25 +- .../locationinfo/inc/locationinfo.inc.php | 23 ++ .../locationinfo/lang/de/messages.json | 14 +- .../locationinfo/lang/de/template-tags.json | 37 +- .../locationinfo/lang/en/messages.json | 14 +- .../locationinfo/lang/en/template-tags.json | 27 +- modules-available/locationinfo/page.inc.php | 197 +++++++--- .../templates/page-config-panel-default.html | 418 +++++++++++++++++++++ .../locationinfo/templates/page-config-panel.html | 349 ----------------- .../locationinfo/templates/page-locations.html | 20 +- .../locationinfo/templates/page-panels.html | 57 +++ .../locationinfo/templates/page-servers.html | 117 +++--- .../locationinfo/templates/page-tabs.html | 6 + 13 files changed, 796 insertions(+), 508 deletions(-) create mode 100644 modules-available/locationinfo/templates/page-config-panel-default.html delete mode 100644 modules-available/locationinfo/templates/page-config-panel.html create mode 100644 modules-available/locationinfo/templates/page-panels.html create mode 100644 modules-available/locationinfo/templates/page-tabs.html diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 644f990b..34c2a41a 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -230,7 +230,7 @@ function getConfig($locationID) LEFT JOIN `locationinfo_locationconfig` AS li ON (l.locationid = li.locationid) WHERE l.locationid = :locationID", array('locationID' => $locationID)); - $config = defaultConfig(); + $config = LocationInfo::defaultPanelConfig(); if ($dbresult !== false) { if (!empty($dbresult['config'])) { @@ -247,29 +247,6 @@ function getConfig($locationID) return $config; } -/** - * Creates and returns a default config for room that didn't saved a config yet. - * - * @return array Return a default config. - */ -function defaultConfig() -{ - return array( - 'language' => 'en', - 'mode' => 1, - 'vertical' => false, - 'eco' => false, - 'scaledaysauto' => true, - 'daystoshow' => 7, - 'rotation' => 0, - 'scale' => 50, - 'switchtime' => 20, - 'calupdate' => 30, - 'roomupdate' => 5, - 'configupdate' => 180, - ); -} - /** * Gets the pc states of the given locations. * diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 6b13ad9a..fa97a0c6 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -60,4 +60,27 @@ class LocationInfo } } + /** + * Creates and returns a default config for room that didn't saved a config yet. + * + * @return array Return a default config. + */ + public static function defaultPanelConfig() + { + return array( + 'language' => 'en', + 'mode' => 1, + 'vertical' => false, + 'eco' => false, + 'scaledaysauto' => true, + 'daystoshow' => 7, + 'rotation' => 0, + 'scale' => 50, + 'switchtime' => 20, + 'calupdate' => 30, + 'roomupdate' => 15, + 'configupdate' => 180, + ); + } + } diff --git a/modules-available/locationinfo/lang/de/messages.json b/modules-available/locationinfo/lang/de/messages.json index 52a48a02..8da5bd33 100644 --- a/modules-available/locationinfo/lang/de/messages.json +++ b/modules-available/locationinfo/lang/de/messages.json @@ -1,8 +1,10 @@ { - "no-days-selected": "Es wurden keine Tage ausgewählt.", - "added-x-entries": "Eintr\u00e4ge hinzugef\u00fcgt: {{0}}", - "deleted-x-entries": "Eintr\u00e4ge gelöscht: {{0}}", - "openingtime-updated": "Öffnungszeiten aktualisiert.", + "auth-failed": "[{{0}}] {{1}} Error: {{2}}", "config-saved": "Einstellungen erfolgreich gespeichert.", - "auth-failed": "[{{0}}] {{1}} Error: {{2}}" -} + "ignored-invalid-end": "Eintrag mit ung\u00fcltiger Endzeit ignoriert", + "ignored-invalid-range": "Eintrag mit ung\u00fcltiger Range ignoriert", + "ignored-invalid-start": "Eintrag mit ung\u00fcltiger Startzeit ignoriert", + "ignored-line-no-days": "Eintrag ohne ausgew\u00e4hlte Tage ignoriert", + "invalid-panel-id": "Ung\u00fcltige Panel-ID '{{0}}'", + "invalid-server-id": "Ung\u00fcltige Server-ID '{{0}}'" +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 379730e5..9b30a14a 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -1,32 +1,42 @@ { "lang_addServer": "Server", + "lang_areYouSure": "Sind Sie sicher?", "lang_autoScale": "Auto Tage", "lang_autoscaleTooltip": "Berechnet anhand der Bildschirmbreite die optimale Anzahl an Tagen, die der Kalender anzeigt", - "lang_buildingTable": "Geb\u00e4ude \/ Raum Liste", + "lang_backend": "Backend", + "lang_backends": "Backends", "lang_calendar": "Kalender", "lang_calupdateTooltip": "Zeit nachdem der Kalender aktualisiert wird (in Minuten)", "lang_checkConnection": "Verbindung pr\u00fcfen", "lang_closingTime": "Schlie\u00dfungszeit", "lang_config": "Einstellungen", "lang_configupdateTooltip": "Zeit nach der die Einstellungen aktualisiert werden (in Minuten)", + "lang_createPanel": "Panel anlegen", "lang_credentials": "Anmeldung", - "lang_customUrl": "Benutzerdefinierte URL", - "lang_customUrlTooltip": "Diese URL \u00fcberschreibt die Einstellungen des Raumes", "lang_day": "Tag", "lang_daysToShow": "Tage", "lang_daysToShowTooltip": "Legt die Anzahl an Tagen im Kalender fest, die angezeigt werden", + "lang_defaultPanel": "Standard-Panel", "lang_deleteConfirmation": "Sind Sie sicher?", "lang_display": "Anzeige", + "lang_displayName": "Name", + "lang_displayNameTooltip": "Anzeigename f\u00fcr dieses Panel", "lang_ecoMode": "E-Ink Modus", "lang_ecoTooltip": "Anstelle der Farb-basierten PC-Status Bilder, werden Symbol-basierte PC Bilder verwendet", + "lang_editDefaultPanelHints": "Hier k\u00f6nnen Sie ein Panel (z.B. digitales T\u00fcrschild) in Aussehen und Funktionsweise definieren. Um im Kalender \u00d6ffnungszeiten anzeigen zu k\u00f6nnen, m\u00fcssen Sie im Tab \"Raum-\/Ortsbezogene Einstellungen\" f\u00fcr den ausgew\u00e4hlten Raum entsprechend \u00d6ffnungszeiten eintragen. Damit im Kalender Veranstaltungen und andere Termine angezeigt werden k\u00f6nnen, muss ein funktionierendes Backend konfiguriert und den ausgew\u00e4hlten R\u00e4umen zugewiesen worden sein.", + "lang_editPanel": "Panel bearbeiten", "lang_entryName": "Name", + "lang_error": "Fehler", "lang_expertMode": "Expertenmodus", + "lang_fourLocsHint": "Hier k\u00f6nnen Sie bis zu vier Orte ausw\u00e4hlen, die in diesem Panel angezeigt werden.", "lang_general": "Allgemein", "lang_language": "Sprache", "lang_languageTooltip": "Legt die Sprache der angezeigten Oberfl\u00e4che fest", "lang_locationName": "Name", - "lang_locationSettings": "Einstellungen", - "lang_mainHeader": "Infoscreen", + "lang_locationSettings": "Raum-\/Ortsbezogene Einstellungen", + "lang_locations": "Orte", + "lang_locationsTable": "R\u00e4ume \/ Orte", + "lang_locationsTableHints": "Hier k\u00f6nnen Sie f\u00fcr die R\u00e4ume und Orte Ihrer Einrichtung \u00d6ffnungszeiten hinterlegen, sowie die Verkn\u00fcpfung mit Raum-IDs aus konfigurierten Backends (z.B. HISinOne) vornehmen, damit Belegungspl\u00e4ne abgerufen werden k\u00f6nnen.", "lang_mode": "Modus", "lang_mode1": "Kalender & Raum", "lang_mode2": "Kalender", @@ -35,9 +45,18 @@ "lang_modeTooltip": "Die Anzeigemodi, welche das Frontend unterst\u00fctzt", "lang_monTilFr": "Montag - Freitag", "lang_nameTooltip": "Legt den Namen des Servers fest", + "lang_noLocationsWarning": "Sie haben keine Orte f\u00fcr dieses Panel ausgew\u00e4hlt", "lang_noServer": "", "lang_openingTime": "\u00d6ffnungszeit", - "lang_pleaseSelect": "Bitte w\u00e4hlen...", + "lang_openingtimes": "\u00d6ffnungszeiten", + "lang_panel": "Panel", + "lang_panelType": "Typ", + "lang_panels": "Panels", + "lang_panelsTable": "Panels verwalten", + "lang_panelsTableHints": "Hier sehen Sie alle erstellen Anzeigetafeln, die per Browser an beliebiger Stelle angezeigt werden k\u00f6nnen, z.B. als digitales T\u00fcrschild.", + "lang_pleaseSelect": "Bitte w\u00e4hlen\u2026", + "lang_recursiveServerSet": "Auch f\u00fcr alle untergeordneten R\u00e4ume setzen", + "lang_recursiveSetTooltip": "Wenn aktiviert, wird der Backend-Server auch f\u00fcr alle untergeordneten R\u00e4ume auf den hier gew\u00e4hlten Wert gesetzt", "lang_remoteSchedule": "Abruf Belegungsplan", "lang_room": "Raum", "lang_roomId": "Raum ID", @@ -54,8 +73,9 @@ "lang_scaleTooltip": "[10-90] Legt die Kalenderbreite fest (in Prozent)", "lang_sec": "sek", "lang_server": "Server", - "lang_serverTable": "Server Liste", - "lang_serverTooltip": "Legt fest, von welchem Server die Kalenderdaten bezogen werden", + "lang_serverTable": "Backend-Server verwalten", + "lang_serverTableHints": "Liste aller definierten Backend-Server. Diese werden ben\u00f6tigt, um Belegungspl\u00e4ne f\u00fcr R\u00e4ume abzurufen.", + "lang_serverTooltip": "Legt fest, von welchem Backend-Server die Kalenderdaten bezogen werden", "lang_serverType": "Typ", "lang_shortFriday": "Fr", "lang_shortMonday": "Mo", @@ -64,6 +84,7 @@ "lang_shortThursday": "Do", "lang_shortTuesday": "Di", "lang_shortWednesday": "Mi", + "lang_summaryPanel": "\u00dcbersichts-Panel", "lang_sunday": "Sonntag", "lang_switchTime": "Wechselintervall", "lang_switchTimeTooltip": "[1-120] Legt die Zeit fest, die vergeht bis ein Wechsel erfolgt (in Sekunden)", diff --git a/modules-available/locationinfo/lang/en/messages.json b/modules-available/locationinfo/lang/en/messages.json index b85b56cd..6767bfcf 100644 --- a/modules-available/locationinfo/lang/en/messages.json +++ b/modules-available/locationinfo/lang/en/messages.json @@ -1,8 +1,10 @@ { - "no-days-selected": "No days selected.", - "added-x-entries": "Entries added: {{0}}", - "deleted-x-entries": "Entries deleted: {{0}}", - "openingtime-updated": "Openingtime updated.", + "auth-failed": "[{{0}}] {{1}} Error: {{2}}", "config-saved": "Config successfully saved.", - "auth-failed": "[{{0}}] {{1}} Error: {{2}}" -} + "ignored-invalid-end": "Ignored entry with invalid end time", + "ignored-invalid-range": "Ignored entry with invalid range", + "ignored-invalid-start": "Ignored entry with invalid start time", + "ignored-line-no-days": "Ignored entry with no days selected", + "invalid-panel-id": "Invalid panel id '{{0}}'", + "invalid-server-id": "Invalid server id '{{0}}'" +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 6df405c9..ae308281 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -1,32 +1,41 @@ { + "lang_defaultPanel": "Default panel", "lang_addServer": "Server", + "lang_summaryPanel": "Summary panel", + "lang_areYouSure": "Are you sure?", "lang_autoScale": "Auto Days", "lang_autoscaleTooltip": "Calculates the optimum amount of days to show from the display width", - "lang_buildingTable": "Building \/ Room List", + "lang_backend": "Backend", + "lang_backends": "Backends", "lang_calendar": "Calendar", "lang_calupdateTooltip": "Time the calender querys for updates (in minutes)", "lang_checkConnection": "Check connection", "lang_closingTime": "Closing time", "lang_config": "Config", "lang_configupdateTooltip": "Time interval the config gets updated (in minutes)", + "lang_createPanel": "Create panel", "lang_credentials": "Login", - "lang_customUrl": "Custom URL", - "lang_customUrlTooltip": "This URL will override the config settings from the room", "lang_day": "Day", "lang_daysToShow": "Days", "lang_daysToShowTooltip": "Defines the amount of days to show in the calendar", "lang_deleteConfirmation": "Are you sure?", "lang_display": "Display", + "lang_displayName": "Name", + "lang_displayNameTooltip": "Display name for this panel", "lang_ecoMode": "E-Ink mode", "lang_ecoTooltip": "Symbolic based pc state pictures are used instead of the colour based ones", + "lang_editPanel": "Edit panel", "lang_entryName": "Name", + "lang_error": "Error", "lang_expertMode": "Expert mode", + "lang_fourLocsHint": "You can pick up to four locations that will be shown in this panel.", "lang_general": "General", "lang_language": "Language", "lang_languageTooltip": "The language the frontend uses", "lang_locationName": "Name", "lang_locationSettings": "Settings", - "lang_mainHeader": "Infoscreen", + "lang_locations": "Locations", + "lang_locationsTable": "Rooms \/ Locations", "lang_mode": "Mode", "lang_mode1": "Calendar & Room", "lang_mode2": "Calendar", @@ -35,9 +44,17 @@ "lang_modeTooltip": "The display modes the frontend supports", "lang_monTilFr": "Monday - Friday", "lang_nameTooltip": "Defines the name of the server", + "lang_noLocationsWarning": "Please select at least one location this panel should display", "lang_noServer": "", "lang_openingTime": "Opening time", + "lang_openingtimes": "Opening times", + "lang_panel": "Panel", + "lang_panelType": "Type", + "lang_panels": "Panels", + "lang_panelsTable": "Manage panels", "lang_pleaseSelect": "Please select...", + "lang_recursiveServerSet": "Also set for all child locations", + "lang_recursiveSetTooltip": "If checked, all direct and indirect child locations will be configured to use the backend server selected above", "lang_remoteSchedule": "Time table retrieval", "lang_room": "Room", "lang_roomId": "Room ID", @@ -54,7 +71,7 @@ "lang_scaleTooltip": "[10-90] Defines the calendar width (in percent)", "lang_sec": "sec", "lang_server": "Server", - "lang_serverTable": "Server List", + "lang_serverTable": "Manage backend servers", "lang_serverTooltip": "Defines from which server the room queries the calendar data", "lang_serverType": "Type", "lang_shortFriday": "Fri", diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 333e5c48..996a5fa6 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -25,12 +25,16 @@ class Page_LocationInfo extends Page $show = 'locations'; } elseif ($this->action === 'deleteServer') { $this->deleteServer(); + } elseif ($this->action === 'deletePanel') { + $this->deletePanel(); } elseif ($this->action === 'checkConnection') { $this->checkConnection(Request::post('serverid', 0, 'int')); + $show = 'backends'; } elseif ($this->action === 'updateServerSettings') { $this->updateServerSettings(); + $show = 'backends'; } elseif (Request::isPost()) { - Messages::addWarning('main.invalid-action', $this->action); + Message::addWarning('main.invalid-action', $this->action); } if (Request::isPost()) { if (!empty($show)) { @@ -45,19 +49,24 @@ class Page_LocationInfo extends Page */ protected function doRender() { + $backends = $this->loadBackends(); $show = Request::get('show', '', 'string'); + Render::addTemplate('page-tabs', array('class-' . $show => 'active')); switch ($show) { case 'locations': $this->showLocationsTable(); break; + case 'backends': + $this->showBackendsTable($backends); + break; case 'edit-panel': - $this->showConfigPanel(); + $this->showPanelConfig(); break; case '': - $this->showInfoScreenTable(); + $this->showPanelsTable(); break; default: - Message::addError('main.value-invalid', 'show', $show); + Util::redirect('?do=locationinfo'); } } @@ -71,7 +80,23 @@ class Page_LocationInfo extends Page Messages::addError('server-id-missing'); return; } - Database::exec("DELETE FROM `locationinfo_coursebackend` WHERE serverid=:id", array('id' => $id)); + $res = Database::exec("DELETE FROM `locationinfo_coursebackend` WHERE serverid=:id", array('id' => $id)); + if ($res !== 1) { + Message::addWarning('invalid-server-id', $id); + } + } + + private function deletePanel() + { + $id = Request::post('uuid', false, 'string'); + if ($id === false) { + Messages::addError('main.parameter-missing', 'uuid'); + return; + } + $res = Database::exec("DELETE FROM `locationinfo_panel` WHERE paneluuid = :id", array('id' => $id)); + if ($res !== 1) { + Message::addWarning('invalid-panel-id', $id); + } } private function getTime($str) @@ -87,7 +112,7 @@ class Page_LocationInfo extends Page // Check locations $locationid = Request::post('locationid', false, 'int'); if ($locationid === false) { - Message::addError('main.paramter-missing', 'locationid'); + Message::addError('main.parameter-missing', 'locationid'); return false; } if (Location::get($locationid) === false) { @@ -186,17 +211,18 @@ class Page_LocationInfo extends Page private function writePanelConfig() { // UUID - existing or new - $paneluuid = Request::post('paneluuid', false, 'string'); + $paneluuid = Request::post('uuid', false, 'string'); if (($paneluuid === false || strlen($paneluuid) !== 36) && $paneluuid !== 'new') { Message::addError('invalid-panel-id', $paneluuid); Util::redirect('?do=locationinfo'); } // Check locations - $locationids = Request::post('locationids', false, 'array'); + $locationids = Request::post('locationids', false, 'string'); if ($locationids === false) { Message::addError('main.paramter-missing', 'locationids'); Util::redirect('?do=locationinfo'); } + $locationids = explode(',', $locationids); $all = array_map(function ($item) { return $item['locationid']; }, Location::queryLocations()); $locationids = array_filter($locationids, function ($item) use ($all) { return in_array($item, $all); }); if (empty($locationids)) { @@ -222,24 +248,28 @@ class Page_LocationInfo extends Page 'roomupdate' => Request::post('roomupdate', 30, 'int'), 'configupdate' => Request::post('configupdate', 180, 'int'), ); - if ($conf['roomupdate'] < 30) { - $conf['roomupdate'] = 30; + if ($conf['roomupdate'] < 15) { + $conf['roomupdate'] = 15; } - if ($conf['calupdate'] < 120) { - $conf['calupdate'] = 120; + if ($conf['calupdate'] < 30) { + $conf['calupdate'] = 30; + } + if ($conf['configupdate'] < 10) { + $conf['configupdate'] = 10; } if ($paneluuid === 'new') { $paneluuid = Util::randomUuid(); - $query = "INSERT INTO `locationinfo_panel` (paneluuid, locationids, paneltype, panelconfig) - VALUES (:id, :locationids, :type, :config)"; + $query = "INSERT INTO `locationinfo_panel` (paneluuid, panelname, locationids, paneltype, panelconfig) + VALUES (:id, :name, :locationids, :type, :config)"; } else { $query = "UPDATE `locationinfo_panel` - SET locationids = :locationids, paneltype = :type, panelconfig = :config + SET panelname = :name, locationids = :locationids, paneltype = :type, panelconfig = :config WHERE paneluuid = :id"; } Database::exec($query, array( 'id' => $paneluuid, + 'name' => Request::post('name', '-', 'string'), 'locationids' => implode(',', $locationids), 'type' => 'DEFAULT', // TODO 'config' => json_encode($conf), @@ -317,10 +347,7 @@ class Page_LocationInfo extends Page LocationInfo::setServerError($serverid, $serverInstance->getError()); } - /** - * Loads the Infoscreen page in the admin-panel and passes all needed information. - */ - private function showInfoScreenTable() + private function loadBackends() { // Get a list of all the backend types. $servertypes = array(); @@ -329,10 +356,9 @@ class Page_LocationInfo extends Page $typeInstance = CourseBackend::getInstance($s); $servertypes[$s] = $typeInstance->getDisplayName(); } - - // Get the Serverlist from the DB and make it mustache accessable + // Build list of defined backends $serverlist = array(); - $dbquery2 = Database::simpleQuery("SELECT * FROM `locationinfo_coursebackend`"); + $dbquery2 = Database::simpleQuery("SELECT * FROM `locationinfo_coursebackend` ORDER BY servername ASC"); while ($row = $dbquery2->fetch(PDO::FETCH_ASSOC)) { if (isset($servertypes[$row['servertype']])) { $row['typename'] = $servertypes[$row['servertype']]; @@ -353,7 +379,14 @@ class Page_LocationInfo extends Page } $serverlist[] = $row; } + return $serverlist; + } + /** + * Show the list of backends + */ + private function showBackendsTable($serverlist) + { // Pass the data to the html and render it. Render::addTemplate('page-servers', array( 'serverlist' => $serverlist, @@ -404,6 +437,28 @@ class Page_LocationInfo extends Page )); } + private function showPanelsTable() + { + $res = Database::simpleQuery('SELECT p.paneluuid, p.panelname, p.locationids, + p.paneltype FROM locationinfo_panel p + ORDER BY panelname ASC'); + $panels = array(); + $locations = Location::getLocationsAssoc(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $lids = explode(',', $row['locationids']); + $locs = array_map(function($id) use ($locations) { + return isset($locations[$id]) ? $locations[$id]['locationname'] : $id; + }, $lids); + $row['locations'] = implode(', ', $locs); + $len = mb_strlen($row['panelname']); + if ($len < 5) { + $row['panelname'] .= str_repeat('…', 5 - $len); + } + $panels[] = $row; + } + Render::addTemplate('page-panels', array('panels' => $panels)); + } + /** * AJAX */ @@ -632,22 +687,53 @@ class Page_LocationInfo extends Page } /** - * Ajax the config of a location. + * Ajax the config of a panel. * * @param $id Location ID */ - private function showConfigPanel() + private function showPanelConfig() { - $id = Request::get('paneluuid', false, 'string'); - // Get Config data from db - $panel = Database::queryFirst("SELECT locationids, paneltype, panelconfig - FROM locationinfo_panel - WHERE paneluuid = :id", array('id' => $id)); - if ($panel === false) { - die("Invalid panel id: $id"); + $id = Request::get('uuid', false, 'string'); + if ($id === false) { + Message::addError('main.parameter-missing', 'uuid'); + return; } + $config = false; + if ($id === 'new-default') { + // Creating new panel + $panel = array( + 'panelname' => '', + 'locationids' => '', + 'paneltype' => 'DEFAULT', + ); + $id = 'new'; + } elseif ($id === 'new-summary') { + // Creating new panel + $panel = array( + 'panelname' => '', + 'locationids' => '', + 'paneltype' => 'SUMMARY', + ); + $id = 'new'; + } else { + // Get Config data from db + $panel = Database::queryFirst("SELECT panelname, locationids, paneltype, panelconfig + FROM locationinfo_panel + WHERE paneluuid = :id", array('id' => $id)); + if ($panel === false) { + Message::addError('invalid-panel-id', $id); + return; + } - $config = json_decode($panel['panelconfig'], true); // TODO: Validate we got an array, fill with defaults otherwise + $config = json_decode($panel['panelconfig'], true); + } + + $def = LocationInfo::defaultPanelConfig($panel['paneltype']); + if (!is_array($config)) { + $config = $def; + } else { + $config += $def; + } $langs = Dictionary::getLanguages(true); foreach ($langs as &$lang) { @@ -656,21 +742,38 @@ class Page_LocationInfo extends Page } } - Render::addTemplate('page-config-panel', array( - 'id' => $id, - 'languages' => $langs, - 'mode' => $config['mode'], - 'vertical_checked' => $config['vertical'] ? 'checked' : '', - 'eco_checked' => $config['eco'] ? 'checked' : '', - 'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '', - 'daystoshow' => $config['daystoshow'], - 'rotation' => $config['rotation'], - 'scale' => $config['scale'], - 'switchtime' => $config['switchtime'], - 'calupdate' => $config['calupdate'], - 'roomupdate' => $config['roomupdate'], - 'configupdate' => $config['configupdate'], - )); + if ($panel['paneltype'] === 'DEFAULT') { + Render::addTemplate('page-config-panel-default', array( + 'new' => $id === 'new', + 'uuid' => $id, + 'panelname' => $panel['panelname'], + 'languages' => $langs, + 'mode' => $config['mode'], + 'vertical_checked' => $config['vertical'] ? 'checked' : '', + 'eco_checked' => $config['eco'] ? 'checked' : '', + 'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '', + 'daystoshow' => $config['daystoshow'], + 'rotation' => $config['rotation'], + 'scale' => $config['scale'], + 'switchtime' => $config['switchtime'], + 'calupdate' => $config['calupdate'], + 'roomupdate' => $config['roomupdate'], + 'configupdate' => $config['configupdate'], + 'locations' => Location::getLocations(), + 'locationids' => $panel['locationids'], + )); + } else { // TODO + Render::addTemplate('page-config-panel-summary', array( + 'new' => $id === 'new', + 'uuid' => $id, + 'panelname' => $panel['panelname'], + 'languages' => $langs, + 'roomupdate' => $config['roomupdate'], + 'configupdate' => $config['configupdate'], + 'locations' => Location::getLocations(), + 'locationids' => $panel['locationids'], + )); + } } } diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html new file mode 100644 index 00000000..450b29e9 --- /dev/null +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -0,0 +1,418 @@ +

+ {{#new}}{{lang_createPanel}}{{/new}} + {{^new}}{{lang_editPanel}}{{/new}} +

+ +

{{lang_editDefaultPanelHints}}

+ +
+ + + + +
+ +
+
+
{{lang_display}}
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
{{lang_updateRates}}
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
{{lang_mode}}
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ +
+
+  % + +
+
+ + + +
+
+
+ +
+
+
+ +
+
+  {{lang_sec}} + +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
{{lang_locations}}
+
+ +

{{lang_fourLocsHint}}

+
    + +
+ +
+
+
+
+ +
+
+ + {{lang_cancel}} +
+ + + + diff --git a/modules-available/locationinfo/templates/page-config-panel.html b/modules-available/locationinfo/templates/page-config-panel.html deleted file mode 100644 index 244b80c9..00000000 --- a/modules-available/locationinfo/templates/page-config-panel.html +++ /dev/null @@ -1,349 +0,0 @@ -
- - - - -
-
-
-
{{lang_display}}
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
-
-
-
-
-
- -
-
-
-
-
{{lang_mode}}
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
-  % - -
-
- - - -
-
-
- -
-
-
- -
-
-  {{lang_sec}} - -
-
- - - -
-
-
-
-
-
-
- -
-
-
{{lang_updateRates}}
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
- -
-
-
- -
-
- -
-
- - - -
-
-
-
-
-
-
-
-
- -
-
- - - - {{lang_customUrl}} -
-
-
- -
-
-
- - diff --git a/modules-available/locationinfo/templates/page-locations.html b/modules-available/locationinfo/templates/page-locations.html index 27c2d9a2..3eafa7bf 100644 --- a/modules-available/locationinfo/templates/page-locations.html +++ b/modules-available/locationinfo/templates/page-locations.html @@ -1,17 +1,25 @@ -

{{lang_buildingTable}}

- +

{{lang_locationsTable}}

+

{{lang_locationsTableHints}}

+ +
+ - - + + + + {{#list}} - {{/list}} +
{{lang_locationName}}{{lang_openingTime}}{{lang_locationSettings}}{{lang_backend}}{{lang_openingtimes}}
- {{locationname}} + + {{locationname}} + +
{{backend}} @@ -20,8 +28,8 @@