                    [cljs.core.match.macros :refer [match]]))
 
 (ws-repl/connect "ws://localhost:9001" :verbose true)
-
 (enable-console-print!)
 
-(let [date-formatter (timef/formatter "yyyy-MM-dd")
-      end-date (time/today-at 12 00)
+(def date-formatter (timef/formatter "yyyy-MM-dd"))
+
+(let [end-date (time/today-at 12 00)
       start-date (time/minus end-date (time/months 1))
       end-date (timef/unparse date-formatter end-date)
       start-date (timef/unparse date-formatter start-date)]

                                       (>! event-channel [:metric-selected selected-metric])))))))
    om/IRenderState
    (render-state [_ {:keys [event-channel]}]
      (html
       [:div.form-group
        [:label {:for "metrics-selector"} "Metric:"]

              (condp = topic
                :detector-selected
                (do
                  (println "detector-selected")
                  (om/transact! state (fn [state]
                                        (let [state (assoc state
                                                      :selected-detector message
                                                      :selected-metric nil
                                                      :alerts nil)
                                              state (assoc-in state [:error :message] "")]
                                          state))))

                :metric-selected
                (let [detector (:selected-detector @state)]
                  (om/transact! state (fn [state]
                                        (let [state (assoc state :selected-metric message)
                                              state (assoc-in state [:error :message] "")]
                                          state))))

                :from-selected
                (do
                  (om/update! state [:selected-date-range 0] message))

                :to-selected
                (do
                  (om/update! state [:selected-date-range 1] message)))

              ;retrieve resources
              (let [selected-detector (:selected-detector @state)
                    selected-metric (:selected-metric @state)
                    selected-start-date (get-in @state [:selected-date-range 0])
                    selected-end-date (get-in @state [:selected-date-range 1])]
                (match [selected-detector selected-metric]
                       [nil nil]
                       ()

                       [_ nil]
                       (do
                         (update-resource state :metrics
