summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schulthess2017-03-01 16:14:49 +0100
committerChristoph Schulthess2017-03-01 16:14:49 +0100
commit0edfd21498c514e9f5da9aea10fc2082fe6fe834 (patch)
treead3c3a281517bab29a1d94240f09c682c960312f
parentMerge branch 'master' of git.openslx.org:openslx-ng/slx-admin into remote-debug (diff)
downloadslx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.tar.gz
slx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.tar.xz
slx-admin-0edfd21498c514e9f5da9aea10fc2082fe6fe834.zip
Added active relay list to debugconfig
-rw-r--r--apis/debugrequest.inc.php2
-rw-r--r--modules-available/debugconfig/page.inc.php39
-rw-r--r--modules-available/debugconfig/templates/debugconfig.html5
-rw-r--r--modules-available/debugconfig/templates/relaystatus.html60
4 files changed, 80 insertions, 26 deletions
diff --git a/apis/debugrequest.inc.php b/apis/debugrequest.inc.php
index 0d423bec..54ebffb2 100644
--- a/apis/debugrequest.inc.php
+++ b/apis/debugrequest.inc.php
@@ -19,6 +19,6 @@ if ($validclient == false) {
$data = array("hosts" => array($_SERVER["REMOTE_ADDR"], $debug_settings["debugServer"]),
"ports" => array($port, intval($debug_settings["port"])), "descs" => array("bwlpclient", "debugserver"));
$taskstruct = Taskmanager::submit('DispatchRelay', $data);
- Property::setDebugTaskStruct($taskstruct);
+ Property::addToList("DispatchedRelay", $taskstruct['id']);
}
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