From 913693d9d855d6e59b60f5a44a189cfeffbf9ae3 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Sun, 25 Sep 2022 15:09:20 +0000 Subject: [PATCH] cleanup --- main.go | 18 +- static/edit.js | 6 +- static/edit.ts | 7 +- templates/editGroup.html | 430 ------------------ templates/viewWatch.html | 37 -- .../{watchCreate.html => watch/create.html} | 0 templates/{diagrams.html => watch/view.html} | 6 +- 7 files changed, 19 insertions(+), 485 deletions(-) delete mode 100644 templates/editGroup.html delete mode 100644 templates/viewWatch.html rename templates/{watchCreate.html => watch/create.html} (100%) rename templates/{diagrams.html => watch/view.html} (95%) diff --git a/main.go b/main.go index 4e8e879..8e050d8 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,6 @@ func (web Web) watchCreate(c *gin.Context) { } func (web Web) watchCreatePost(c *gin.Context) { - log.Println("TEST") var watch Watch errMap, err := bindAndValidateWatch(&watch, c) if err != nil { @@ -77,14 +76,14 @@ func (web Web) watchView(c *gin.Context) { var connections []FilterConnection web.db.Model(&FilterConnection{}).Where("watch_id = ?", watch.ID).Find(&connections) - c.HTML(http.StatusOK, "watch", gin.H{ + c.HTML(http.StatusOK, "watchView", gin.H{ "Watch": watch, "Filters": filters, "Connections": connections, }) } -func (web Web) watchSave(c *gin.Context) { +func (web Web) watchUpdate(c *gin.Context) { var watch Watch bindAndValidateWatch(&watch, c) @@ -289,22 +288,19 @@ func main() { templates := multitemplate.NewRenderer() templates.AddFromFiles("index", "templates/base.html", "templates/index.html") - templates.AddFromFiles("watchCreate", "templates/base.html", "templates/watchCreate.html") - templates.AddFromFiles("viewWatch", "templates/base.html", "templates/viewWatch.html") - templates.AddFromFiles("editGroup", "templates/base.html", "templates/editGroup.html") - - templates.AddFromFiles("watch", "templates/base.html", "templates/diagrams.html") + templates.AddFromFiles("watchCreate", "templates/base.html", "templates/watch/create.html") + templates.AddFromFiles("watchView", "templates/base.html", "templates/watch/view.html") templates.AddFromFiles("500", "templates/base.html", "templates/500.html") router.HTMLRender = templates router.GET("/", web.index) - router.GET("/watch/new", web.watchCreate) - router.POST("/watch/create", web.watchCreatePost) router.POST("/watch/delete", web.deleteWatch) router.GET("/watch/:id", web.watchView) - router.POST("/watch/save", web.watchSave) + router.GET("/watch/new", web.watchCreate) + router.POST("/watch/create", web.watchCreatePost) + router.POST("/watch/update", web.watchUpdate) router.Run("0.0.0.0:8080") } diff --git a/static/edit.js b/static/edit.js index 2964dc3..4b8a65f 100644 --- a/static/edit.js +++ b/static/edit.js @@ -239,7 +239,9 @@ function pageInit() { select.onchange = onTypeChange; var addFilterButton = document.getElementById("filterButton"); addFilterButton.onclick = addFilterButtonClicked; - var saveButton = document.getElementById("saveButton"); - saveButton.onclick = saveWatch; + var saveButtonModal = document.getElementById("saveButtonModal"); + saveButtonModal.onclick = saveWatch; + var saveButtonMain = document.getElementById("saveButtonMain"); + saveButtonMain.onclick = saveWatch; } document.addEventListener('DOMContentLoaded', pageInit, false); diff --git a/static/edit.ts b/static/edit.ts index de792b8..53eeb40 100644 --- a/static/edit.ts +++ b/static/edit.ts @@ -222,8 +222,11 @@ function pageInit(){ let addFilterButton = document.getElementById("filterButton") as HTMLButtonElement; addFilterButton.onclick = addFilterButtonClicked - let saveButton = document.getElementById("saveButton") as HTMLButtonElement; - saveButton.onclick = saveWatch; + let saveButtonModal = document.getElementById("saveButtonModal") as HTMLButtonElement; + saveButtonModal.onclick = saveWatch; + + let saveButtonMain = document.getElementById("saveButtonMain") as HTMLButtonElement; + saveButtonMain.onclick = saveWatch; } document.addEventListener('DOMContentLoaded', pageInit, false); \ No newline at end of file diff --git a/templates/editGroup.html b/templates/editGroup.html deleted file mode 100644 index 1fa8ea6..0000000 --- a/templates/editGroup.html +++ /dev/null @@ -1,430 +0,0 @@ -{{define "content"}} -
-
-
{{ .Group.URL.Watch.Name }} - {{ .Group.Name }}
-
{{ .Group.URL.URL }}
-
-
-
-
- {{ .Group.Type }} -
-
- -
-
-
-
-
- - - {{ range .Group.Filters }} - - - - - - - - - {{ end }} - - - - -
{{ .Name }}{{ .Type }}{{ .From }}{{ .To }} - - -
- - - -
-
-
-
-
- -
-
-
-
-
-
-
-{{ range .currentResult }} -
-
-
Result
-
-
- - {{ . }} - -
-
-{{ end }} - - - - - - - - - -{{ range .Group.Filters }} - - -{{ end }} - -{{ end }} diff --git a/templates/viewWatch.html b/templates/viewWatch.html deleted file mode 100644 index f74a951..0000000 --- a/templates/viewWatch.html +++ /dev/null @@ -1,37 +0,0 @@ -{{define "content"}} -
-
-
- {{ .Watch.Name }} -
-
- {{ .Watch.Interval }} -
-
-
- - - - - - - - - - -{{ range .Filters }} - - {{ range .Depth }} - - {{ end }} - - - - {{ range .RevDepth }} - - {{ end }} - -{{ end }} -
IDIDParentIDName
{{ .Filter.ID }}{{ .Filter.ParentID }}{{ .Filter.Name }}
- -{{ end }} diff --git a/templates/watchCreate.html b/templates/watch/create.html similarity index 100% rename from templates/watchCreate.html rename to templates/watch/create.html diff --git a/templates/diagrams.html b/templates/watch/view.html similarity index 95% rename from templates/diagrams.html rename to templates/watch/view.html index b8f3f05..ce3df7d 100644 --- a/templates/diagrams.html +++ b/templates/watch/view.html @@ -73,7 +73,7 @@
-
@@ -87,7 +87,7 @@