diff options
author | Christoph Schulthess | 2017-03-01 16:14:49 +0100 |
---|---|---|
committer | Christoph Schulthess | 2017-03-01 16:14:49 +0100 |
commit | 0edfd21498c514e9f5da9aea10fc2082fe6fe834 (patch) | |
tree | ad3c3a281517bab29a1d94240f09c682c960312f /modules-available/debugconfig | |
parent | Merge branch 'master' of git.openslx.org:openslx-ng/slx-admin into remote-debug (diff) | |
download | slx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.tar.gz slx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.tar.xz slx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.zip |
Added active relay list to debugconfig
Diffstat (limited to 'modules-available/debugconfig')
-rw-r--r-- | modules-available/debugconfig/page.inc.php | 39 | ||||
-rw-r--r-- | modules-available/debugconfig/templates/debugconfig.html | 5 | ||||
-rw-r--r-- | modules-available/debugconfig/templates/relaystatus.html | 60 |
3 files changed, 79 insertions, 25 deletions
diff --git a/modules-available/debugconfig/page.inc.php b/modules-available/debugconfig/page.inc.php index 09ae0d7d..3ec394f6 100644 --- a/modules-available/debugconfig/page.inc.php +++ b/modules-available/debugconfig/page.inc.php @@ -13,24 +13,22 @@ class Page_debugConfig extends Page Util::redirect('?do=Main'); } if (Request::post('action') === 'debugconf') { - /*if (!filter_var(Request::get('debugServer'), FILTER_VALIDATE_IP)) { - return; - }*/ $this->setConfig(); } + elseif (Request::post("action") === "clearRelay") { + $this->clearRelay(); + } + elseif (Request::post("action") === "refreshList") { + $this->getActiveRelays(); + } } protected function doRender() { $debug_config = $this->getConfig(); Render::addTemplate('debugconfig', array("debugEnabled" => $debug_config["enabled"], "debugServer" => $debug_config["debugServer"], "port" => $debug_config["port"])); - - $task = Property::getDebugTaskStruct(); - $taskid = $task['id']; - $taskstatus = Taskmanager::status($task); - error_log(print_r($taskstatus, true)); - - Render::addTemplate('relaystatus', array("taskid" => $taskid, "taskstatus" => $taskstatus)); + $relays = $this->getActiveRelays(); + Render::addTemplate('relaystatus', array("activeRelays" => $relays)); } private function getConfig() @@ -45,6 +43,27 @@ class Page_debugConfig extends Page { $enabled = isset($_POST['toggleDebug']) ? true : false; Property::setRemoteDebugConfig(array('enabled' => $enabled, 'debugServer' => Request::post('debugServer'), 'port' => Request::post('port'))); + } + + private function getActiveRelays() + { + $relays = Property::getList("DispatchedRelay"); + foreach ($relays as $key => $value) { + $task = Taskmanager::status($value); + $finished = Taskmanager::isFinished($task); + $endpoints = $task["data"]["endpoints"]; + if ($task["statusCode"] == "NO_SUCH_INSTANCE" || $finished) { + Property::removeFromList("DispatchedRelay", $value); + unset($relays[$key]); + } + $relays[$key] = array("id" => $value, "bwlpclient" => $endpoints[0], "debugserver" => $endpoints[1]); + } + return $relays; } + + private function clearRelay() + { + Property::removeFromList("DispatchedRelay", Request::post("relayid")); + } } diff --git a/modules-available/debugconfig/templates/debugconfig.html b/modules-available/debugconfig/templates/debugconfig.html index 4e5353b5..200eb355 100644 --- a/modules-available/debugconfig/templates/debugconfig.html +++ b/modules-available/debugconfig/templates/debugconfig.html @@ -35,8 +35,9 @@ </div> </div> </div> - </div> - <div> + <div class="panel-footer"> <button type="submit" class="btn btn-primary">{{lang_save}}</button> + </div> </div> + </form> diff --git a/modules-available/debugconfig/templates/relaystatus.html b/modules-available/debugconfig/templates/relaystatus.html index 60e4c494..d38b3735 100644 --- a/modules-available/debugconfig/templates/relaystatus.html +++ b/modules-available/debugconfig/templates/relaystatus.html @@ -1,18 +1,52 @@ <div class="panel panel-default"> - <div class="panel-heading">Relay Status for task: {{taskid}}</div> + <div class="panel-heading"> + Active relays + </div> <div class="panel-body"> - <div data-tm-id="{{taskid}}" data-tm-log="messages"></div> + <table class="table table-striped table-condensed"> + <thead> + <tr> + <th>Relay ID</th> + <th>BWLP client</th> + <th>Debug Server</th> + <th> + <form method="post"> + <input type="hidden" name="token" value={{token}}> + <input type="hidden" name="action" value="refreshList"> + <button type="submit" class="btn btn-default pull-right btn-xs" title="Refresh relay list"><span class="glyphicon glyphicon-refresh"></span></button> + </form> + </th> + </tr> + </thead> + <tbody> + {{#activeRelays}} + <tr> + <td>{{id}}</td> + <td>{{bwlpclient}}</td> + <td>{{debugserver}}</td> + <td> + <div class="btn-group pull-right"> + <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#log" title="Show log"><span class="glyphicon glyphicon-paperclip"></span></button> + <div id="log" class="modal fade" tabindex="-1" role="dialog"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header">Relay ID: {{id}}</div> + <div class="modal-body" data-tm-id="{{id}}" data-tm-log="messages"></div> + <div class="modal-footer"> + <a class="btn btn-primary" data-dismiss="modal">Close</a> + </div> + </div> + </div> + </div> + </div> + </td> + </tr> + {{/activeRelays}} + </tbody> + </table> + <!-- </div> + <div data-tm-id="{{id}}" data-tm-log="messages"> + </div> --> </div> </div> - -<!-- <script type="text/javascript"> - function restartCb(task) - { - console.log("here"); - if (!task) - console.log("nothing"); - else - console.log("something"); - } -</script> -->
\ No newline at end of file |