From 330e23aca7bd770e5f14fd1464e2fa2ab92f5465 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Sat, 30 Oct 2021 09:51:33 -0400 Subject: [PATCH 1/2] fix key copying --- html/keys.html | 8 ++++---- html/script.html | 1 + main.go | 3 --- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/html/keys.html b/html/keys.html index 514981e..713787c 100644 --- a/html/keys.html +++ b/html/keys.html @@ -16,10 +16,10 @@ - -
-
-
+ +
+
+

diff --git a/html/script.html b/html/script.html index bd40e91..ef83d20 100644 --- a/html/script.html +++ b/html/script.html @@ -6,6 +6,7 @@ function setUp(tabName, message) { setVisibility(tabName); + getNodeStatus(); nodeStatus = window.setInterval(getNodeStatus, 30000); if (message != "") { alert(message) diff --git a/main.go b/main.go index a3b8ac7..8fcd3b7 100644 --- a/main.go +++ b/main.go @@ -107,10 +107,7 @@ func WrapRelayNetwork(network string, data models.Node) map[string]interface{} { func AuthRequired(c *gin.Context) { session := sessions.Default(c) - options := session.Options - fmt.Println("checking authorization\n", options) - fmt.Printf("type %v value %s\n", options, options) loggedIn := session.Get("loggedIn") fmt.Println("loggedIn status: ", loggedIn) if loggedIn != true { From bc09d1eeb73edaa8eea293d63a0d9ed5348c02fa Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Sat, 30 Oct 2021 10:53:26 -0400 Subject: [PATCH 2/2] node display --- handlers.go | 7 ++++--- html/nodes.html | 10 +++++----- html/script.html | 12 ++++++------ types.go | 7 ++++--- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/handlers.go b/handlers.go index 6f37740..541bac2 100644 --- a/handlers.go +++ b/handlers.go @@ -410,15 +410,16 @@ func NodeHealth(c *gin.Context) { var nodeHealth NodeStatus for _, node := range nodes { nodeHealth.Mac = node.MacAddress + nodeHealth.Network = node.Network lastupdate := time.Now().Sub(time.Unix(node.LastCheckIn, 0)) if lastupdate.Minutes() > 15.0 { - nodeHealth.Status = "Dead: Node last checked in more than 15 minutes ago" + nodeHealth.Status = "Error: Node last checked in more than 15 minutes ago: " nodeHealth.Color = "w3-deep-orange" } else if lastupdate.Minutes() > 5.0 { - nodeHealth.Status = "Warning: Node last checked in more than 5 minutes ago" + nodeHealth.Status = "Warning: Node last checked in more than 5 minutes ago: " nodeHealth.Color = "w3-khaki" } else { - nodeHealth.Status = "Healthy: Node checked in within the last 5 minutes" + nodeHealth.Status = "Healthy: Node checked in within the last 5 minutes: " nodeHealth.Color = "w3-teal" } response = append(response, nodeHealth) diff --git a/html/nodes.html b/html/nodes.html index 5eabdbe..8443273 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -1,27 +1,27 @@ {{ define "Nodes" }}
{{range .Nodes}} -

+

{{template "NodeDetails" .}} {{end}}
{{end}} {{define "NodeDetails"}} -
+
{{.Name }} -
+

-
+

-
+ diff --git a/html/script.html b/html/script.html index ef83d20..6ffd4a9 100644 --- a/html/script.html +++ b/html/script.html @@ -129,12 +129,12 @@ } const nodes = JSON.parse(this.responseText); nodes.forEach((element, index, array) => { - document.getElementById("node_status"+element.Mac).innerHTML=element.Status; - document.getElementById("button"+element.Mac).classList.remove("w3-lightgrey") - document.getElementById("button"+element.Mac).classList.remove("w3-deep-orange") - document.getElementById("button"+element.Mac).classList.remove("w3-khaki") - document.getElementById("button"+element.Mac).classList.remove("w3-teal") - document.getElementById("button"+element.Mac).classList.add(element.Color) + document.getElementById("node_status"+element.Mac+element.Network).innerHTML=element.Status; + document.getElementById("button"+element.Mac+element.Network).classList.remove("w3-lightgrey") + document.getElementById("button"+element.Mac+element.Network).classList.remove("w3-deep-orange") + document.getElementById("button"+element.Mac+element.Network).classList.remove("w3-khaki") + document.getElementById("button"+element.Mac+element.Network).classList.remove("w3-teal") + document.getElementById("button"+element.Mac+element.Network).classList.add(element.Color) }); } xHttp.send(); diff --git a/types.go b/types.go index d1f32ab..c003030 100644 --- a/types.go +++ b/types.go @@ -12,9 +12,10 @@ import ( ) type NodeStatus struct { - Mac string - Status string - Color string + Mac string + Network string + Status string + Color string } type Relay struct {