From 1b044ff5cd15442ddd4eb9fe98c935d5fe876e30 Mon Sep 17 00:00:00 2001 From: Bryce Date: Thu, 1 Jun 2023 12:00:30 -0700 Subject: [PATCH] every ssr page is tailwindified. --- .gitignore | 2 +- resources/public/favicon.png | Bin 0 -> 2380 bytes resources/public/output.css | 17 +++++ src/clj/auto_ap/routes/ezcater_xls.clj | 69 +++++++++++-------- src/clj/auto_ap/ssr/admin.clj | 5 +- src/clj/auto_ap/ssr/company.clj | 2 +- src/clj/auto_ap/ssr/components/aside.clj | 8 ++- src/clj/auto_ap/ssr/components/data_grid.clj | 2 +- src/clj/auto_ap/ssr/core.clj | 2 +- src/clj/auto_ap/ssr/grid_page_helper.clj | 2 +- src/clj/auto_ap/ssr/transaction/insights.clj | 2 +- src/clj/auto_ap/ssr/ui.clj | 5 +- 12 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 resources/public/favicon.png diff --git a/.gitignore b/.gitignore index 30527c7d..9e28974e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ pom.xml.asc *.class /.lein-* /.nrepl-port -/resources/public/js/compiled +resources/public/js/compiled *.log examples/ \#*\# diff --git a/resources/public/favicon.png b/resources/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..ebd29da8e9e573f4a63ba8fae4496ce66ea7b03c GIT binary patch literal 2380 zcmaJ@dpuO@8Xn~O%QYm|)ksCm4WpTwGGhiqgHSGEo6EvrW{sJ_phWCUZaH1plq6KM zDGJG@vOAI^?Su+ZBH5v&wp&ztw9`I+oX+~KwZ6;md7k%uzxVm$JL2Kyq^hE?0)xR+ zsm^3i>4=qnwn_@pzsf^Bfpl0Wr1%QGpb%j!oe#o@EQkRDR1Q59^aSawxTybt+hH&{ zINRG-=u6v$XF?nVeHnugad=WT47Pozh(~8efI@%)hO)T?_*CO9IKXBR;6AoA6piNq zhOwRF`Jh+4n>RB)f{A0nckTeTi||qb4k)ApB2FY%fEN+qUv=@)`SLar4t#|OBM9)n zlk%l`01glz1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4*4DUHT+f!lJ=17;tgCUWbS>!}ygOG<>5=d#qOl0Z zf7H(QW4lSPTNVt9e}1UrUYl7Ja^Y@%1KBXHZ-TxwxvT4D-5}wMPR^oS`YZ8ExK`z) z7`LnZwZc9j9sc(6?>Y8{>&}3@t`_hF2^2nB^K}MBJ-Wo_)zF zH{|z@N(!#V%*9sL)z|ATicI_uu9p-Xv(z7MfGURi;~X?iUq_8KzC5#J3H;)f#XP=0 zBOwt;KXqP}5_x~#%b0(80XwA99>sHQQ$5w7DA%FM|1-~~C*pv;8!X4`xgG4M9JAaT za_YRJT4^8rTjO#r5*DXw?zFX_2IAQ%QLsw~tAPM`0t9@DrQP;hb;M}rnxQi&obtwO jQ$a?!{HW%_z9bo#%%i!+x1+4V<@*hl;zqtq3O@7~mCx7u literal 0 HcmV?d00001 diff --git a/resources/public/output.css b/resources/public/output.css index 47a21da6..b46f38d3 100644 --- a/resources/public/output.css +++ b/resources/public/output.css @@ -1570,6 +1570,18 @@ input:checked + .toggle-bg { margin-bottom: calc(1.5rem * var(--tw-space-y-reverse)); } +.space-y-8 > :not([hidden]) ~ :not([hidden]) { + --tw-space-y-reverse: 0; + margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse))); + margin-bottom: calc(2rem * var(--tw-space-y-reverse)); +} + +.space-y-4 > :not([hidden]) ~ :not([hidden]) { + --tw-space-y-reverse: 0; + margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse))); + margin-bottom: calc(1rem * var(--tw-space-y-reverse)); +} + .divide-y > :not([hidden]) ~ :not([hidden]) { --tw-divide-y-reverse: 0; border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse))); @@ -1786,6 +1798,11 @@ input:checked + .toggle-bg { background-color: rgb(255 205 205 / var(--tw-bg-opacity)); } +.bg-blue-300 { + --tw-bg-opacity: 1; + background-color: rgb(102 196 242 / var(--tw-bg-opacity)); +} + .bg-opacity-50 { --tw-bg-opacity: 0.5; } diff --git a/src/clj/auto_ap/routes/ezcater_xls.clj b/src/clj/auto_ap/routes/ezcater_xls.clj index ebf995d1..f6296219 100644 --- a/src/clj/auto_ap/routes/ezcater_xls.clj +++ b/src/clj/auto_ap/routes/ezcater_xls.clj @@ -18,7 +18,8 @@ [com.brunobonacci.mulog :as mu] [datomic.api :as dc] [hiccup2.core :as hiccup] - [amazonica.aws.s3 :as s3])) + [amazonica.aws.s3 :as s3] + [auto-ap.ssr.components :as com])) (defn fmt-amount [a] (with-precision 2 @@ -27,18 +28,12 @@ (.setScale 2 java.math.RoundingMode/HALF_UP) (double)))) - - - (defn rows->maps [rows] (let [[headers & rows] rows] (for [r rows] (into {} (map vector headers r))))) - - - (defn map->sales-order [r clients] (let [order-number (get r "Order Number") event-date (get r "Event Date") @@ -136,30 +131,29 @@ (stream->sales-orders s))) (defn page* [] - [:div - [:h1.title "EZCater XLS Import"] - [:div.card.block {:style {:width "500px"}} - [:div.card-content - "Please go to " - [:a {:href "https://www.ezcater.com/ez_manage/reports/new" :target "_blank"} "EZCater's report page"] - " to generate a new report. Then drop it below."]] - [:div#page-notification.notification.block {:style {:display "none"}}] - [:div.card.block - [:div.card-content - [:form {:action (bidi/path-for ssr-routes/only-routes - :admin-ezcater-xls) - :method "POST" - :class "dropzone" - :id "ezcater"}]]] - [:script - (hiccup/raw - " + [:div.mt-4 + (com/card {} + [:div.px-4.py-3.space-y-4.flex.flex-col + [:h1.text-2xl.mb-3.font-bold "EZCater XLS Import"] + [:p.text-sm.italic + "Please go to " + (com/link {:href "https://www.ezcater.com/ez_manage/reports/new" :target "_blank"} "EZCater's report page") + " to generate a new report. Then drop it below."] + [:div#page-notification.notification.block {:style {:display "none"}}] + [:form.bg-blue-300 {:action (bidi/path-for ssr-routes/only-routes + :admin-ezcater-xls) + :method "POST" + :class "dropzone" + :id "ezcater"}] + [:script + (hiccup/raw + " Dropzone.options.ezcater = { success: function (file, response) { document.getElementById(\"page-notification\").innerHTML = response; document.getElementById(\"page-notification\").style[\"display\"] = \"block\"; } - }")]]) + }")]])]) (defn upload-xls [{:keys [identity] :as request}] @@ -195,8 +189,23 @@ (if (= :post request-method) (upload-xls request) (base-page - request - (page*) - - (admin-side-bar matched-route)))) + request + (com/page {:nav (com/company-aside-nav) + :active-client (:client (:session request)) + :identity (:identity request) + :app-params {:hx-get (bidi/path-for ssr-routes/only-routes + :admin-ezcater-xls) + :hx-trigger "clientSelected from:body" + :hx-select "#app-contents" + :hx-swap "outerHTML swap:300ms"}} + (com/breadcrumbs {} + [:a {:href (bidi/path-for ssr-routes/only-routes + :admin)} + "Admin"] + [:a {:href (bidi/path-for ssr-routes/only-routes + :admin-ezcater-xls)} + "EZCater XLS Import"]) + (page*)) + + "EZCater upload"))) diff --git a/src/clj/auto_ap/ssr/admin.clj b/src/clj/auto_ap/ssr/admin.clj index b3da35f0..17ff022a 100644 --- a/src/clj/auto_ap/ssr/admin.clj +++ b/src/clj/auto_ap/ssr/admin.clj @@ -111,8 +111,7 @@ (com/data-grid-card {:id "history-table" :title (format "History for %s: %d" (str/capitalize best-guess-entity) entity-id) :route :history-table - :start 0 - :per-page (count history) + :paginate? false :total (count history) :subtitle nil :action-buttons nil @@ -188,4 +187,4 @@ [:div#history-table]) [:div#inspector] ]) - nil))) + "History"))) diff --git a/src/clj/auto_ap/ssr/company.clj b/src/clj/auto_ap/ssr/company.clj index 1d20c4d9..d3b657ab 100644 --- a/src/clj/auto_ap/ssr/company.clj +++ b/src/clj/auto_ap/ssr/company.clj @@ -63,5 +63,5 @@ :company)} "My Company"]) (main-content* {:client (:client (:session request))})) - nil)) + "My Company")) diff --git a/src/clj/auto_ap/ssr/components/aside.clj b/src/clj/auto_ap/ssr/components/aside.clj index c94a41d1..f230a660 100644 --- a/src/clj/auto_ap/ssr/components/aside.clj +++ b/src/clj/auto_ap/ssr/components/aside.clj @@ -33,7 +33,8 @@ (update-in c [1 1 :class ] str " flex items-center p-2 pl-11 w-full text-base font-normal text-gray-900 rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")])]) (defn left-aside- [{:keys [nav page-specific]} & children] - [:aside {:id "left-nav", :class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform -translate-x-full lg:translate-x-0", :aria-labelledby "left-nav" :aria-hidden "true"} + [:aside {:id "left-nav", :class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform -translate-x-full lg:translate-x-0", :aria-labelledby "left-nav" :aria-hidden "true" + "_" (hiccup/raw "init call initSidebarToggle()")} [:div {:class "overflow-y-auto py-5 px-3 h-full bg-gray-50 border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"} nav @@ -125,6 +126,7 @@ [:use {:width "30", :height "20", :transform "matrix(16 -19.968 19.968 16 256 230.4)", :xlink:href "#a"}]] "中文 (繁體)"]]]]]] [:script {:lang "text/javascript"} (hiccup/raw " + function initSidebarToggle() { var $targetEl = document.getElementById('left-nav'); var $triggerEl = document.getElementById('left-nav-toggle'); @@ -140,8 +142,8 @@ } }; - // var collapse = new Collapse($targetEl, $triggerEl, options); - + var collapse = new Collapse($targetEl, $triggerEl, options); + } ")]]) (defn main-aside-nav- [] diff --git a/src/clj/auto_ap/ssr/components/data_grid.clj b/src/clj/auto_ap/ssr/components/data_grid.clj index 9034f438..5438036f 100644 --- a/src/clj/auto_ap/ssr/components/data_grid.clj +++ b/src/clj/auto_ap/ssr/components/data_grid.clj @@ -85,7 +85,7 @@ rows)] (when (or paginate? - (not (nil? paginate?))) + (nil? paginate?)) (paginator- {:start start :end (Math/min (+ start per-page) total) :per-page per-page diff --git a/src/clj/auto_ap/ssr/core.clj b/src/clj/auto_ap/ssr/core.clj index 76328117..f667f685 100644 --- a/src/clj/auto_ap/ssr/core.clj +++ b/src/clj/auto_ap/ssr/core.clj @@ -18,7 +18,7 @@ (def key->handler {:logout auth/logout :admin-history (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/history))) - :admin-history-search (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/history-search))) + :admin-history-search (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/history))) :admin-history-inspect (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/inspect))) :active-client (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin company-dropdown/active-client))) :company-dropdown-search-results diff --git a/src/clj/auto_ap/ssr/grid_page_helper.clj b/src/clj/auto_ap/ssr/grid_page_helper.clj index ccc46650..ff557dcb 100644 --- a/src/clj/auto_ap/ssr/grid_page_helper.clj +++ b/src/clj/auto_ap/ssr/grid_page_helper.clj @@ -183,4 +183,4 @@ (table* grid-spec identity (extract-params grid-spec request))) - nil)) + (:title grid-spec))) diff --git a/src/clj/auto_ap/ssr/transaction/insights.clj b/src/clj/auto_ap/ssr/transaction/insights.clj index 9a15813e..9583a5bd 100644 --- a/src/clj/auto_ap/ssr/transaction/insights.clj +++ b/src/clj/auto_ap/ssr/transaction/insights.clj @@ -214,4 +214,4 @@ (insight-table* {:selected-client (-> session :client :db/id) :identity identity})] - [:div (company-side-bar matched-route)])) + "Transaction Insights")) diff --git a/src/clj/auto_ap/ssr/ui.clj b/src/clj/auto_ap/ssr/ui.clj index 51606f61..39974204 100644 --- a/src/clj/auto_ap/ssr/ui.clj +++ b/src/clj/auto_ap/ssr/ui.clj @@ -11,15 +11,16 @@ {} hiccup))}) -(defn base-page [request contents side-bar-contents] +(defn base-page [request contents page-name] (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"] + [:title (str "Integreat | " page-name)] [:link {:href "/css/font.min.css", :rel "stylesheet"}] + [:link {:rel "icon" :type "image/png" :href "/favicon.png"}] [:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}] [:link {:rel "stylesheet", :href "/output.css"}]