makes more changes.
This commit is contained in:
@@ -99,8 +99,6 @@
|
|||||||
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 ring-1"
|
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 ring-1"
|
||||||
"@keydown.escape" "tippy.hide(); value = {value: '', label: '' }; "
|
"@keydown.escape" "tippy.hide(); value = {value: '', label: '' }; "
|
||||||
:x-destroy "if ($refs.input) {$refs.input.focus();}"}
|
:x-destroy "if ($refs.input) {$refs.input.focus();}"}
|
||||||
|
|
||||||
|
|
||||||
[:input {:type "text"
|
[:input {:type "text"
|
||||||
:autofocus true
|
:autofocus true
|
||||||
:class (-> (:class params)
|
:class (-> (:class params)
|
||||||
@@ -266,6 +264,12 @@
|
|||||||
(assoc
|
(assoc
|
||||||
:type "hidden"
|
:type "hidden"
|
||||||
"x-bind:value" "v"))]]
|
"x-bind:value" "v"))]]
|
||||||
|
[:template {:x-if "value.size == 0"}
|
||||||
|
[:input (-> params
|
||||||
|
(dissoc :class :value-fn :content-fn :placeholder :x-model)
|
||||||
|
(assoc :type "hidden"
|
||||||
|
:value ""
|
||||||
|
))]]
|
||||||
[:div.flex.w-full.justify-items-stretch
|
[:div.flex.w-full.justify-items-stretch
|
||||||
(multi-typeahead-selected-pill- params)
|
(multi-typeahead-selected-pill- params)
|
||||||
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
|
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
|
||||||
|
|||||||
@@ -284,7 +284,7 @@
|
|||||||
|
|
||||||
(defn maybe-trim-clients [request client ]
|
(defn maybe-trim-clients [request client ]
|
||||||
(if (= :all client)
|
(if (= :all client)
|
||||||
(cond-> {:client (take 5 (:clients request))}
|
(cond-> {:client (take 20 (:clients request))}
|
||||||
(> (count (:clients request)) 20)
|
(> (count (:clients request)) 20)
|
||||||
(assoc :warning "You requested a report with more than 20 clients. This report will only contain the first 20."))
|
(assoc :warning "You requested a report with more than 20 clients. This report will only contain the first 20."))
|
||||||
{:client client}))
|
{:client client}))
|
||||||
@@ -303,8 +303,8 @@
|
|||||||
:table report
|
:table report
|
||||||
:warning (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))} ))))])
|
:warning (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))} ))))])
|
||||||
|
|
||||||
(defn form* [request]
|
(defn form* [request & children]
|
||||||
(let [params (merge (:query-params request) (:form-params request) {})]
|
(let [params (:query-params request)]
|
||||||
(fc/start-form
|
(fc/start-form
|
||||||
params
|
params
|
||||||
(:form-errors request)
|
(:form-errors request)
|
||||||
@@ -348,10 +348,11 @@
|
|||||||
(com/button {:color :primary :class "w-32"}
|
(com/button {:color :primary :class "w-32"}
|
||||||
"Run")
|
"Run")
|
||||||
(com/button {:formaction (bidi.bidi/path-for ssr-routes/only-routes ::route/export-balance-sheet) } "Export PDF")]]] ]
|
(com/button {:formaction (bidi.bidi/path-for ssr-routes/only-routes ::route/export-balance-sheet) } "Export PDF")]]] ]
|
||||||
(balance-sheet* request)])))
|
children])))
|
||||||
|
|
||||||
(defn form [request]
|
(defn form [request]
|
||||||
(html-response (form* request)
|
(html-response (form* request
|
||||||
|
(balance-sheet* request))
|
||||||
:headers {"hx-retarget" "#balance-sheet-form"
|
:headers {"hx-retarget" "#balance-sheet-form"
|
||||||
"hx-push-url" (str "?" (:query-string request))}))
|
"hx-push-url" (str "?" (:query-string request))}))
|
||||||
|
|
||||||
@@ -404,24 +405,27 @@
|
|||||||
|
|
||||||
(defn print-balance-sheet [request]
|
(defn print-balance-sheet [request]
|
||||||
(let [uuid (str (UUID/randomUUID))
|
(let [uuid (str (UUID/randomUUID))
|
||||||
|
{:keys [client warning]} (maybe-trim-clients request (:client (:query-params request)))
|
||||||
|
request (assoc-in request [:query-params :client] client)
|
||||||
pdf-data (make-balance-sheet-pdf request (:report (get-report request)))
|
pdf-data (make-balance-sheet-pdf request (:report (get-report request)))
|
||||||
name (balance-sheet-args->name request)
|
name (balance-sheet-args->name request)
|
||||||
key (str "reports/balance-sheet/" uuid "/" name ".pdf")
|
key (str "reports/balance-sheet/" uuid "/" name ".pdf")
|
||||||
url (str "https://" (:data-bucket env) "/" key)]
|
url (str "https://" (:data-bucket env) "/" key)]
|
||||||
|
(println "CLIENT IS" client)
|
||||||
(s3/put-object :bucket-name (:data-bucket env/env)
|
(s3/put-object :bucket-name (:data-bucket env/env)
|
||||||
:key key
|
:key key
|
||||||
:input-stream (io/make-input-stream pdf-data {})
|
:input-stream (io/make-input-stream pdf-data {})
|
||||||
:metadata {:content-length (count pdf-data)
|
:metadata {:content-length (count pdf-data)
|
||||||
:content-type "application/pdf"})
|
:content-type "application/pdf"})
|
||||||
@(dc/transact conn
|
@(dc/transact conn
|
||||||
[{:report/name name
|
[{:report/name name
|
||||||
:report/client (map :db/id (:client (:query-params request)))
|
:report/client (map :db/id client)
|
||||||
:report/key key
|
:report/key key
|
||||||
:report/url url
|
:report/url url
|
||||||
:report/creator (:user (:identity request))
|
:report/creator (:user (:identity request))
|
||||||
:report/created (java.util.Date.)}])
|
:report/created (java.util.Date.)}])
|
||||||
{:report/name name
|
{:report/name name
|
||||||
:report/url url }))
|
:report/url url}))
|
||||||
|
|
||||||
;; TODO PRINT WARNING
|
;; TODO PRINT WARNING
|
||||||
(defn export [request]
|
(defn export [request]
|
||||||
@@ -431,16 +435,17 @@
|
|||||||
{}
|
{}
|
||||||
"Ready!"
|
"Ready!"
|
||||||
(com/modal-body {}
|
(com/modal-body {}
|
||||||
[:div.flex.flex-col.mt-4.space-y-4.items-center
|
(let [bs (print-balance-sheet request)]
|
||||||
[:a {:href (:report/url (print-balance-sheet request))}
|
[:div.flex.flex-col.mt-4.space-y-4.items-center
|
||||||
[:div.w-24.h-24.bg-green-50.rounded-full.p-4.text-green-300 {:class " hover:scale-110 transition duration-100"}
|
[:a {:href (:report/url bs)}
|
||||||
|
[:div.w-24.h-24.bg-green-50.rounded-full.p-4.text-green-300 {:class " hover:scale-110 transition duration-100"}
|
||||||
|
|
||||||
svg/download]]
|
svg/download]]
|
||||||
[:span.text-gray-800
|
[:span.text-gray-800
|
||||||
"Click "
|
"Click "
|
||||||
(com/link {:href (:report/url (print-balance-sheet request))} "here")
|
(com/link {:href (:report/url bs)} "here")
|
||||||
" to download"]
|
" to download"]
|
||||||
])
|
]))
|
||||||
nil))
|
nil))
|
||||||
:headers (-> {}
|
:headers (-> {}
|
||||||
(assoc "hx-retarget" ".modal-stack")
|
(assoc "hx-retarget" ".modal-stack")
|
||||||
|
|||||||
Reference in New Issue
Block a user