summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2017-03-17 06:10:28 +0100
committerJannik Schönartz2017-03-17 06:10:28 +0100
commitd2d52eaa1ed8ac2007c1f710cee74823f080de6d (patch)
tree1dec30739e49d55b54be6e1126eaa12e8ec12985
parentLocationinfo: Reformat code. (diff)
downloadslx-admin-d2d52eaa1ed8ac2007c1f710cee74823f080de6d.tar.gz
slx-admin-d2d52eaa1ed8ac2007c1f710cee74823f080de6d.tar.xz
slx-admin-d2d52eaa1ed8ac2007c1f710cee74823f080de6d.zip
Rework of the Server List. Many Bugfixes (see Mail).
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php4
-rw-r--r--modules-available/locationinfo/lang/de/messages.json2
-rw-r--r--modules-available/locationinfo/lang/de/template-tags.json22
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json14
-rw-r--r--modules-available/locationinfo/page.inc.php165
-rw-r--r--modules-available/locationinfo/style.css15
-rw-r--r--modules-available/locationinfo/templates/config.html2
-rw-r--r--modules-available/locationinfo/templates/credentials.html31
-rw-r--r--modules-available/locationinfo/templates/location-info.html175
-rw-r--r--modules-available/locationinfo/templates/server-settings.html128
-rw-r--r--modules-available/locationinfo/templates/timetable.html4
11 files changed, 302 insertions, 260 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
index 3dd0f7aa..e6ba0fe8 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
@@ -4,7 +4,7 @@ class Coursebackend_Dummy extends CourseBackend {
public function setCredentials($json,$location,$serverID) {
$x = $json;
- $this->pw = $x['password'];
+ $this->pw = $x['password_str'];
if ($this->pw == "mfg") {
$this->error = false;
@@ -29,7 +29,7 @@ class Coursebackend_Dummy extends CourseBackend {
public function getCredentials(){
$options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"];
- $credentials = ["username" => "string","password"=>"string","option"=>$options];
+ $credentials = ["username" => ["string", "This is a helptext.", false],"password_str"=>["string", "SOME SECRET PW U WILL NEVER KNOW!", true],"password_int"=>["int", "INT PW", true],"option"=>[$options, "OMG WHAT THE", false], "CheckTheBox" => ["bool", "Test with a cb", false]];
return $credentials;
}
diff --git a/modules-available/locationinfo/lang/de/messages.json b/modules-available/locationinfo/lang/de/messages.json
index d2ea6b05..52a48a02 100644
--- a/modules-available/locationinfo/lang/de/messages.json
+++ b/modules-available/locationinfo/lang/de/messages.json
@@ -2,7 +2,7 @@
"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 aktualisierts.",
+ "openingtime-updated": "Öffnungszeiten aktualisiert.",
"config-saved": "Einstellungen erfolgreich gespeichert.",
"auth-failed": "[{{0}}] {{1}} Error: {{2}}"
}
diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json
index 5525dec2..75a945ce 100644
--- a/modules-available/locationinfo/lang/de/template-tags.json
+++ b/modules-available/locationinfo/lang/de/template-tags.json
@@ -3,6 +3,7 @@
"lang_locationName": "Name",
"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_locationSettings": "Einstellungen",
"lang_locationConfig": "Config",
@@ -12,9 +13,8 @@
"lang_pcY": "Y",
"lang_pcState": "PC Status",
"lang_day": "Tag",
- "lang_openingTime": "Öffnungszeit",
+ "lang_openingTime": "Öffnungszeiten",
"lang_closingTime": "Schließungszeit",
- "lang_deleteAll": "Alles Löschen",
"lang_shortMonday": "Mo",
"lang_shortTuesday": "Di",
"lang_shortWednesday": "Mi",
@@ -27,6 +27,7 @@
"lang_saturday": "Samstag",
"lang_sunday": "Sonntag",
"lang_expertMode": "Experten Modus",
+ "lang_expertMode_title": "Ermöglicht es dir Öffnungzeiten für jeden Tag zu Setzen.",
"lang_language": "Sprache",
"lang_languageEn": "en",
"lang_languageDe": "de",
@@ -49,26 +50,31 @@
"lang_rotation2": "180°",
"lang_rotation3": "90° ⟳",
"lang_vertical": "Vertikal",
- "lang_calupdate": "Kalender update rate",
+ "lang_calupdate": "Kalenderabfragrate",
"lang_calupdateTooltip": "Zeit nachdem der Kalender geupdated wird (in minutes)",
- "lang_roomupdate": "Raum update rate",
+ "lang_roomupdate": "Raumabfragrate",
"lang_roomupdateTooltip": "Zeit nachder die Pcs geupdated werden (in sekunden)",
- "lang_configupdate": "Einstellungs update rate",
+ "lang_configupdate": "Einstellungsabfragrate",
"lang_configupdateTooltip": "Zeit nachder die Einstellungen geupdated werden (in minuten)",
"lang_min": "min",
"lang_sec": "sec",
"lang_autoScale": "Auto skalierung",
"lang_deleteConfirmation": "Bist du sicher?",
"lang_addServer": "Server",
+ "lang_addServer_title": "Server hinzufügen",
"lang_serverTable": "Server Liste",
"lang_buildingTable": "Gebäude / Raum Liste",
- "lang_serverUrl": "Url",
- "lang_serverType": "Type",
+ "lang_serverUrl": "URL",
+ "lang_serverType": "Typ",
"lang_serverUser": "Benutzer",
"lang_serverPassword": "Passwort",
"lang_serverID": "Server ID",
"lang_sID": "sID",
"lang_server": "Server",
"lang_serverRoomId": "Server: Raum ID",
- "lang_credentials": "Anmeldeinformationen"
+ "lang_credentials": "Anmeldung",
+ "lang_refresh_title": "Überprüft ob die Serververbindung gültig ist.",
+ "lang_delete": "Löschen",
+ "lang_refresh": "Aktualisieren",
+ "lang_general": "Allgemein"
}
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 3b3a9e56..ec0bae12 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -4,6 +4,7 @@
"lang_locationName": "Name",
"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_locationSettings": "Settings",
"lang_locationConfig": "Config",
@@ -15,9 +16,8 @@
"lang_pcState": "PC state",
"lang_day": "Day",
- "lang_openingTime": "Opening time",
+ "lang_openingTime": "Opening times",
"lang_closingTime": "Closing time",
- "lang_deleteAll": "Delete all",
"lang_shortMonday": "Mon",
"lang_shortTuesday": "Tue",
@@ -31,6 +31,7 @@
"lang_saturday": "Saturday",
"lang_sunday": "Sunday",
"lang_expertMode": "Expert mode",
+ "lang_expertMode_title": "Allows you to set openingtimes for every day.",
"lang_language": "Language",
"lang_languageEn": "en",
@@ -65,9 +66,10 @@
"lang_autoScale": "Auto scale",
"lang_deleteConfirmation": "Are you sure?",
"lang_addServer": "Server",
+ "lang_addServer_title": "Add server",
"lang_serverTable": "Server List",
"lang_buildingTable": "Building / Room List",
- "lang_serverUrl": "Url",
+ "lang_serverUrl": "URL",
"lang_serverType": "Type",
"lang_serverUser": "User",
"lang_serverPassword": "Password",
@@ -75,5 +77,9 @@
"lang_sID": "sID",
"lang_server": "Server",
"lang_serverRoomId": "Server: Room ID",
- "lang_credentials": "Credentials"
+ "lang_credentials": "Login",
+ "lang_refresh_title": "Checks if the server connection is valid.",
+ "lang_delete": "Delete",
+ "lang_refresh": "Refresh",
+ "lang_general": "General"
}
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index ede1ac37..ccf37d0e 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -27,10 +27,10 @@ class Page_LocationInfo extends Page
$this->updateServer();
} elseif ($this->action === 'deleteServer') {
$this->deleteServer();
- } elseif ($this->action === 'updateCredentials') {
- $this->updateCredentials();
} elseif ($this->action === 'checkConnection') {
$this->checkConnection();
+ } elseif ($this->action === 'updateServerSettings') {
+ $this->updateServerSettings();
}
}
@@ -109,18 +109,32 @@ class Page_LocationInfo extends Page
Util::redirect('?do=locationinfo');
}
- private function updateCredentials() {
- $serverid = Request::post('id', 0, 'int');
- $dbresult = Database::queryFirst('SELECT servertype FROM `setting_location_info` WHERE serverid = :id', array('id' => $serverid));
- $backend = CourseBackend::getInstance($dbresult['servertype']);
+ private function updateServerSettings() {
+ $serverid = Request::post('id', -1, 'int');
+ $servername = Request::post('name', 'unnamed', 'string');
+ $serverurl = Request::post('url', '', 'string');
+ $servertype = Request::post('type', '', 'string');
+
+ $backend = CourseBackend::getInstance($servertype);
$tmptypeArray = $backend->getCredentials();
$credentialsJson = array();
foreach ($tmptypeArray as $key => $value) {
$credentialsJson[$key] = Request::post($key);
}
- Database::exec('UPDATE `setting_location_info` SET credentials = :credentials WHERE serverid = :id', array('id' => $serverid, 'credentials' => json_encode($credentialsJson, true)));
- $this->checkConnection();
+ if ($serverid == 0) {
+ Database::exec('INSERT INTO `setting_location_info` (servername, serverurl, servertype, credentials) VALUES (:name, :url, :type, :credentials)',
+ array('name' => $servername, 'url' => $serverurl, 'type' => $servertype, 'credentials' => json_encode($credentialsJson, true)));
+
+ $dbresult = Database::queryFirst('SELECT serverid FROM `setting_location_info` WHERE servername = :name AND serverurl = :url AND servertype = :type AND credentials = :credentials',
+ array('name' => $servername, 'url' => $serverurl, 'type' => $servertype, 'credentials' => json_encode($credentialsJson, true)));
+
+ $this->checkConnection($dbresult['serverid']);
+ } else {
+ Database::exec('UPDATE `setting_location_info` SET servername = :name, serverurl = :url, servertype = :type, credentials = :credentials WHERE serverid = :id',
+ array('id' => $serverid, 'name' => $servername, 'url' => $serverurl, 'type' => $servertype, 'credentials' => json_encode($credentialsJson, true)));
+ $this->checkConnection();
+ }
}
private function updateOpeningTimeExpert()
@@ -235,15 +249,17 @@ class Page_LocationInfo extends Page
Util::redirect('?do=locationinfo');
}
- private function checkConnection() {
+ private function checkConnection($id = 0) {
$serverid = Request::post('id', 0, 'int');
+ if ($id != 0) {
+ $serverid = $id;
+ }
if ($serverid != 0) {
$dbresult = Database::queryFirst("SELECT * FROM `setting_location_info` WHERE serverid = :serverid", array('serverid' => $serverid));
$serverInstance = CourseBackend::getInstance($dbresult['servertype']);
$serverInstance->setCredentials(json_decode($dbresult['credentials'], true), $dbresult['serverurl'], $serverid);
- //$setCred = $serverInstance->fetchSchedule(array(42));
$setCred = $serverInstance->checkConnection();
if (!$setCred) {
@@ -356,10 +372,10 @@ class Page_LocationInfo extends Page
$servertypes = array();
$s_list = CourseBackend::getList();
foreach ($s_list as $s) {
- $type['type'] = $s;
+ $t['type'] = $s;
$typeInstance = CourseBackend::getInstance($s);
- $type['display'] = $typeInstance->getDisplayName();
- $servertypes[] = $type;
+ $t['display'] = $typeInstance->getDisplayName();
+ $servertypes[] = $t;
}
// Get the Serverlist from the DB and make it mustache accesable
@@ -368,6 +384,13 @@ class Page_LocationInfo extends Page
while($db=$dbquery2->fetch(PDO::FETCH_ASSOC)) {
$server['id'] = $db['serverid'];
$server['name'] = $db['servername'];
+ $server['type'] = $db['servertype'];
+ foreach ($servertypes as $type) {
+ if ($server['type'] == $type['type']) {
+ $server['display'] = $type['display'];
+ break;
+ }
+ }
if ($db['error'] == NULL) {
$server['auth'] = true;
@@ -377,30 +400,16 @@ class Page_LocationInfo extends Page
$time = date('Y/m/d H:i:s', $error['timestamp']);
- Message::addError('auth-failed', $server['id'], $time, $error['error']);
+ Message::addError('auth-failed', $server['name'], $time, $error['error']);
}
- $serverty = array();
- foreach ($servertypes as $type) {
- $st = array();
- $st['type'] = $type['type'];
- $st['display'] = $type['display'];
- if ($type['type'] == $db['servertype']) {
- $st['active'] = true;
- } else {
- $st['active'] = false;
- }
- $serverty[] = $st;
- }
- $server['types'] = $serverty;
-
$server['url'] = $db['serverurl'];
$serverlist[] = $server;
}
// Pass the data to the html and render it.
Render::addTemplate('location-info', array(
- 'list' => array_values($pcs), 'serverlist' => array_values($serverlist), 'servertypelist' => array_values($servertypes),
+ 'list' => array_values($pcs), 'serverlist' => array_values($serverlist),
));
}
@@ -420,47 +429,75 @@ class Page_LocationInfo extends Page
} elseif ($action === 'config') {
$id = Request::any('id', 0, 'int');
$this->ajaxConfig($id);
- } elseif ($action === 'credentials') {
+ } elseif ($action === 'serverSettings') {
$id = Request::any('id', 0, 'int');
- $this->ajaxCredentials($id);
+ $this->ajaxServerSettings($id);
}
}
- private function ajaxCredentials($id) {
- $dbresult = Database::queryFirst('SELECT servertype, credentials FROM `setting_location_info` WHERE serverid = :id', array('id' => $id));
- $tmpcredentialArray = json_decode($dbresult['credentials'], true);
- $backend = CourseBackend::getInstance($dbresult['servertype']);
- $tmptypeArray = $backend->getCredentials();
- $credentialsArray = array();
- foreach ($tmptypeArray as $key => $value) {
- $x['name'] = $key;
+ private function ajaxServerSettings($id) {
+ $dbresult = Database::queryFirst('SELECT servername, serverurl, servertype, credentials FROM `setting_location_info` WHERE serverid = :id', array('id' => $id));
- foreach ($tmpcredentialArray as $ke => $val) {
- if($ke == $key) {
- $x['value'] = $val;
- break;
- }
+ // Credentials stuff.
+ $dbcredentials = json_decode($dbresult['credentials'], true);
+
+ // Get a list of all the backend types.
+ $serverBackends = array();
+ $s_list = CourseBackend::getList();
+ foreach ($s_list as $s) {
+ $backend['typ'] = $s;
+ $backendInstance = CourseBackend::getInstance($s);
+ $backend['display'] = $backendInstance->getDisplayName();
+
+ if ($backend['typ'] == $dbresult['servertype']) {
+ $backend['active'] = true;
+ } else {
+ $backend['active'] = false;
}
- $x['type'] = $value;
-
- if (is_array($value)) {
- $selection = array();
- foreach ($value as $opt) {
- $option['option'] = $opt;
- if ($opt == $x['value']) {
- $option['active'] = true;
- } else {
- $option['active'] = false;
+
+ $credentials = $backendInstance->getCredentials();
+ $backend['credentials'] = array();
+ foreach ($credentials as $key => $value) {
+ $credential['name'] = $key;
+ $credential['type'] = $value[0];
+ $credential['title'] = $value[1];
+
+ if (Property::getPasswordFieldType() === 'text') {
+ $credential['mask'] = false;
+ } else {
+ $credential['mask'] = $value[2];
+ }
+
+ if ($backend['typ'] == $dbresult['servertype']) {
+ foreach ($dbcredentials as $k => $v) {
+ if($k == $key) {
+ $credential['value'] = $v;
+ break;
+ }
}
- $selection[] = $option;
}
- $x['type'] = "array";
- $x['array'] = $selection;
+
+ if (is_array($value[0])) {
+ $selection = array();
+ foreach ($value[0] as $opt) {
+ $option['option'] = $opt;
+ if ($opt == $credential['value']) {
+ $option['active'] = true;
+ } else {
+ $option['active'] = false;
+ }
+ $selection[] = $option;
+ }
+ $credential['type'] = "array";
+ $credential['array'] = $selection;
+ }
+
+ $backend['credentials'][] = $credential;
}
- $credentialsArray[] = $x;
+ $serverBackends[] = $backend;
}
- echo Render::parse('credentials', array('id' => $id, 'credentials' => array_values($credentialsArray)));
+ echo Render::parse('server-settings', array('id' => $id, 'name' => $dbresult['servername'], 'url' => $dbresult['serverurl'], 'servertype' => $dbresult['servertype'], 'backendList' => array_values($serverBackends)));
}
private function ajaxTimeTable($id) {
@@ -480,10 +517,16 @@ class Page_LocationInfo extends Page
foreach($dbresult as $db) {
$index = 0;
foreach ($db as $key) {
- $str = "| ";
+ $str = "";
+
+ $first = true;
foreach ($key['days'] as $val) {
+ if ($first) {
+ $first = false;
+ } else {
+ $str .= ", ";
+ }
$str .= $val;
- $str .= " | ";
}
$ar = array();
$ar['days'] = $str;
diff --git a/modules-available/locationinfo/style.css b/modules-available/locationinfo/style.css
index c0b10cd9..b152c3b3 100644
--- a/modules-available/locationinfo/style.css
+++ b/modules-available/locationinfo/style.css
@@ -1,3 +1,18 @@
.tablerow:hover {
background-color: #F2F2F2;
}
+
+.glyphicon-refresh-animate {
+ -animation: spin .7s infinite linear;
+ -webkit-animation: spin2 .7s infinite linear;
+}
+
+@-webkit-keyframes spin2 {
+ from { -webkit-transform: rotate(0deg);}
+ to { -webkit-transform: rotate(360deg);}
+}
+
+@keyframes spin {
+ from { transform: scale(1) rotate(0deg);}
+ to { transform: scale(1) rotate(360deg);}
+}
diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html
index 79d6f085..3168c6a2 100644
--- a/modules-available/locationinfo/templates/config.html
+++ b/modules-available/locationinfo/templates/config.html
@@ -17,7 +17,7 @@
<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;"></input>
+ style="width: 250px; text-align: center;">
</div>
diff --git a/modules-available/locationinfo/templates/credentials.html b/modules-available/locationinfo/templates/credentials.html
deleted file mode 100644
index f8c04bcb..00000000
--- a/modules-available/locationinfo/templates/credentials.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<div>
- <form method="post" action="?do=locationinfo" id="credentialsForm">
- <input type="hidden" name="token" value="{{token}}">
- <input type="hidden" name="action" value="updateCredentials">
- <input type="hidden" name="id" value="{{id}}">
- <div id="div"></div>
- <button type="submit" class="btn btn-primary">{{lang_save}}</button>
- </form>
-</div>
-<script type="text/javascript">
-
- // {{name}} name of auth {{type}} type of auth (string, int etc.) {{value}} value from the db
- {{#credentials}}
- if ("{{type}}" == "string") {
- $("#div").before('<label>{{name}}</label><br><input required type="text" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>');
- } else if ("{{type}}" == "int") {
- $("#div").before('<label>{{name}}</label><br><input required type="number" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>');
- } else if ("{{type}}" == "bool") {
- $("#div").before('<label>{{name}}</label><br><input type="checkbox" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>');
- } else if ("{{type}}" == "array") {
- $("#div").before('<label>{{name}}</label><br>\
- <select name="{{name}}" form="credentialsForm">\
- {{#array}}\
- <option value="{{option}}" {{#active}}selected{{/active}}>{{option}}</option>\
- {{/array}}\
- </select>\
- <br><br>');
- }
- {{/credentials}}
-
-</script>
diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html
index ef8de412..d494ebdc 100644
--- a/modules-available/locationinfo/templates/location-info.html
+++ b/modules-available/locationinfo/templates/location-info.html
@@ -3,11 +3,10 @@
<br>
<h4>{{lang_serverTable}}</h4>
- <div id="serverTable">
+ <div id="serverTable">
<table class="table table-condensed locations" style="margin-bottom:0;">
<tr>
- <th title="{{lang_serverID}}">{{lang_sID}}</th>
<th width="1">{{lang_serverType}}</th>
<th>{{lang_locationName}}</th>
<th>{{lang_serverUrl}}</th>
@@ -21,40 +20,24 @@
<input type="submit" id="submit-serverForm-{{id}}" style="display:none;">
<tr class=tablerow>
- <td align="center"><input id="input-id-{{id}}" name="id" type="hidden" value="{{id}}">{{id}}</td>
- <td id="type-{{id}}">
- <select disabled id="input-type-{{id}}" name="type" value="{{type}}"
- onchange="servertype_changed(this.value, {{id}});">
- {{#types}}
- <option id="{{type}}" value="{{type}}" {{#active}}selected{{/active}}>{{display}}
- {{/types}}
- </select>
- </td>
- <td id="name-{{id}}" style="padding:8px;">
- <input readonly required id="input-name-{{id}}" name="name" type="text" value="{{name}}"
- style="padding:0;height:100%;width:100%;"></input>
- </td>
- <td id="url-{{id}}" style="padding:8px;">
- <input readonly required id="input-url-{{id}}" name="url" type="text" value="{{url}}"
- style="padding:0;height:100%;width:100%;"></input>
- </td>
+ <input id="input-id-{{id}}" name="id" type="hidden" value="{{id}}">
+ <td id="type-{{id}}" nowrap>{{display}}</td>
+ <td id="name-{{id}}" nowrap>{{name}}</td>
+ <td id="url-{{id}}" nowrap>{{url}}</td>
<td align="center" id="credentials-{{id}}" onclick="event.cancelBubble = true;"
style="white-space:nowrap;">
<button {{#auth}}class="btn btn-sm btn-success" {{/auth}}
{{^auth}}class="btn btn-sm btn-danger"{{/auth}} id="credentials-btn-{{id}}" type="button"
- title="credentials" onclick="loadCredentialModal({{id}},'{{name}}');">{{lang_credentials}}
+ onclick="loadSettingsModal({{id}},'{{name}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-cog"></span>{{lang_locationSettings}}
</button>
- <button class="btn btn-sm btn-primary table-refresh" id="refresh-btn-{{id}}" title="refresh"
- onclick="refreshButtonClick({{id}});">&#8634
+ <button class="btn btn-sm btn-primary table-refresh" id="refresh-btn-{{id}}" title="{{lang_refresh_title}}"
+ onclick="refreshButtonClick({{id}});"><span id="refresh-btn-animate-{{id}}" style="margin-right: 5px;" class="glyphicon glyphicon-refresh"></span>{{lang_refresh}}
</button>
</td>
<td align="center" id="btncell-{{id}}" style="white-space:nowrap;">
- <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}"
- onclick="editButtonClick({{id}});" id="edit">&#x270E
- </button>
- <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}"
- onclick="deleteButtonClick({{id}});">&#10008
+ <button class="btn btn-sm btn-danger table-delete" type="button"
+ onclick="deleteButtonClick({{id}});"><span style="margin-right: 5px;" class="glyphicon glyphicon-remove"></span>{{lang_delete}}
</button>
</td>
</tr>
@@ -69,8 +52,8 @@
</table>
<br>
- <button class="btn btn-success btn-sm" id="addServerButton" onclick="addNewServerRow()"><span
- class="glyphicon glyphicon-plus-sign"> {{lang_addServer}}</span></button>
+ <button class="btn btn-sm btn-success" id="addServerButton" onclick="addServer()"><span
+ title="{{lang_addServer_title}}"><span style="margin-right: 5px;" class="glyphicon glyphicon-plus"></span>{{lang_addServer}}</button>
<br><br><br>
</div>
@@ -83,7 +66,7 @@
<th>{{lang_locationName}}</th>
<th width=10>{{lang_locationID}}</th>
<th width=80>{{lang_locationInUse}}</th>
- <th width=50>{{lang_locationIsHidden}}</th>
+ <th width=50 title="{{lang_locationIsHidden_title}}">{{lang_locationIsHidden}}</th>
<th width=50>{{lang_openingTime}}</th>
<th width=50>{{lang_locationSettings}}</th>
</tr>
@@ -113,10 +96,10 @@
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}}');">{{lang_openingTime}}</a>
+ onclick="loadTimeModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-time"></span>{{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>
+ onclick="loadConfigModal({{locationid}}, '{{locationname}}');"><span style="margin-right: 5px;" class="glyphicon glyphicon-cog"></span>{{lang_locationSettings}}</a>
</td>
</tr>
@@ -151,11 +134,11 @@
window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value;
}
- function loadCredentialModal(serverid, servername) {
- $('#myModalHeader').text("[" + serverid + "] " + servername).css("font-weight", "Bold");
+ function loadSettingsModal(serverid, servername) {
+ $('#myModalHeader').text("{{lang_locationSettings}}").css("font-weight", "Bold");
$('#myModal').modal('show');
- $('#myModalBody').load("?do=locationinfo&action=credentials&id=" + serverid);
+ $('#myModalBody').load("?do=locationinfo&action=serverSettings&id=" + serverid);
}
function loadTimeModal(locationId, locationName) {
@@ -165,6 +148,11 @@
$('#myModalBody').load("?do=locationinfo&action=timetable&id=" + locationId);
}
+ /**
+ *
+ * @param locationId
+ * @param locationName
+ */
function loadConfigModal(locationId, locationName) {
$('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight", "Bold");
@@ -187,124 +175,13 @@
}
}
- function servertype_changed(value, id) {
- if (value == "Frontend") {
- $('#input-user-' + id).removeAttr('required');
- $('#input-password-' + id).removeAttr('required');
- } else {
- $('#input-user-' + id).attr('required');
- $('#input-password-' + id).attr('required');
- }
- }
-
- function editButtonClick(id) {
- var name = $('#input-name-' + id);
- var url = $('#input-url-' + id);
- var user = $('#input-user-' + id);
- var password = $('#input-password-' + id);
- var type = $('#input-type-' + id);
-
- name.attr('readonly', false);
- url.attr('readonly', false);
- user.attr('readonly', false);
- password.attr('readonly', false);
- type.attr('disabled', false);
-
- name.css("color", "#000");
- url.css("color", "#000");
- user.css("color", "#000");
- password.css("color", "#000");
- type.css("color", "#000");
-
- preEditName = name.val();
- preEditUrl = url.val();
- preEditUser = user.val();
- preEditPassword = password.val();
- preEditType = type.val();
-
- servertype_changed(preEditType, id);
-
- $('#btncell-' + id).html('\
- <button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="saveButtonClick(' + id + ');">&#10004</button> \
- <button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="cancelButtonClick(' + id + ');">&#10008</button>');
- $('.table-edit').attr('disabled', true);
- $('.table-delete').attr('disabled', true);
- $('.table-refresh').attr('disabled', true);
- $('#addServerButton').attr('disabled', true);
- }
-
- function saveButtonClick(id) {
- $('#serverFormAction-' + id).val("updateServer");
- $('#submit-serverForm-' + id).trigger("click");
- }
-
function refreshButtonClick(id) {
+ $('#refresh-btn-animate-' + id).addClass('glyphicon-refresh-animate');
$('#serverFormAction-' + id).val("checkConnection");
$('#submit-serverForm-' + id).trigger("click");
}
- function addNewServer() {
- $('#serverFormAction-0').val("updateServer");
-
- $('#submit-serverForm-0').trigger("click");
- }
-
- function cancelButtonClick(id) {
- var name = $('#input-name-' + id);
- var url = $('#input-url-' + id);
- var user = $('#input-user-' + id);
- var password = $('#input-password-' + id);
- var type = $('#input-type-' + id);
-
- name.attr('readonly', true);
- url.attr('readonly', true);
- user.attr('readonly', true);
- password.attr('readonly', true);
- type.attr('disabled', true);
-
- name.css("color", "");
- url.css("color", "");
- user.css("color", "");
- password.css("color", "");
- type.css("color", "");
-
- name.val(preEditName);
- url.val(preEditUrl);
- user.val(preEditUser);
- password.val(preEditPassword);
- type.val(preEditType);
-
- $('#btncell-' + id).html('\
- <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}" onclick="editButtonClick(' + id + ');" id="edit">&#x270E</button> \
- <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" onclick="deleteButtonClick(' + id + ');">&#10008</button>');
- $('.table-edit').attr('disabled', false);
- $('.table-delete').attr('disabled', false);
- $('.table-refresh').attr('disabled', false);
- $('#addServerButton').attr('disabled', false);
- }
-
- function deleteNewServer() {
- $('#new').remove();
- $('.table-edit').attr('disabled', false);
- $('.table-delete').attr('disabled', false);
- $('#addServerButton').attr('disabled', false);
- }
-
- function addNewServerRow() {
- $('#lastServerTableElement').before('<tr class=tablerow id="new">\
- <td align="center"><input id="input-id-0" name="id" type="hidden" form="serverForm-0" value="0"></td>\
- <td id="type-0"><select id="input-type-0" name="type" form="serverForm-0" onchange="servertype_changed(this.value, 0)">\
- {{#servertypelist}}<option value="{{type}}"> {{display}}{{/servertypelist}}\
- </select></td>\
- <td id="name-0" style="padding:0;"><input required id="input-name-0" name="name" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></td>\
- <td id="url-0" style="padding:0;"><a><input required id="input-url-0" name="url" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></a></td>\
- <td align="center" id="btncell-new">\
- <button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="addNewServer();">&#10004</button> \
- <button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="deleteNewServer();">&#10008</button>\
- </td>\
- </tr>');
- $('.table-edit').attr('disabled', true);
- $('.table-delete').attr('disabled', true);
- $('#addServerButton').attr('disabled', true);
+ function addServer() {
+ loadSettingsModal(0, '');
}
</script>
diff --git a/modules-available/locationinfo/templates/server-settings.html b/modules-available/locationinfo/templates/server-settings.html
new file mode 100644
index 00000000..f7aa2af8
--- /dev/null
+++ b/modules-available/locationinfo/templates/server-settings.html
@@ -0,0 +1,128 @@
+<div>
+ <form method="post" action="?do=locationinfo" id="settingsForm">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" value="updateServerSettings">
+ <input type="hidden" name="id" value="{{id}}">
+
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_general}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3" >
+ <label>{{lang_locationName}}</label>
+ </div>
+ <div class="col-md-8">
+ <input required class="form-control" id="input-name-{{id}}" name="name" type="text" value="{{name}}"></input>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3">
+ <label>{{lang_serverUrl}}</label>
+ </div>
+ <div class="col-md-8">
+ <input required class="form-control" id="input-url-{{id}}" name="url" type="text" value="{{url}}" ></input>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <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);">
+ {{#backendList}}
+ <option id="{{typ}}" value="{{typ}}" {{#active}}selected{{/active}}>{{display}}
+ {{/backendList}}
+ </select>
+
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+
+ <div class="panel panel-default" id="credentials-div">
+ <div class="panel-heading">{{lang_credentials}}</div>
+ <div class="panel-body">
+ <div class="list-group" id="credentials-list">
+
+ </div>
+ </div>
+ </div>
+
+ <div id="credentials" class="list-group"></div>
+ <button type="submit" class="btn btn-primary">{{lang_save}}</button>
+ </form>
+</div>
+<script type="text/javascript">
+ var type = "{{servertype}}";
+ if (type == "") {
+ type = $('#input-type-{{id}}').val();
+ }
+ loadCredentials();
+ function loadCredentials() {
+ // {{name}} name of auth {{type}} type of auth (string, int etc.) {{value}} value from the db
+ {{#backendList}}
+ if (type == "{{typ}}") {
+ {{#credentials}}
+ $('#credentials-div').fadeIn('fast');
+
+ 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="{{name}}" value="{{value}}" form="settingsForm">\
+ </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="{{name}}" value="{{value}}" form="settingsForm">\
+ </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="form-control" type="checkbox" name="{{name}}" value="true" form="settingsForm" {{#value}}checked{{/value}}>\
+ </div></div></div>');
+ } 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="{{name}}" form="settingsForm">\
+ {{#array}}\
+ <option value="{{option}}" {{#active}}selected{{/active}}>{{option}}</option>\
+ {{/array}}\
+ </select>\
+ </div></div></div>');
+ }
+ {{/credentials}}
+ {{^credentials}}
+ $('#credentials-div').hide();
+ {{/credentials}}
+ }
+ {{/backendList}}
+
+ }
+
+ function servertype_changed(value) {
+ type = value;
+ $('#credentials-div').fadeOut('fast', function() {
+ $('#credentials-list').empty();
+ loadCredentials();
+ });
+ }
+
+</script>
diff --git a/modules-available/locationinfo/templates/timetable.html b/modules-available/locationinfo/templates/timetable.html
index 29446f58..78d13e29 100644
--- a/modules-available/locationinfo/templates/timetable.html
+++ b/modules-available/locationinfo/templates/timetable.html
@@ -1,7 +1,7 @@
<div>
<div align="right">
- <label for="CB_1">{{lang_expertMode}}</label>
+ <label for="CB_1" title="{{lang_expertMode_title}}">{{lang_expertMode}}</label>
<input class="bs-switch" name="1" id="CB_1" type="checkbox" {{#expertMode}}checked="checked"{{/expertMode}}>
</div>
<br>
@@ -115,7 +115,6 @@
<td>{{openingtime}}</td>
<td>{{closingtime}}</td>
<td align="center"><input type="checkbox" name="delete[]" value="{{index}}"></td>
- <!--<td><button class="btn btn-sm btn-danger">X</button></td>-->
</tr>
{{/openingtimes}}
@@ -125,7 +124,6 @@
<br>
<a class="btn btn-success btn-sm" onclick=newOpeningTime()><span class="glyphicon glyphicon-plus-sign"></span>
{{lang_openingTime}}</a>
- <!--<a class="btn btn-danger btn-sm" onclick=>{{lang_deleteAll}}</a>-->
<br>
<br>
<button type="submit" class="btn btn-primary">{{lang_save}}</button>