diff --git a/src/clj/auto_ap/ssr/admin.clj b/src/clj/auto_ap/ssr/admin.clj index d135464f..2ab8462f 100644 --- a/src/clj/auto_ap/ssr/admin.clj +++ b/src/clj/auto_ap/ssr/admin.clj @@ -11,6 +11,17 @@ [datomic.api :as d] [hiccup2.core :as hiccup])) +(defn setup-script [request] + (str + " +window.onload = function () { + document.body.addEventListener(\"htmx:configRequest\", function(event) { + event.detail.headers[\"Authorization\"] = \"Token \" + localStorage.getItem(\"jwt\") ; + + console.log(event.detail.headers[\"Authorization\"]); + }); +}")) + (defn base-page [request contents] [:html.has-navbar-fixed-top [:head @@ -29,19 +40,13 @@ [:link {:rel "stylesheet", :href "/css/main.css"}] [:link {:rel "stylesheet", :href "https://unpkg.com/placeholder-loading/dist/css/placeholder-loading.min.css"}] [:script {:src "https://unpkg.com/hyperscript.org@0.9.7"}] - [:script {:src "https://unpkg.com/htmx.org@1.8.4" - :integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" - :crossorigin="anonymous"}] - [:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }]] - [:script {:type "text/javascript"} - (hiccup/raw - (str - " -window.onload = function () { - document.body.addEventListener(\"htmx:configRequest\", function(event) { - event.detail.headers[\"Authorization\"] = \"Token " (get (:query-params request) "jwt")" \" ; - }); -}"))] + [:script {:src "https://unpkg.com/htmx.org@1.8.4" + :integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" + :crossorigin= "anonymous"}] + [:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }] + [:script {:type "text/javascript"} + (hiccup/raw (setup-script request))]] + [:body [:div {:id "app"} @@ -81,6 +86,7 @@ window.onload = function () { {:status 200 :headers {"Content-Type" "text/html"} :body (str + "" (hiccup/html {} hiccup))}) diff --git a/src/cljs/auto_ap/views/components/admin/side_bar.cljs b/src/cljs/auto_ap/views/components/admin/side_bar.cljs index cb0dc0b8..4f7b42ac 100644 --- a/src/cljs/auto_ap/views/components/admin/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/admin/side_bar.cljs @@ -48,7 +48,7 @@ [:li.menu-item [:a {:href (str "/admin/history?jwt=" (.getItem js/localStorage "jwt")) :class (str "item" (active-when ap = :admin-history))} [:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}] - [:span {:class "name"} "History"]]] + [:span {:class "name"} "History "]]] [:ul ]] [:p.menu-label "Import"] [:ul.menu-list