put page in container

This commit is contained in:
Jörg Thalheim 2013-10-04 14:58:58 +02:00
parent c7f6d46818
commit f4eebef8a9
3 changed files with 52 additions and 46 deletions

View File

@ -4,37 +4,40 @@ $(function() {
function refreshNodes() {
$("#nodeTable tr[data-node]").each(function(){
var $this = $(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"]);
})
refreshNode($(this));
});
}
function setNasWakeUpLink($row, data) {
var $nasStatus = $row.find("#nasStatus");
function refreshNode($node) {
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){
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")
$node.find(".host").append(ele);
$nasStatus = $node.find("#nasStatus")
}
if (data["Status"] == "DOWN") {
$nasStatus.show();

View File

@ -1,16 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>{{.Title}}</title>
<meta charset="utf-8" />
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/assets/app.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="/assets/app.css">
<title>{{.Title}}</title>
<meta charset="utf-8" />
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/assets/app.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="/assets/app.css">
</head>
<body>
<div class="container">
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">{{.Title}}</div>
@ -21,17 +22,19 @@
<th>Ping</th>
</tr>
{{range $node := .Nodes}}
<tr data-node="{{$node}}">
<td class="host">{{$node}}</td>
<td>
<span class="loading"><i class="icon-spinner icon-spin"></i>Loading...</span>
<span class="status label"></span>
</td>
<td class="ping">
-
</td>
</tr>
<tr data-node="{{$node}}">
<td class="host">{{$node}}</td>
<td class="status">
<span class="loading"><i class="icon-spinner icon-spin"></i>Loading...</span>
<span class="status-text label"></span>
</td>
<td class="ping">
-
</td>
</tr>
{{end}}
</table>
</div>
<a href="/assets/tinc-graph.svg" target="_blank">Show Network Graph</a>
</div>
</body>

View File

@ -4,8 +4,8 @@ import (
"fmt"
"net/http"
"html/template"
"os/exec"
"os"
"os/exec"
"regexp"
"strconv"
"bytes"
@ -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");
fmt.Printf("Running on http://0.0.0.0:8080\n")
http.ListenAndServe(":8080", nil)
}