Refactor names and logic

This commit is contained in:
Saskia Lindner 2017-08-22 11:58:46 +02:00
parent b9a83a9908
commit fd21fec4e5
1 changed files with 10 additions and 13 deletions

View File

@ -149,8 +149,8 @@
(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? (get-in @trace-detail-expansions [:overrides id] show-row? (get-in @trace-detail-expansions [:overrides id]
(:showing @trace-detail-expansions)) (:show-all? @trace-detail-expansions))
#_#__ (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
@ -161,11 +161,9 @@
:re-frame.router/fsm-trigger "#fd701e" :re-frame.router/fsm-trigger "#fd701e"
nil)}} nil)}}
[:td {:style (merge row-style {:cursor "pointer"}) [:td {:style (merge row-style {:cursor "pointer"})
:on-click (fn [e] :on-click #(swap! trace-detail-expansions update-in [:overrides id]
(when show? (fn [bool] (if show-row? false (not bool))))}
(swap! trace-detail-expansions assoc-in [:overrides id] true)) (if show-row? "▼" "▶")]
(swap! trace-detail-expansions update-in [:overrides id] not))}
(if show? "▼" "▶")]
[:td {:style row-style} (str op-type)] [:td {:style row-style} (str op-type)]
[:td {:style row-style} (if (= PersistentVector (type (js->clj operation))) [:td {:style row-style} (if (= PersistentVector (type (js->clj operation)))
(second operation) (second operation)
@ -178,7 +176,7 @@
:white-space "nowrap"})} :white-space "nowrap"})}
(.toFixed duration 1) " ms"]] (.toFixed duration 1) " ms"]]
(when show? (when show-row?
[: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)))]]))))))
@ -187,7 +185,7 @@
filter-items (r/atom []) filter-items (r/atom [])
filter-type (r/atom :contains) filter-type (r/atom :contains)
input-error (r/atom false) input-error (r/atom false)
trace-detail-expansions (r/atom {:showing false :overrides {}})] trace-detail-expansions (r/atom {:show-all? false :overrides {}})]
(fn [] (fn []
(let [showing-traces (if (= @filter-items []) (let [showing-traces (if (= @filter-items [])
@traces @traces
@ -235,10 +233,9 @@
[:th [:button.text-button [:th [:button.text-button
{:style {:cursor "pointer"} {:style {:cursor "pointer"}
:on-click (fn [e] :on-click (fn [e]
(when (:showing @trace-detail-expansions) (swap! trace-detail-expansions assoc :overrides {})
(swap! trace-detail-expansions assoc :overrides {})) (swap! trace-detail-expansions update :show-all? not))}
(swap! trace-detail-expansions update :showing not))} (if (:show-all? @trace-detail-expansions) "-" "+")]]
(if (:showing @trace-detail-expansions) "-" "+")]]
[:th "operations"] [:th "operations"]
[:th [:th
(when (pos? (count @filter-items)) (when (pos? (count @filter-items))