diff options
author | Jannik Schönartz | 2017-03-05 17:43:29 +0100 |
---|---|---|
committer | Jannik Schönartz | 2017-03-05 17:43:29 +0100 |
commit | 70c3039846a4f04fe4ea9691f23a949035395a05 (patch) | |
tree | 104060c4ff8369fb199d03984011c75179ff6124 | |
parent | ServerList: Fixed a bug while editing the list would not show the not selecte... (diff) | |
download | slx-admin-70c3039846a4f04fe4ea9691f23a949035395a05.tar.gz slx-admin-70c3039846a4f04fe4ea9691f23a949035395a05.tar.xz slx-admin-70c3039846a4f04fe4ea9691f23a949035395a05.zip |
Admin-panel: Credentials Button is now red/green if the connection failed/succeeded. Also an error msg is shown if the connection failed.
5 files changed, 26 insertions, 8 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php index 23f62455..54783142 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php @@ -12,7 +12,7 @@ class Coursebackend_Dummy extends CourseBackend { } public function checkConnection(){ - return $true; + return "Your Error could be shown here!"; } public function getCredentials(){ diff --git a/modules-available/locationinfo/lang/de/messages.json b/modules-available/locationinfo/lang/de/messages.json index 6526c320..426374f6 100644 --- a/modules-available/locationinfo/lang/de/messages.json +++ b/modules-available/locationinfo/lang/de/messages.json @@ -3,5 +3,6 @@ "added-x-entries": "Eintr\u00e4ge hinzugef\u00fcgt: {{0}}", "deleted-x-entries": "Eintr\u00e4ge gelöscht: {{0}}", "openingtime-updated": "Öffnungszeiten aktualisierts.", - "config-saved": "Einstellungen erfolgreich gespeichert." + "config-saved": "Einstellungen erfolgreich gespeichert.", + "auth-failed": "Authentifizierung fehlgeschlagen: Locationid {{0}} Error: {{1}}" } diff --git a/modules-available/locationinfo/lang/en/messages.json b/modules-available/locationinfo/lang/en/messages.json index 22c9b549..9537fba1 100644 --- a/modules-available/locationinfo/lang/en/messages.json +++ b/modules-available/locationinfo/lang/en/messages.json @@ -3,5 +3,6 @@ "added-x-entries": "Entries added: {{0}}", "deleted-x-entries": "Entries deleted: {{0}}", "openingtime-updated": "Openingtime updated.", - "config-saved": "Config successfully saved." + "config-saved": "Config successfully saved.", + "auth-failed": "Authentification failed: Locationid {{0}} Error: {{1}}" } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 537d0887..b3bf7c66 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -286,7 +286,10 @@ class Page_LocationInfo extends Page } } +// Loads the Infoscreen pange 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 $dbquery = Database::simpleQuery("SELECT l.locationname, l.locationid, li.hidden, m.pcState, m.total FROM `location_info` AS li RIGHT JOIN `location` AS l ON li.locationid=l.locationid LEFT JOIN (SELECT locationid, Count(case m.logintime WHEN NOT 1 THEN null else 1 end) AS pcState, Count(*) AS total FROM `machine` AS m @@ -325,6 +328,7 @@ class Page_LocationInfo extends Page } } + // Get a list of all the backend types. $servertypes = array(); $s_list = CourseBackend::getList(); foreach ($s_list as $s) { @@ -334,22 +338,33 @@ class Page_LocationInfo extends Page $servertypes[] = $type; } + // Get the Serverlist from the DB and make it mustache accesable $serverlist = array(); $dbquery2 = Database::simpleQuery("SELECT * FROM `setting_location_info`"); while($db=$dbquery2->fetch(PDO::FETCH_ASSOC)) { $server['id'] = $db['serverid']; $server['name'] = $db['servername']; + // Instance the backend and set the credentials to check if the Authentification is accepted. + $backendType = CourseBackend::getInstance($db['servertype']); + $backendType->setCredentials(json_encode($db['credentials'], true), $db['serverurl'], $db['serverid']); + + $connection = $backendType->checkConnection(); + if ($connection === true) { + $server['auth'] = true; + } else { + $server['auth'] = false; + Message::addError('auth-failed', $server['id'], $connection); + } + $serverty = array(); foreach ($servertypes as $type) { $st = array(); + $st['type'] = $type['type']; + $st['display'] = $type['display']; if ($type['type'] == $db['servertype']) { - $st['type'] = $type['type']; - $st['display'] = $type['display']; $st['active'] = true; } else { - $st['type'] = $type['type']; - $st['display'] = $type['display']; $st['active'] = false; } $serverty[] = $st; @@ -360,6 +375,7 @@ class Page_LocationInfo extends Page $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), )); diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html index c7db6c66..65a7a0dc 100644 --- a/modules-available/locationinfo/templates/location-info.html +++ b/modules-available/locationinfo/templates/location-info.html @@ -37,7 +37,7 @@ </td> <td align="center" id="credentials-{{id}}" onclick="event.cancelBubble = true;"> - <button class="btn btn-sm btn-primary" id="credentials-btn-{{id}}" type="button" title="credentials" onclick="loadCredentialModal({{id}},'{{name}}');" id="credentials">{{lang_credentials}}</button> + <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}}');" id="credentials">{{lang_credentials}}</button> </td> <td align="center" id="btncell-{{id}}"> <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}" onclick="editButtonClick({{id}});" id="edit">✎</button> |