Should (mostly) fix the new history page.
This commit is contained in:
@@ -2,21 +2,21 @@
|
|||||||
(:require
|
(:require
|
||||||
[amazonica.core :refer [defcredential]]
|
[amazonica.core :refer [defcredential]]
|
||||||
[auto-ap.client-routes :as client-routes]
|
[auto-ap.client-routes :as client-routes]
|
||||||
[auto-ap.ssr.admin :as ssr-admin]
|
|
||||||
[auto-ap.routes.auth :as auth]
|
[auto-ap.routes.auth :as auth]
|
||||||
[auto-ap.routes.exports :as exports]
|
[auto-ap.routes.exports :as exports]
|
||||||
|
[auto-ap.routes.ezcater :as ezcater]
|
||||||
[auto-ap.routes.graphql :as graphql]
|
[auto-ap.routes.graphql :as graphql]
|
||||||
[auto-ap.routes.invoices :as invoices]
|
[auto-ap.routes.invoices :as invoices]
|
||||||
[auto-ap.routes.queries :as queries]
|
[auto-ap.routes.queries :as queries]
|
||||||
[auto-ap.routes.ezcater :as ezcater]
|
|
||||||
[auto-ap.routes.yodlee2 :as yodlee2]
|
[auto-ap.routes.yodlee2 :as yodlee2]
|
||||||
|
[auto-ap.ssr.admin :as ssr-admin]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
|
[buddy.auth.backends.session :refer [session-backend]]
|
||||||
[buddy.auth.backends.token :refer [jws-backend]]
|
[buddy.auth.backends.token :refer [jws-backend]]
|
||||||
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
|
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
#_{:clj-kondo/ignore [:refer-all]}
|
[compojure.core :refer [ANY context defroutes GET routes]]
|
||||||
[compojure.core :refer [defroutes GET routes context ANY]]
|
|
||||||
[compojure.route :as route]
|
[compojure.route :as route]
|
||||||
[config.core :refer [env]]
|
[config.core :refer [env]]
|
||||||
[mount.core :as mount]
|
[mount.core :as mount]
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
[ring.middleware.multipart-params :as mp]
|
[ring.middleware.multipart-params :as mp]
|
||||||
[ring.middleware.params :refer [wrap-params]]
|
[ring.middleware.params :refer [wrap-params]]
|
||||||
[ring.middleware.reload :refer [wrap-reload]]
|
[ring.middleware.reload :refer [wrap-reload]]
|
||||||
|
[ring.middleware.session :refer [wrap-session]]
|
||||||
[ring.util.response :as response]
|
[ring.util.response :as response]
|
||||||
[unilog.context :as lc]))
|
[unilog.context :as lc]))
|
||||||
|
|
||||||
@@ -93,8 +94,12 @@
|
|||||||
(def app
|
(def app
|
||||||
(-> #'app-routes
|
(-> #'app-routes
|
||||||
(wrap-logging)
|
(wrap-logging)
|
||||||
(wrap-authorization auth-backend)
|
(wrap-authorization auth-backend
|
||||||
(wrap-authentication auth-backend)
|
)
|
||||||
|
(wrap-authentication auth-backend
|
||||||
|
(session-backend))
|
||||||
|
|
||||||
|
(wrap-session)
|
||||||
(wrap-reload)
|
(wrap-reload)
|
||||||
(wrap-params)
|
(wrap-params)
|
||||||
(mp/wrap-multipart-params)
|
(mp/wrap-multipart-params)
|
||||||
|
|||||||
@@ -39,22 +39,25 @@
|
|||||||
:user/provider-id (:id profile)
|
:user/provider-id (:id profile)
|
||||||
:user/role :user-role/none
|
:user/role :user-role/none
|
||||||
:user/name (:name profile)})
|
:user/name (:name profile)})
|
||||||
|
auth {:user (:name profile)
|
||||||
|
:exp (time/plus (time/now) (time/days 30))
|
||||||
|
:user/clients (map (fn [c]
|
||||||
|
(select-keys c [:client/code :db/id :client/name :client/locations]))
|
||||||
|
(:user/clients user))
|
||||||
|
:user/role (name (:user/role user))
|
||||||
|
:user/name (:name profile)}
|
||||||
]
|
]
|
||||||
(log/info "authenticated as user" user)
|
(log/info "authenticated as user" user)
|
||||||
;; TODO - these namespaces are not being transmitted/deserialized properly
|
;; TODO - these namespaces are not being transmitted/deserialized properly
|
||||||
|
|
||||||
(if (and token user)
|
(if (and token user)
|
||||||
(let [jwt (jwt/sign {:user (:name profile)
|
(let [jwt (jwt/sign auth
|
||||||
:exp (time/plus (time/now) (time/days 30))
|
|
||||||
:user/clients (map (fn [c]
|
|
||||||
(select-keys c [:client/code :db/id :client/name :client/locations]))
|
|
||||||
(:user/clients user))
|
|
||||||
:user/role (name (:user/role user))
|
|
||||||
:user/name (:name profile)}
|
|
||||||
(:jwt-secret env)
|
(:jwt-secret env)
|
||||||
{:alg :hs512})]
|
{:alg :hs512})]
|
||||||
|
|
||||||
{:status 301
|
{:status 301
|
||||||
:headers {"Location" (str "/?jwt=" jwt)}})
|
:headers {"Location" (str "/?jwt=" jwt)}
|
||||||
|
:session {:identity auth}})
|
||||||
{:status 401
|
{:status 401
|
||||||
:body "Couldn't authenticate"}))
|
:body "Couldn't authenticate"}))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
|
|||||||
@@ -11,47 +11,42 @@
|
|||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
[hiccup2.core :as hiccup]))
|
[hiccup2.core :as hiccup]))
|
||||||
|
|
||||||
(defn setup-script [request]
|
(defn html-page [hiccup]
|
||||||
(str
|
{:status 200
|
||||||
"
|
:headers {"Content-Type" "text/html"}
|
||||||
window.onload = function () {
|
:body (str (hiccup/html
|
||||||
document.body.addEventListener(\"htmx:configRequest\", function(event) {
|
{}
|
||||||
event.detail.headers[\"Authorization\"] = \"Token \" + localStorage.getItem(\"jwt\") ;
|
hiccup))})
|
||||||
|
|
||||||
console.log(event.detail.headers[\"Authorization\"]);
|
(defn base-page [contents]
|
||||||
});
|
(html-page
|
||||||
}"))
|
[:html.has-navbar-fixed-top
|
||||||
|
[:head
|
||||||
(defn base-page [request contents]
|
[:meta {:charset "utf-8"}]
|
||||||
[:html.has-navbar-fixed-top
|
[:meta {:http-equiv "X-UA-Compatible", :content "IE=edge"}]
|
||||||
[:head
|
[:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
|
||||||
[:meta {:charset "utf-8"}]
|
[:title "Integreat"]
|
||||||
[:meta {:http-equiv "X-UA-Compatible", :content "IE=edge"}]
|
[: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"}]
|
||||||
[:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
|
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
|
||||||
[:title "Integreat"]
|
[:link {:rel "stylesheet", :href "/css/bulma.min.css"}]
|
||||||
[: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 {:rel "stylesheet", :href "/css/bulma-calendar.min.css"}]
|
||||||
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
|
[:link {:rel "stylesheet", :href "/css/bulma-badge.min.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/bulma.min.css"}]
|
[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/bulma-calendar.min.css"}]
|
[:link {:rel "stylesheet", :href "/css/animate.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/bulma-badge.min.css"}]
|
[:link {:rel "stylesheet", :href "/finance-font/style.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
|
[:link {:rel "stylesheet", :href "/css/main.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/animate.css"}]
|
[:link {:rel "stylesheet", :href "https://unpkg.com/placeholder-loading/dist/css/placeholder-loading.min.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/finance-font/style.css"}]
|
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/main.css"}]
|
[:script {:src "https://unpkg.com/htmx.org@1.8.4"
|
||||||
[:link {:rel "stylesheet", :href "https://unpkg.com/placeholder-loading/dist/css/placeholder-loading.min.css"}]
|
:integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV"
|
||||||
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7"}]
|
:crossorigin= "anonymous"}]
|
||||||
[:script {:src "https://unpkg.com/htmx.org@1.8.4"
|
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }]]
|
||||||
: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
|
||||||
[:script {:type "text/javascript"}
|
[:div {:id "app"}
|
||||||
(hiccup/raw (setup-script request))]]
|
[:div
|
||||||
|
[:nav {:class "navbar has-shadow is-fixed-top is-grey"}
|
||||||
|
|
||||||
[:body
|
|
||||||
[:div {:id "app"}
|
|
||||||
[:div
|
|
||||||
[:nav {:class "navbar has-shadow is-fixed-top is-grey"}
|
|
||||||
|
|
||||||
[:div {:class "container"}
|
[:div {:class "container"}
|
||||||
[:div {:class "navbar-brand"}
|
[:div {:class "navbar-brand"}
|
||||||
@@ -59,28 +54,28 @@ window.onload = function () {
|
|||||||
[:img {:src "/img/logo.png"}]]]
|
[:img {:src "/img/logo.png"}]]]
|
||||||
[:div.navbar-menu {:id "navMenu"}
|
[:div.navbar-menu {:id "navMenu"}
|
||||||
[:div.navbar-start
|
[:div.navbar-start
|
||||||
[:a.navbar-item {:href "/"}
|
[:a.navbar-item {:href "/"}
|
||||||
"Home" ]
|
"Home" ]
|
||||||
[:a.navbar-item {:href "/invoices/"}
|
[:a.navbar-item {:href "/invoices/"}
|
||||||
"Invoices" ]
|
"Invoices" ]
|
||||||
[:a.navbar-item {:href "/payments/"}
|
[:a.navbar-item {:href "/payments/"}
|
||||||
"Payments" ]
|
"Payments" ]
|
||||||
[:a.navbar-item {:href "/pos/sales-orders/"}
|
[:a.navbar-item {:href "/pos/sales-orders/"}
|
||||||
"POS" ]
|
"POS" ]
|
||||||
[:a.navbar-item {:href "/transactions/"}
|
[:a.navbar-item {:href "/transactions/"}
|
||||||
"Transactions" ]
|
"Transactions" ]
|
||||||
|
|
||||||
[:a.navbar-item {:href "/ledger/"}
|
[:a.navbar-item {:href "/ledger/"}
|
||||||
"Ledger" ]]]]]
|
"Ledger" ]]]]]
|
||||||
[:div {:class "columns has-shadow", :id "mail-app", :style "margin-bottom: 0px; height: calc(100vh - 46px);"}
|
[:div {:class "columns has-shadow", :id "mail-app", :style "margin-bottom: 0px; height: calc(100vh - 46px);"}
|
||||||
[:aside {:class "column aside menu is-2 "}
|
[:aside {:class "column aside menu is-2 "}
|
||||||
[:div {:class "main left-nav"}
|
[:div {:class "main left-nav"}
|
||||||
[:div]]]
|
[:div]]]
|
||||||
[:div {:class "column messages hero ", :id "message-feed", :style "overflow: auto;"}
|
[:div {:class "column messages hero ", :id "message-feed", :style "overflow: auto;"}
|
||||||
[:div {:class "inbox-messages"}
|
[:div {:class "inbox-messages"}
|
||||||
contents]]]
|
contents]]]
|
||||||
[:div]
|
[:div]
|
||||||
[:div {:id "dz-hidden"}]]]]])
|
[:div {:id "dz-hidden"}]]]]]))
|
||||||
|
|
||||||
(defn html-response [hiccup]
|
(defn html-response [hiccup]
|
||||||
{:status 200
|
{:status 200
|
||||||
@@ -158,7 +153,6 @@ window.onload = function () {
|
|||||||
table]])
|
table]])
|
||||||
|
|
||||||
(defn history-search [{:keys [form-params params] identity :identity :as request}]
|
(defn history-search [{:keys [form-params params] identity :identity :as request}]
|
||||||
|
|
||||||
(assert-admin identity)
|
(assert-admin identity)
|
||||||
(log/info ::request
|
(log/info ::request
|
||||||
request)
|
request)
|
||||||
@@ -207,10 +201,10 @@ window.onload = function () {
|
|||||||
(for [[tx a c] history]
|
(for [[tx a c] history]
|
||||||
[:tr
|
[:tr
|
||||||
[:td (:db/id tx)]
|
[:td (:db/id tx)]
|
||||||
[:td (-> (:db/txInstant tx)
|
[:td (some-> (:db/txInstant tx)
|
||||||
coerce/to-date-time
|
coerce/to-date-time
|
||||||
atime/localize
|
atime/localize
|
||||||
(atime/unparse atime/standard-time))]
|
(atime/unparse atime/standard-time))]
|
||||||
[:td (str (:audit/user tx))]
|
[:td (str (:audit/user tx))]
|
||||||
[:td (namespace a) ": " (name a)]
|
[:td (namespace a) ": " (name a)]
|
||||||
[:td
|
[:td
|
||||||
@@ -230,12 +224,11 @@ window.onload = function () {
|
|||||||
(alog/info ::trace
|
(alog/info ::trace
|
||||||
:bge best-guess-entity
|
:bge best-guess-entity
|
||||||
:headers (:headers request))
|
:headers (:headers request))
|
||||||
(html-response
|
(if (get (:headers request) "hx-request")
|
||||||
(if (get (:headers request) "hx-request")
|
(html-response
|
||||||
table
|
table)
|
||||||
(base-page request
|
(base-page (page-template :table table
|
||||||
(page-template :table table
|
:entity-id entity-id))))
|
||||||
:entity-id entity-id)))))
|
|
||||||
(catch NumberFormatException e
|
(catch NumberFormatException e
|
||||||
(html-response
|
(html-response
|
||||||
(str [:div.notification.is-danger.is-light
|
(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."]))))
|
"Cannot parse the entity-id " entity-id ". It should be a number."]))))
|
||||||
|
|
||||||
(defn history [{:keys [identity] :as request}]
|
(defn history [{:keys [identity] :as request}]
|
||||||
(html-response
|
(base-page (page-template )))
|
||||||
(base-page request (page-template ))))
|
|
||||||
|
|
||||||
(defroutes admin-routes
|
(defroutes admin-routes
|
||||||
(routes
|
(routes
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
||||||
[:span {:class "name"} "Rules"]]]
|
[:span {:class "name"} "Rules"]]]
|
||||||
[:li.menu-item
|
[:li.menu-item
|
||||||
[:a {:href (str "/admin/history?jwt=" (.getItem js/localStorage "jwt")) :class (str "item" (active-when ap = :admin-history))}
|
[:a {:href (str "/admin/history") :class (str "item" (active-when ap = :admin-history))}
|
||||||
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
||||||
[:span {:class "name"} "History "]]]
|
[:span {:class "name"} "History "]]]
|
||||||
[:ul ]]
|
[:ul ]]
|
||||||
|
|||||||
Reference in New Issue
Block a user