put page in container
This commit is contained in:
parent
c7f6d46818
commit
f4eebef8a9
@ -4,37 +4,40 @@ $(function() {
|
|||||||
|
|
||||||
function refreshNodes() {
|
function refreshNodes() {
|
||||||
$("#nodeTable tr[data-node]").each(function(){
|
$("#nodeTable tr[data-node]").each(function(){
|
||||||
var $this = $(this);
|
refreshNode($(this));
|
||||||
var node = $this.data("node");
|
|
||||||
$.getJSON("/status/"+node, function (data) {
|
|
||||||
$this.find("span.loading").hide();
|
|
||||||
var label;
|
|
||||||
if (data["Status"] === "UP") {
|
|
||||||
label = "label-success";
|
|
||||||
$this.addClass("success");
|
|
||||||
$this.find("td.ping").text(data["Ping"] + "ms");
|
|
||||||
} else if (data["Status"] === "SLOW") {
|
|
||||||
label = "label-warning";
|
|
||||||
$this.addClass("warning");
|
|
||||||
$this.find("td.ping").text(data["Ping"] + "ms");
|
|
||||||
} else {
|
|
||||||
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) {
|
function refreshNode($node) {
|
||||||
var $nasStatus = $row.find("#nasStatus");
|
var node = $node.data("node");
|
||||||
|
$.getJSON("/status/"+node, function (data) {
|
||||||
|
$node.find("span.loading").hide();
|
||||||
|
var label;
|
||||||
|
if (data["Status"] === "UP") {
|
||||||
|
label = "label-success";
|
||||||
|
$node.addClass("success");
|
||||||
|
$node.find("td.ping").text(data["Ping"] + "ms");
|
||||||
|
} else if (data["Status"] === "SLOW") {
|
||||||
|
label = "label-warning";
|
||||||
|
$node.addClass("warning");
|
||||||
|
$node.find("td.ping").text(data["Ping"] + "ms");
|
||||||
|
} else {
|
||||||
|
label = "label-danger";
|
||||||
|
$node.addClass("danger");
|
||||||
|
}
|
||||||
|
if (data["Domain"] === "devkid-nas.vpn") {
|
||||||
|
setNasWakeUpLink($node, data);
|
||||||
|
}
|
||||||
|
$node.find("span.status-text").addClass(label).text(data["Status"]);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setNasWakeUpLink($node, data) {
|
||||||
|
var $nasStatus = $node.find("#nasStatus");
|
||||||
if ($nasStatus.length == 0){
|
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>'
|
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);
|
$node.find(".host").append(ele);
|
||||||
$nasStatus = $row.find("#nasStatus")
|
$nasStatus = $node.find("#nasStatus")
|
||||||
}
|
}
|
||||||
if (data["Status"] == "DOWN") {
|
if (data["Status"] == "DOWN") {
|
||||||
$nasStatus.show();
|
$nasStatus.show();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="/assets/app.css">
|
<link rel="stylesheet" type="text/css" href="/assets/app.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="container">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<!-- Default panel contents -->
|
<!-- Default panel contents -->
|
||||||
<div class="panel-heading">{{.Title}}</div>
|
<div class="panel-heading">{{.Title}}</div>
|
||||||
@ -23,9 +24,9 @@
|
|||||||
{{range $node := .Nodes}}
|
{{range $node := .Nodes}}
|
||||||
<tr data-node="{{$node}}">
|
<tr data-node="{{$node}}">
|
||||||
<td class="host">{{$node}}</td>
|
<td class="host">{{$node}}</td>
|
||||||
<td>
|
<td class="status">
|
||||||
<span class="loading"><i class="icon-spinner icon-spin"></i>Loading...</span>
|
<span class="loading"><i class="icon-spinner icon-spin"></i>Loading...</span>
|
||||||
<span class="status label"></span>
|
<span class="status-text label"></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="ping">
|
<td class="ping">
|
||||||
-
|
-
|
||||||
@ -34,4 +35,6 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="/assets/tinc-graph.svg" target="_blank">Show Network Graph</a>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os/exec"
|
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -106,6 +106,6 @@ func main() {
|
|||||||
http.HandleFunc("/status/", statusHandler)
|
http.HandleFunc("/status/", statusHandler)
|
||||||
http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("./assets/"))))
|
http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("./assets/"))))
|
||||||
http.HandleFunc("/", indexHandler)
|
http.HandleFunc("/", indexHandler)
|
||||||
fmt.Printf("Running on http://0.0.0.0:8080\n");
|
fmt.Printf("Running on http://0.0.0.0:8080\n")
|
||||||
http.ListenAndServe(":8080", nil)
|
http.ListenAndServe(":8080", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user