Save filter items to localstorage.

This commit is contained in:
chris (daiyi) 2017-08-22 18:07:08 +02:00 committed by Daniel Compton
parent 09fdd66e71
commit 312b5d3b50
2 changed files with 5 additions and 3 deletions

View File

@ -9,7 +9,7 @@
(defn get! [key] (defn get! [key]
(let [store (storage)] (let [store (storage)]
(.get store key))) (cljs.reader/read-string (.get store key))))
(defn set! [key val] (defn set! [key val]
(let [store (storage)] (let [store (storage)]

View File

@ -6,6 +6,7 @@
[re-frame.trace :as trace :include-macros true] [re-frame.trace :as trace :include-macros true]
[cljs.pprint :as pprint] [cljs.pprint :as pprint]
[clojure.string :as str] [clojure.string :as str]
[cljs.reader :as reader]
[reagent.core :as r] [reagent.core :as r]
[reagent.interop :refer-macros [$ $!]] [reagent.interop :refer-macros [$ $!]]
[reagent.impl.util :as util] [reagent.impl.util :as util]
@ -186,13 +187,14 @@
(str (subs tag-str 0 string-size-limit) " ...") (str (subs tag-str 0 string-size-limit) " ...")
tag-str))]])))))) tag-str))]]))))))
(defn render-trace-panel [] (defn render-trace-panel [])
(let [filter-input (r/atom "") (let [filter-input (r/atom "")
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 {:show-all? false :overrides {}})] trace-detail-expansions (r/atom {:show-all? false :overrides {}})]
(fn [] (fn []
(localstorage/set! "filter-items" (str @filter-items))
(let [showing-traces (if (= @filter-items []) (let [showing-traces (if (= @filter-items [])
@traces @traces
(filter (apply every-pred (map query->fn @filter-items)) @traces)) (filter (apply every-pred (map query->fn @filter-items)) @traces))
@ -254,7 +256,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 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