From 6dbdd4c8c739a1e0309309b939be1e3e99d4b58b Mon Sep 17 00:00:00 2001 From: Gregg8 Date: Wed, 10 Jan 2018 16:34:35 +1100 Subject: [PATCH] Refactored Overview to Event, added Timing panel and hid View panel --- src/day8/re_frame/trace/db.cljs | 2 +- src/day8/re_frame/trace/view/container.cljs | 120 ++++++++++---------- src/day8/re_frame/trace/view/event.cljs | 19 ++++ src/day8/re_frame/trace/view/overview.cljs | 19 ---- src/day8/re_frame/trace/view/timing.cljs | 15 +++ 5 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 src/day8/re_frame/trace/view/event.cljs delete mode 100644 src/day8/re_frame/trace/view/overview.cljs create mode 100644 src/day8/re_frame/trace/view/timing.cljs diff --git a/src/day8/re_frame/trace/db.cljs b/src/day8/re_frame/trace/db.cljs index 1a54b79..32657b1 100644 --- a/src/day8/re_frame/trace/db.cljs +++ b/src/day8/re_frame/trace/db.cljs @@ -5,7 +5,7 @@ (defn init-db [] (let [panel-width% (localstorage/get "panel-width-ratio" 0.35) show-panel? (localstorage/get "show-panel" false) - selected-tab (localstorage/get "selected-tab" :overview) + selected-tab (localstorage/get "selected-tab" :event) filter-items (localstorage/get "filter-items" []) app-db-paths (localstorage/get "app-db-paths" '()) json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{}) diff --git a/src/day8/re_frame/trace/view/container.cljs b/src/day8/re_frame/trace/view/container.cljs index e4d3e5a..3056a5a 100644 --- a/src/day8/re_frame/trace/view/container.cljs +++ b/src/day8/re_frame/trace/view/container.cljs @@ -2,11 +2,12 @@ (:require-macros [day8.re-frame.trace.utils.macros :as macros]) (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf] [re-frame.db :as db] - [day8.re-frame.trace.view.overview :as overview] + [day8.re-frame.trace.view.event :as event] [day8.re-frame.trace.view.app-db :as app-db] [day8.re-frame.trace.view.subs :as subs] [day8.re-frame.trace.view.views :as views] [day8.re-frame.trace.view.traces :as traces] + [day8.re-frame.trace.view.timing :as timing] [day8.re-frame.trace.view.debug :as debug] [day8.re-frame.trace.view.settings :as settings] [garden.core :refer [css style]] @@ -31,27 +32,26 @@ (let [selected-tab (rf/subscribe [:settings/selected-tab]) showing-settings? (= @selected-tab :settings)] [rc/h-box - :align :center - :children - [(when showing-settings? - [:button {:class "bm-active-button" - :on-click #(rf/dispatch [:settings/toggle-settings])} "Done"]) - [:img.nav-icon.noselect - {:title "Pause" - :src (str "data:image/svg+xml;utf8," - pause-svg) - :on-click #(rf/dispatch [:settings/pause])}] - [:img.nav-icon.noselect - {:title "Settings" - :src (str "data:image/svg+xml;utf8," - (if showing-settings? orange-settings-svg settings-svg)) - :on-click #(rf/dispatch [:settings/toggle-settings])}] - (when-not external-window? - [:img.nav-icon.active.noselect - {:title "Pop out" - :src (str "data:image/svg+xml;utf8," - open-external) - :on-click #(rf/dispatch-sync [:global/launch-external])}])]]) + :align :center + :children [(when showing-settings? + [:button {:class "bm-active-button" + :on-click #(rf/dispatch [:settings/toggle-settings])} "Done"]) + [:img.nav-icon.noselect + {:title "Pause" + :src (str "data:image/svg+xml;utf8," + pause-svg) + :on-click #(rf/dispatch [:settings/pause])}] + [:img.nav-icon.noselect + {:title "Settings" + :src (str "data:image/svg+xml;utf8," + (if showing-settings? orange-settings-svg settings-svg)) + :on-click #(rf/dispatch [:settings/toggle-settings])}] + (when-not external-window? + [:img.nav-icon.active.noselect + {:title "Pop out" + :src (str "data:image/svg+xml;utf8," + open-external) + :on-click #(rf/dispatch-sync [:global/launch-external])}])]]) ) (defn settings-header [external-window?] @@ -59,8 +59,7 @@ :align :center :size "auto" :gap common/gs-12s - :children - [[rc/label :class "bm-title-text" :label "Settings"]]] + :children [[rc/label :class "bm-title-text" :label "Settings"]]] ;; TODO: this line needs to be between Done and other buttons [rc/gap-f :size common/gs-12s] [rc/line :size "2px" :color common/sidebar-heading-divider-color] @@ -70,15 +69,14 @@ (defn standard-header [external-window?] (let [current-event @(rf/subscribe [:epochs/current-event])] [[rc/h-box - :align :center - :size "auto" - :gap common/gs-12s - :children - [[:span.arrow {:on-click #(rf/dispatch [:epochs/previous-epoch])} "◀"] - [rc/v-box - :size "auto" - :children [[:span.event-header (prn-str current-event)]]] - [:span.arrow {:on-click #(rf/dispatch [:epochs/next-epoch])} "▶"]]] + :align :center + :size "auto" + :gap common/gs-12s + :children [[:span.arrow {:on-click #(rf/dispatch [:epochs/previous-epoch])} "◀"] + [rc/v-box + :size "auto" + :children [[:span.event-header (prn-str current-event)]]] + [:span.arrow {:on-click #(rf/dispatch [:epochs/next-epoch])} "▶"]]] [rc/gap-f :size common/gs-12s] [rc/line :size "2px" :color common/sidebar-heading-divider-color] [right-hand-buttons external-window?]]) @@ -94,31 +92,27 @@ {:style {:width "100%" :display "flex" :flex-direction "column" :background-color common/standard-background-color}} (if showing-settings? [rc/h-box - :class "panel-content-top nav" - :style {:padding "0px 19px"} - :children - (settings-header external-window?)] + :class "panel-content-top nav" + :style {:padding "0px 19px"} + :children (settings-header external-window?)] [rc/h-box - :class "panel-content-top nav" - :style {:padding "0px 19px"} - :children - (standard-header external-window?)]) + :class "panel-content-top nav" + :style {:padding "0px 19px"} + :children (standard-header external-window?)]) (when-not showing-settings? [rc/h-box - :class "panel-content-tabs" - :justify :between - :children - [[rc/h-box - :gap "7px" - :align :center - :children - [(tab-button :overview "Overview") - (tab-button :app-db "app-db") - (tab-button :subs "Subs") - (tab-button :views "Views") - (tab-button :traces "Trace") - (tab-button :debug "Debug")]] - ]]) + :class "panel-content-tabs" + :justify :between + :children [[rc/h-box + :gap "7px" + :align :center + :children [(tab-button :event "Event") + (tab-button :app-db "app-db") + (tab-button :subs "Subs") + ;(tab-button :views "Views") + (tab-button :traces "Trace") + (tab-button :timing "Timing") + (tab-button :debug "Debug")]]]]) [rc/line :color "#EEEEEE"] (when (and external-window? @unloading?) [:h1.host-closed "Host window has closed. Reopen external window to continue tracing."]) @@ -127,13 +121,13 @@ [rc/v-box :size "auto" :style {:margin-left common/gs-19s :overflow "auto"} - :children - [(case @selected-tab - :overview [overview/render traces] - :app-db [app-db/render-state db/app-db] - :subs [subs/subs-panel] - :views [views/render] - :traces [traces/render-trace-panel traces] - :debug [debug/render-debug] + :children [(case @selected-tab + :event [event/render traces] + :app-db [app-db/render-state db/app-db] + :subs [subs/subs-panel] + :views [views/render] + :traces [traces/render-trace-panel traces] + :timing [timing/render] + :debug [debug/render-debug] :settings [settings/render] [app-db/render-state db/app-db])]]])) diff --git a/src/day8/re_frame/trace/view/event.cljs b/src/day8/re_frame/trace/view/event.cljs new file mode 100644 index 0000000..ef6eaa6 --- /dev/null +++ b/src/day8/re_frame/trace/view/event.cljs @@ -0,0 +1,19 @@ +(ns day8.re-frame.trace.view.event + (:require [day8.re-frame.trace.utils.re-com :as rc] + [day8.re-frame.trace.metamorphic :as metam])) + +(defn render [traces] + [rc/v-box + :padding "12px 0px" + :children [[rc/label :label "Event"] + [rc/label :label "Dispatch Point"] + [rc/label :label "Coeffects"] + [rc/label :label "Effects"] + [rc/label :label "Interceptors"] + + [rc/h-box + :children [[:p "Subs Run"] [:p "Created"] [:p "Destroyed"]]] + [:p "Views Rendered"] + [rc/h-box + :children [[:p "Timing"] [:p "Animation Frames"]]] + ]]) diff --git a/src/day8/re_frame/trace/view/overview.cljs b/src/day8/re_frame/trace/view/overview.cljs deleted file mode 100644 index 4b10f9b..0000000 --- a/src/day8/re_frame/trace/view/overview.cljs +++ /dev/null @@ -1,19 +0,0 @@ -(ns day8.re-frame.trace.view.overview - (:require [day8.re-frame.trace.utils.re-com :as rc] - [day8.re-frame.trace.metamorphic :as metam])) - -(defn render [traces] - [rc/v-box - :children - [[rc/label :label "Event"] - [rc/label :label "Dispatch Point"] - [rc/label :label "Coeffects"] - [rc/label :label "Effects"] - [rc/label :label "Interceptors"] - - [rc/h-box - :children [[:p "Subs Run"] [:p "Created"] [:p "Destroyed"]]] - [:p "Views Rendered"] - [rc/h-box - :children [[:p "Timing"] [:p "Animation Frames"]]] - ]]) diff --git a/src/day8/re_frame/trace/view/timing.cljs b/src/day8/re_frame/trace/view/timing.cljs new file mode 100644 index 0000000..e1bbd1b --- /dev/null +++ b/src/day8/re_frame/trace/view/timing.cljs @@ -0,0 +1,15 @@ +(ns day8.re-frame.trace.view.timing + (:require [clojure.string :as str] + [devtools.prefs] + [devtools.formatters.core] + [day8.re-frame.trace.view.components :as components] + [mranderson047.re-frame.v0v10v2.re-frame.core :as rf] + [mranderson047.reagent.v0v6v0.reagent.core :as r] + [day8.re-frame.trace.utils.re-com :as rc] + [day8.re-frame.trace.common-styles :as common]) + (:require-macros [day8.re-frame.trace.utils.macros :as macros])) + +(defn render [] + [rc/v-box + :padding "12px 0px" + :children [[rc/label :label "Timing panel"]]])