hide/show nas wake up link

This commit is contained in:
Jörg Thalheim 2013-10-04 11:11:31 +02:00
parent 02a191a6e1
commit c7f6d46818
2 changed files with 23 additions and 2 deletions

View File

@ -1,4 +1,8 @@
$(function() {
refreshNodes();
})
function refreshNodes() {
$("#nodeTable tr[data-node]").each(function(){
var $this = $(this);
var node = $this.data("node");
@ -17,7 +21,24 @@ $(function() {
label = "label-danger";
$this.addClass("danger");
}
if (data["Domain"] === "devkid-nas.vpn") {
setNasWakeUpLink($this, data);
}
$this.find("span.status").addClass(label).text(data["Status"]);
})
});
})
}
function setNasWakeUpLink($row, data) {
var $nasStatus = $row.find("#nasStatus");
if ($nasStatus.length == 0){
var ele = '<a id="nasStatus" href="http://devkid-router.vpn:8080/cgi-bin/wake-nas" class="btn btn-link btn-sm">Wake up NAS</a>'
$row.find(".host").append(ele);
$nasStatus = $row.find("#nasStatus")
}
if (data["Status"] == "DOWN") {
$nasStatus.show();
} else {
$nasStatus.hide();
}
}

View File

@ -106,6 +106,6 @@ func main() {
http.HandleFunc("/status/", statusHandler)
http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("./assets/"))))
http.HandleFunc("/", indexHandler)
fmt.Printf("Running on http://0.0.0.0:8080\n");
http.ListenAndServe(":8080", nil)
fmt.Printf("Running on 8080")
}