Makes the history page use local storage

This commit is contained in:
2023-01-11 13:15:46 -08:00
parent 3a2dc07227
commit 045aa01edc
2 changed files with 20 additions and 14 deletions

View File

@@ -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
"<!DOCTYPE html>"
(hiccup/html
{}
hiccup))})

View File

@@ -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