making ssr pages incorporate auth.
This commit is contained in:
@@ -8,14 +8,19 @@
|
|||||||
merge-query
|
merge-query
|
||||||
pull-many
|
pull-many
|
||||||
query2]]
|
query2]]
|
||||||
[auto-ap.graphql.utils :refer [can-see-client? limited-clients]]
|
[auto-ap.graphql.utils :refer [can-see-client? extract-client-ids]]
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[datomic.api :as dc]))
|
[datomic.api :as dc]))
|
||||||
|
|
||||||
(def default-read '[:db/id :report/client :report/created :report/url :report/name :report/creator])
|
(def default-read '[:db/id :report/client :report/created :report/url :report/name :report/creator])
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(let [query (cond-> {:query {:find []
|
|
||||||
|
(let [valid-clients (extract-client-ids (:clients args)
|
||||||
|
(:client-id args)
|
||||||
|
(when (:client-code args)
|
||||||
|
[:client/code (:client-code args)]))
|
||||||
|
query (cond-> {:query {:find []
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where []}
|
:where []}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
@@ -24,7 +29,7 @@
|
|||||||
(seq (:clients args))
|
(seq (:clients args))
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :report/client ?xx]]}
|
:where ['[?e :report/client ?xx]]}
|
||||||
:args [(set (map :db/id (:clients args)))]})
|
:args [valid-clients]})
|
||||||
|
|
||||||
(:sort args) (add-sorter-fields {"client" ['[?e :report/client ?c]
|
(:sort args) (add-sorter-fields {"client" ['[?e :report/client ?c]
|
||||||
'[?c :client/name ?sort-client]]
|
'[?c :client/name ?sort-client]]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
merge-query
|
merge-query
|
||||||
pull-many
|
pull-many
|
||||||
query2]]
|
query2]]
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[datomic.api :as dc]))
|
[datomic.api :as dc]))
|
||||||
|
|
||||||
@@ -18,36 +18,37 @@
|
|||||||
(-> x (update :yodlee-provider-account/last-updated c/from-date)))
|
(-> x (update :yodlee-provider-account/last-updated c/from-date)))
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(->> (cond-> {:query {:find []
|
(let [valid-clients (extract-client-ids (:clients args)
|
||||||
:in ['$]
|
(:client-id args)
|
||||||
:where ['[?e :yodlee-provider-account/id]]}
|
(when (:client-code args)
|
||||||
:args [db]}
|
[:client/code (:client-code args)]))]
|
||||||
|
(->> (cond-> {:query {:find []
|
||||||
|
:in ['$ '[?xx ...]]
|
||||||
|
:where ['[?e :yodlee-provider-account/id]
|
||||||
|
'[?e :yodlee-provider-account/client ?xx]]}
|
||||||
|
:args [db valid-clients]}
|
||||||
|
|
||||||
(seq (:clients args))
|
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
|
||||||
:where ['[?e :yodlee-provider-account/client ?xx]]}
|
|
||||||
:args [(set (map :db/id (:clients args)))]})
|
|
||||||
|
|
||||||
(:client-id args)
|
(:client-id args)
|
||||||
(merge-query {:query {:in ['?client-id]
|
(merge-query {:query {:in ['?client-id]
|
||||||
:where ['[?e :yodlee-provider-account/client ?client-id]]}
|
:where ['[?e :yodlee-provider-account/client ?client-id]]}
|
||||||
:args [ (:client-id args)]})
|
:args [ (:client-id args)]})
|
||||||
|
|
||||||
(:client-code args)
|
(:client-code args)
|
||||||
(merge-query {:query {:in ['?client-code]
|
(merge-query {:query {:in ['?client-code]
|
||||||
:where ['[?e :yodlee-provider-account/client ?client-id]
|
:where ['[?e :yodlee-provider-account/client ?client-id]
|
||||||
'[?client-id :client/code ?client-code]]}
|
'[?client-id :client/code ?client-code]]}
|
||||||
:args [ (:client-code args)]})
|
:args [ (:client-code args)]})
|
||||||
|
|
||||||
(:sort args) (add-sorter-fields {"status" ['[?e :yodlee-provider-account/status ?sort-status]]}
|
(:sort args) (add-sorter-fields {"status" ['[?e :yodlee-provider-account/status ?sort-status]]}
|
||||||
args)
|
args)
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?e ]
|
(merge-query {:query {:find ['?e ]
|
||||||
:where ['[?e :yodlee-provider-account/id]]}}) )
|
:where ['[?e :yodlee-provider-account/id]]}}) )
|
||||||
|
|
||||||
(query2)
|
(query2)
|
||||||
(apply-sort-3 args)
|
(apply-sort-3 args)
|
||||||
(apply-pagination args)))
|
(apply-pagination args))))
|
||||||
|
|
||||||
|
|
||||||
(defn graphql-results [ids db _]
|
(defn graphql-results [ids db _]
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
(ns auto-ap.ssr.company.company-1099
|
(ns auto-ap.ssr.company.company-1099
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [apply-pagination-raw conn remove-nils]]
|
[auto-ap.datomic :refer [apply-pagination-raw conn remove-nils]]
|
||||||
[auto-ap.graphql.utils :refer [assert-can-see-client is-admin?]]
|
[auto-ap.graphql.utils
|
||||||
|
:refer [assert-can-see-client extract-client-ids is-admin?]]
|
||||||
[auto-ap.ssr-routes :as ssr-routes]
|
[auto-ap.ssr-routes :as ssr-routes]
|
||||||
[auto-ap.ssr.components :as com]
|
[auto-ap.ssr.components :as com]
|
||||||
[auto-ap.ssr.grid-page-helper :as helper]
|
[auto-ap.ssr.grid-page-helper :as helper]
|
||||||
@@ -10,8 +11,7 @@
|
|||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[cemerick.url :as url]
|
[cemerick.url :as url]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[datomic.api :as dc]
|
[datomic.api :as dc]))
|
||||||
[iol-ion.query :refer [can-see-client?]]))
|
|
||||||
|
|
||||||
(def vendor-read '[:db/id
|
(def vendor-read '[:db/id
|
||||||
:vendor/name
|
:vendor/name
|
||||||
@@ -45,7 +45,10 @@
|
|||||||
vendor-id)))
|
vendor-id)))
|
||||||
|
|
||||||
(defn get-1099-companies [user {:keys [clients] :as args}]
|
(defn get-1099-companies [user {:keys [clients] :as args}]
|
||||||
(let [
|
(let [valid-clients (extract-client-ids (:clients args)
|
||||||
|
(:client-id args)
|
||||||
|
(when (:client-code args)
|
||||||
|
[:client/code (:client-code args)]))
|
||||||
results (cond
|
results (cond
|
||||||
clients
|
clients
|
||||||
(dc/q '[:find
|
(dc/q '[:find
|
||||||
@@ -63,7 +66,7 @@
|
|||||||
[?p :payment/amount ?a]
|
[?p :payment/amount ?a]
|
||||||
[?p :payment/vendor ?v]]
|
[?p :payment/vendor ?v]]
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
(set (map :db/id clients))
|
valid-clients
|
||||||
vendor-read)
|
vendor-read)
|
||||||
|
|
||||||
(is-admin? user)
|
(is-admin? user)
|
||||||
@@ -100,7 +103,7 @@
|
|||||||
[?p :payment/amount ?a]
|
[?p :payment/amount ?a]
|
||||||
[?p :payment/vendor ?v]]
|
[?p :payment/vendor ?v]]
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
clients
|
valid-clients
|
||||||
vendor-read))
|
vendor-read))
|
||||||
all (->> results
|
all (->> results
|
||||||
(filter (fn [[_ _ a]]
|
(filter (fn [[_ _ a]]
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
pull-attr
|
pull-attr
|
||||||
pull-many-by-id
|
pull-many-by-id
|
||||||
query2]]
|
query2]]
|
||||||
[auto-ap.graphql.utils :refer [assert-can-see-client limited-clients]]
|
[auto-ap.graphql.utils
|
||||||
|
:refer [assert-can-see-client extract-client-ids]]
|
||||||
[auto-ap.logging :as alog]
|
[auto-ap.logging :as alog]
|
||||||
[auto-ap.plaid.core :as p]
|
[auto-ap.plaid.core :as p]
|
||||||
[auto-ap.ssr-routes :as ssr-routes]
|
[auto-ap.ssr-routes :as ssr-routes]
|
||||||
@@ -36,20 +37,20 @@
|
|||||||
:plaid-account/name]}])
|
:plaid-account/name]}])
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(let [query (cond-> {:query {:find []
|
(println "ARGS " args)
|
||||||
:in ['$]
|
(let [valid-clients (extract-client-ids (:clients args)
|
||||||
:where []}
|
(:client-id args)
|
||||||
:args [db]}
|
(when (:client-code args)
|
||||||
|
[:client/code (:client-code args)]))
|
||||||
|
query (cond-> {:query {:find []
|
||||||
|
:in ['$ '[?xx ...]]
|
||||||
|
:where ['[?e :plaid-item/client ?xx]]}
|
||||||
|
:args [db valid-clients]}
|
||||||
|
|
||||||
(:sort args) (add-sorter-fields {"external-id" ['[?e :plaid-item/external-id ?sort-external-id]]
|
(:sort args) (add-sorter-fields {"external-id" ['[?e :plaid-item/external-id ?sort-external-id]]
|
||||||
"status" ['[?e :plaid-item/status ?sort-status]]}
|
"status" ['[?e :plaid-item/status ?sort-status]]}
|
||||||
args)
|
args)
|
||||||
|
|
||||||
(:clients args)
|
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
|
||||||
:where ['[?e :plaid-item/client ?xx]]}
|
|
||||||
:args [ (set (map :db/id (:clients args)))]})
|
|
||||||
|
|
||||||
(:client-id args)
|
(:client-id args)
|
||||||
(merge-query {:query {:in '[?client-id]
|
(merge-query {:query {:in '[?client-id]
|
||||||
:where ['[?e :plaid-item/client ?client-id]]}
|
:where ['[?e :plaid-item/client ?client-id]]}
|
||||||
@@ -142,7 +143,7 @@
|
|||||||
:nav (com/company-aside-nav)
|
:nav (com/company-aside-nav)
|
||||||
:id-fn :db/id
|
:id-fn :db/id
|
||||||
:fetch-page (fn [user args]
|
:fetch-page (fn [user args]
|
||||||
(get-page (assoc args :id user)))
|
(get-page (assoc args :id user :clients (:clients (:request args)))))
|
||||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||||
:company)}
|
:company)}
|
||||||
"My Company"]
|
"My Company"]
|
||||||
|
|||||||
@@ -181,6 +181,7 @@
|
|||||||
request
|
request
|
||||||
(com/page {:nav (:nav grid-spec)
|
(com/page {:nav (:nav grid-spec)
|
||||||
:client-selection (:client-selection (:session request))
|
:client-selection (:client-selection (:session request))
|
||||||
|
:clients (:clients request)
|
||||||
:client (:client request)
|
:client (:client request)
|
||||||
:identity (:identity request)}
|
:identity (:identity request)}
|
||||||
(apply com/breadcrumbs {} (:breadcrumbs grid-spec))
|
(apply com/breadcrumbs {} (:breadcrumbs grid-spec))
|
||||||
|
|||||||
Reference in New Issue
Block a user