added streams to template execution for side menu list
This commit is contained in:
parent
506c4d6a15
commit
8d8853800c
4 changed files with 27 additions and 17 deletions
12
main.go
12
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,
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
<div class="flex-row">
|
||||
<div class="menu flex-column">
|
||||
<div class="menu-header">Streams</div>
|
||||
<div class="menu-item">Test</div>
|
||||
<div class="menu-item">Test</div>
|
||||
<div class="menu-item">Test</div>
|
||||
<div class="menu-item">Test</div>
|
||||
<div class="menu-item">Test</div>
|
||||
{{if .Streams}}
|
||||
{{range $name, $stream := .Streams}}
|
||||
<a href="/?name={{$name}}" class="menu-item">{{$name}}</a>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<div>No Streams</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="content">
|
||||
{{template "content" .}}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<tr>
|
||||
<td colspan="5"><a href="/addStream">Add</a></td>
|
||||
</tr>
|
||||
{{range $streamName, $stream := .}}
|
||||
{{range $streamName, $stream := .Streams}}
|
||||
<tr>
|
||||
<td>{{ $stream.Name }}</td>
|
||||
<td>{{ $stream.URL }} </td>
|
||||
|
|
|
|||
|
|
@ -5,26 +5,26 @@
|
|||
{{define "content"}}
|
||||
<div class="flex-column" id="content">
|
||||
<div class="content-header">
|
||||
<h1>{{ .Name }}</h1>
|
||||
<h2>{{ .URL }}</h2>
|
||||
<h1>{{ .Stream.Name }}</h1>
|
||||
<h2>{{ .Stream.URL }}</h2>
|
||||
</div>
|
||||
<div class="stream-canvas-div">
|
||||
<img class="stream-canvas" src="{{ .GetCurrentColorURL }}" id="current_color_stream" hidden>
|
||||
<img class="stream-canvas" src="{{ .Stream.GetCurrentColorURL }}" id="current_color_stream" hidden>
|
||||
<canvas class="stream-canvas" id="canvas">Not supported</canvas>
|
||||
</div>
|
||||
<div class="flex-row">
|
||||
<div class="debug-img-div">
|
||||
<img src="{{ .GetPreviousURL }}" class="debug-img">
|
||||
<img src="{{ .Stream.GetPreviousURL }}" class="debug-img">
|
||||
</div>
|
||||
<div class="debug-img-div">
|
||||
<img src="{{ .GetDebugURL }}" class="debug-img">
|
||||
<img src="{{ .Stream.GetDebugURL }}" class="debug-img">
|
||||
</div>
|
||||
<div class="debug-img-div">
|
||||
<img src="{{ .GetCurrentURL }}" class="debug-img">
|
||||
<img src="{{ .Stream.GetCurrentURL }}" class="debug-img">
|
||||
</div>
|
||||
</div>
|
||||
<form action="/addWatchArea" method="GET" id="newWatchAreaForm">
|
||||
<input type="hidden" name="streamName" value="{{ .Name }}">
|
||||
<input type="hidden" name="streamName" value="{{ .Stream.Name }}">
|
||||
<table class="pure-table pure-table-horizontal">
|
||||
<caption>Watches</caption>
|
||||
<thead>
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody id="watchAreas">
|
||||
{{range $watchArea := .WatchAreas}}
|
||||
{{range $watchArea := .Stream.WatchAreas}}
|
||||
<tr style="background-color:rgb({{ $watchArea.Color.R }}, {{$watchArea.Color.G}}, {{$watchArea.Color.B}})">
|
||||
<td>{{ $watchArea.Name }}</td>
|
||||
<td>{{ $watchArea.Color.R }}</td>
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
{{range $watchArea := .WatchAreas}}
|
||||
{{range $watchArea := .Stream.WatchAreas}}
|
||||
watchAreas.push(new WatchArea(
|
||||
'{{ $watchArea.Name }}',
|
||||
{{ $watchArea.Area.Min.X }}, {{ $watchArea.Area.Min.Y }},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue