can delete watches

This commit is contained in:
BroodjeAap 2022-09-25 15:17:48 +00:00
parent 63b519ec2e
commit 69a4b6e15d
3 changed files with 14 additions and 7 deletions

View file

@ -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")
} }

View file

@ -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>

View file

@ -59,11 +59,13 @@
</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>
@ -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>