From da6411c00d951cb6277d679d18e4dff771730c72 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 24 Nov 2016 18:19:43 -0800 Subject: Settings added. All settings can be configured now in the slx-admin panel. It will load/save from/in the db. Also minor fixes. --- .../locationinfo/lang/de/messages.json | 4 +- .../locationinfo/lang/de/template-tags.json | 36 ++++- .../locationinfo/lang/en/messages.json | 4 +- .../locationinfo/lang/en/template-tags.json | 35 ++++- modules-available/locationinfo/page.inc.php | 55 +++++++- .../locationinfo/templates/config.html | 152 +++++++++++++++++++++ .../locationinfo/templates/location-info.html | 32 +++-- .../locationinfo/templates/timetable.html | 2 +- 8 files changed, 297 insertions(+), 23 deletions(-) create mode 100644 modules-available/locationinfo/templates/config.html (limited to 'modules-available') diff --git a/modules-available/locationinfo/lang/de/messages.json b/modules-available/locationinfo/lang/de/messages.json index 26822083..f71ee38d 100644 --- a/modules-available/locationinfo/lang/de/messages.json +++ b/modules-available/locationinfo/lang/de/messages.json @@ -1,4 +1,6 @@ { "no-days-selected": "Es wurden keine Tage ausgewählt.", - "added-x-entries": "Eintr\u00e4ge hinzugef\u00fcgt: {{0}}" + "added-x-entries": "Eintr\u00e4ge hinzugef\u00fcgt: {{0}}", + "deleted-x-entries": "Eintr\u00e4ge gelöscht: {{0}}", + "config-saved": "Einstellungen erfolgreich gespeichert." } diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index d27d55e4..eb5121ae 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -6,7 +6,7 @@ "lang_locationIsHidden": "Versteckt", "lang_locationInUse": "In Benutzung / Gesamt", "lang_locationSettings": "Einstellungen", - + "lang_locationConfig": "Config", "lang_pcID": "ID", "lang_pcIP": "IP", @@ -19,12 +19,42 @@ "lang_closingTime": "Schließungszeit", "lang_deleteAll": "Alles Löschen", - "lang_shortMonday": "Mo", "lang_shortTuesday": "Di", "lang_shortWednesday": "Mi", "lang_shortThursday": "Do", "lang_shortFriday": "Fr", "lang_shortSaturday": "Sa", - "lang_shortSunday": "So" + "lang_shortSunday": "So", + + "lang_language": "Sprache", + "lang_languageEn": "en", + "lang_languageDe": "de", + "lang_languagePt": "pt", + "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_switchTime": "Wechsel Zeit", + "lang_switchTimeTooltip": "[1-120] Die Zeit die vergeht bis ein wechsel erfolgt in modus 4 (in sekunden)", + "lang_rotation": "Rotation", + "lang_rotation1": "0°", + "lang_rotation2": "+90°", + "lang_rotation3": "+180°", + "lang_rotation4": "-90°", + "lang_vertical": "Vertikal", + "lang_calupdate": "Kalender update rate", + "lang_calupdateTooltip": "Zeit nachdem der Kalender geupdated wird (in minutes)", + "lang_roomupdate": "Raum update rate", + "lang_roomupdateTooltip": "Zeit nachder die Pcs geupdated werden (in sekunden)", + "lang_configupdate": "Einstellungs update rate", + "lang_configupdateTooltip": "Zeit nachder die Einstellungen geupdated werden (in minuten)", + "lang_min": "min", + "lang_sec": "sec" } diff --git a/modules-available/locationinfo/lang/en/messages.json b/modules-available/locationinfo/lang/en/messages.json index 114cade7..cbb8006f 100644 --- a/modules-available/locationinfo/lang/en/messages.json +++ b/modules-available/locationinfo/lang/en/messages.json @@ -1,4 +1,6 @@ { "no-days-selected": "No days selected.", - "added-x-entries": "Entries added: {{0}}" + "added-x-entries": "Entries added: {{0}}", + "deleted-x-entries": "Entries deleted: {{0}}", + "config-saved": "Config successfully saved." } diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index a63751a8..dc8b2920 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -6,7 +6,7 @@ "lang_locationIsHidden": "Hidden", "lang_locationInUse": "In use / total", "lang_locationSettings": "Settings", - + "lang_locationConfig": "Config", "lang_pcID": "ID", "lang_pcIP": "IP", @@ -25,5 +25,36 @@ "lang_shortThursday": "Thu", "lang_shortFriday": "Fri", "lang_shortSaturday": "Sat", - "lang_shortSunday": "Sun" + "lang_shortSunday": "Sun", + + "lang_language": "Language", + "lang_languageEn": "en", + "lang_languageDe": "de", + "lang_languagePt": "pt", + "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_switchTime": "Switchtime", + "lang_switchTimeTooltip": "[1-120] Sets the time between switching in mode 4 (in seconds)", + "lang_rotation": "Rotation", + "lang_rotation1": "0°", + "lang_rotation2": "+90°", + "lang_rotation3": "+180°", + "lang_rotation4": "-90°", + "lang_vertical": "Vertical", + "lang_calupdate": "Calendar update rate", + "lang_calupdateTooltip": "Time the calender querys for updates (in minutes)", + "lang_roomupdate": "Room update rate", + "lang_roomupdateTooltip": "Time the PCs in the room gets updated (in seconds)", + "lang_configupdate": "Config update", + "lang_configupdateTooltip": "Time interval the config gets updated (in minutes)", + "lang_min": "min", + "lang_sec": "sec" } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 98246388..a18ca22c 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -19,6 +19,8 @@ class Page_LocationInfo extends Page $this->action = Request::post('action'); if ($this->action === 'updateOpeningTime') { $this->updateOpeningTime(); + } elseif ($this->action === 'updateConfig') { + $this->updateConfig(); } } @@ -49,6 +51,30 @@ class Page_LocationInfo extends Page } } + private function updateConfig() + { + $result = array(); + + $locationid = Request::post('id', 0, 'int'); + $result['language'] = Request::post('language'); + $result['mode'] = Request::post('mode', 1, 'int'); + $result['vertical'] = Request::post('vertical', false, 'bool'); + $result['eco'] = Request::post('eco', false, 'bool'); + $result['daystoshow'] = Request::post('daystoshow', 7, 'int'); + $result['rotation'] = Request::post('rotation', 0, 'int'); + $result['scale'] = Request::post('scale', 50, 'int'); + $result['switchtime'] = Request::post('switchtime', 20, 'int'); + $result['calupdate'] = Request::post('calupdate', 0, 'int'); //TODO SET DEFAULT TIME INSTEAD OF 0 + $result['roomupdate'] = Request::post('roomupdate', 0, 'int'); //TODO SET DEFAULT TIME INSTEAD OF 0 + $result['configupdate'] = Request::post('configupdate', 0, 'int'); //TODO SET DEFAULT TIME INSTEAD OF 0 + + Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, '', :config, '') ON DUPLICATE KEY UPDATE config=:config", + array('id' => $locationid, 'hidden' => false, 'config' => json_encode($result, true))); + + Message::addSuccess('config-saved'); + Util::redirect('?do=locationinfo'); + } + private function updateOpeningTime() { $existingDays = Request::post('existingdays'); @@ -61,6 +87,7 @@ class Page_LocationInfo extends Page $count = 0; $result = array(); $resulttmp = array(); + $deleteCounter = 0; $dbquery = Database::simpleQuery("SELECT openingtime FROM `location_info` WHERE locationid = :id", array('id' => $locationid)); while($dbdata=$dbquery->fetch(PDO::FETCH_ASSOC)) { @@ -79,6 +106,7 @@ class Page_LocationInfo extends Page } if ($skip == true) { $index++; + $deleteCounter++; continue; } @@ -119,7 +147,13 @@ class Page_LocationInfo extends Page Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, :openingtime, '', '') ON DUPLICATE KEY UPDATE openingtime=:openingtime", array('id' => $locationid, 'hidden' => false, 'openingtime' => json_encode($result, true))); - Message::addSuccess('added-x-entries', $count); + if ($deleteCounter > 0) { + Message::addSuccess('deleted-x-entries', $deleteCounter); + } + if ($count > 0) { + Message::addSuccess('added-x-entries', $count); + } + Util::redirect('?do=locationinfo'); } @@ -206,11 +240,12 @@ class Page_LocationInfo extends Page if ($action === 'pcsubtable') { $id = Request::any('id'); $this->ajaxShowLocation($id); - } - - if ($action === 'timetable') { + } elseif ($action === 'timetable') { $id = Request::any('id'); $this->ajaxTimeTable($id); + } elseif ($action === 'config') { + $id = Request::any('id'); + $this->ajaxConfig($id); } } @@ -263,4 +298,16 @@ class Page_LocationInfo extends Page } echo Render::parse('timetable', array('id' => $id, 'openingtimes' => array_values($array))); } + + private function ajaxConfig($id) { + $array = array(); + $dbquery = Database::simpleQuery("SELECT config FROM `location_info` WHERE locationid = :id", array('id' => $id)); + while($dbdata=$dbquery->fetch(PDO::FETCH_ASSOC)) { + $array = json_decode($dbdata['config'], true); + } + echo Render::parse('config', array('id' => $id, 'language' => $array['language'], 'mode' => 'mode'.$array['mode'], 'vertical' => $array['vertical'], + 'eco' => $array['eco'], 'daystoshow' => 'day'.$array['daystoshow'], 'rotation' => 'rotation'.$array['rotation'], + 'scale' => $array['scale'], 'switchtime' => $array['switchtime'], 'calupdate' => $array['calupdate'], + 'roomupdate' => $array['roomupdate'], 'configupdate' => $array['configupdate'])); + } } diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html new file mode 100644 index 00000000..0fac50fa --- /dev/null +++ b/modules-available/locationinfo/templates/config.html @@ -0,0 +1,152 @@ +
+
+ + + + +
+
+ +
+
+
+ +
+
+ {{lang_vertical}}
+ {{lang_ecoMode}} +
+ +
+
+ +
+ +
+
+ +
+ +



+ +
+ 50 % + +

+ +
+ 20 {{lang_sec}} + +

+ +
+
+
+ {{lang_min}} +
+
+
+ {{lang_sec}} +
+
+
+ {{lang_min}} +
+
+ +



+ + + +
+
+ + diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html index 254eae8b..b0165eb4 100644 --- a/modules-available/locationinfo/templates/location-info.html +++ b/modules-available/locationinfo/templates/location-info.html @@ -8,19 +8,17 @@ {{lang_locationID}} {{lang_locationInUse}} {{lang_locationIsHidden}} + {{lang_openingTime}} {{lang_locationSettings}} - {{#list}} -
{{#hasPcs}}{{/hasPcs}}{{locationname}} - {{locationid}} - +
{{#hasPcs}}
{{/hasPcs}}{{locationname}} + [{{locationid}}] {{#hasPcs}}{{inUse}} / {{total}}{{/hasPcs}} - - - {{lang_locationSettings}} + {{lang_openingTime}} + {{lang_locationSettings}} {{/list}} @@ -47,7 +45,7 @@