various bug fixes.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -2,6 +2,7 @@
|
||||
(:require [amazonica.aws.s3 :as s3]
|
||||
[auto-ap.datomic :refer [conn pull-attr]]
|
||||
[auto-ap.datomic.clients :refer [full-read]]
|
||||
[auto-ap.graphql.utils :refer [assert-can-see-client]]
|
||||
[auto-ap.permissions :as permissions]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
@@ -33,51 +34,100 @@
|
||||
:hx-target "this"
|
||||
:hx-swap "outerHTML"}
|
||||
[:div.col-span-1.p-4 {:class "p-4 sm:p-6 space-y-4 overflow-visible "
|
||||
:x-data (hx/json {"signature" nil
|
||||
}
|
||||
[:h3 {:class "mb-4 text-xl font-semibold dark:text-white"}
|
||||
"Signature"]
|
||||
[:div#signature-notification.notification.block {:style {:display "none"}}]
|
||||
[:div {:x-data (hx/json {"signature" nil
|
||||
"editing" false
|
||||
"existing" (boolean signature-file)})
|
||||
:hx-put (bidi/path-for ssr-routes/only-routes
|
||||
:company-update-signature)
|
||||
:hx-trigger "accepted"
|
||||
:hx-vals "js:{signatureData: event.detail.signatureData}"}
|
||||
[:h3 {:class "mb-4 text-xl font-semibold dark:text-white"}
|
||||
"Signature"]
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
[:div.ml-3 "Loading..."]]]
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
[:div.ml-3 "Loading..."]]]
|
||||
|
||||
[:div.htmx-indicator-hidden
|
||||
(when signature-file
|
||||
[:img.rounded.rounded-lg.border.border-gray-300.bg-gray-50 {:src signature-file
|
||||
:width 696
|
||||
:height 261
|
||||
:x-show "existing && !editing"}])
|
||||
[:canvas.rounded.rounded-lg.border.border-gray-300
|
||||
[:div.htmx-indicator-hidden
|
||||
(when signature-file
|
||||
[:img.rounded.rounded-lg.border.border-gray-300.bg-gray-50 {:src signature-file
|
||||
:width 696
|
||||
:height 261
|
||||
:x-show "existing && !editing"}])
|
||||
[:canvas.rounded.rounded-lg.border.border-gray-300
|
||||
|
||||
|
||||
{:style {:width 696
|
||||
:height 261}
|
||||
:x-init "signature= new SignaturePad($el); signature.off()"
|
||||
":class" "editing ? 'bg-white' : 'bg-gray-50' "
|
||||
:width 696
|
||||
:height 261
|
||||
:x-show "existing ? editing: true"}]]
|
||||
{:style {:width 696
|
||||
:height 261}
|
||||
:x-init "signature= new SignaturePad($el); signature.off()"
|
||||
":class" "editing ? 'bg-white' : 'bg-gray-50' "
|
||||
:width 696
|
||||
:height 261
|
||||
:x-show "existing ? editing: true"}]]
|
||||
|
||||
[:div.flex.gap-2.justify-end
|
||||
(com/button {:color :primary
|
||||
:x-show "!editing"
|
||||
"@click" "signature.clear(); signature.on(); editing=true;"}
|
||||
"New signature")
|
||||
(com/button {:color :primary
|
||||
:x-show "editing"
|
||||
"@click" "signature.clear();"}
|
||||
"Clear")
|
||||
|
||||
(com/button {:color :primary
|
||||
"@click" "$data.signatureData=signature.toDataURL('image/png'); signature.off(); editing=false; $dispatch('accepted', {signatureData: $data.signatureData}) "
|
||||
:x-show "editing"}
|
||||
"Accept")]])))
|
||||
[:div.flex.gap-2.justify-end
|
||||
(com/button {:color :primary
|
||||
:x-show "!editing"
|
||||
"@click" "signature.clear(); signature.on(); editing=true;"}
|
||||
"New signature")
|
||||
(com/button {:color :primary
|
||||
:x-show "editing"
|
||||
"@click" "signature.clear();"}
|
||||
"Clear")
|
||||
|
||||
(com/button {:color :primary
|
||||
"@click" "$data.signatureData=signature.toDataURL('image/png'); signature.off(); editing=false; $dispatch('accepted', {signatureData: $data.signatureData}) "
|
||||
:x-show "editing"}
|
||||
"Accept")]]
|
||||
|
||||
[:div
|
||||
[:div.flex.justify-center " - or -"]
|
||||
[:form {:hx-post (bidi/path-for ssr-routes/only-routes
|
||||
:company-upload-signature)
|
||||
:hx-disinherit "hx-vals"
|
||||
:hx-encoding "multipart/form-data"
|
||||
#_#_:hx-target "#signature-notification"
|
||||
:hx-swap "outerHTML"
|
||||
:id "upload"
|
||||
:hx-trigger "z"
|
||||
}
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
[:div.ml-3 "Loading..."]]]
|
||||
[:div.htmx-indicator-hidden
|
||||
[:div.border-2.border-dashed.rounded-lg.p-4.w-full.text-center.cursor-pointer.h-64.flex.items-center.justify-center.text-lg.relative
|
||||
{:x-data (hx/json {"files" nil
|
||||
"hovering" false})
|
||||
:x-dispatch:z "files"
|
||||
":class" "{'bg-blue-100': !hovering,
|
||||
'border-blue-300': !hovering,
|
||||
'text-blue-700': !hovering,
|
||||
'bg-green-100': hovering,
|
||||
'border-green-300': hovering,
|
||||
'text-green-700': hovering
|
||||
}"}
|
||||
|
||||
|
||||
|
||||
[:input {:type "file"
|
||||
:name "file"
|
||||
:class "absolute inset-0 m-0 p-0 w-full h-full outline-none opacity-0",
|
||||
:x-on:change "files = $event.target.files;",
|
||||
:x-on:dragover "hovering = true",
|
||||
:x-on:dragleave "hovering = false",
|
||||
:x-on:drop "hovering = false"}]
|
||||
[:div.flex.flex-col.space-2
|
||||
[:div
|
||||
[:ul {:x-show "files != null"}
|
||||
[:template {:x-for "f in files"}
|
||||
[:li (com/pill {:color :primary :x-text "f.name"})]]]]
|
||||
|
||||
|
||||
[:div.htmx-indicator-hidden "Drop a signature file (696x261 pixels jpeg) here."]]]] ]]])))
|
||||
|
||||
(defn upload-signature-data [{{:strs [signatureData]} :form-params client :client :as request}]
|
||||
(let [prefix "data:image/png;base64,"]
|
||||
@@ -97,6 +147,69 @@
|
||||
(html-response
|
||||
(signature request))))))
|
||||
|
||||
(defn upload-signature-file [{{:strs [signatureData]} :form-params client :client user :identity :as request}]
|
||||
(assert-can-see-client user client)
|
||||
(let [{:strs [file]} (:multipart-params request) ]
|
||||
(try
|
||||
(let [signature-id (str (UUID/randomUUID)) ]
|
||||
(s3/put-object :bucket-name "integreat-signature-images" #_(:data-bucket env)
|
||||
:key (str signature-id ".jpg")
|
||||
:input-stream (io/input-stream (:tempfile file))
|
||||
:metadata {:content-type "image/jpeg"
|
||||
:content-length (:length (:tempfile file))}
|
||||
:canned-acl "public-read")
|
||||
@(dc/transact conn [{:db/id (:db/id client)
|
||||
:client/signature-file (str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg")}])
|
||||
(html-response
|
||||
(signature request)))
|
||||
(catch Exception e
|
||||
(println e)
|
||||
#_(-> result
|
||||
(assoc :error? true)
|
||||
(update :results conj {:filename filename
|
||||
:response (.getMessage e)
|
||||
:sample (:sample (ex-data e))
|
||||
:template (:template (ex-data e))}))))
|
||||
#_(html-response [:div#page-notification.p-4.rounded-lg
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700"
|
||||
"bg-primary-50 text-primary-700")}
|
||||
[:table
|
||||
[:thead
|
||||
[:tr [:td "File"] [:td "Result"]
|
||||
[:td "Template"]
|
||||
(if (:error? results)
|
||||
[:td "Sample match"])]
|
||||
#_[:tr "Result"]
|
||||
#_[:tr "Template"]]
|
||||
(for [r (:results results)]
|
||||
[:tr
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:filename r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:response r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
"Template: " (:template r)]
|
||||
(if (:error? results)
|
||||
[:td.p-2.border
|
||||
{:class "bg-red-50 text-red-700 border-red-300"}
|
||||
|
||||
[:ul
|
||||
(for [[k v] (dissoc (:sample r) :template :source-url :full-text :text)]
|
||||
[:li (name k) ": " (str v)])]
|
||||
#_(:template r)])])]]
|
||||
:headers
|
||||
{"hx-trigger" "invalidated"})))
|
||||
|
||||
(defn main-content* [{:keys [client identity] :as request}]
|
||||
(if-not client
|
||||
(please-select-client-screen*)
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
:company-plaid-link (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/link))
|
||||
:company-plaid-relink (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/relink))
|
||||
:company-update-signature (wrap-client-redirect-unauthenticated (wrap-secure company/upload-signature-data))
|
||||
:company-upload-signature (wrap-client-redirect-unauthenticated (wrap-secure company/upload-signature-file))
|
||||
:company-yodlee (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/page))
|
||||
:company-yodlee-table (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/table))
|
||||
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
|
||||
|
||||
@@ -308,9 +308,9 @@
|
||||
:class "w-full h-full"}
|
||||
[:fieldset {:class "hx-disable h-full"}
|
||||
(com/modal-card
|
||||
{}
|
||||
{:class "md:h-[800px] md:w-[750px]"}
|
||||
[:div.flex [:div.p-2 "User"] [:p.ml-2.rounded.bg-gray-200.p-2.dark:bg-gray-600 (:user/name entity)]]
|
||||
[:div.space-y-6
|
||||
[:div.space-y-6.overflow-y-scroll
|
||||
(fc/with-field :db/id
|
||||
(com/hidden {:name (fc/field-name)
|
||||
:value (fc/field-value)}))
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
;; TODO Include IDS in routes for company-specific things, as opposed to headers
|
||||
"company" {"" :company
|
||||
"/dropdown" :company-dropdown-search-results
|
||||
"/signature" {"/put" :company-update-signature}
|
||||
"/signature" {"/put" :company-update-signature
|
||||
"/post" :company-upload-signature}
|
||||
"/search" :company-search
|
||||
"/bank-account/typeahead" :bank-account-typeahead
|
||||
["/" [#"\d+" :db/id] "/bank-account"] {"/search" :bank-account-search}
|
||||
|
||||
Reference in New Issue
Block a user