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

Use new song-table on search result page

This commit is contained in:
heyarne 2019-03-10 10:36:35 +01:00
commit 60a4b41371
2 changed files with 13 additions and 13 deletions

View file

@ -45,16 +45,16 @@
[:a {:href (routes/url-for ::routes/artist.detail {:id id})} artist] [:a {:href (routes/url-for ::routes/artist.detail {:id id})} artist]
artist)) artist))
(defn song-link [{:keys [song album idx]}] (defn song-link [{:keys [songs song idx]}]
[:a [:a
{:href "#" :on-click (h/muted-dispatch [:audio-player/play-all (:song album) idx] :sync? true)} {:href "#" :on-click (h/muted-dispatch [:audio-player/play-all songs idx] :sync? true)}
(:title song)]) (:title song)])
(defn song-actions [{:keys [song album idx]}] (defn song-actions [song]
[dropdown {:items [{:label "Play next" :event [:audio-player/enqueue-next song]} [dropdown {:items [{:label "Play next" :event [:audio-player/enqueue-next song]}
{:label "Play last" :event [:audio-player/enqueue-last song]}]}]) {:label "Play last" :event [:audio-player/enqueue-last song]}]}])
(defn song-table [{:keys [album]}] (defn song-table [songs]
;; we subscribe here instead of one level higher up to make this a more ;; we subscribe here instead of one level higher up to make this a more
;; reusable component; this way we can for example get a list of all songs ;; reusable component; this way we can for example get a list of all songs
;; in a search result and easily highlight the currently playing track ;; in a search result and easily highlight the currently playing track
@ -67,18 +67,16 @@
[:td.song-duration "Duration"] [:td.song-duration "Duration"]
[:td.is-narrow]] [:td.is-narrow]]
[:tbody [:tbody
(for [[idx song] (map-indexed vector (:song album))] (for [[idx song] (map-indexed vector songs)]
^{:key idx} ^{:key idx}
[(if (= (:id song) (:id current-song)) :tr.is-playing :tr) [(if (= (:id song) (:id current-song)) :tr.is-playing :tr)
[:td.song-tracknr.is-narrow (:track song)] [:td.song-tracknr.is-narrow (:track song)]
[:td.song-artist [artist-link song]] [:td.song-artist [artist-link song]]
[:td.song-title [song-link {:album album [:td.song-title [song-link {:songs songs
:song song :song song
:idx idx}]] :idx idx}]]
[:td.song-duration (h/format-duration (:duration song) :brief? true)] [:td.song-duration (h/format-duration (:duration song) :brief? true)]
[:td.song-actions.is-narrow [song-actions {:album album [:td.song-actions.is-narrow [song-actions song]]])]]))
:song song
:idx idx}]]])]]))
(defn detail (defn detail
"Shows a detail view of a single album, listing all " "Shows a detail view of a single album, listing all "
@ -93,4 +91,4 @@
[:h3.subtitle (:artist album)] [:h3.subtitle (:artist album)]
[collection-info album]]]]] [collection-info album]]]]]
[:section.section>div.container [:section.section>div.container
[song-table {:album album}]]]) [song-table (:song album)]]])

View file

@ -2,7 +2,8 @@
(:require [re-frame.core :refer [dispatch subscribe]] (:require [re-frame.core :refer [dispatch subscribe]]
[goog.functions :refer [debounce]] [goog.functions :refer [debounce]]
[airsonic-ui.routes :as routes :refer [url-for]] [airsonic-ui.routes :as routes :refer [url-for]]
[airsonic-ui.views.song :as song] [airsonic-ui.components.collection.views :refer [song-table]]
[airsonic-ui.components.debug :refer [debug]]
[airsonic-ui.views.cover :refer [card]])) [airsonic-ui.views.cover :refer [card]]))
(defn form [] (defn form []
@ -41,8 +42,9 @@
(defn album-results [{:keys [album]}] (defn album-results [{:keys [album]}]
[result-cards (map (juxt album-url identity) album)]) [result-cards (map (juxt album-url identity) album)])
(defn song-results [{:keys [song]}] (defn song-results [{songs :song}]
[song/listing song]) []
[song-table songs])
(defn results [{:keys [search]}] (defn results [{:keys [search]}]
(let [term @(subscribe [:search/current-term])] (let [term @(subscribe [:search/current-term])]