Refactor adding new filters

This commit is contained in:
Saskia Lindner 2017-08-31 11:55:54 +02:00
parent df1bc168fa
commit e3c9eb6947
1 changed files with 8 additions and 12 deletions

View File

@ -145,16 +145,12 @@
(fn [trace] (fn [trace]
(< (:query query) (:duration trace))))) (< (:query query) (:duration trace)))))
(defn add-filter [filter-items filter-input filter-type from-mouse?] (defn add-filter [filter-items filter-input filter-type]
(swap! filter-items conj {:id (random-uuid) (swap! filter-items conj {:id (random-uuid)
:query (if from-mouse? :query (if (= filter-type :contains)
(str/lower-case (name filter-input)) (str/lower-case filter-input)
(if (= @filter-type :contains) (js/parseFloat filter-input))
(str/lower-case @filter-input) :filter-type filter-type}))
(js/parseFloat @filter-input)))
:filter-type (if from-mouse?
:contains
@filter-type)}))
(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions] (defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
(doall (doall
@ -183,13 +179,13 @@
[:td {:style row-style} [:td {:style row-style}
[:div.op-string [:div.op-string
[:span {:on-click (fn [ev] [:span {:on-click (fn [ev]
(add-filter filter-items (name op-type) :contains true) (add-filter filter-items (name op-type) :contains)
(.stopPropagation ev))} (.stopPropagation ev))}
(str op-type)]]] (str op-type)]]]
[:td {:style row-style} [:td {:style row-style}
[:div.op-string [:div.op-string
[:span {:on-click (fn [ev] [:span {:on-click (fn [ev]
(add-filter filter-items (name op-name) :contains true) (add-filter filter-items (name op-name) :contains)
(.stopPropagation ev))} (.stopPropagation ev))}
op-name]]] op-name]]]
[:td [:td
@ -228,7 +224,7 @@
(reset! input-error true) (reset! input-error true)
(do (do
(reset! input-error false) (reset! input-error false)
(add-filter filter-items filter-input filter-type false))))] (add-filter filter-items @filter-input @filter-type))))]
[:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}} [:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}}