Refactor save query function

This commit is contained in:
Saskia Lindner 2017-08-29 16:43:27 +02:00
parent 48f17700d3
commit 50deba5281

View File

@ -144,20 +144,27 @@
(fn [trace]
(< (:query query) (:duration trace)))))
(defn render-traces [showing-traces filter-items trace-detail-expansions]
(defn add-filter [filter-items filter-input filter-type from-mouse?]
(swap! filter-items conj {:id (random-uuid)
:query (if from-mouse?
(str/lower-case (name filter-input))
(if (= @filter-type :contains)
(str/lower-case @filter-input)
(js/parseFloat @filter-input)))
:filter-type (if from-mouse?
:contains
@filter-type)}))
(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
(doall
(for [{:keys [op-type id operation tags duration] :as trace} showing-traces]
(let [padding {:padding "0px 5px 0px 5px"}
row-style (merge padding {:border-top (case op-type :event "1px solid lightgrey" nil)})
show-row? (get-in @trace-detail-expansions [:overrides id]
(:show-all? @trace-detail-expansions))
show-row? (get-in @trace-detail-expansions [:overrides id]
(:show-all? @trace-detail-expansions))
op-name (if (vector? operation)
(second operation)
operation)
save-query (fn [filter-for-string]
(swap! filter-items conj {:id (random-uuid)
:query (str/lower-case (name filter-for-string))
:filter-type :contains}))
#_#__ (js/console.log (devtools/header-api-call tags))]
(list [:tr {:key id
:on-click (fn [ev]
@ -175,15 +182,15 @@
[:td {:style row-style}
[:div.op-string
[:span {:on-click (fn [ev]
(save-query op-type)
(.stopPropagation ev))
:style {:cursor "pointer"}} (str op-type)]]]
(add-filter filter-items (name op-type) :contains true)
(.stopPropagation ev))}
(str op-type)]]]
[:td {:style row-style}
[:div.op-string
[:span {:on-click (fn [ev]
(save-query op-name)
(.stopPropagation ev))
:style {:cursor "pointer"}}] op-name]]
(add-filter filter-items (name op-name) :contains true)
(.stopPropagation ev))}
op-name]]]
[:td
{:style (merge row-style {
; :font-weight (if (< slower-than-bold-int duration)
@ -212,11 +219,9 @@
(reset! input-error true)
(do
(reset! input-error false)
(swap! filter-items conj {:id (random-uuid)
:query (if (= @filter-type :contains)
(str/lower-case @filter-input)
(js/parseFloat @filter-input))
:filter-type @filter-type}))))]
(add-filter filter-items filter-input filter-type false))))]
[:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}}
[:div.filter-control
[:div.filter-control-input
@ -264,7 +269,7 @@
(when (pos? (count @traces))
[:span "(" [:button.text-button {:on-click #(do (trace/reset-tracing!) (reset! traces []))} "clear"] ")"])]
[:th "meta"]]
[:tbody (render-traces showing-traces filter-items trace-detail-expansions)]]]]))))
[:tbody (render-traces showing-traces filter-items filter-input trace-detail-expansions)]]]]))))
(defn resizer-style [draggable-area]
{:position "absolute" :z-index 2 :opacity 0