Skip to content

Commit

Permalink
Merge pull request #439 from yetanalytics/admin-re-route
Browse files Browse the repository at this point in the history
Update base UI path to `/admin/ui`
  • Loading branch information
kelvinqian00 authored Jan 14, 2025
2 parents 74a4dd4 + 740f803 commit a20e679
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/main/lrsql/admin/interceptors/ui.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
(ns lrsql.admin.interceptors.ui
(:require [ring.util.response :as resp]
[selmer.parser :as selm-parser]
[io.pedestal.interceptor :refer [interceptor]]
[com.yetanalytics.lrs.pedestal.interceptor :as i]
[lrsql.admin.interceptors.oidc :as oidc-i]
[lrsql.init.localization :refer [custom-language-map]]))

(defn get-spa
"Handler function that returns the index.html file."
[path-prefix]
(fn [_]
(-> (selm-parser/render-file "public/admin/index.html"
{:prefix path-prefix})
resp/response
(resp/content-type "text/html"))))

(defn admin-ui-redirect
"Handler function to redirect to the admin ui"
"Handler function to redirect to the admin UI."
[path-prefix]
(fn [_]
(resp/redirect (str path-prefix "/admin/index.html"))))
(resp/redirect (str path-prefix "/admin/ui"))))

(defn get-env
"Provide select config data to client upon request. Takes a map with static
Expand Down
21 changes: 13 additions & 8 deletions src/main/lrsql/admin/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,23 @@

(defn admin-ui-routes
[common-interceptors {:keys [proxy-path] :as inject-config}]
#{;; Redirect root to admin UI
#{["/admin/env" :get (conj common-interceptors
(ui/get-env inject-config))
:route-name :lrsql.admin.ui/get-env]
;; SPA routes
["/admin/ui" :get (ui/get-spa proxy-path)
:route-name :lrsql.admin.ui/main-path]
["/admin/ui/" :get (ui/get-spa proxy-path)
:route-name :lrsql.admin.ui/slash-path]
["/admin/ui/*path" :get (ui/get-spa proxy-path)
:route-name :lrsql.admin.ui/sub-paths]
;; SPA redirects
["/" :get (ui/admin-ui-redirect proxy-path)
:route-name :lrsql.admin.ui/root-redirect]
;; Redirect admin w/o slash to admin UI
["/admin" :get (ui/admin-ui-redirect proxy-path)
:route-name :lrsql.admin.ui/path-redirect]
;; Redirect admin with slash to admin UI
["/admin/" :get (ui/admin-ui-redirect proxy-path)
:route-name :lrsql.admin.ui/slash-redirect]
["/admin/env" :get (conj common-interceptors
(ui/get-env inject-config))
:route-name :lrsql.admin.ui/get-env]})
["/admin/" :get (ui/admin-ui-redirect proxy-path)
:route-name :lrsql.admin.ui/slash-redirect-2]})

(defn admin-reaction-routes
[common-interceptors jwt-secret jwt-leeway no-val-opts]
Expand Down

0 comments on commit a20e679

Please # to comment.