Merge pull request #48 from Day8/feature/extend-filter

Enable selecting trace names as filters
This commit is contained in:
Dexter Gramfors 2017-08-31 12:12:48 +02:00 committed by GitHub
commit 04e86a84a4
1 changed files with 39 additions and 23 deletions

View File

@ -146,31 +146,49 @@
(fn [trace] (fn [trace]
(< (:query query) (:duration trace))))) (< (:query query) (:duration trace)))))
(defn render-traces [showing-traces trace-detail-expansions] (defn add-filter [filter-items filter-input filter-type]
(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}))
(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
(doall (doall
(for [{:keys [op-type id operation tags duration] :as trace} showing-traces] (for [{:keys [op-type id operation tags duration] :as trace} showing-traces]
(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)})
show-row? (get-in @trace-detail-expansions [:overrides id] show-row? (get-in @trace-detail-expansions [:overrides id]
(:show-all? @trace-detail-expansions)) (:show-all? @trace-detail-expansions))
op-name (if (vector? operation)
(second operation)
operation)
#_#__ (js/console.log (devtools/header-api-call tags))] #_#__ (js/console.log (devtools/header-api-call tags))]
(list [:tr {:key id (list [:tr {:key id
:on-click (fn [ev] :on-click (fn [ev]
(swap! trace-detail-expansions update-in [:overrides id] (swap! trace-detail-expansions update-in [:overrides id]
#(if show-row? false (not %)))) #(if show-row? false (not %))))
:style {:color (case op-type :style {:color (case op-type
:sub/create "green" :sub/create "green"
:sub/run "#fd701e" :sub/run "#fd701e"
:event "blue" :event "blue"
:render "purple" :render "purple"
:re-frame.router/fsm-trigger "#fd701e" :re-frame.router/fsm-trigger "#fd701e"
nil)}} nil)}}
[:td {:style row-style} [:td {:style row-style}
[:button (if show-row? "▼" "▶")]] [:button (if show-row? "▼" "▶")]]
[:td {:style row-style} (str op-type)] [:td {:style row-style}
[:td {:style row-style} (if (= PersistentVector (type (js->clj operation))) [:div.op-string
(second operation) [:span {:on-click (fn [ev]
operation)] (add-filter filter-items (name op-type) :contains)
(.stopPropagation ev))}
(str op-type)]]]
[:td {:style row-style}
[:div.op-string
[:span {:on-click (fn [ev]
(add-filter filter-items (name op-name) :contains)
(.stopPropagation ev))}
op-name]]]
[:td [:td
{:style (merge row-style { {:style (merge row-style {
; :font-weight (if (< slower-than-bold-int duration) ; :font-weight (if (< slower-than-bold-int duration)
@ -207,11 +225,9 @@
(reset! input-error true) (reset! input-error true)
(do (do
(reset! input-error false) (reset! input-error false)
(swap! filter-items conj {:id (random-uuid) (add-filter filter-items @filter-input @filter-type))))]
:query (if (= @filter-type :contains)
(str/lower-case @filter-input)
(js/parseFloat @filter-input))
:filter-type @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"}}
[:div.filter-control [:div.filter-control
[:div.filter-control-input [:div.filter-control-input
@ -260,7 +276,7 @@
(when (pos? (count @traces)) (when (pos? (count @traces))
[:span "(" [:button.text-button {:on-click #(do (trace/reset-tracing!) (reset! traces []))} "clear"] ")"])] [:span "(" [:button.text-button {:on-click #(do (trace/reset-tracing!) (reset! traces []))} "clear"] ")"])]
[:th "meta"]] [:th "meta"]]
[:tbody (render-traces showing-traces trace-detail-expansions)]]]])))) [:tbody (render-traces showing-traces filter-items filter-input trace-detail-expansions)]]]]))))
(defn resizer-style [draggable-area] (defn resizer-style [draggable-area]
{:position "absolute" :z-index 2 :opacity 0 {:position "absolute" :z-index 2 :opacity 0