 
 (defn header []
   (let [cursor  (r/cursor app-state [:info])
-                title   (@cursor :name)
-                message (@cursor :greet_message)]
+        title   (@cursor :name)
+        message (@cursor :greet_message)]
     [:header
-      [:h1 title]
-      [:p message]]))
+     [:h1 title]
+     [:p message]]))
 
 ;; -------------------------
 ;; Player

(defn now-playing []
  (let [track (@app-state :now-playing)]
    [:p#player-track
      [:i.fa.fa-music]
      [:span (if track
               (str (:artist track) " - " (:title track))
               [:em "Nothing is playing."])]]))

(defn player-section []
  (let [audio-ref (r/atom nil)]
    (fn []
      (when-let [url (get-in @app-state [:info :stream_url])]
        [:section#player
          [:audio {:ref #(reset! audio-ref %)}
                  [:source {:src url}]]

          [:div#player-controls.pure-button-group
            {:role "group"}
            (when-let [audio @audio-ref]
              (if (.-paused audio)
                [:button.pure-button.pure-button-primary
                  {:on-click #(.play audio)}
                  [:i.fa.fa-play] "Play"]
                [:button.pure-button.pure-button-primary.pure-button-active
                  {:on-click #(.pause audio)}
                  [:i.fa.fa-pause] "Pause"]))

            [:a.pure-button {:href url :target "_blank"}
                            [:i.fa.fa-external-link]
                            "Open stream"]]

          [now-playing]]))))

;; -------------------------
;; Upload

  (let [form-ref (r/atom nil)]
    (fn []
      [:section#upload
       [:h2 "Upload"]

       [:form.pure-form
        {:ref #(reset! form-ref %)}
        [:input.pure-input-3-4 {:type "file" :name "track"}]
        [:input.pure-button.pure-button-primary.pure-input-1-4
         {:type "button" :value "Upload"
          :on-click #(when-let [form @form-ref] (req/upload! form))}]
        [progress-bar]]

       [:p (@app-state :upload-status)]])))

;; -------------------------
;; Tracks

(defn playlist-add-button [track]
  [:i.fa.fa-plus-square
   {:on-click #(req/playlist-add! (:uuid track))}])

(defn playlist-remove-button [track]
  [:i.fa.fa-minus-square
   {:on-click #(req/playlist-remove! (:uuid track))}])

(defn track-tr [track action-button]
  [:tr.track
   [:td
    (when action-button
      [action-button track])]
   [:td (track :title)] [:td (track :artist)] [:td (track :album)]])

;; -------------------------
;; Playlist

(defn playlist-section []
  [:section#playlist
   [:h2 "Playlist"]
   (if-let [tracks (not-empty (@app-state :playlist))]
     [:table.pure-table.pure-table-striped
      [:thead
       [:tr [:th] [:th  "Title"] [:th "Artist"] [:th "Album"]]]
      [:tbody (for [track tracks]
                ^{:key track} [track-tr track playlist-remove-button])]]
     "The playlist is empty.")])

;; -------------------------
;; Search
