Should (mostly) fix the new history page.

This commit is contained in:
2023-01-11 14:09:08 -08:00
parent 045aa01edc
commit b096863842
4 changed files with 82 additions and 82 deletions

View File

@@ -11,47 +11,42 @@
[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\") ;
(defn html-page [hiccup]
{:status 200
:headers {"Content-Type" "text/html"}
:body (str (hiccup/html
{}
hiccup))})
console.log(event.detail.headers[\"Authorization\"]);
});
}"))
(defn base-page [request contents]
[:html.has-navbar-fixed-top
[:head
[:meta {:charset "utf-8"}]
[:meta {:http-equiv "X-UA-Compatible", :content "IE=edge"}]
[:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
[:title "Integreat"]
[:link {:rel "stylesheet", :href "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css", :integrity "sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=", :crossorigin "anonymous"}]
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
[:link {:rel "stylesheet", :href "/css/bulma.min.css"}]
[:link {:rel "stylesheet", :href "/css/bulma-calendar.min.css"}]
[:link {:rel "stylesheet", :href "/css/bulma-badge.min.css"}]
[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
[:link {:rel "stylesheet", :href "/css/animate.css"}]
[:link {:rel "stylesheet", :href "/finance-font/style.css"}]
[: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 (setup-script request))]]
[:body
[:div {:id "app"}
[:div
[:nav {:class "navbar has-shadow is-fixed-top is-grey"}
(defn base-page [contents]
(html-page
[:html.has-navbar-fixed-top
[:head
[:meta {:charset "utf-8"}]
[:meta {:http-equiv "X-UA-Compatible", :content "IE=edge"}]
[:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
[:title "Integreat"]
[:link {:rel "stylesheet", :href "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css", :integrity "sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=", :crossorigin "anonymous"}]
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
[:link {:rel "stylesheet", :href "/css/bulma.min.css"}]
[:link {:rel "stylesheet", :href "/css/bulma-calendar.min.css"}]
[:link {:rel "stylesheet", :href "/css/bulma-badge.min.css"}]
[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
[:link {:rel "stylesheet", :href "/css/animate.css"}]
[:link {:rel "stylesheet", :href "/finance-font/style.css"}]
[: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" }]]
[:body
[:div {:id "app"}
[:div
[:nav {:class "navbar has-shadow is-fixed-top is-grey"}
[:div {:class "container"}
[:div {:class "navbar-brand"}
@@ -59,28 +54,28 @@ window.onload = function () {
[:img {:src "/img/logo.png"}]]]
[:div.navbar-menu {:id "navMenu"}
[:div.navbar-start
[:a.navbar-item {:href "/"}
[:a.navbar-item {:href "/"}
"Home" ]
[:a.navbar-item {:href "/invoices/"}
[:a.navbar-item {:href "/invoices/"}
"Invoices" ]
[:a.navbar-item {:href "/payments/"}
[:a.navbar-item {:href "/payments/"}
"Payments" ]
[:a.navbar-item {:href "/pos/sales-orders/"}
"POS" ]
[:a.navbar-item {:href "/transactions/"}
[:a.navbar-item {:href "/transactions/"}
"Transactions" ]
[:a.navbar-item {:href "/ledger/"}
[:a.navbar-item {:href "/ledger/"}
"Ledger" ]]]]]
[:div {:class "columns has-shadow", :id "mail-app", :style "margin-bottom: 0px; height: calc(100vh - 46px);"}
[:aside {:class "column aside menu is-2 "}
[:div {:class "main left-nav"}
[:div]]]
[:div {:class "column messages hero ", :id "message-feed", :style "overflow: auto;"}
[:div {:class "inbox-messages"}
contents]]]
[:div]
[:div {:id "dz-hidden"}]]]]])
[:div {:class "columns has-shadow", :id "mail-app", :style "margin-bottom: 0px; height: calc(100vh - 46px);"}
[:aside {:class "column aside menu is-2 "}
[:div {:class "main left-nav"}
[:div]]]
[:div {:class "column messages hero ", :id "message-feed", :style "overflow: auto;"}
[:div {:class "inbox-messages"}
contents]]]
[:div]
[:div {:id "dz-hidden"}]]]]]))
(defn html-response [hiccup]
{:status 200
@@ -158,7 +153,6 @@ window.onload = function () {
table]])
(defn history-search [{:keys [form-params params] identity :identity :as request}]
(assert-admin identity)
(log/info ::request
request)
@@ -207,10 +201,10 @@ window.onload = function () {
(for [[tx a c] history]
[:tr
[:td (:db/id tx)]
[:td (-> (:db/txInstant tx)
coerce/to-date-time
atime/localize
(atime/unparse atime/standard-time))]
[:td (some-> (:db/txInstant tx)
coerce/to-date-time
atime/localize
(atime/unparse atime/standard-time))]
[:td (str (:audit/user tx))]
[:td (namespace a) ": " (name a)]
[:td
@@ -230,12 +224,11 @@ window.onload = function () {
(alog/info ::trace
:bge best-guess-entity
:headers (:headers request))
(html-response
(if (get (:headers request) "hx-request")
table
(base-page request
(page-template :table table
:entity-id entity-id)))))
(if (get (:headers request) "hx-request")
(html-response
table)
(base-page (page-template :table table
:entity-id entity-id))))
(catch NumberFormatException e
(html-response
(str [:div.notification.is-danger.is-light
@@ -268,8 +261,7 @@ window.onload = function () {
"Cannot parse the entity-id " entity-id ". It should be a number."]))))
(defn history [{:keys [identity] :as request}]
(html-response
(base-page request (page-template ))))
(base-page (page-template )))
(defroutes admin-routes
(routes