adds glimpse for power users
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -10,6 +10,7 @@
|
|||||||
[auto-ap.routes.outgoing-invoice :as oi-routes]
|
[auto-ap.routes.outgoing-invoice :as oi-routes]
|
||||||
[auto-ap.routes.payments :as payment-routes]
|
[auto-ap.routes.payments :as payment-routes]
|
||||||
[auto-ap.ssr-routes :as ssr-routes]
|
[auto-ap.ssr-routes :as ssr-routes]
|
||||||
|
[auto-ap.ssr.components.tags :as tags]
|
||||||
[auto-ap.ssr.hiccup-helper :as hh]
|
[auto-ap.ssr.hiccup-helper :as hh]
|
||||||
[auto-ap.ssr.hx :as hx]
|
[auto-ap.ssr.hx :as hx]
|
||||||
[auto-ap.ssr.svg :as svg]
|
[auto-ap.ssr.svg :as svg]
|
||||||
@@ -45,8 +46,8 @@
|
|||||||
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
|
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
|
||||||
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
|
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
|
||||||
:x-ref "submenu"
|
:x-ref "submenu"
|
||||||
:style (cond-> {} (:active? params) (assoc "max-height" "400px"))
|
:style (cond-> {} (:active? params) (assoc "max-height" "900px"))
|
||||||
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
|
":style" (format "selected == '%s' ? 'max-height: ' + $el.scrollHeight + 'px' : ''" (:selector params))))
|
||||||
(for [c children]
|
(for [c children]
|
||||||
[:li
|
[:li
|
||||||
(update-in c [1 1 :class ] (fn [c]
|
(update-in c [1 1 :class ] (fn [c]
|
||||||
@@ -83,7 +84,7 @@
|
|||||||
|
|
||||||
(defn main-aside-nav- [request]
|
(defn main-aside-nav- [request]
|
||||||
(let [selected (cond
|
(let [selected (cond
|
||||||
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new} (:matched-route request))
|
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new :invoice-glimpse :invoice-glimpse-textract-invoice} (:matched-route request))
|
||||||
"invoices"
|
"invoices"
|
||||||
|
|
||||||
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
|
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
|
||||||
@@ -140,6 +141,17 @@
|
|||||||
:activity :import})
|
:activity :import})
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
:import-invoices)} "Import"))
|
:import-invoices)} "Import"))
|
||||||
|
|
||||||
|
(when (can? (:identity request)
|
||||||
|
{:subject :invoice
|
||||||
|
:activity :import})
|
||||||
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
|
:invoice-glimpse))
|
||||||
|
:active? (= :invoice-glimpse (:matched-route request))
|
||||||
|
:hx-boost "true"}
|
||||||
|
[:div.flex.gap-2
|
||||||
|
"Glimpse"
|
||||||
|
(tags/pill- {:color :secondary} "Beta")]))
|
||||||
|
|
||||||
|
|
||||||
(when (can? (:identity request)
|
(when (can? (:identity request)
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
(ns auto-ap.ssr.core
|
(ns auto-ap.ssr.core
|
||||||
(:require
|
(:require [auto-ap.permissions :refer [wrap-must]]
|
||||||
[auto-ap.routes.ezcater-xls :as ezcater-xls]
|
[auto-ap.routes.ezcater-xls :as ezcater-xls]
|
||||||
[auto-ap.routes.utils
|
[auto-ap.routes.utils
|
||||||
:refer [wrap-admin wrap-client-redirect-unauthenticated wrap-secure]]
|
:refer [wrap-admin wrap-client-redirect-unauthenticated wrap-secure]]
|
||||||
[auto-ap.ssr.account :as account]
|
[auto-ap.ssr.account :as account]
|
||||||
[auto-ap.ssr.payments :as payments]
|
[auto-ap.ssr.admin :as admin]
|
||||||
[auto-ap.ssr.admin :as admin]
|
[auto-ap.ssr.admin.accounts :as admin-accounts]
|
||||||
[auto-ap.ssr.admin.accounts :as admin-accounts]
|
[auto-ap.ssr.admin.background-jobs :as admin-jobs]
|
||||||
[auto-ap.ssr.admin.background-jobs :as admin-jobs]
|
[auto-ap.ssr.admin.clients :as admin-clients]
|
||||||
[auto-ap.ssr.admin.excel-invoice :as admin-excel-invoices]
|
[auto-ap.ssr.admin.excel-invoice :as admin-excel-invoices]
|
||||||
[auto-ap.ssr.admin.history :as history]
|
[auto-ap.ssr.admin.history :as history]
|
||||||
[auto-ap.ssr.admin.import-batch :as import-batch]
|
[auto-ap.ssr.admin.import-batch :as import-batch]
|
||||||
[auto-ap.ssr.admin.transaction-rules :as admin-rules]
|
[auto-ap.ssr.admin.sales-summaries :as admin-sales-summaries]
|
||||||
[auto-ap.ssr.admin.vendors :as admin-vendors]
|
[auto-ap.ssr.admin.transaction-rules :as admin-rules]
|
||||||
[auto-ap.ssr.admin.clients :as admin-clients]
|
[auto-ap.ssr.admin.vendors :as admin-vendors]
|
||||||
[auto-ap.ssr.admin.sales-summaries :as admin-sales-summaries]
|
[auto-ap.ssr.auth :as auth]
|
||||||
[auto-ap.ssr.auth :as auth]
|
[auto-ap.ssr.company :as company]
|
||||||
[auto-ap.ssr.indicators :as indicators]
|
[auto-ap.ssr.company-dropdown :as company-dropdown]
|
||||||
[auto-ap.ssr.company :as company]
|
[auto-ap.ssr.company.company-1099 :as company-1099]
|
||||||
[auto-ap.ssr.company-dropdown :as company-dropdown]
|
[auto-ap.ssr.company.plaid :as company-plaid]
|
||||||
[auto-ap.ssr.company.company-1099 :as company-1099]
|
[auto-ap.ssr.company.reports :as company-reports]
|
||||||
[auto-ap.ssr.company.plaid :as company-plaid]
|
[auto-ap.ssr.company.yodlee :as company-yodlee]
|
||||||
[auto-ap.ssr.company.reports :as company-reports]
|
[auto-ap.ssr.indicators :as indicators]
|
||||||
[auto-ap.ssr.company.yodlee :as company-yodlee]
|
[auto-ap.ssr.invoice.glimpse :as invoice-glimpse]
|
||||||
[auto-ap.ssr.invoice.glimpse :as invoice-glimpse]
|
[auto-ap.ssr.invoices :as invoice]
|
||||||
[auto-ap.ssr.pos.cash-drawer-shifts :as pos-cash-drawer-shifts]
|
[auto-ap.ssr.outgoing-invoice.new :as oin]
|
||||||
[auto-ap.ssr.pos.expected-deposits :as pos-expected-deposits]
|
[auto-ap.ssr.payments :as payments]
|
||||||
[auto-ap.ssr.pos.refunds :as pos-refunds]
|
[auto-ap.ssr.pos.cash-drawer-shifts :as pos-cash-drawer-shifts]
|
||||||
[auto-ap.ssr.pos.sales-orders :as pos-sales]
|
[auto-ap.ssr.pos.expected-deposits :as pos-expected-deposits]
|
||||||
[auto-ap.ssr.pos.tenders :as pos-tenders]
|
[auto-ap.ssr.pos.refunds :as pos-refunds]
|
||||||
[auto-ap.ssr.invoices :as invoice]
|
[auto-ap.ssr.pos.sales-orders :as pos-sales]
|
||||||
[auto-ap.ssr.outgoing-invoice.new :as oin]
|
[auto-ap.ssr.pos.tenders :as pos-tenders]
|
||||||
[auto-ap.ssr.search :as search]
|
[auto-ap.ssr.search :as search]
|
||||||
[auto-ap.ssr.transaction.insights :as insights]
|
[auto-ap.ssr.transaction.insights :as insights]
|
||||||
[auto-ap.ssr.users :as users]
|
[auto-ap.ssr.users :as users]
|
||||||
[auto-ap.ssr.vendor :as vendors]
|
[auto-ap.ssr.vendor :as vendors]
|
||||||
[ring.middleware.json :refer [wrap-json-response]]))
|
[ring.middleware.json :refer [wrap-json-response]]))
|
||||||
|
|
||||||
;; from auto-ap.ssr-routes, because they're shared
|
;; from auto-ap.ssr-routes, because they're shared
|
||||||
|
|
||||||
@@ -66,11 +66,11 @@
|
|||||||
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
|
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
|
||||||
:company-yodlee-provider-account-refresh (wrap-client-redirect-unauthenticated (wrap-admin company-yodlee/refresh-provider-account))
|
:company-yodlee-provider-account-refresh (wrap-client-redirect-unauthenticated (wrap-admin company-yodlee/refresh-provider-account))
|
||||||
:company-yodlee-provider-account-reauthenticate (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/reauthenticate))
|
:company-yodlee-provider-account-reauthenticate (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/reauthenticate))
|
||||||
:invoice-glimpse (wrap-client-redirect-unauthenticated (wrap-admin invoice-glimpse/page))
|
:invoice-glimpse (wrap-client-redirect-unauthenticated (wrap-must (wrap-secure invoice-glimpse/page) {:activity :import :subject :invoice}))
|
||||||
:invoice-glimpse-upload (wrap-client-redirect-unauthenticated (wrap-admin invoice-glimpse/upload))
|
:invoice-glimpse-upload (wrap-client-redirect-unauthenticated (wrap-must (wrap-secure invoice-glimpse/upload) {:activity :import :subject :invoice}))
|
||||||
:invoice-glimpse-textract-invoice (wrap-client-redirect-unauthenticated (wrap-admin invoice-glimpse/textract-invoice))
|
:invoice-glimpse-textract-invoice (wrap-client-redirect-unauthenticated (wrap-must (wrap-secure invoice-glimpse/textract-invoice) {:activity :import :subject :invoice}))
|
||||||
:invoice-glimpse-create-invoice (wrap-client-redirect-unauthenticated (wrap-admin invoice-glimpse/create-invoice))
|
:invoice-glimpse-create-invoice (wrap-client-redirect-unauthenticated (wrap-must (wrap-secure invoice-glimpse/create-invoice) {:activity :import :subject :invoice}))
|
||||||
:invoice-glimpse-update-textract-invoice (wrap-client-redirect-unauthenticated (wrap-admin invoice-glimpse/update-textract-invoice))
|
:invoice-glimpse-update-textract-invoice (wrap-client-redirect-unauthenticated (wrap-must (wrap-secure invoice-glimpse/update-textract-invoice) {:activity :import :subject :invoice}))
|
||||||
:vendor-search (wrap-client-redirect-unauthenticated (wrap-secure vendors/search))
|
:vendor-search (wrap-client-redirect-unauthenticated (wrap-secure vendors/search))
|
||||||
:transaction-insights (wrap-client-redirect-unauthenticated (wrap-admin insights/page))
|
:transaction-insights (wrap-client-redirect-unauthenticated (wrap-admin insights/page))
|
||||||
:transaction-insight-table (wrap-client-redirect-unauthenticated (wrap-admin insights/insight-table))
|
:transaction-insight-table (wrap-client-redirect-unauthenticated (wrap-admin insights/insight-table))
|
||||||
|
|||||||
@@ -1,33 +1,32 @@
|
|||||||
|
|
||||||
(ns auto-ap.ssr.invoice.glimpse
|
(ns auto-ap.ssr.invoice.glimpse
|
||||||
(:require
|
(:require [amazonica.aws.s3 :as s3]
|
||||||
[amazonica.aws.s3 :as s3]
|
[amazonica.aws.textract :as textract]
|
||||||
[amazonica.aws.textract :as textract]
|
[auto-ap.client-routes :as client-routes]
|
||||||
[auto-ap.datomic :refer [conn pull-attr pull-id]]
|
[auto-ap.datomic :refer [conn pull-attr]]
|
||||||
[auto-ap.datomic.clients :as d-clients]
|
[auto-ap.datomic.clients :as d-clients]
|
||||||
[auto-ap.logging :as alog]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.solr :as solr]
|
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||||
[auto-ap.ssr-routes :as ssr-routes]
|
[auto-ap.logging :as alog]
|
||||||
[auto-ap.ssr.components :as com]
|
[auto-ap.solr :as solr]
|
||||||
[auto-ap.ssr.ui :refer [base-page]]
|
[auto-ap.ssr-routes :as ssr-routes]
|
||||||
[auto-ap.ssr.utils :refer [html-response path->name]]
|
[auto-ap.ssr.components :as com]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.ssr.ui :refer [base-page]]
|
||||||
[bidi.bidi :as bidi]
|
[auto-ap.ssr.utils :refer [html-response path->name]]
|
||||||
[cemerick.url :as url]
|
[auto-ap.time :as atime]
|
||||||
[clj-time.coerce :as coerce]
|
[bidi.bidi :as bidi]
|
||||||
[cheshire.core :as cheshire]
|
[cemerick.url :as url]
|
||||||
[clojure.java.io :as io]
|
[cheshire.core :as cheshire]
|
||||||
[clojure.string :as str]
|
[clj-time.coerce :as coerce]
|
||||||
[com.brunobonacci.mulog :as mu]
|
[clj-time.core :as time]
|
||||||
[config.core :refer [env]]
|
[clojure.java.io :as io]
|
||||||
[datomic.api :as dc]
|
[clojure.string :as str]
|
||||||
[hiccup2.core :as hiccup]
|
[com.brunobonacci.mulog :as mu]
|
||||||
[iol-ion.tx :refer [random-tempid]]
|
[config.core :refer [env]]
|
||||||
[auto-ap.client-routes :as client-routes]
|
[datomic.api :as dc]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[hiccup2.core :as hiccup]
|
||||||
[clj-time.core :as time])
|
[iol-ion.tx :refer [random-tempid]])
|
||||||
(:import
|
(:import (java.util UUID)))
|
||||||
(java.util UUID)))
|
|
||||||
|
|
||||||
(def bucket-name (:data-bucket env))
|
(def bucket-name (:data-bucket env))
|
||||||
|
|
||||||
@@ -63,8 +62,12 @@
|
|||||||
[[] #{}]
|
[[] #{}]
|
||||||
xs)))
|
xs)))
|
||||||
|
|
||||||
(defn textract->textract-invoice [id tx]
|
(defn textract->textract-invoice [request id tx]
|
||||||
(let [lookup (lookup tx)
|
(let [lookup (lookup tx)
|
||||||
|
valid-client-ids (extract-client-ids (:clients request)
|
||||||
|
(:client-id request)
|
||||||
|
(when (:client-code request)
|
||||||
|
[:client/code (:client-code request)]))
|
||||||
total-options (->> (stack-rank #{"AMOUNT_DUE"} lookup)
|
total-options (->> (stack-rank #{"AMOUNT_DUE"} lookup)
|
||||||
(map (fn [t]
|
(map (fn [t]
|
||||||
[t (some->> t
|
[t (some->> t
|
||||||
@@ -87,8 +90,16 @@
|
|||||||
[t (->> (solr/query solr/impl "clients" {"query" (format "name:(%s) ", (clean-customer t)) "fields" "score, *"})
|
[t (->> (solr/query solr/impl "clients" {"query" (format "name:(%s) ", (clean-customer t)) "fields" "score, *"})
|
||||||
#_(filter (fn [d] (> (:score d) 4.0)))
|
#_(filter (fn [d] (> (:score d) 4.0)))
|
||||||
(map (comp #(Long/parseLong %) :id))
|
(map (comp #(Long/parseLong %) :id))
|
||||||
first)]))))
|
first)]))
|
||||||
|
(filter (fn [[t id]]
|
||||||
|
(valid-client-ids id)))))
|
||||||
deduplicate)
|
deduplicate)
|
||||||
|
customer-identifier-options (if (seq customer-identifier-options)
|
||||||
|
customer-identifier-options
|
||||||
|
(->> valid-client-ids
|
||||||
|
(take 10)
|
||||||
|
(map (fn [c]
|
||||||
|
[(pull-attr (dc/db conn) :client/name c) c]))))
|
||||||
vendor-name-options (->> (stack-rank #{"VENDOR_NAME"} lookup)
|
vendor-name-options (->> (stack-rank #{"VENDOR_NAME"} lookup)
|
||||||
(mapcat (fn [t]
|
(mapcat (fn [t]
|
||||||
(for [m (->> (solr/query solr/impl "vendors" {"query" (format "name:(%s) ", t) "fields" "score, *"})
|
(for [m (->> (solr/query solr/impl "vendors" {"query" (format "name:(%s) ", t) "fields" "score, *"})
|
||||||
@@ -161,13 +172,13 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
(update :textract-invoice/vendor-name vendor-name-tuple->vendor-tuple)
|
(update :textract-invoice/vendor-name vendor-name-tuple->vendor-tuple)
|
||||||
(update :textract-invoice/vendor-name-options #(map vendor-name-tuple->vendor-tuple %) )))
|
(update :textract-invoice/vendor-name-options #(map vendor-name-tuple->vendor-tuple %) )))
|
||||||
|
|
||||||
(defn refresh-job [id]
|
(defn refresh-job [request id]
|
||||||
(let [{:keys [:db/id :textract-invoice/job-id :textract-invoice/textract-status]} (get-job id)]
|
(let [{:keys [:db/id :textract-invoice/job-id :textract-invoice/textract-status]} (get-job id)]
|
||||||
(when (and job-id (= "IN_PROGRESS" textract-status))
|
(when (and job-id (= "IN_PROGRESS" textract-status))
|
||||||
(let [result (textract/get-expense-analysis {:job-id job-id})
|
(let [result (textract/get-expense-analysis {:job-id job-id})
|
||||||
new-status (:job-status result)]
|
new-status (:job-status result)]
|
||||||
(cond (= "SUCCEEDED" new-status)
|
(cond (= "SUCCEEDED" new-status)
|
||||||
@(dc/transact conn [[:upsert-entity (textract->textract-invoice id result)]])
|
@(dc/transact conn [[:upsert-entity (textract->textract-invoice request id result)]])
|
||||||
:else
|
:else
|
||||||
@(dc/transact conn [{:db/id id :textract-invoice/textract-status new-status}]))))
|
@(dc/transact conn [{:db/id id :textract-invoice/textract-status new-status}]))))
|
||||||
(get-job id)))
|
(get-job id)))
|
||||||
@@ -198,6 +209,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
(com/field {:label "Client"}
|
(com/field {:label "Client"}
|
||||||
(com/text-input {:name (path->name [:invoice/client])
|
(com/text-input {:name (path->name [:invoice/client])
|
||||||
:value (-> textract-invoice :textract-invoice/customer-identifier second second)
|
:value (-> textract-invoice :textract-invoice/customer-identifier second second)
|
||||||
|
:class "w-96"
|
||||||
:placeholder "Client"
|
:placeholder "Client"
|
||||||
:disabled true
|
:disabled true
|
||||||
:autofocus true}))]
|
:autofocus true}))]
|
||||||
@@ -213,6 +225,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
[:div.col-span-6
|
[:div.col-span-6
|
||||||
(com/field {:label "Vendor"}
|
(com/field {:label "Vendor"}
|
||||||
(com/text-input {:name (path->name [:invoice/vendor])
|
(com/text-input {:name (path->name [:invoice/vendor])
|
||||||
|
:class "w-96"
|
||||||
:value (-> textract-invoice :textract-invoice/vendor-name second second)
|
:value (-> textract-invoice :textract-invoice/vendor-name second second)
|
||||||
:disabled true
|
:disabled true
|
||||||
:placeholder "Vendor"}))]
|
:placeholder "Vendor"}))]
|
||||||
@@ -270,8 +283,8 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
(str invoice-number))})]
|
(str invoice-number))})]
|
||||||
(com/button {:color :primary} "Save")])
|
(com/button {:color :primary} "Save")])
|
||||||
|
|
||||||
(defn job-progress* [id]
|
(defn job-progress* [request id]
|
||||||
(let [textract-invoice (refresh-job id)]
|
(let [textract-invoice (refresh-job request id)]
|
||||||
(cond
|
(cond
|
||||||
(= "IN_PROGRESS" (:textract-invoice/textract-status textract-invoice))
|
(= "IN_PROGRESS" (:textract-invoice/textract-status textract-invoice))
|
||||||
[:div.bg-blue-100.border-2.border-dashed.rounded-lg.border-blue-300.p-4.max-w-md.w-md.text-center.cursor-pointer
|
[:div.bg-blue-100.border-2.border-dashed.rounded-lg.border-blue-300.p-4.max-w-md.w-md.text-center.cursor-pointer
|
||||||
@@ -290,12 +303,12 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
[:div {:style {:width "805"}}
|
[:div {:style {:width "805"}}
|
||||||
(com/card {}
|
(com/card {}
|
||||||
[:iframe.p-4 {:src (:textract-invoice/pdf-url textract-invoice) :width 791 :height 700}])]
|
[:iframe.p-4 {:src (:textract-invoice/pdf-url textract-invoice) :width 791 :height 700}])]
|
||||||
[:div {:class "basis-1/4"}
|
[:div {:class "basis-1/2"}
|
||||||
(com/card {}
|
(com/card {}
|
||||||
[:div.p-4
|
[:div.p-4
|
||||||
(textract->invoice-form* textract-invoice)])]]])))
|
(textract->invoice-form* textract-invoice)])]]])))
|
||||||
|
|
||||||
(defn page* [id]
|
(defn page* [request id]
|
||||||
[:div#invoice-glimpse-content.mt-4
|
[:div#invoice-glimpse-content.mt-4
|
||||||
(com/card {}
|
(com/card {}
|
||||||
[:div.px-4.py-3.space-y-4.flex.flex-col
|
[:div.px-4.py-3.space-y-4.flex.flex-col
|
||||||
@@ -307,7 +320,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
[:p.text-sm.italic "Import your invoices with the power of AI. Please only use PDFs with a single invoice in them."]
|
[:p.text-sm.italic "Import your invoices with the power of AI. Please only use PDFs with a single invoice in them."]
|
||||||
|
|
||||||
(when id
|
(when id
|
||||||
(job-progress* id))
|
(job-progress* request id))
|
||||||
(when-not id
|
(when-not id
|
||||||
(upload-form*))])])
|
(upload-form*))])])
|
||||||
|
|
||||||
@@ -402,7 +415,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
_ (when new-invoice-id @(dc/transact conn [{:db/id (:db/id current-job)
|
_ (when new-invoice-id @(dc/transact conn [{:db/id (:db/id current-job)
|
||||||
:textract-invoice/invoice new-invoice-id}]))]
|
:textract-invoice/invoice new-invoice-id}]))]
|
||||||
(if new-invoice-id
|
(if new-invoice-id
|
||||||
(html-response (page* nil)
|
(html-response (page* request nil)
|
||||||
:headers {"hx-push-url" (bidi/path-for ssr-routes/only-routes :invoice-glimpse)
|
:headers {"hx-push-url" (bidi/path-for ssr-routes/only-routes :invoice-glimpse)
|
||||||
"hx-retarget" "#invoice-glimpse-content"
|
"hx-retarget" "#invoice-glimpse-content"
|
||||||
"hx-trigger" (cheshire/generate-string {"notification" (str (hiccup/html [:div "Successfully created "
|
"hx-trigger" (cheshire/generate-string {"notification" (str (hiccup/html [:div "Successfully created "
|
||||||
@@ -420,10 +433,11 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
:method request-method)
|
:method request-method)
|
||||||
(base-page
|
(base-page
|
||||||
request
|
request
|
||||||
(com/page {:nav com/admin-aside-nav
|
(com/page {:nav com/main-aside-nav
|
||||||
:client-selection (:client-selection request)
|
:client-selection (:client-selection request)
|
||||||
:client (:client request)
|
:client (:client request)
|
||||||
:clients (:clients request)
|
:clients (:clients request)
|
||||||
|
:request request
|
||||||
:identity (:identity request)
|
:identity (:identity request)
|
||||||
:app-params {:hx-get (bidi/path-for ssr-routes/only-routes
|
:app-params {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||||
:invoice-glimpse)
|
:invoice-glimpse)
|
||||||
@@ -437,7 +451,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
[:a {:href (bidi/path-for ssr-routes/only-routes
|
[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||||
:invoice-glimpse)}
|
:invoice-glimpse)}
|
||||||
"Glimpse"])
|
"Glimpse"])
|
||||||
(page* (some-> request
|
(page* request (some-> request
|
||||||
:route-params
|
:route-params
|
||||||
:textract-invoice-id
|
:textract-invoice-id
|
||||||
Long/parseLong)))
|
Long/parseLong)))
|
||||||
@@ -446,7 +460,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
|
|
||||||
(defn textract-invoice [request]
|
(defn textract-invoice [request]
|
||||||
(if (get-in request [:headers "hx-request"])
|
(if (get-in request [:headers "hx-request"])
|
||||||
(html-response (job-progress* (some-> request
|
(html-response (job-progress* request (some-> request
|
||||||
:route-params
|
:route-params
|
||||||
:textract-invoice-id
|
:textract-invoice-id
|
||||||
Long/parseLong)))
|
Long/parseLong)))
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
(ns auto-ap.permissions)
|
(ns auto-ap.permissions
|
||||||
|
#?(:clj
|
||||||
|
(:require [cemerick.url :as url])))
|
||||||
|
|
||||||
;; TODO after getting rid of cljs, use malli schemas to decode this
|
;; TODO after getting rid of cljs, use malli schemas to decode this
|
||||||
(defn get-client-id [client]
|
(defn get-client-id [client]
|
||||||
@@ -113,3 +115,13 @@
|
|||||||
|
|
||||||
:else
|
:else
|
||||||
false)))
|
false)))
|
||||||
|
|
||||||
|
#? (:clj
|
||||||
|
(defn wrap-must [handler policy]
|
||||||
|
(fn [request]
|
||||||
|
(if (can? (:identity request) policy)
|
||||||
|
(handler request)
|
||||||
|
{:status 302
|
||||||
|
:headers {"Location" (str "/login?"
|
||||||
|
(url/map->query {"redirect-to" (:uri request)}))}}))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user