Revamps all of the IOL's routing, so that the new history page can share with the rest.

This commit is contained in:
2023-01-12 16:56:40 -08:00
parent ce01a63797
commit 46dd191391
29 changed files with 1294 additions and 1053 deletions

108
src/clj/auto_ap/ssr/ui.clj Normal file
View File

@@ -0,0 +1,108 @@
(ns auto-ap.ssr.ui
(:require
[auto-ap.logging :as alog]
[config.core :refer [env]]
[hiccup2.core :as hiccup]))
(defn html-page [hiccup]
{:status 200
:headers {"Content-Type" "text/html"}
:body (str
"<!DOCTYPE html>"
(hiccup/html
{}
hiccup))})
(defn base-page [contents side-bar-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"}
[:a {:class "navbar-item", :href "../"}
[:img {:src "/img/logo.png"}]]]
[:div.navbar-menu {:id "navMenu"}
[:div.navbar-start
[:a.navbar-item {:href "/"}
"Home" ]
[:a.navbar-item {:href "/invoices/"}
"Invoices" ]
[:a.navbar-item {:href "/payments/"}
"Payments" ]
[:a.navbar-item {:href "/pos/sales-orders/"}
"POS" ]
[:a.navbar-item {:href "/transactions/"}
"Transactions" ]
[: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"}
side-bar-contents]]
[: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 & {:keys [status] :or {status 200}}]
{:status status
:headers {"Content-Type" "text/html"}
:body (str
(hiccup/html
{}
hiccup))})
(defn wrap-error-response [handler]
(fn [request]
(try
(handler request)
(catch Exception e
(if-let [v (or (:validation-error (ex-data e))
(:validation-error (ex-data (.getCause e))))]
(do
(alog/warn ::request-validation-error
:exception e)
(html-response
[:div.notification.is-warning.is-light
v]
:status 400))
(do
(alog/error ::request-error
:exception e)
(when (= "dev" (:dd-env env))
(println e))
(html-response
[:div.notification.is-danger.is-light
"Server error occured."
(ex-message e)]
:status 500)))))))