Skip to content

Commit

Permalink
ui: add a link to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
safchain committed Feb 26, 2021
1 parent 237bbd7 commit 8eddf14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions statics/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
Status
</a>
</router-link>
<li>
<a href="/ui_v2" target="_blank" style="color: #54808e;">UI Version 2<sup>Beta</sup>
</a>
</li>
<router-link tag="li" to="/logout">
<a>
Logout
Expand Down
28 changes: 14 additions & 14 deletions ui/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

0 comments on commit 8eddf14

Please sign in to comment.