Add setting to ignore events/epochs
This commit is contained in:
parent
db14e69f17
commit
022a070fb8
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. This change
|
|||
|
||||
* Setting to control how many epochs are retained
|
||||
* Setting to reset all epochs
|
||||
* Setting to ignore epochs
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})
|
||||
external-window? (localstorage/get "external-window?" false)
|
||||
using-trace? (localstorage/get "using-trace?" true)
|
||||
ignored-events (localstorage/get "ignored-events" {})
|
||||
num-epochs (localstorage/get "retained-epochs" 5)
|
||||
categories (localstorage/get "categories" #{:event :sub/run :sub/create :sub/dispose})]
|
||||
(when using-trace?
|
||||
|
@ -18,6 +19,7 @@
|
|||
(rf/dispatch [:settings/panel-width% panel-width%])
|
||||
(rf/dispatch [:settings/show-panel? show-panel?])
|
||||
(rf/dispatch [:settings/selected-tab selected-tab])
|
||||
(rf/dispatch [:settings/set-ignored-events ignored-events])
|
||||
(rf/dispatch [:settings/set-number-of-retained-epochs num-epochs])
|
||||
(when external-window?
|
||||
(rf/dispatch [:global/launch-external]))
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
(defonce traces (r/atom []))
|
||||
(defonce total-traces (r/atom 0))
|
||||
(defonce number-of-epochs-to-retain (atom default-number-of-epochs-to-retain))
|
||||
(defonce events-to-ignore (atom #{}))
|
||||
|
||||
(defn log-trace? [trace]
|
||||
(let [render-operation? (or (= (:op-type trace) :render)
|
||||
|
@ -46,10 +47,13 @@
|
|||
(do (reset! total-traces 0)
|
||||
(into [] new2))))
|
||||
new))))
|
||||
;; TODO: there is a bit of double handling here, that will be cleaned up
|
||||
;; when the epoch parsing is refactored.
|
||||
(let [epochs (metam/parse-traces @traces)
|
||||
retained-epochs (take-last @number-of-epochs-to-retain (:matches epochs))
|
||||
;; TODO: there is a bit of double handling here with retaining the last n epochs,
|
||||
;; that will be cleaned up when the epoch parsing is refactored.
|
||||
(let [matches (:matches (metam/parse-traces @traces))
|
||||
matches (remove (fn [match]
|
||||
(let [event (get-in (metam/matched-event match) [:tags :event])]
|
||||
(contains? @events-to-ignore (first event)))) matches)
|
||||
retained-epochs (take-last @number-of-epochs-to-retain matches)
|
||||
first-id-to-retain (:id (ffirst retained-epochs))
|
||||
new-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
|
||||
(reset! traces new-traces)
|
||||
|
@ -71,6 +75,10 @@
|
|||
m)
|
||||
(dissoc m k)))
|
||||
|
||||
(defn read-string-maybe [s]
|
||||
(try (cljs.tools.reader.edn/read-string s)
|
||||
(catch :default e
|
||||
nil)))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/panel-width%
|
||||
|
@ -154,6 +162,38 @@
|
|||
(localstorage/save! "retained-epochs" num)
|
||||
(assoc-in db [:settings :number-of-epochs] num))))
|
||||
|
||||
(def ignored-event-mw
|
||||
[(rf/path [:settings :ignored-events]) (rf/after #(localstorage/save! "ignored-events" %)) (rf/after #(reset! events-to-ignore (->> % vals (map :event-id) set)))])
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/add-ignored-event
|
||||
ignored-event-mw
|
||||
(fn [ignored-events _]
|
||||
(let [id (random-uuid)]
|
||||
(assoc ignored-events id {:id id :event-str "" :event-id nil :sort (js/Date.now)}))))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/remove-ignored-event
|
||||
ignored-event-mw
|
||||
(fn [ignored-events [_ id]]
|
||||
(dissoc ignored-events id)))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/update-ignored-event
|
||||
ignored-event-mw
|
||||
(fn [ignored-events [_ id event-str]]
|
||||
;; TODO: this won't inform users if they type bad strings in.
|
||||
(let [event (read-string-maybe event-str)]
|
||||
(-> ignored-events
|
||||
(assoc-in [id :event-str] event-str)
|
||||
(update-in [id :event-id] (fn [old-event] (if event event old-event)))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/set-ignored-events
|
||||
ignored-event-mw
|
||||
(fn [_ [_ ignored-events]]
|
||||
ignored-events))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/low-level-trace
|
||||
[(rf/path [:settings :low-level-trace])]
|
||||
|
@ -320,10 +360,7 @@
|
|||
(fn [paths _]
|
||||
(assoc paths (js/Date.now) {:diff? false :open? true :path nil :path-str "[]" :valid-path? true})))
|
||||
|
||||
(defn read-string-maybe [s]
|
||||
(try (cljs.tools.reader.edn/read-string s)
|
||||
(catch :default e
|
||||
nil)))
|
||||
|
||||
|
||||
;; The core idea with :app-db/update-path and :app-db/update-path-blur
|
||||
;; is that we need to separate the users text input (`path-str`) with the
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
(fn [settings]
|
||||
(:number-of-epochs settings)))
|
||||
|
||||
(rf/reg-sub
|
||||
:settings/ignored-events
|
||||
:<- [:settings/root]
|
||||
(fn [settings]
|
||||
(sort-by :sort (vals (:ignored-events settings)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:settings/low-level-trace
|
||||
;; TODO: filter from traces panel
|
||||
|
|
|
@ -121,9 +121,8 @@
|
|||
[[:p num-epochs " epochs currently retained, involving " num-traces " traces."]]
|
||||
settings-box-81])
|
||||
|
||||
;; TODO: ignore epochs for:
|
||||
#_[rc/line]
|
||||
#_[settings-box
|
||||
[rc/line]
|
||||
[settings-box
|
||||
[[rc/h-box
|
||||
:align :center
|
||||
:gap horizontal-gap
|
||||
|
@ -134,17 +133,18 @@
|
|||
:label [rc/v-box
|
||||
:align :center
|
||||
:children ["+ event-id"]]
|
||||
:on-click #(add-item *ignore-items)]]]
|
||||
:on-click #(rf/dispatch [:settings/add-ignored-event])]]]
|
||||
[rc/v-box
|
||||
:width comp-section-width
|
||||
:gap vertical-gap
|
||||
:children (for [item @*ignore-items]
|
||||
^{:key (:id item)}
|
||||
:children (for [item @(rf/subscribe [:settings/ignored-events])
|
||||
:let [id (:id item)]]
|
||||
^{:key id}
|
||||
[closeable-text-box
|
||||
:model (:text item)
|
||||
:model (:event-str item)
|
||||
:width "212px"
|
||||
:on-close #(delete-item *ignore-items (:id item))
|
||||
:on-change #(update-item-field *ignore-items (:id item) :text %)])]]
|
||||
:on-close #(rf/dispatch [:settings/remove-ignored-event id])
|
||||
:on-change #(rf/dispatch [:settings/update-ignored-event id %])])]]
|
||||
[[:p "All trace associated with these events will be ignored."]
|
||||
[:p "Useful if you want to ignore a periodic background polling event."]]
|
||||
settings-box-131]
|
||||
|
|
|
@ -224,7 +224,6 @@
|
|||
(defn pod-section []
|
||||
(let [all-subs @(rf/subscribe [:subs/visible-subs])
|
||||
sub-expansions @(rf/subscribe [:subs/sub-expansions])]
|
||||
;(js/console.log sub-expansions)
|
||||
[rc/v-box
|
||||
:size "1"
|
||||
;:gap pod-gap
|
||||
|
|
Loading…
Reference in New Issue