Merge branch 'master' into datomic

This commit is contained in:
BC
2018-10-25 21:13:18 -07:00
6 changed files with 90 additions and 27 deletions

View File

@@ -11,6 +11,7 @@
[auto-ap.subs :as subs]))
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
[action-modal {:id id
:title [:span (if (:id vendor)
@@ -23,7 +24,7 @@
:save-event save-event
:can-submit? (s/valid? ::entity/vendor vendor)}
(doto (s/explain ::entity/vendor vendor) println)
[horizontal-field
[:label.label "Name"]

View File

@@ -2,6 +2,7 @@
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
[clojure.string :as str]
[auto-ap.subs :as subs]
[auto-ap.events.admin.companies :as events]
[auto-ap.entities.companies :as entity]
@@ -56,6 +57,28 @@
:on-success [::got-accounts]
:on-error [::save-error]}}))
(re-frame/reg-event-fx
::kicked
(fn [{:keys [db]} [_ id state]]
{:db (update-in db [::yodlee :accounts]
(fn [as]
(map (fn [a]
(if (= (:id a) id)
(assoc a :status state)
a))
as)))}))
(re-frame/reg-event-fx
::kick
(fn [{:keys [db]} [_ id]]
{:http {:token (:user db)
:method :post
:headers {"Content-Type" "application/edn"}
:uri (str "/api/yodlee/accounts/" id)
:on-success [::kicked id :kicking]
:on-error [::kicked id :errored]}}))
(re-frame/reg-event-fx
::got-accounts
(fn [{:keys [db]} [_ accounts]]
@@ -106,15 +129,30 @@
[:tr
[:th "Account Name"]
[:th "Account Number"]
[:th "Yodlee Account Number"]]]
[:th "Yodlee Account Number"]
[:th "Yodlee Last updated"]
[:th "Yodlee Status"]
[:th]]]
(if @(re-frame/subscribe [::accounts-loading?])
[:tr [:td {:col-span "3"} "Loading..."]
[:tr [:td {:col-span "6"} "Loading..."]
]
(for [account @(re-frame/subscribe [::accounts])]
[:tr
[:td (:accountName account)]
[:td (:accountNumber account)]
[:td (:id account)]]))]])
[:td (:id account)]
[:td (str/join ", " (map :lastUpdated (:dataset account)))]
[:td (str/join ", " (map :additionalStatus (:dataset account)))]
[:td
(cond (= (:status account) :kicking)
[:button.button.is-success.is-loading {:disabled "disabled"} "Kick."]
(= (:status account) :error)
[:button.button.is-error.is-loading {:disabled "disabled"} "Error."]
:else
[:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Kick." ])]]))]])
(defn admin-yodlee-page []