diff --git a/src/clj/auto_ap/routes/yodlee.clj b/src/clj/auto_ap/routes/yodlee.clj index 56d34e88..97ec09b8 100644 --- a/src/clj/auto_ap/routes/yodlee.clj +++ b/src/clj/auto_ap/routes/yodlee.clj @@ -36,5 +36,11 @@ (let [[session token] (yodlee/get-access-token)] {:status 200 :headers {"Content-Type" "application/edn"} - :body (pr-str (yodlee/get-accounts)) }))) + :body (pr-str (yodlee/get-accounts)) })) + (POST "/accounts/:id" {:keys [query-params identity] {:keys [id]} :route-params :as request} + (assert-admin identity) + (let [[session token] (yodlee/get-access-token)] + {:status 200 + :headers {"Content-Type" "application/edn"} + :body (pr-str (yodlee/update-yodlee (Long/parseLong id))) }))) wrap-secure)) diff --git a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs index 221975a7..fd929e06 100644 --- a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs +++ b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs @@ -57,6 +57,18 @@ :on-success [::got-accounts] :on-error [::save-error]}})) + +(re-frame/reg-event-fx + ::kick + (fn [{:keys [db]} [_ id]] + {:db (assoc-in db [::yodlee] {:accounts-loading? true}) + :http {:token (:user db) + :method :post + :headers {"Content-Type" "application/edn"} + :uri (str "/api/yodlee/accounts/" id) + :on-success [::mounted] + :on-error [::save-error]}})) + (re-frame/reg-event-fx ::got-accounts (fn [{:keys [db]} [_ accounts]] @@ -108,7 +120,9 @@ [:th "Account Name"] [:th "Account Number"] [:th "Yodlee Account Number"] + [:th "Yodlee Last updated"] [:th "Yodlee Status"]]] + (if @(re-frame/subscribe [::accounts-loading?]) [:tr [:td {:col-span "3"} "Loading..."] ] @@ -117,7 +131,9 @@ [:td (:accountName account)] [:td (:accountNumber account)] [:td (:id account)] + [:td (str/join ", " (map :lastUpdated (:dataset account)))] [:td (str/join ", " (map :additionalStatus (:dataset account)))] + [:td [:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Kick." ]] ]))]])