From 9ca19408342b7db23b1010d4173fa4786b6766e3 Mon Sep 17 00:00:00 2001 From: James Read Date: Wed, 14 Aug 2024 12:35:10 +0100 Subject: [PATCH] feature: change all navigation to path based (#384) * feature: change all navigation to path based * bugfix: load default dashboard if actions is empty --- internal/httpservers/webuiServer.go | 15 +- webui.dev/index.html | 15 +- webui.dev/js/marshaller.js | 269 ++++++++++++++++------------ webui.dev/js/websocket.js | 2 +- webui.dev/main.js | 5 +- 5 files changed, 184 insertions(+), 122 deletions(-) diff --git a/internal/httpservers/webuiServer.go b/internal/httpservers/webuiServer.go index 83b7bde..a9c73e8 100644 --- a/internal/httpservers/webuiServer.go +++ b/internal/httpservers/webuiServer.go @@ -135,11 +135,24 @@ func startWebUIServer(cfg *config.Config) { setupCustomWebuiDir() mux := http.NewServeMux() - mux.Handle("/", http.FileServer(http.Dir(findWebuiDir()))) mux.Handle("/custom-webui/", http.StripPrefix("/custom-webui/", http.FileServer(http.Dir(findCustomWebuiDir())))) mux.HandleFunc("/theme.css", generateThemeCss) mux.HandleFunc("/webUiSettings.json", generateWebUISettings) + webuiDir := findWebuiDir() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + dirName := path.Dir(r.URL.Path) + + // Mangle requests for any path like /logs or /config to load the webui index.html + if path.Ext(r.URL.Path) == "" && r.URL.Path != "/" { + log.Infof("Mangling request for %s to /index.html", r.URL.Path) + + http.ServeFile(w, r, path.Join(webuiDir, "index.html")) + } else { + http.StripPrefix(dirName, http.FileServer(http.Dir(webuiDir))).ServeHTTP(w, r) + } + }) + srv := &http.Server{ Addr: cfg.ListenAddressWebUI, Handler: mux, diff --git a/webui.dev/index.html b/webui.dev/index.html index 14f8850..f7d0907 100644 --- a/webui.dev/index.html +++ b/webui.dev/index.html @@ -8,8 +8,8 @@ OliveTin - - + + @@ -17,6 +17,8 @@ + + @@ -28,16 +30,16 @@ @@ -64,7 +66,6 @@