diff options
8 files changed, 297 insertions, 23 deletions
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 @@ +<div> + <form method="post" action="?do=locationinfo" id="configForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="updateConfig"> + <input type="hidden" name="id" value="{{id}}"> + + <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}} + </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</opton> + <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="1" id="rotation1">{{lang_rotation1}}</option> + <option value="2" id="rotation2">{{lang_rotation2}}</option> + <option value="3" id="rotation3">{{lang_rotation3}}</option> + <option value="4" id="rotation4">{{lang_rotation4}}</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> + + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + + </form> +</div> + +<script type="text/javascript"> +loadValues(); + +function loadValues() { + $("#{{language}}").attr("selected","selected"); + + var mode = $("#{{mode}}"); + if (!mode.length) { + 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); + } + + var day = $("#{{daystoshow}}"); + if (!day.length) { + day = $("#day7"); + } + day.attr("selected","selected"); + + var rotation = $("#{{rotation}}"); + if (!rotation.length) { + rotation = $("#rotation1"); + } + rotation.attr("selected","selected"); + + var scaleVal = '{{scale}}'; + if (scaleVal == '') { + scaleVal = 50; + } + $('#sl_scale').attr('value', '{{scale}}'); + showScaleValue(scaleVal); + + var switchVal = '{{switchtime}}'; + if (switchVal == '') { + switchVal = 20; + } + $("#sl_switch").attr('value', switchVal); + showSwitchValue(switchVal); + + $("#updateCalendar").attr("value", '{{calupdate}}'); + $("#updateRoom").attr("value", '{{roomupdate}}'); + $("#updateConfig").attr("value", '{{configupdate}}'); +} + +function showScaleValue(newValue) { + $("#scale").text(newValue + " %"); +} + +function showSwitchValue(newValue) { + $("#switch").text(newValue + " " + '{{lang_sec}}'); +} + +function vertical_cb(value) { + if (value == 1) { + $("#cb_vertical").prop("disabled", false); + } else { + $("#cb_vertical").prop("disabled", true); + $("#cb_vertical").prop("checked", false); + } +} +</script> 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 @@ <th width=10>{{lang_locationID}}</th> <th width=80>{{lang_locationInUse}}</th> <th width=50>{{lang_locationIsHidden}}</th> + <th width=50>{{lang_openingTime}}</th> <th width=50>{{lang_locationSettings}}</th> - <th width=1/> </tr> {{#list}} <tr class="tablerow" onclick="{{#hasPcs}}slxOpenLocationInfo(this, {{locationid}}){{/hasPcs}}"> - <td><div style="display:inline-block;width:{{depth}}em"></div>{{#hasPcs}}<a>{{/hasPcs}}{{locationname}}</td> - <td align="center">{{locationid}}</td> - + <td><div style="display:inline-block;width:{{depth}}em"></div>{{#hasPcs}}<a>{{/hasPcs}}{{locationname}}</td> + <td align="center">[{{locationid}}]</td> <td align="center">{{#hasPcs}}{{inUse}} / {{total}}{{/hasPcs}}</td> - <td id={{locationid}} onclick="event.cancelBubble = true;" align="center"></td> <script> var cbh = document.getElementById('{{locationid}}'); @@ -36,8 +34,8 @@ } cb.addEventListener("click", function() { cbClick(this, {{locationid}}); }); </script> - - <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" onclick="loadModal({{locationid}});">{{lang_locationSettings}}</a><td> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" onclick="loadTimeModal({{locationid}}, '{{locationname}}');">{{lang_openingTime}}</a></td> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" onclick="loadConfigModal({{locationid}}, '{{locationname}}');">{{lang_locationSettings}}</a></td> </tr> {{/list}} @@ -47,7 +45,7 @@ <div class="modal-dialog"> <div class="modal-content"> - <div class="modal-header"></div> + <div class="modal-header" id="myModalHeader"></div> <div class="modal-body" id="myModalBody"></div> <div class="modal-footer"> <a class="btn btn-primary" data-dismiss="modal">{{lang_close}}</a> @@ -90,7 +88,7 @@ function slxOpenLocationInfo(e, locationId) { return; } - var td = $('<td>').attr('colspan', '2').css('padding', '0px 0px 12px'); + var td = $('<td>').attr('colspan', '3').css('padding', '0px 0px 12px'); var tr = $('<tr>').attr('id', 'subtable' + locationId); tr.append(td); $(e).closest('tr').addClass('active slx-bold').after(tr); @@ -98,8 +96,20 @@ function slxOpenLocationInfo(e, locationId) { lastPcSubTable = tr; } -function loadModal(locationId) { - $('#myModal').modal('show') +function loadTimeModal(locationId, locationName) { + $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight","Bold"); + + $('#myModal').modal('show'); $('#myModalBody').load("?do=locationinfo&action=timetable&id=" + locationId); + +} + +function loadConfigModal(locationId, locationName) { + $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight","Bold"); + + $('#myModal').modal('show'); + $('#myModalBody').load("?do=locationinfo&action=config&id=" + locationId); + } + </script> diff --git a/modules-available/locationinfo/templates/timetable.html b/modules-available/locationinfo/templates/timetable.html index c06a70eb..2484ddc8 100644 --- a/modules-available/locationinfo/templates/timetable.html +++ b/modules-available/locationinfo/templates/timetable.html @@ -1,5 +1,5 @@ <div> - <form method="post" action="?do=locationinfo"> + <form method="post" action="?do=locationinfo" id="timeForm"> <input type="hidden" name="token" value="{{token}}"> <input type="hidden" name="action" value="updateOpeningTime"> <input type="hidden" name="id" value="{{id}}"> |