aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dashboard
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-10-08 15:22:58 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-10-08 15:52:07 -0400
commit9b13628980d48e5efd0cc582c80a4a3e94a59a25 (patch)
treece61517801f7a4510d02ee8fa6cf830d41e452c3 /dashboard
parent3f5e6e9c3ebb396949b091ee43b76d3303401fd3 (diff)
Remove dashboard rendering
The dashboard html falls out of the responsibility of the backend. The static site provides the html.
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/dashboard.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/dashboard/dashboard.go b/dashboard/dashboard.go
deleted file mode 100644
index 8daf375..0000000
--- a/dashboard/dashboard.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package dashboard
-
-import (
- "html/template"
- "log/slog"
- "net/http"
- "nonsense-time/api"
- "path/filepath"
-)
-
-var Logger *slog.Logger
-var templates map[string]*template.Template
-
-func getStatuses() {
-
-}
-
-func Index(w http.ResponseWriter, req *http.Request) {
- t, ok := templates["dashboard"]
-
- if !ok {
- panic(t)
- }
-
- // TODO: poll database
- data := struct {
- ServerStatus api.ServerStatus
- }{
- ServerStatus: api.ServerStatus{},
- }
-
- err := t.Execute(w, data)
- if err != nil {
- Logger.Error("Unable to execute template", slog.Any("err", err))
- http.Error(w, "Internal Server Error", http.StatusInternalServerError)
- return
- }
-}
-
-func StaticHandler(w http.ResponseWriter, req *http.Request) {
- http.StripPrefix("/static", http.FileServer(http.Dir("static"))).ServeHTTP(w, req)
-}
-
-func init() {
- Logger = slog.Default()
- templates = make(map[string]*template.Template)
- templates["dashboard"] = template.Must(template.New("base.html").ParseFiles(
- filepath.Join("templates", "base.html"),
- filepath.Join("templates", "dashboard", "dashboard.html"),
- filepath.Join("templates", "dashboard", "server_status.html"),
- filepath.Join("templates", "dashboard", "server_controls.html"),
- filepath.Join("templates", "dashboard", "server_logs.html"),
- ))
-}