1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-06 18:33:38 +02:00

Add list of recent albums

This commit is contained in:
Arne Schlüter 2018-04-18 19:19:07 +02:00
commit 8e799f651d
4 changed files with 85 additions and 28 deletions

View file

@ -5,6 +5,8 @@
[airsonic-ui.events :as events]
[airsonic-ui.subs :as subs]))
;; login form
(defn login-form []
(let [user (r/atom "")
pass (r/atom "")]
@ -21,10 +23,32 @@
[:div
[:button {:on-click #(re-frame/dispatch [::events/authenticate @user @pass])} "Submit"]]])))
(defn app [route]
;; album list
(defn album-item [album]
(let [{:keys [artist artistId name coverArt year id]} album]
[:div
;; link to artist page
[:a {:href (routes/url-for ::routes/artist-view {:id artistId})} artist]
" - "
;; link to album
[:a {:href (routes/url-for ::routes/album-view {:id id})} name] (when year (str " (" year ")"))]))
(defn album-list []
(let [albums @(re-frame/subscribe [::subs/current-album-list])]
[:ul
(map-indexed (fn [idx album]
[:li {:key idx} [album-item album]])
albums)]))
;; putting everything together
(defn app [route params query]
(let [login @(re-frame/subscribe [::subs/login])]
[:div
[:h2 (str "Currently logged in as " (:u login))]
[:h3 (str "Recently played")]
[album-list]
[:a {:on-click #(re-frame/dispatch [::events/initialize-db]) :href "#"} "Logout"]]))
(defn main-panel []
@ -33,4 +57,4 @@
[:h1 "Airsonic"]
(case route
::routes/login [login-form]
[app route])]))
[app route params query])]))