mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-02-10 05:03:49 +00:00
Refactor code
This commit is contained in:
parent
7b55f8d8fb
commit
e42e7d23a9
@ -137,7 +137,7 @@
|
|||||||
nil)}])))
|
nil)}])))
|
||||||
|
|
||||||
(defn query->fn [query]
|
(defn query->fn [query]
|
||||||
(if (= "contains" (:filter-type query))
|
(if (= :contains (:filter-type query))
|
||||||
(fn [trace]
|
(fn [trace]
|
||||||
(str/includes? (str/lower-case (str (:operation trace) " " (:op-type trace)))
|
(str/includes? (str/lower-case (str (:operation trace) " " (:op-type trace)))
|
||||||
(:query query)))
|
(:query query)))
|
||||||
@ -150,7 +150,6 @@
|
|||||||
(let [padding {:padding "0px 5px 0px 5px"}
|
(let [padding {:padding "0px 5px 0px 5px"}
|
||||||
row-style (merge padding {:border-top (case op-type :event "1px solid lightgrey" nil)})
|
row-style (merge padding {:border-top (case op-type :event "1px solid lightgrey" nil)})
|
||||||
#_#__ (js/console.log (devtools/header-api-call tags))]
|
#_#__ (js/console.log (devtools/header-api-call tags))]
|
||||||
|
|
||||||
(list [:tr {:key id
|
(list [:tr {:key id
|
||||||
:style {:color (case op-type
|
:style {:color (case op-type
|
||||||
:sub/create "green"
|
:sub/create "green"
|
||||||
@ -172,21 +171,17 @@
|
|||||||
[:tr {:key (str id "-details")}
|
[:tr {:key (str id "-details")}
|
||||||
[:td {:col-span 3} (with-out-str (pprint/pprint (dissoc tags :query-v :event :duration)))]]))))))
|
[:td {:col-span 3} (with-out-str (pprint/pprint (dissoc tags :query-v :event :duration)))]]))))))
|
||||||
|
|
||||||
(defonce app-state [:traces {:filter-input ""
|
|
||||||
:filter-items []}]) ;; [{:id (random-uuid) :query "showing" :filter-type "contains"} {:id (random-uuid) :query "Reagent" :filter-type "contains"}
|
|
||||||
|
|
||||||
(defn render-trace-panel []
|
(defn render-trace-panel []
|
||||||
(let [filter-input (r/atom "")
|
(let [filter-input (r/atom "")
|
||||||
filter-items (r/atom [])
|
filter-items (r/atom [])
|
||||||
filter-type (r/atom "contains")]
|
filter-type (r/atom :contains)]
|
||||||
(fn []
|
(fn []
|
||||||
(let [showing-traces (if (= @filter-items [])
|
(let [showing-traces (if (= @filter-items [])
|
||||||
@traces
|
@traces
|
||||||
(filter (apply every-pred (map query->fn @filter-items)) @traces))
|
(filter (apply every-pred (map query->fn @filter-items)) @traces))
|
||||||
save-query (fn [_]
|
save-query (fn [_]
|
||||||
(println @filter-type @filter-input)
|
|
||||||
(swap! filter-items conj {:id (random-uuid)
|
(swap! filter-items conj {:id (random-uuid)
|
||||||
:query (if (= @filter-type "contains")
|
:query (if (= @filter-type :contains)
|
||||||
(str/lower-case @filter-input)
|
(str/lower-case @filter-input)
|
||||||
(js/parseInt @filter-input))
|
(js/parseInt @filter-input))
|
||||||
:filter-type @filter-type}))]
|
:filter-type @filter-type}))]
|
||||||
@ -195,19 +190,15 @@
|
|||||||
[:div.filter-control-input
|
[:div.filter-control-input
|
||||||
{:style {:margin-bottom 10}}
|
{:style {:margin-bottom 10}}
|
||||||
[:select {:value @filter-type :on-change (fn [e]
|
[:select {:value @filter-type :on-change (fn [e]
|
||||||
(reset! filter-type (.. e -target -value))
|
(reset! filter-type
|
||||||
(println (.. e -target -value)))}
|
(keyword (str/replace (.. e -target -value) " " "-"))))}
|
||||||
[:option "contains"]
|
[:option :contains]
|
||||||
[:option "slower than"]]
|
[:option :slower-than]]
|
||||||
[search-input {:on-save save-query
|
[search-input {:on-save save-query
|
||||||
:on-change #(reset! filter-input (.. % -target -value))}]
|
:on-change #(reset! filter-input (.. % -target -value))}]
|
||||||
[:button.button.icon-button {:on-click save-query
|
[:button.button.icon-button {:on-click save-query
|
||||||
:style {:margin 0}}
|
:style {:margin 0}}
|
||||||
[components/icon-add]]
|
[components/icon-add]]
|
||||||
;; [:button {:style {:background "#aae0ec"
|
|
||||||
;; :padding 7
|
|
||||||
;; :margin 5}}
|
|
||||||
;; "-"]]
|
|
||||||
[:br]]
|
[:br]]
|
||||||
[:ul.filter-items
|
[:ul.filter-items
|
||||||
(map (fn [item]
|
(map (fn [item]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user