can delete watches
This commit is contained in:
parent
63b519ec2e
commit
69a4b6e15d
3 changed files with 14 additions and 7 deletions
7
main.go
7
main.go
|
@ -49,9 +49,10 @@ func (web Web) watchCreatePost(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (web Web) deleteWatch(c *gin.Context) {
|
func (web Web) deleteWatch(c *gin.Context) {
|
||||||
id, err := strconv.Atoi(c.PostForm("id"))
|
id, err := strconv.Atoi(c.PostForm("watch_id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusSeeOther, "/watch/new")
|
log.Println(err)
|
||||||
|
c.Redirect(http.StatusSeeOther, "/")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,12 +244,12 @@ func main() {
|
||||||
router.HTMLRender = templates
|
router.HTMLRender = templates
|
||||||
|
|
||||||
router.GET("/", web.index)
|
router.GET("/", web.index)
|
||||||
router.POST("/watch/delete", web.deleteWatch)
|
|
||||||
|
|
||||||
router.GET("/watch/:id", web.watchView)
|
router.GET("/watch/:id", web.watchView)
|
||||||
router.GET("/watch/new", web.watchCreate)
|
router.GET("/watch/new", web.watchCreate)
|
||||||
router.POST("/watch/create", web.watchCreatePost)
|
router.POST("/watch/create", web.watchCreatePost)
|
||||||
router.POST("/watch/update", web.watchUpdate)
|
router.POST("/watch/update", web.watchUpdate)
|
||||||
|
router.POST("/watch/delete", web.deleteWatch)
|
||||||
|
|
||||||
router.Run("0.0.0.0:8080")
|
router.Run("0.0.0.0:8080")
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
<td class="h3">{{ .Name }}</td>
|
<td class="h3">{{ .Name }}</td>
|
||||||
<td class="h3">{{ .Interval }}</td>
|
<td class="h3">{{ .Interval }}</td>
|
||||||
<td>
|
<td>
|
||||||
<form action="/query/delete" method="post">
|
<form action="/watch/delete" method="post">
|
||||||
<input type="hidden" name="id" value="{{ .ID }}">
|
<input type="hidden" name="watch_id" value="{{ .ID }}">
|
||||||
<input type="submit" class="btn btn-danger" value="Delete">
|
<input type="submit" class="btn btn-danger" value="Delete">
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -59,12 +59,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div>
|
||||||
<button class="btn btn-primary mt-4" data-bs-dismiss="modal" id="submitFilterButton">Add Filter</button>
|
<button class="btn btn-primary mt-4" data-bs-dismiss="modal" id="submitFilterButton">Add Filter</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -111,7 +113,11 @@
|
||||||
<input type="hidden" id="connectionsInput" name="connections" value="">
|
<input type="hidden" id="connectionsInput" name="connections" value="">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<button class="btn btn-primary mt-4" id="saveButtonModal" data-bs-dismiss="modal" id="submitWatchButton">Save</button>
|
<button class="btn btn-primary mt-4 float-start" id="saveButtonModal" data-bs-dismiss="modal" id="submitWatchButton">Save</button>
|
||||||
|
<form action="/watch/delete" method="post">
|
||||||
|
<input type="hidden" name="watch_id" value="{{ .Watch.ID }}">
|
||||||
|
<button class="btn btn-danger mt-4 float-end" data-bs-dismiss="modal" id="deleteFilterButton">Delete Filter</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue