diff options
author | Jannik Schönartz | 2016-12-05 18:56:44 +0100 |
---|---|---|
committer | Jannik Schönartz | 2016-12-05 18:56:44 +0100 |
commit | a86d0225dc7768a629ce59c325a1dcc739122ef9 (patch) | |
tree | 3dcfbd03ea58d97a09515d7a4783a8aef761ff26 /modules-available/locationinfo | |
parent | frontend: changed to backend changes, use media querrys, changed free seats f... (diff) | |
download | slx-admin-a86d0225dc7768a629ce59c325a1dcc739122ef9.tar.gz slx-admin-a86d0225dc7768a629ce59c325a1dcc739122ef9.tar.xz slx-admin-a86d0225dc7768a629ce59c325a1dcc739122ef9.zip |
Locationinfo: Added Servertable
Diffstat (limited to 'modules-available/locationinfo')
9 files changed, 367 insertions, 41 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index f4f5c9c2..2642ec78 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -189,11 +189,7 @@ function getPcInfos($locationID, $coords) { $computer['y'] = $position['gridRow']; } - $computer['inUse'] = 0; - - if ($pc['logintime'] > 0) { - $computer['inUse'] = 1; - } + $computer['pcState'] = LocationInfo::getPcState((int)$computer['logintime'], (int)$computer['lastseen']); $pcs[] = $computer; } diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php new file mode 100644 index 00000000..4f26519d --- /dev/null +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -0,0 +1,28 @@ +<?php + +class LocationInfo +{ + //TODO TEST WITH NEWER DB + public function getPcState($logintime, $lastseen) { + /* pcState: + * [0] = IDLE (NOT IN USE) + * [1] = OCCUPIED (IN USE) + * [2] = OFF + * [3] = 10 days offline (BROKEN?) + */ + + $NOW = time(); + + + if ($NOW - $lastseen > 864000) { + return 3; + } elseif ($NOW - $lastseen > 610) { + return 2; + } elseif ($logintime == 0) { + return 0; + } elseif ($logintime > 0) { + return 1; + } + return -1; + } +} diff --git a/modules-available/locationinfo/install.inc.php b/modules-available/locationinfo/install.inc.php index f94c725e..162f000c 100644 --- a/modules-available/locationinfo/install.inc.php +++ b/modules-available/locationinfo/install.inc.php @@ -3,7 +3,9 @@ $res = array(); $res[] = tableCreate('location_info', ' - `locationid` INT(11) NOT NULL, + `locationid` INT(11) NOT NULL, + `serverid` INT(11) NOT NULL, + `serverroomid` INT(11) NOT NULL, `hidden` BOOLEAN NOT NULL DEFAULT 0, `openingtime` VARCHAR(2000) NOT NULL, `config` VARCHAR(2000) NOT NULL, @@ -13,6 +15,7 @@ $res[] = tableCreate('location_info', ' $res[] = tableCreate('setting_location_info', ' `serverid` int(10) NOT NULL AUTO_INCREMENT, + `servername` VARCHAR(2000) NOT NULL, `serverurl` VARCHAR(2000) NOT NULL, `servertype` VARCHAR(100) NOT NULL, `login` VARCHAR(100) NOT NULL, @@ -46,6 +49,22 @@ if (!tableHasColumn('location_info', 'calendar')) { $res[] = UPDATE_DONE; } +if (!tableHasColumn('location_info', 'serverid')) { + $ret = Database::exec("ALTER TABLE `location_info` ADD `serverid` INT(11) NOT NULL AFTER `locationid`"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding serverid to location_info failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} + +if (!tableHasColumn('location_info', 'serverroomid')) { + $ret = Database::exec("ALTER TABLE `location_info` ADD `serverroomid` INT(11) NOT NULL AFTER `serverid`"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding serverroomid to location_info failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} + if (in_array(UPDATE_DONE, $res)) { finalResponse(UPDATE_DONE, 'Tables created successfully'); } diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 3f782970..d43ab0f4 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -12,7 +12,7 @@ "lang_pcIP": "IP", "lang_pcX": "X", "lang_pcY": "Y", - "lang_pcInUse": "In Benutzung", + "lang_pcState": "PC Status", "lang_day": "Tag", "lang_openingTime": "Öffnungszeit", @@ -62,5 +62,17 @@ "lang_configupdateTooltip": "Zeit nachder die Einstellungen geupdated werden (in minuten)", "lang_min": "min", "lang_sec": "sec", - "lang_autoScale": "Auto skalierung" + "lang_autoScale": "Auto skalierung", + "lang_deleteConfirmation": "Bist du sicher?", + "lang_addServer": "Server", + "lang_serverTable": "Server Liste", + "lang_buildingTable": "Gebäude / Raum Liste", + "lang_serverUrl": "Url", + "lang_serverType": "Type", + "lang_serverUser": "Benutzer", + "lang_serverPassword": "Passwort", + "lang_serverID": "Server ID", + "lang_sID": "sID", + "lang_server": "Server", + "lang_serverRoomId": "Server: Raum ID" } diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 07224987..9efeb2c4 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -12,7 +12,7 @@ "lang_pcIP": "IP", "lang_pcX": "X", "lang_pcY": "Y", - "lang_pcInUse": "In Use", + "lang_pcState": "PC state", "lang_day": "Day", "lang_openingTime": "Opening time", @@ -62,5 +62,17 @@ "lang_configupdateTooltip": "Time interval the config gets updated (in minutes)", "lang_min": "min", "lang_sec": "sec", - "lang_autoScale": "Auto scale" + "lang_autoScale": "Auto scale", + "lang_deleteConfirmation": "Are you sure?", + "lang_addServer": "Server", + "lang_serverTable": "Server List", + "lang_buildingTable": "Building / Room List", + "lang_serverUrl": "Url", + "lang_serverType": "Type", + "lang_serverUser": "User", + "lang_serverPassword": "Password", + "lang_serverID": "Server ID", + "lang_sID": "sID", + "lang_server": "Server", + "lang_serverRoomId": "Server: Room ID" } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 271b15fc..9b0cf487 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -23,6 +23,10 @@ class Page_LocationInfo extends Page $this->updateOpeningTimeEasy(); } elseif ($this->action === 'updateConfig') { $this->updateConfig(); + } elseif ($this->action === 'updateServer') { + $this->updateServer(); + } elseif ($this->action === 'deleteServer') { + $this->deleteServer(); } } @@ -54,6 +58,27 @@ class Page_LocationInfo extends Page } + private function updateServer() { + $id = Request::post('id', 0, 'int'); + if ($id == 0) { + Database::exec("INSERT INTO `setting_location_info` (servername, serverurl, servertype, login, passwd) VALUES (:name, :url, :type, :login, :passwd)", + array('name' => Request::post('name', '', 'string'), 'url' => Request::post('url', '', 'string'), 'type' => Request::post('type', '', 'string'), + 'login' => Request::post('user', '', 'string'), 'passwd' => Request::post('password', '', 'string'))); + } else { + Database::exec("INSERT INTO `setting_location_info` (serverid, servername, servertype, serverurl, login, passwd) VALUES (:id, :name, :type, :url, :login, :passwd) + ON DUPLICATE KEY UPDATE servername=:name, serverurl=:url, servertype=:type, login=:login, passwd=:passwd", + array('id' => $id, 'name' => Request::post('name', '', 'string'), 'url' => Request::post('url', '', 'string'), 'type' => Request::post('type', '', 'string'), + 'login' => Request::post('user', '', 'string'), 'passwd' => Request::post('password', '', 'string'))); + } + Util::redirect('?do=locationinfo&action=infoscreen'); + } + + private function deleteServer() { + $id = Request::post('id', 0, 'int'); + Database::exec("DELETE FROM `setting_location_info` WHERE serverid=:id", array('id' => $id)); + Util::redirect('?do=locationinfo&action=infoscreen'); + } + private function updateConfig() { $result = array(); @@ -71,9 +96,12 @@ class Page_LocationInfo extends Page $result['calupdate'] = Request::post('calupdate', 30, 'int'); $result['roomupdate'] = Request::post('roomupdate', 30, 'int'); $result['configupdate'] = Request::post('configupdate', 180, 'int'); + $serverid = Request::post('serverid', 0, 'int'); + $serverroomid = Request::post('serverroomid', 0, 'int'); - 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))); + Database::exec("INSERT INTO `location_info` (locationid, serverid, serverroomid, hidden, config) VALUES (:id, :serverid, :serverroomid, :hidden, :config) + ON DUPLICATE KEY UPDATE config=:config, serverid=:serverid, serverroomid=:serverroomid", + array('id' => $locationid, 'hidden' => false, 'config' => json_encode($result, true), 'serverid' => $serverid, 'serverroomid' => $serverroomid)); Message::addSuccess('config-saved'); Util::redirect('?do=locationinfo'); @@ -150,7 +178,7 @@ class Page_LocationInfo extends Page } } - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, :openingtime, '', '') ON DUPLICATE KEY UPDATE openingtime=:openingtime", + Database::exec("INSERT INTO `location_info` (locationid, hidden, openingtime) VALUES (:id, :hidden, :openingtime) ON DUPLICATE KEY UPDATE openingtime=:openingtime", array('id' => $locationid, 'hidden' => false, 'openingtime' => json_encode($result, true))); if ($deleteCounter > 0) { @@ -184,7 +212,7 @@ class Page_LocationInfo extends Page $opt2['closingtime'] = $closingtime[2]; $result[] = $opt2; - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, :openingtime, '', '') ON DUPLICATE KEY UPDATE openingtime=:openingtime", + Database::exec("INSERT INTO `location_info` (locationid, hidden, openingtime) VALUES (:id, :hidden, :openingtime) ON DUPLICATE KEY UPDATE openingtime=:openingtime", array('id' => $locationid, 'hidden' => false, 'openingtime' => json_encode($result, true))); Message::addSuccess('openingtime-updated'); @@ -192,7 +220,7 @@ class Page_LocationInfo extends Page } protected function toggleHidden($id, $val) { - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, '', '', '') ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $id, 'hidden' => $val)); + Database::exec("INSERT INTO `location_info` (locationid, hidden) VALUES (:id, :hidden) ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $id, 'hidden' => $val)); $this->checkChildRecursive($id, $val); $this->checkParentRecursive($id); @@ -207,7 +235,7 @@ class Page_LocationInfo extends Page } foreach ($childs as $key) { - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, '', '', '') ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $key, 'hidden' => $val)); + Database::exec("INSERT INTO `location_info` (locationid, hidden) VALUES (:id, :hidden) ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $key, 'hidden' => $val)); $this->checkChildRecursive($key, $val); } @@ -236,9 +264,9 @@ class Page_LocationInfo extends Page } if ($amountofzero == 0 AND $amountofnull == 0) { - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, '', '', '') ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $parent, 'hidden' => 1)); + Database::exec("INSERT INTO `location_info` (locationid, hidden) VALUES (:id, :hidden) ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $parent, 'hidden' => 1)); } else { - Database::exec("INSERT INTO `location_info` VALUES (:id, :hidden, '', '', '') ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $parent, 'hidden' => 0)); + Database::exec("INSERT INTO `location_info` (locationid, hidden) VALUES (:id, :hidden) ON DUPLICATE KEY UPDATE hidden=:hidden", array('id' => $parent, 'hidden' => 0)); } $this->checkParentRecursive($parent); @@ -246,9 +274,9 @@ class Page_LocationInfo extends Page } protected function getInfoScreenTable() { - $dbquery = Database::simpleQuery("SELECT l.locationname, l.locationid, li.hidden, m.inUse, m.total FROM `location_info` AS li + $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 inUse, Count(*) AS total FROM `machine` AS m + (SELECT locationid, Count(case m.logintime WHEN NOT 1 THEN null else 1 end) AS pcState, Count(*) AS total FROM `machine` AS m WHERE locationid IS NOT NULL GROUP BY locationid) AS m ON l.locationid=m.locationid"); $pcs = array(); @@ -273,8 +301,8 @@ class Page_LocationInfo extends Page $pcs[$locid]['hidden'] = $roominfo['hidden']; } - if ($roominfo['inUse'] != NULL) { - $pcs[$locid]['inUse'] = $roominfo['inUse']; + if ($roominfo['pcState'] != NULL) { + $pcs[$locid]['pcState'] = $roominfo['pcState']; } if ($roominfo['total'] != NULL) { $pcs[$locid]['total'] = $roominfo['total']; @@ -284,23 +312,29 @@ class Page_LocationInfo extends Page } } + $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']; + if ($db['servertype'] == 'HISinOne') { + $server['HISinOne'] = true; + $server['DAVINCI'] = false; + } elseif ($db['servertype'] == 'DAVINCI') { + $server['HISinOne'] = false; + $server['DAVINCI'] = true; + } + $server['url'] = $db['serverurl']; + $server['user'] = $db['login']; + $server['password'] = $db['passwd']; + $serverlist[] = $server; + } + Render::addTemplate('location-info', array( - 'list' => array_values($pcs), + 'list' => array_values($pcs), 'serverlist' => array_values($serverlist), )); } - private function getInUseStatus($logintime, $lastseen) { - if ($logintime == 0) { - return 0; - } elseif ($logintime > 0) { - return 1; - // TODO lastseen > 610 = OFF TODO DEFEKT! if ... - } elseif ($lastseen > 610) { - return 2; - } - return -1; - } - /** * AJAX */ @@ -323,6 +357,7 @@ class Page_LocationInfo extends Page } } +//TODO REMOVE FUNCTION. NOT NECCESSARY BUT AFTER TESTING pcSTATE private function ajaxShowLocation($id) { $dbquery = Database::simpleQuery("SELECT machineuuid, clientip, position, logintime, lastseen FROM `machine` WHERE locationid = :id", array('id' => $id)); @@ -333,7 +368,7 @@ class Page_LocationInfo extends Page $pc = array(); $pc['id'] = $dbdata['machineuuid']; $pc['ip'] = $dbdata['clientip']; - $pc['inUse'] = $this->getInUseStatus($dbdata['logintime'], $dbdata['lastseen']); + $pc['pcState'] = LocationInfo::getPcState($dbdata['logintime'], $dbdata['lastseen']); $position = json_decode($dbdata['position'], true); $pc['x'] = $position['gridRow']; @@ -399,13 +434,30 @@ class Page_LocationInfo extends Page private function ajaxConfig($id) { $array = array(); - $dbquery = Database::simpleQuery("SELECT config FROM `location_info` WHERE locationid = :id", array('id' => $id)); + + // Get Config data from db + $dbquery = Database::simpleQuery("SELECT config, serverid, serverroomid FROM `location_info` WHERE locationid = :id", array('id' => $id)); + $serverid; + $serverroomid; while($dbdata=$dbquery->fetch(PDO::FETCH_ASSOC)) { $array = json_decode($dbdata['config'], true); + $serverid = $dbdata['serverid']; + $serverroomid = $dbdata['serverroomid']; + } + + // get Server / ID list + $dbq = Database::simpleQuery("SELECT serverid, servername FROM `setting_location_info`"); + $serverList = array(); + while($dbd=$dbq->fetch(PDO::FETCH_ASSOC)) { + $d['sid'] = $dbd['serverid']; + $d['sname'] = $dbd['servername']; + $serverList[] = $d; } + echo Render::parse('config', array('id' => $id, 'language' => $array['language'], 'mode' => 'mode'.$array['mode'], 'vertical' => $array['vertical'], 'eco' => $array['eco'], 'daystoshow' => 'day'.$array['daystoshow'], 'scaledaysauto' => $array['scaledaysauto'], 'rotation' => 'rotation'.$array['rotation'], 'scale' => $array['scale'], 'switchtime' => $array['switchtime'], 'calupdate' => $array['calupdate'], - 'roomupdate' => $array['roomupdate'], 'configupdate' => $array['configupdate'])); + 'roomupdate' => $array['roomupdate'], 'configupdate' => $array['configupdate'], + 'serverlist' => array_values($serverList), 'serverid' => $serverid, 'serverroomid' => $serverroomid)); } } diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html index a814077a..577f8f94 100644 --- a/modules-available/locationinfo/templates/config.html +++ b/modules-available/locationinfo/templates/config.html @@ -1,9 +1,29 @@ <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_server}}</Label><br> + <select name="serverid"> + {{#serverlist}} + <option id="serverOption-{{sid}}" value="{{sid}}">{{sname}}</option> + {{/serverlist}} + </select> + </div> + + <div style="float: left; margin-left: 15px;"> + <Label>{{lang_serverRoomId}}</Label><br> + <input name="serverroomid" id="serverroomid" value="{{serverroomid}}" style="width: 50px; text-align: center;"></input> + </div> + + + <br><br><br><br> + <div style="float: left;"> <Label>{{lang_language}}</Label><br> <select name="language"> @@ -90,6 +110,8 @@ loadValues(); function loadValues() { $("#{{language}}").attr("selected","selected"); + $('#serverOption-{{serverid}}').attr("selected", "selected"); + var mode = $("#{{mode}}"); if (!mode.length) { mode = $("#mode1"); diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html index 69665d01..534f7acb 100644 --- a/modules-available/locationinfo/templates/location-info.html +++ b/modules-available/locationinfo/templates/location-info.html @@ -1,6 +1,70 @@ <div> <h1>{{lang_mainHeader}}</h1> +<br> +<h4>{{lang_serverTable}}</h4> +<div id="serverTable"> + + <table class="table table-condensed locations" style="margin-bottom:0;"> + <tr> + <th width="30" style="text-align: center;" title="{{lang_serverID}}">{{lang_sID}}</th> + <th width="90">{{lang_serverType}}</th> + <th>{{lang_locationName}}</th> + <th>{{lang_serverUrl}}</th> + <th>{{lang_serverUser}}</th> + <th>{{lang_serverPassword}}</th> + <th width="80" style="text-align: center;"></th> + </tr> +{{#serverlist}} + <form method="post" action="?do=locationinfo" id="serverForm-{{id}}"> + <input type="hidden" name="token" value="{{token}}"> + <input id="serverFormAction-{{id}}" type="hidden" name="action" value="updateServer"> + <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}}"> + <option id="HISinOne" value="HISinOne" {{#HISinOne}}selected{{/HISinOne}}>HISinOne + <option id="DAVINCI" value="DAVINCI" {{#DAVINCI}}selected{{/DAVINCI}}>DAVINCI + </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> + <td id="user-{{id}}" style="padding:8px;"> + <input readonly required id="input-user-{{id}}" name="user" type="text" value="{{user}}" style="padding:0;height:100%;width:100%;"></input> + </td> + <td id="password-{{id}}" style="padding:8px;"> + <input readonly required id="input-password-{{id}}" name="password" type="text" value="{{password}}" style="padding:0;height:100%;width:100%;"></input> + </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> + <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" onclick="deleteButtonClick({{id}});">✘</button> + </td> + </tr> + </form> +{{/serverlist}} + <form method="post" action="?do=locationinfo" id="serverForm-0"> + <input type="hidden" name="token" value="{{token}}"> + <input id="serverFormAction-0" type="hidden" name="action" value="updateServer"> + <input type="submit" id="submit-serverForm-0" style="display:none;"> + <tr id="lastServerTableElement"></tr> + </form> + + </table> + <br> + <button class="btn btn-success btn-sm" id="addServerButton" onclick="addNewServerRow()"><span class="glyphicon glyphicon-plus-sign"> {{lang_addServer}}</span></button> + <!--<a class="btn btn-danger btn-sm" onclick=>{{lang_deleteAll}}</a>--> + <br><br><br> + +</div> +<br> + +<h4>{{lang_buildingTable}}</h4> <table class="table table-condensed locations" style="margin-bottom:0"> <tr> @@ -17,7 +81,7 @@ <td><div style="display:inline-block;width:{{depth}}em"></div>{{#hasPcs}}<a>{{/hasPcs}}{{locationname}}{{#hasPcs}}</a>{{/hasPcs}}</td> <td align="center">[{{locationid}}]</td> - <td align="center">{{#hasPcs}}{{inUse}} / {{total}}{{/hasPcs}}</td> + <td align="center">{{#hasPcs}}{{pcState}} / {{total}}{{/hasPcs}}</td> <td id={{locationid}} onclick="event.cancelBubble = true;" align="center"></td> <script> @@ -109,5 +173,126 @@ function loadConfigModal(locationId, locationName) { $('#myModalBody').load("?do=locationinfo&action=config&id=" + locationId); } +// ########### Server Table ########### +var preEditName; +var preEditUrl; +var preEditUser; +var preEditPassword; +var preEditType; + +function deleteButtonClick(id) { + var del = confirm("{{lang_deleteConfirmation}}"); + if (del == true) { + $('#serverFormAction-' + id).val("deleteServer"); + $('#serverForm-' + id).submit(); + } +}; + +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(); + + $('#btncell-' + id).html('\ + <button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="saveButtonClick(' + id + ');">✔</button> \ + <button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="cancelButtonClick(' + id + ');">✘</button>'); + $('.table-edit').attr('disabled', true); + $('.table-delete').attr('disabled', true); + $('#addServerButton').attr('disabled', true); +}; + +function saveButtonClick(id) { + //$('#input-name-' + id).val($('#lname-' + id).text()); + //$('#input-url-' + id).val($('#lurl-' + id).text()); + //$('#input-user-' + id).val($('#luser-' + id).text()); + //$('#input-password-' + id).val($('#lpassword-' + id).text()); + $('#serverFormAction-' + id).val("updateServer"); + + $('#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">✎</button> \ + <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" onclick="deleteButtonClick(' + id + ');">✘</button>'); + $('.table-edit').attr('disabled', false); + $('.table-delete').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"><option value="HISinOne">HISinOne<option value="DAVINCI">DAVINCI</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 id="user-0" style="padding:0;"><input required id="input-user-0" name="user" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></td>\ + <td id="password-0" style="padding:0;"><input required id="input-password-0" name="password" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></td>\ + <td align="center" id="btncell-new">\ + <button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="addNewServer();">✔</button> \ + <button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="deleteNewServer();">✘</button>\ + </td>\ + </tr>'); + $('.table-edit').attr('disabled', true); + $('.table-delete').attr('disabled', true); + $('#addServerButton').attr('disabled', true); +}; </script> </div> diff --git a/modules-available/locationinfo/templates/pcsubtable.html b/modules-available/locationinfo/templates/pcsubtable.html index 22eea6f1..59aa28b2 100644 --- a/modules-available/locationinfo/templates/pcsubtable.html +++ b/modules-available/locationinfo/templates/pcsubtable.html @@ -6,7 +6,7 @@ <th width=120>{{lang_pcIP}}</th> <th width=50>{{lang_pcX}}</th> <th width=50>{{lang_pcY}}</th> - <th width=20>{{lang_pcInUse}}</th> + <th width=20>{{lang_pcState}}</th> </tr> {{#list}} @@ -15,7 +15,7 @@ <td>{{ip}}</td> <td>{{x}}</td> <td>{{y}}</td> - <td align="center">{{inUse}}</td> + <td align="center">{{pcState}}</td> </tr> {{/list}} |