From 4b86aadae428276f06637d357307985da9529c7b Mon Sep 17 00:00:00 2001 From: adro Date: Thu, 17 Feb 2022 13:54:52 +0100 Subject: [PATCH] Handle id/alias mismatch, index --- web/index.go | 2 +- web/template/device.html.tmpl | 11 ++++++----- web/wake.go | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/web/index.go b/web/index.go index 4b4bd00..bbee9f7 100644 --- a/web/index.go +++ b/web/index.go @@ -22,7 +22,7 @@ func index(w http.ResponseWriter, r *http.Request) { sCookie, err := r.Cookie("session") if err == nil && isAuthenticated(sCookie.Value) == nil { page.Title = "Miniwol" - contentBuffer.WriteString("TODO") + contentBuffer.WriteString("Device") } else { page.Title = "Login" err = loginTemplate.Execute(&contentBuffer, struct{}{}) diff --git a/web/template/device.html.tmpl b/web/template/device.html.tmpl index 5d190e7..030127b 100644 --- a/web/template/device.html.tmpl +++ b/web/template/device.html.tmpl @@ -5,14 +5,15 @@ IP/Broadcast Actions - {{range .}} + {{range $i, $d := .}} - {{.Alias}} - {{.MAC}} - {{.IP}} + {{$d.Alias}} + {{$d.MAC}} + {{$d.IP}}
- + +
diff --git a/web/wake.go b/web/wake.go index a1d2692..21cb4a9 100644 --- a/web/wake.go +++ b/web/wake.go @@ -1,6 +1,7 @@ package web import ( + "fmt" "miniwol/config" "miniwol/lib" "net/http" @@ -12,8 +13,8 @@ func wake(w http.ResponseWriter, r *http.Request) { return } - for _, device := range config.Config.Device { - if r.FormValue("alias") == device.Alias { + for i, device := range config.Config.Device { + if r.FormValue("alias") == device.Alias && r.FormValue("index") == fmt.Sprint(i) { if !strings.Contains(device.IP, ":") { device.IP += ":9" }