From 8eddf14a2327a0fd2a043a3860c542a566040982 Mon Sep 17 00:00:00 2001 From: Sylvain Afchain Date: Thu, 25 Feb 2021 01:36:04 +0100 Subject: [PATCH] ui: add a link to v2 --- statics/ui/index.html | 4 ++++ ui/server.go | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/statics/ui/index.html b/statics/ui/index.html index 2db7130100..2aee64e517 100644 --- a/statics/ui/index.html +++ b/statics/ui/index.html @@ -168,6 +168,10 @@ Status +
  • + UI Version 2Beta + +
  • Logout diff --git a/ui/server.go b/ui/server.go index 23ff0ebd00..8b801b411d 100644 --- a/ui/server.go +++ b/ui/server.go @@ -164,12 +164,12 @@ func (s *Server) ServeIndex(index string, baseURL string) func(w http.ResponseWr ExtraAssets map[string]ExtraAsset GlobalVars interface{} Permissions []rbac.Permission - BaseURL string + BaseURL string }{ ExtraAssets: s.extraAssets, GlobalVars: s.globalVars, Permissions: permissions, - BaseURL: baseURL, + BaseURL: baseURL, } shttp.SetTLSHeader(w, &r.Request) @@ -196,24 +196,24 @@ func NewServer(server *shttp.Server, assetsFolder string) *Server { s.loadExtraAssets(assetsFolder, ExtraAssetPrefix) } - router.HandleFunc("/", shttp.NoAuthenticationWrap(s.ServeIndex("statics/ui/index.html", "/ui/"))) + // server index for the following url as the client side will redirect + // the user to the correct page + routes := []shttp.Route{ + {Path: "/", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + {Path: "/ui/", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + {Path: "/ui/login", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + {Path: "/ui/topology", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + {Path: "/ui/preference", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + {Path: "/ui/status", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, + } + server.RegisterRoutes(routes, shttp.NewNoAuthenticationBackend()) + router.PathPrefix("/ui/").HandlerFunc(s.serveStatics()) router.PathPrefix(ExtraAssetPrefix).HandlerFunc(s.serveStatics()) - // v2 router.HandleFunc("/ui_v2", shttp.NoAuthenticationWrap(s.ServeIndex("statics/ui_v2/index.html", "/ui_v2/"))) router.PathPrefix("/ui_v2/").HandlerFunc(s.serveStatics()) - - - // server index for the following url as the client side will redirect - // the user to the correct page - routes := []shttp.Route{ - {Path: "/topology", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, - {Path: "/preference", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, - {Path: "/status", Method: "GET", HandlerFunc: s.ServeIndex("statics/ui/index.html", "/ui/")}, - } - server.RegisterRoutes(routes, shttp.NewNoAuthenticationBackend()) return s }