summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-12 04:50:44 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-12 04:50:44 +0000
commitfbf0f6250dadf3fb3ba70b8b8f40b2c265b09939 (patch)
tree4b312e2d8e2e9dacaa4458dfce35a6c5ea699047 /cmd
parent7d131bea17205c314387700787286365cbd98d5a (diff)
An Operations list page now renders data in table
The data is fetched from the database and uses html/template to render the rows in a list. A critical bug was not including the dot in {{ template "main" . }} in the base template. THIS MEANT THAT NO DATA PASSED TO ExecuteTemplate function rendered and took a long time to figure out.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/web/handlers.go4
-rw-r--r--cmd/web/routes.go2
2 files changed, 2 insertions, 4 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 40ca509..e27b39b 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"html/template"
- "log"
"net/http"
"strconv"
@@ -34,7 +33,6 @@ func (app *application) listOperations(w http.ResponseWriter, r *http.Request) {
data := operationsTemplateData{
Operations: ops,
}
- log.Println(data)
err = ts.ExecuteTemplate(w, "base", data)
if err != nil {
@@ -42,7 +40,7 @@ func (app *application) listOperations(w http.ResponseWriter, r *http.Request) {
}
}
-func (app *application) listOrganisation(w http.ResponseWriter, r *http.Request) {
+func (app *application) listOrganisations(w http.ResponseWriter, r *http.Request) {
files := []string{
"./ui/html/base.tmpl.html",
"./ui/html/pages/organisations/list.tmpl.html",
diff --git a/cmd/web/routes.go b/cmd/web/routes.go
index e21b25d..d23855a 100644
--- a/cmd/web/routes.go
+++ b/cmd/web/routes.go
@@ -9,7 +9,7 @@ func (app *application) routes() *http.ServeMux {
mux.Handle("/static/", http.StripPrefix("/static", fileServer))
mux.HandleFunc("/", app.home)
- mux.HandleFunc("/organisation/list", app.listOrganisation)
+ mux.HandleFunc("/organisation/list", app.listOrganisations)
mux.HandleFunc("/organisation/view", app.organisationView)
mux.HandleFunc("/organisation/create", app.organisationCreate)
mux.HandleFunc("/operation/list", app.listOperations)