Update epochs to retain

This commit is contained in:
Daniel Compton 2018-01-22 16:32:08 +13:00
parent a2c3f7c36b
commit 23a63de354
3 changed files with 37 additions and 19 deletions

View File

@ -127,12 +127,21 @@
(rf/reg-event-db
:settings/set-number-of-retained-epochs
(fn [db [_ num-str]]
(let [num (js/parseInt num-str)]
(if-not (js/isNaN num)
(do
(localstorage/save! "retained-epochs" num)
(assoc-in db [:settings :number-of-epochs] num))
db))))
;; TODO: this is not perfect, there is an issue in re-com
;; where it won't update its model if it never receives another
;; changes after it's on-change is fired.
(let [num (js/parseInt num-str)
num (if (and (not (js/isNaN num)) (pos-int? num))
num
30)]
(localstorage/save! "retained-epochs" num)
(assoc-in db [:settings :number-of-epochs] num))))
(rf/reg-event-db
:settings/low-level-trace
[(rf/path [:settings :low-level-trace])]
(fn [low-level [_ trace-type capture?]]
(assoc low-level trace-type capture?)))
;; Global

View File

@ -40,6 +40,14 @@
(fn [settings]
(:number-of-epochs settings)))
(rf/reg-sub
:settings/low-level-trace
;; TODO: filter from traces panel
;; TODO: eventually drop these low level traces after computing the state we need from them.
:<- [:settings/root]
(fn [settings]
(:low-level-trace settings)))
;; App DB
(rf/reg-sub

View File

@ -95,7 +95,7 @@
:margin-right common/gs-19s}
:children [(let [num-epochs @(rf/subscribe [:epochs/number-of-matches])
num-traces @(rf/subscribe [:traces/number-of-traces])
epochs-to-retain @(rf/subscribe [:settings/number-of-retained-epochs])]
epochs-to-retain (rf/subscribe [:settings/number-of-retained-epochs])]
[settings-box
[[rc/h-box
:align :center
@ -175,18 +175,19 @@
settings-box-131]
[rc/line]
[settings-box
[[rc/label :label "Remove low level trace"]
[rc/checkbox
:model false
:label "reagent internals"
:on-change #(rf/dispatch [:settings/low-level-trace :reagent %])]
[rc/checkbox
:model false
:label "re-frame internals"
:on-change #(rf/dispatch [:settings/low-level-trace :re-frame %])]]
[[:p "Most of the time, low level trace is noisy and you want it filtered out."]]
settings-box-131]
(let [low-level-trace @(rf/subscribe [:settings/low-level-trace])]
[settings-box
[[rc/label :label "Remove low level trace"]
[rc/checkbox
:model (:reagent low-level-trace)
:label "reagent internals"
:on-change #(rf/dispatch [:settings/low-level-trace :reagent %])]
[rc/checkbox
:model (:re-frame low-level-trace)
:label "re-frame internals"
:on-change #(rf/dispatch [:settings/low-level-trace :re-frame %])]]
[[:p "Most of the time, low level trace is noisy and you want it filtered out."]]
settings-box-131])
[rc/line]
[settings-box