From 4e029fb83a1e70495330eaac94981a97de24682e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 26 Jan 2025 00:04:38 +0100 Subject: feat(webui): bootstrap a proper UI --- pkg/webui/error.go | 2 ++ pkg/webui/html/base.html | 54 ++++++++++++++++++++++++++++++++-------------- pkg/webui/html/error.html | 8 +++---- pkg/webui/html/login.html | 51 +++++++++++++++++++++---------------------- pkg/webui/html/logout.html | 6 +++--- pkg/webui/html/states.html | 51 +++++++++++++++++++++++++------------------ pkg/webui/index.go | 5 +++++ pkg/webui/login.go | 6 +++++- pkg/webui/logout.go | 7 +++++- pkg/webui/states.go | 2 ++ pkg/webui/static/main.css | 10 +++++++-- 11 files changed, 127 insertions(+), 75 deletions(-) (limited to 'pkg') diff --git a/pkg/webui/error.go b/pkg/webui/error.go index 05d8e9e..afce9a6 100644 --- a/pkg/webui/error.go +++ b/pkg/webui/error.go @@ -9,11 +9,13 @@ var errorTemplates = template.Must(template.ParseFS(htmlFS, "html/base.html", "h func errorResponse(w http.ResponseWriter, status int, err error) { type ErrorData struct { + Page Err error Status int StatusText string } render(w, errorTemplates, status, &ErrorData{ + Page: Page{Title: "Error", Section: "error"}, Err: err, Status: status, StatusText: http.StatusText(status), diff --git a/pkg/webui/html/base.html b/pkg/webui/html/base.html index 7821d28..06328e4 100644 --- a/pkg/webui/html/base.html +++ b/pkg/webui/html/base.html @@ -1,28 +1,50 @@ +{{ define "nav" }} +
+ +
+{{ if eq .Page.Section "login" }} + + login + Login + +{{ else }} + + home_storage + States + +
+ + logout + Logout + +{{ end }} +{{ end }} - + - - - tfstated + + + TFSTATED - {{ .Page.Title }} - -
+ + + + +
-
- {{ template "main" . }} -
-