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)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
indexTemplate.Execute(w, server.Streams)
|
indexTemplate.Execute(w, server)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name := r.FormValue("name")
|
name := r.FormValue("name")
|
||||||
|
|
@ -42,7 +42,13 @@ func (server Server) index(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
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) {
|
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
|
return
|
||||||
}
|
}
|
||||||
addStreamTemplate.Execute(w, struct {
|
addStreamTemplate.Execute(w, struct {
|
||||||
|
Streams map[string]*Stream
|
||||||
NameMessage string
|
NameMessage string
|
||||||
URLMessage string
|
URLMessage string
|
||||||
IntervalMessage string
|
IntervalMessage string
|
||||||
MotionIntervalMessage string
|
MotionIntervalMessage string
|
||||||
}{
|
}{
|
||||||
|
server.Streams,
|
||||||
nameMessage,
|
nameMessage,
|
||||||
URLMessage,
|
URLMessage,
|
||||||
intervalMessage,
|
intervalMessage,
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,13 @@
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<div class="menu flex-column">
|
<div class="menu flex-column">
|
||||||
<div class="menu-header">Streams</div>
|
<div class="menu-header">Streams</div>
|
||||||
<div class="menu-item">Test</div>
|
{{if .Streams}}
|
||||||
<div class="menu-item">Test</div>
|
{{range $name, $stream := .Streams}}
|
||||||
<div class="menu-item">Test</div>
|
<a href="/?name={{$name}}" class="menu-item">{{$name}}</a>
|
||||||
<div class="menu-item">Test</div>
|
{{end}}
|
||||||
<div class="menu-item">Test</div>
|
{{else}}
|
||||||
|
<div>No Streams</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{template "content" .}}
|
{{template "content" .}}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"><a href="/addStream">Add</a></td>
|
<td colspan="5"><a href="/addStream">Add</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{range $streamName, $stream := .}}
|
{{range $streamName, $stream := .Streams}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $stream.Name }}</td>
|
<td>{{ $stream.Name }}</td>
|
||||||
<td>{{ $stream.URL }} </td>
|
<td>{{ $stream.URL }} </td>
|
||||||
|
|
|
||||||
|
|
@ -5,26 +5,26 @@
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<div class="flex-column" id="content">
|
<div class="flex-column" id="content">
|
||||||
<div class="content-header">
|
<div class="content-header">
|
||||||
<h1>{{ .Name }}</h1>
|
<h1>{{ .Stream.Name }}</h1>
|
||||||
<h2>{{ .URL }}</h2>
|
<h2>{{ .Stream.URL }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="stream-canvas-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>
|
<canvas class="stream-canvas" id="canvas">Not supported</canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<div class="debug-img-div">
|
<div class="debug-img-div">
|
||||||
<img src="{{ .GetPreviousURL }}" class="debug-img">
|
<img src="{{ .Stream.GetPreviousURL }}" class="debug-img">
|
||||||
</div>
|
</div>
|
||||||
<div class="debug-img-div">
|
<div class="debug-img-div">
|
||||||
<img src="{{ .GetDebugURL }}" class="debug-img">
|
<img src="{{ .Stream.GetDebugURL }}" class="debug-img">
|
||||||
</div>
|
</div>
|
||||||
<div class="debug-img-div">
|
<div class="debug-img-div">
|
||||||
<img src="{{ .GetCurrentURL }}" class="debug-img">
|
<img src="{{ .Stream.GetCurrentURL }}" class="debug-img">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form action="/addWatchArea" method="GET" id="newWatchAreaForm">
|
<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">
|
<table class="pure-table pure-table-horizontal">
|
||||||
<caption>Watches</caption>
|
<caption>Watches</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="watchAreas">
|
<tbody id="watchAreas">
|
||||||
{{range $watchArea := .WatchAreas}}
|
{{range $watchArea := .Stream.WatchAreas}}
|
||||||
<tr style="background-color:rgb({{ $watchArea.Color.R }}, {{$watchArea.Color.G}}, {{$watchArea.Color.B}})">
|
<tr style="background-color:rgb({{ $watchArea.Color.R }}, {{$watchArea.Color.G}}, {{$watchArea.Color.B}})">
|
||||||
<td>{{ $watchArea.Name }}</td>
|
<td>{{ $watchArea.Name }}</td>
|
||||||
<td>{{ $watchArea.Color.R }}</td>
|
<td>{{ $watchArea.Color.R }}</td>
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{{range $watchArea := .WatchAreas}}
|
{{range $watchArea := .Stream.WatchAreas}}
|
||||||
watchAreas.push(new WatchArea(
|
watchAreas.push(new WatchArea(
|
||||||
'{{ $watchArea.Name }}',
|
'{{ $watchArea.Name }}',
|
||||||
{{ $watchArea.Area.Min.X }}, {{ $watchArea.Area.Min.Y }},
|
{{ $watchArea.Area.Min.X }}, {{ $watchArea.Area.Min.Y }},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue