mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Squashed commit of the following:
commit b03c1ea7ed0d2fbd56f56f3273e694abc5454101
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 29 11:38:32 2018 +0200
Fix bug where dropdown menus behind notifications could not be hovered
commit f4d3cd3dad89d0de84f131dbef7268422b26aa35
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 29 11:16:41 2018 +0200
Move navigation to top
commit 564d972291aebb382d1ca560a21fad332d70cd0c
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 29 10:23:17 2018 +0200
Move audio player into its own component
commit 382e9e88021db1506efc5fb78935b7846b8257db
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 29 10:11:14 2018 +0200
Remove link to last.fm in bio
commit f248c2999ca88eeb82769d7491b1e786ee4a7c9d
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 29 10:01:10 2018 +0200
Add links to external services & hero headers to album and artist pages
79 lines
3.4 KiB
Clojure
79 lines
3.4 KiB
Clojure
(ns airsonic-ui.views
|
|
"This module contains the outmost layer of our app views. It makes sure that
|
|
the proper subscriptions are run and arranges the complete layout."
|
|
(:require [re-frame.core :refer [dispatch subscribe]]
|
|
[airsonic-ui.routes :as routes :refer [url-for]]
|
|
[airsonic-ui.events :as events]
|
|
[airsonic-ui.subs :as subs]
|
|
[airsonic-ui.helpers :refer [add-classes]]
|
|
|
|
[airsonic-ui.views.notifications :refer [notification-list]]
|
|
[airsonic-ui.views.breadcrumbs :refer [breadcrumbs]]
|
|
[airsonic-ui.views.login :refer [login-form]]
|
|
[airsonic-ui.components.audio-player.views :refer [audio-player]]
|
|
[airsonic-ui.components.search.views :as search]
|
|
[airsonic-ui.components.library.views :as library]
|
|
[airsonic-ui.components.artist.views :as artist]
|
|
[airsonic-ui.components.collection.views :as collection]))
|
|
|
|
(def logo-url "./img/airsonic-light-350x100.png")
|
|
|
|
(defn navbar-top
|
|
"Contains search, some navigational links and the logo"
|
|
[{:keys [user]}]
|
|
[:nav.navbar.is-fixed-top.is-dark {:role "navigation", :aria-label "search and navigation"}
|
|
[:div.navbar-brand
|
|
[:div.navbar-item>img {:src logo-url}]]
|
|
;; user is `nil` when we're not logged in, we can hide the extended navbar
|
|
(when user
|
|
[:div.navbar-menu
|
|
[:div.navbar-start
|
|
[:div.navbar-item [search/form]]]
|
|
[:div.navbar-end
|
|
[:div.navbar-item.has-dropdown.is-hoverable
|
|
[:div.navbar-link "Library"]
|
|
[:div.navbar-dropdown
|
|
[:a.navbar-item {:href (url-for ::routes/library {:criteria "recent"})} "Recently played"]
|
|
[:a.navbar-item {:href (url-for ::routes/library {:criteria "newest"})} "Newest additions"]
|
|
[:a.navbar-item {:href (url-for ::routes/library {:criteria "starred"})} "Starred"]]]
|
|
[:a.navbar-item {} "Podcasts"]
|
|
[:a.navbar-item {} "Shares"]
|
|
[:div.navbar-item.has-dropdown.is-hoverable
|
|
[:div.navbar-link "More"]
|
|
[:div.navbar-dropdown.is-right
|
|
[:a.navbar-item {:disabled true} "Settings"]
|
|
[:a.navbar-item
|
|
{:on-click #(dispatch [::events/logout]) :href "#"}
|
|
(str "Logout (" (:name user) ")")]]]]])])
|
|
|
|
(defn media-content
|
|
"Provides the complete UI to browse the media library, interact with search
|
|
results etc"
|
|
[route-id params query]
|
|
(let [;; TODO: Move this to a layer 3 subscription ↓
|
|
route-events @(subscribe [:routes/events-for-current-route])
|
|
content @(subscribe [:api/route-data route-events])]
|
|
[:div
|
|
[:section.section
|
|
[breadcrumbs content]
|
|
(case route-id
|
|
::routes/library [library/main [route-id params query] content]
|
|
::routes/artist-view [artist/detail content]
|
|
::routes/album-view [collection/detail content]
|
|
::routes/search [search/results content])]
|
|
[audio-player]]))
|
|
|
|
(defn main-panel []
|
|
(let [notifications @(subscribe [::subs/notifications])
|
|
is-booting? @(subscribe [::subs/is-booting?])
|
|
[route-id params query] @(subscribe [:routes/current-route])
|
|
user @(subscribe [::subs/user])]
|
|
[(add-classes :div route-id)
|
|
[notification-list notifications]
|
|
(if is-booting?
|
|
[:div.app-loading>div.loader]
|
|
[:div
|
|
[navbar-top {:user user}]
|
|
(case route-id
|
|
::routes/login [login-form]
|
|
[media-content route-id params query])])]))
|