feature: change all navigation to path based (#384)

* feature: change all navigation to path based

* bugfix: load default dashboard if actions is empty
This commit is contained in:
James Read
2024-08-14 11:35:10 +00:00
committed by GitHub
parent 37160a91f3
commit 9ca1940834
5 changed files with 184 additions and 122 deletions
+14 -1
View File
@@ -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,