From 8d8853800c153fca017a016e9a6c69454fbdcba3 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Sun, 2 Aug 2020 14:19:08 +0000 Subject: [PATCH] added streams to template execution for side menu list --- main.go | 12 ++++++++++-- templates/base.html | 12 +++++++----- templates/index.html | 2 +- templates/stream.html | 18 +++++++++--------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index c634b81..2de9414 100755 --- a/main.go +++ b/main.go @@ -28,7 +28,7 @@ func (server Server) index(w http.ResponseWriter, r *http.Request) { log.Println(err) return } - indexTemplate.Execute(w, server.Streams) + indexTemplate.Execute(w, server) return } name := r.FormValue("name") @@ -42,7 +42,13 @@ func (server Server) index(w http.ResponseWriter, r *http.Request) { log.Println(err) return } - streamTemplate.Execute(w, stream) + streamTemplate.Execute(w, struct { + Streams map[string]*Stream + Stream *Stream + }{ + server.Streams, + stream, + }) } func (server Server) addStream(w http.ResponseWriter, r *http.Request) { @@ -99,11 +105,13 @@ func (server Server) addStream(w http.ResponseWriter, r *http.Request) { return } addStreamTemplate.Execute(w, struct { + Streams map[string]*Stream NameMessage string URLMessage string IntervalMessage string MotionIntervalMessage string }{ + server.Streams, nameMessage, URLMessage, intervalMessage, diff --git a/templates/base.html b/templates/base.html index 7b6bdb4..14d1f62 100755 --- a/templates/base.html +++ b/templates/base.html @@ -10,11 +10,13 @@
{{template "content" .}} diff --git a/templates/index.html b/templates/index.html index bd46721..f469493 100755 --- a/templates/index.html +++ b/templates/index.html @@ -16,7 +16,7 @@ Add - {{range $streamName, $stream := .}} + {{range $streamName, $stream := .Streams}} {{ $stream.Name }} {{ $stream.URL }} diff --git a/templates/stream.html b/templates/stream.html index e0d26b3..600743c 100755 --- a/templates/stream.html +++ b/templates/stream.html @@ -5,26 +5,26 @@ {{define "content"}}
-

{{ .Name }}

-

{{ .URL }}

+

{{ .Stream.Name }}

+

{{ .Stream.URL }}

- + Not supported
- +
- +
- +
- + @@ -47,7 +47,7 @@ - {{range $watchArea := .WatchAreas}} + {{range $watchArea := .Stream.WatchAreas}} @@ -80,7 +80,7 @@
Watches
{{ $watchArea.Name }} {{ $watchArea.Color.R }}