added notifiers page, with test button
This commit is contained in:
parent
afc7033a9a
commit
3f8f6aa81a
4 changed files with 50 additions and 3 deletions
20
main.go
20
main.go
|
@ -131,6 +131,9 @@ func (web *Web) initRouter() {
|
||||||
web.router.GET("/cache/view", web.cacheView)
|
web.router.GET("/cache/view", web.cacheView)
|
||||||
web.router.POST("/cache/clear", web.cacheClear)
|
web.router.POST("/cache/clear", web.cacheClear)
|
||||||
|
|
||||||
|
web.router.GET("/notifiers/view", web.notifiersView)
|
||||||
|
web.router.POST("/notifiers/test", web.notifiersTest)
|
||||||
|
|
||||||
web.router.SetTrustedProxies(nil)
|
web.router.SetTrustedProxies(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +153,8 @@ func (web *Web) initTemplates() {
|
||||||
|
|
||||||
web.templates.Add("cacheView", template.Must(template.ParseFS(templatesFS, "base.html", "cache/view.html")))
|
web.templates.Add("cacheView", template.Must(template.ParseFS(templatesFS, "base.html", "cache/view.html")))
|
||||||
|
|
||||||
|
web.templates.Add("notifiersView", template.Must(template.ParseFS(templatesFS, "base.html", "notifiers.html")))
|
||||||
|
|
||||||
web.templates.Add("500", template.Must(template.ParseFS(templatesFS, "base.html", "500.html")))
|
web.templates.Add("500", template.Must(template.ParseFS(templatesFS, "base.html", "500.html")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +322,21 @@ func (web *Web) index(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (web *Web) notifiersView(c *gin.Context) {
|
||||||
|
c.HTML(http.StatusOK, "notifiersView", web.notifiers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (web *Web) notifiersTest(c *gin.Context) {
|
||||||
|
notifierName := c.PostForm("notifier_name")
|
||||||
|
notifier, exists := web.notifiers[notifierName]
|
||||||
|
if !exists {
|
||||||
|
c.Redirect(http.StatusSeeOther, "/notifiers/view")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
notifier.Message("GoWatch Test")
|
||||||
|
c.Redirect(http.StatusSeeOther, "/notifiers/view")
|
||||||
|
}
|
||||||
|
|
||||||
func (web *Web) watchCreate(c *gin.Context) {
|
func (web *Web) watchCreate(c *gin.Context) {
|
||||||
templateFiles, err := EMBED_FS.ReadDir("watchTemplates")
|
templateFiles, err := EMBED_FS.ReadDir("watchTemplates")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="/">Home</a>
|
<a class="nav-link active" aria-current="page" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" aria-current="page" href="/notifiers/view">Notifiers</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" aria-current="page" id="newWatchLink" href="/watch/create">New</a>
|
<a class="nav-link" aria-current="page" id="newWatchLink" href="/watch/create">New</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
27
templates/notifiers.html
Normal file
27
templates/notifiers.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{{define "title"}}
|
||||||
|
GoWatch
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "content"}}
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead class="table-dark">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Test</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{ range $name, $notifier := . }}
|
||||||
|
<tr>
|
||||||
|
<td class="h3">{{ $name }}</td>
|
||||||
|
<td>
|
||||||
|
<form action="/notifiers/test" method="post">
|
||||||
|
<input type="hidden" name="notifier_name" value="{{ $name }}">
|
||||||
|
<input type="submit" class="btn btn-primary" value="Test">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{end}}
|
3
todo.md
3
todo.md
|
@ -11,7 +11,4 @@
|
||||||
- organize docs?
|
- organize docs?
|
||||||
- disable gin debug
|
- disable gin debug
|
||||||
- add favicon
|
- add favicon
|
||||||
- notifiers overview page
|
|
||||||
- with test for notifier
|
|
||||||
- last success/error message
|
|
||||||
- db prune readme
|
- db prune readme
|
Loading…
Add table
Reference in a new issue