Minor cleanup tweaks
This commit is contained in:
@@ -99,7 +99,7 @@
|
|||||||
client-word-match (->> clients
|
client-word-match (->> clients
|
||||||
(map
|
(map
|
||||||
(fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
|
(fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
|
||||||
(let [client-words (-> #{}
|
(let [client-words (-> #{}
|
||||||
(into
|
(into
|
||||||
(mapcat
|
(mapcat
|
||||||
(fn [match] (str/split (.toLowerCase match) #"\s" ))
|
(fn [match] (str/split (.toLowerCase match) #"\s" ))
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
(ns auto-ap.routes.yodlee2
|
|
||||||
(:require
|
|
||||||
[auto-ap.graphql :as graphql]
|
|
||||||
[clj-http.client :as http]
|
|
||||||
|
|
||||||
[auto-ap.yodlee.core2 :as yodlee]
|
|
||||||
[auto-ap.graphql.utils :refer [->graphql assert-admin]]
|
|
||||||
[auto-ap.routes.utils :refer [wrap-secure]]
|
|
||||||
[clj-time.coerce :refer [to-date]]
|
|
||||||
[ring.middleware.json :refer [wrap-json-response]]
|
|
||||||
[compojure.core :refer [GET POST context defroutes wrap-routes]]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[config.core :refer [env]]
|
|
||||||
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[auto-ap.datomic.clients :as d-clients]))
|
|
||||||
|
|
||||||
(defroutes routes
|
|
||||||
(wrap-routes
|
|
||||||
(context "/yodlee2" []
|
|
||||||
(GET "/fastlink" {:keys [query-params identity] :as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(let [token (yodlee/get-access-token (get query-params "client"))]
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str {:token token
|
|
||||||
:url (:yodlee2-fastlink env)}) }))
|
|
||||||
(GET "/accounts" {:keys [query-params identity] :as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(let [[session token] (yodlee/get-access-token)]
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str (yodlee/get-accounts)) }))
|
|
||||||
|
|
||||||
(POST "/reauthenticate/:id" {:keys [query-params identity] {:keys [id]} :route-params
|
|
||||||
data :edn-params
|
|
||||||
:as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(try
|
|
||||||
(let [[session token] (yodlee/get-access-token)]
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str (yodlee/reauthenticate (Long/parseLong id) data)) })
|
|
||||||
(catch Exception e
|
|
||||||
(log/error e)
|
|
||||||
{:status 500
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str {:message (.getMessage e)
|
|
||||||
:error (.toString e)})})))
|
|
||||||
(POST "/provider-accounts/refresh/" {:keys [query-params identity edn-params]
|
|
||||||
{:keys [id]} :route-params
|
|
||||||
:as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(log/info "refreshing " edn-params)
|
|
||||||
(try
|
|
||||||
(yodlee/refresh-provider-account (-> (:client-id edn-params)
|
|
||||||
Long/parseLong
|
|
||||||
d-clients/get-by-id
|
|
||||||
:client/code)
|
|
||||||
(:provider-account-id edn-params))
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body "{}" }
|
|
||||||
(catch Exception e
|
|
||||||
(log/error e)
|
|
||||||
{:status 400
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str {:message (.getMessage e)
|
|
||||||
:error (.toString e)})})))
|
|
||||||
(POST "/provider-accounts/delete/" {:keys [query-params edn-params identity] {:keys [id]} :route-params :as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(try
|
|
||||||
(yodlee/delete-provider-account (-> (:client-id edn-params)
|
|
||||||
Long/parseLong
|
|
||||||
d-clients/get-by-id
|
|
||||||
:client/code)
|
|
||||||
(:provider-account-id edn-params))
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str {}) }
|
|
||||||
(catch Exception e
|
|
||||||
(log/error e)
|
|
||||||
{:status 400
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str {:message (.getMessage e)
|
|
||||||
:error (.toString e)})})))
|
|
||||||
(POST "/provider-accounts/:id" {:keys [query-params identity] {:keys [id]} :route-params :as request}
|
|
||||||
(assert-admin identity)
|
|
||||||
(try
|
|
||||||
(let [[session token] (yodlee/get-access-token)]
|
|
||||||
{:status 200
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str (yodlee/update-yodlee (Long/parseLong id))) })
|
|
||||||
(catch Exception e
|
|
||||||
{:status 400
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:body (pr-str e)}))))
|
|
||||||
wrap-secure))
|
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
|
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||||
(ns auto-ap.core
|
(ns auto-ap.core
|
||||||
(:require [reagent.core :as reagent]
|
(:require [reagent.core :as reagent]
|
||||||
[reagent.dom :as rdom]
|
[reagent.dom :as rdom]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.views.main :refer [page active-page] ]
|
[auto-ap.views.main :refer [active-page] ]
|
||||||
[auto-ap.reload :as reload]
|
[auto-ap.reload :as reload]
|
||||||
[auto-ap.events :as events]
|
|
||||||
|
|
||||||
[auto-ap.config :as config]
|
[auto-ap.config :as config]
|
||||||
[auto-ap.effects :as effects]
|
[auto-ap.effects :as effects]
|
||||||
[pushy.core :as pushy]
|
[pushy.core :as pushy]
|
||||||
@@ -32,8 +31,7 @@
|
|||||||
(do
|
(do
|
||||||
(.setItem js/localStorage "jwt" jwt)
|
(.setItem js/localStorage "jwt" jwt)
|
||||||
(re-frame/dispatch-sync [::events/initialize-db jwt]))
|
(re-frame/dispatch-sync [::events/initialize-db jwt]))
|
||||||
(do
|
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")]))
|
||||||
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")])))
|
|
||||||
(pushy/start! p/history)
|
(pushy/start! p/history)
|
||||||
(mount-root))
|
(mount-root))
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||||
(ns auto-ap.subs
|
(ns auto-ap.subs
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
@@ -6,6 +7,7 @@
|
|||||||
[minisearch :as ms]))
|
[minisearch :as ms]))
|
||||||
(set! *warn-on-infer* true)
|
(set! *warn-on-infer* true)
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:unresolved-symbol]}
|
||||||
(def MiniSearch (if ms (aget ms "default")
|
(def MiniSearch (if ms (aget ms "default")
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
@@ -211,7 +213,7 @@
|
|||||||
all-vendors
|
all-vendors
|
||||||
|
|
||||||
client
|
client
|
||||||
(filter (fn [{:keys [hidden usage name] :as vendor}]
|
(filter (fn [{:keys [hidden usage]}]
|
||||||
(or (not hidden)
|
(or (not hidden)
|
||||||
(-> (first (filter #(= (:client-id %)
|
(-> (first (filter #(= (:client-id %)
|
||||||
(:id client))
|
(:id client))
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[react-signature-canvas :as canvas]))
|
[react-signature-canvas]))
|
||||||
|
|
||||||
(def signature-canvas (r/adapt-react-class (.-default canvas)))
|
(def signature-canvas (r/adapt-react-class (.-default react-signature-canvas)))
|
||||||
|
|
||||||
(defn upload-replacement-button [{:keys [on-change]} text]
|
(defn upload-replacement-button [{:keys [on-change]} text]
|
||||||
(let [button (atom nil)]
|
(let [button (atom nil)]
|
||||||
|
|||||||
@@ -2,21 +2,17 @@
|
|||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[reagent.dom :as rdom]
|
[reagent.dom :as rdom]
|
||||||
[auto-ap.events :as events]
|
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.entities.clients :as client]
|
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||||
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar]]
|
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar]]
|
||||||
[auto-ap.views.utils :refer [dispatch-event bind-field with-user]]
|
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
|
||||||
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||||
[cljs.reader :as edn]
|
[cljs.reader :as edn]
|
||||||
[clojure.string :as str]
|
|
||||||
[vimsical.re-frame.cofx.inject :as inject]
|
|
||||||
[auto-ap.status :as status]
|
[auto-ap.status :as status]
|
||||||
[vimsical.re-frame.fx.track :as track]
|
[vimsical.re-frame.fx.track :as track]
|
||||||
|
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||||
[dropzone :as dz]
|
[dropzone :as dz]
|
||||||
[auto-ap.views.pages.data-page :as data-page]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
@@ -37,7 +33,7 @@
|
|||||||
(fn []
|
(fn []
|
||||||
(re-frame/dispatch [::status/completed ::import])))
|
(re-frame/dispatch [::status/completed ::import])))
|
||||||
|
|
||||||
(.on t "success" (fn [_ files]
|
(.on t "success" (fn [_ _]
|
||||||
(re-frame/dispatch [::invalidated])))
|
(re-frame/dispatch [::invalidated])))
|
||||||
(.on t "error" (fn [_ error]
|
(.on t "error" (fn [_ error]
|
||||||
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]])))))
|
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]])))))
|
||||||
@@ -49,7 +45,6 @@
|
|||||||
:previewsContainer "#dz-hidden"
|
:previewsContainer "#dz-hidden"
|
||||||
:previewTemplate "<div class='dz-hidden-preview'></div>"})))
|
:previewTemplate "<div class='dz-hidden-preview'></div>"})))
|
||||||
:reagent-render (fn []
|
:reagent-render (fn []
|
||||||
{:key batch}
|
|
||||||
[:form.dz {:action "/api/invoices/upload"}
|
[:form.dz {:action "/api/invoices/upload"}
|
||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
@@ -87,14 +82,14 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::invalidated
|
::invalidated
|
||||||
(fn [{:keys [db]} [_ params]]
|
(fn [{:keys [db]} _]
|
||||||
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
||||||
[::data-page/reset-checked :import-invoices]]
|
[::data-page/reset-checked :import-invoices]]
|
||||||
:db (update db ::batch inc)}))
|
:db (update db ::batch inc)}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::mounted
|
::mounted
|
||||||
(fn [cofx [_ params]]
|
(fn [_ _]
|
||||||
{::track/register [{:id ::params
|
{::track/register [{:id ::params
|
||||||
:subscription [::data-page/params :import-invoices]
|
:subscription [::data-page/params :import-invoices]
|
||||||
:event-fn (fn [params]
|
:event-fn (fn [params]
|
||||||
@@ -107,7 +102,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::unmounted
|
::unmounted
|
||||||
(fn [cofx [_ params]]
|
(fn [_ _]
|
||||||
{::track/dispose {:id ::params}
|
{::track/dispose {:id ::params}
|
||||||
:dispatch [::data-page/dispose :import-invoices]}))
|
:dispatch [::data-page/dispose :import-invoices]}))
|
||||||
|
|
||||||
@@ -132,7 +127,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::reject-invoices-clicked
|
::reject-invoices-clicked
|
||||||
(fn [{:keys [db]} [_ invoices on-success]]
|
(fn [{:keys [db]} [_ invoices]]
|
||||||
{:graphql
|
{:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:owns-state {:single ::reject}
|
:owns-state {:single ::reject}
|
||||||
@@ -145,7 +140,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::approve-invoices-clicked
|
::approve-invoices-clicked
|
||||||
(fn [{:keys [db]} [_ invoices on-success]]
|
(fn [{:keys [db]} [_ invoices]]
|
||||||
{:graphql
|
{:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:owns-state {:single ::approve}
|
:owns-state {:single ::approve}
|
||||||
@@ -173,20 +168,18 @@
|
|||||||
:disabled (or (not (boolean (seq checked)))
|
:disabled (or (not (boolean (seq checked)))
|
||||||
(status/disabled-for @(re-frame/subscribe [::status/single ::approve])))}
|
(status/disabled-for @(re-frame/subscribe [::status/single ::approve])))}
|
||||||
"Approve "
|
"Approve "
|
||||||
(when (> (count checked ))
|
(str
|
||||||
(str
|
(count checked)
|
||||||
(count checked)
|
" invoices")
|
||||||
" invoices"))
|
|
||||||
[:span " "]]
|
[:span " "]]
|
||||||
[:button.button.is-warning {:on-click (dispatch-event [::reject-invoices-clicked checked])
|
[:button.button.is-warning {:on-click (dispatch-event [::reject-invoices-clicked checked])
|
||||||
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
|
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
|
||||||
:disabled (or (not (boolean (seq checked)))
|
:disabled (or (not (boolean (seq checked)))
|
||||||
(status/disabled-for @(re-frame/subscribe [::status/single ::reject])))}
|
(status/disabled-for @(re-frame/subscribe [::status/single ::reject])))}
|
||||||
"Reject "
|
"Reject "
|
||||||
(when (> (count checked ))
|
(str
|
||||||
(str
|
(count checked)
|
||||||
(count checked)
|
" invoices")
|
||||||
" invoices"))
|
|
||||||
[:span " "]]])
|
[:span " "]]])
|
||||||
|
|
||||||
(def import-invoices-content
|
(def import-invoices-content
|
||||||
|
|||||||
Reference in New Issue
Block a user