-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web UI works perfectly for loading, unloading, and reloading modules.…
… Server now terminates when it's module unloads.
- Loading branch information
1 parent
936f695
commit 03c8d64
Showing
4 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,64 @@ | ||
//$("#modtable").bootgrid() | ||
|
||
|
||
function onData(data){ | ||
$("#modtable tbody tr").remove() | ||
html = ""; | ||
for(var i = 0; i < data.modules.length; i++){ | ||
html += '<tr><td>' + data.modules[i].subsystem + '</td><td>' | ||
+ data.modules[i].filename + '</td><td>' | ||
+ data.modules[i].filename + '</td><td>' | ||
+ data.modules[i].status + '</td></tr>' | ||
unload_command = 'command_unloadmod("' + data.modules[i].subsystem + '")' | ||
reload_command = 'command_reloadmod("' + data.modules[i].subsystem + '")' | ||
mod_select = 'watch_module("' + data.modules[i].subsystem + '")' | ||
commands = "<button class='btn btn-warning' onClick='" + unload_command + "'>unload</button> <button class='btn btn-danger' onClick='" + reload_command +"'>reload</button>" | ||
status_tag = "<h4 style='display: inline;'><span class='label label-default'>" + data.modules[i].status + "</span></h4>" | ||
if(data.modules[i].status == "Loaded"){ | ||
status_tag = "<h4 style='display: inline;'><span class='label label-success'>" + data.modules[i].status + "</span></h4>" | ||
} | ||
html += '<tr onClick=' + mod_select + '><td>' + data.modules[i].subsystem + '</td><td>' | ||
+ data.modules[i].filename + '</td><td>' | ||
+ status_tag + '</td><td>' | ||
+ commands + '</td></tr>' | ||
} | ||
|
||
$("#modtable tbody").html(html) | ||
} | ||
|
||
function watch_module(modname){ | ||
var watchingmod = modname | ||
getData() | ||
} | ||
|
||
function load_handler(){ | ||
send_command("load", $("#module_target")[0].value) | ||
} | ||
|
||
function command_unloadmod(modname){ | ||
send_command("unload", modname) | ||
} | ||
|
||
function command_reloadmod(modname){ | ||
send_command("reload", modname) | ||
} | ||
|
||
function send_command(command, target){ | ||
data = { command: command, target: target } | ||
$.post("/api/command", data) | ||
setTimeout(getData, 200); | ||
} | ||
|
||
function getDataLoop() { | ||
$.getJSON("/json", onData); | ||
getData() | ||
//setTimeout(getDataLoop, 1000); | ||
} | ||
|
||
function getData(){$.getJSON("/api/json", onData)} | ||
|
||
$(document).ready(function(){ | ||
setTimeout(getDataLoop, 1000); | ||
$("#modtable").bootgrid() | ||
$("#load_button").click(load_handler) | ||
$('#module_target').keypress(function (e) { | ||
if (e.which == 13) { | ||
load_handler(); | ||
return false; | ||
} | ||
}); | ||
setTimeout(getDataLoop, 100); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters