Merge remote-tracking branch 'origin/main' into 19-implement-file-uploads

This commit is contained in:
Ethan Girouard 2024-05-18 18:10:03 -04:00
commit 3978526231
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146
7 changed files with 34 additions and 27 deletions

View File

@ -0,0 +1 @@
ALTER TABLE albums DROP COLUMN image_path;

View File

@ -0,0 +1 @@
ALTER TABLE albums ADD COLUMN image_path VARCHAR;

View File

@ -14,6 +14,10 @@ pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc. // Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context(); provide_meta_context();
let play_status = PlayStatus::default();
let play_status = create_rw_signal(play_status);
let upload_open = create_rw_signal(false);
view! { view! {
// injects a stylesheet into the document <head> // injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet // id=leptos means cargo-leptos will hot-reload this stylesheet
@ -33,7 +37,11 @@ pub fn App() -> impl IntoView {
}> }>
<main> <main>
<Routes> <Routes>
<Route path="" view=HomePage/> <Route path="" view=move || view! { <HomePage play_status=play_status upload_open=upload_open/> }>
<Route path="" view=Dashboard />
<Route path="dashboard" view=Dashboard />
<Route path="search" view=Search />
</Route>
<Route path="/login" view=Login /> <Route path="/login" view=Login />
<Route path="/signup" view=Signup /> <Route path="/signup" view=Signup />
</Routes> </Routes>
@ -50,22 +58,13 @@ use crate::components::upload::*;
/// Renders the home page of your application. /// Renders the home page of your application.
#[component] #[component]
fn HomePage() -> impl IntoView { fn HomePage(play_status: RwSignal<PlayStatus>, upload_open: RwSignal<bool>) -> impl IntoView {
let play_status = PlayStatus::default();
let play_status = create_rw_signal(play_status);
let upload_open = create_rw_signal(false);
let (dashboard_open, set_dashboard_open) = create_signal(true);
view! { view! {
<div class="home-container"> <div class="home-container">
<Upload open=upload_open/> <Upload open=upload_open/>
<Sidebar setter=set_dashboard_open active=dashboard_open upload_open=upload_open /> <Sidebar upload_open=upload_open/>
<Show // This <Outlet /> will render the child route components
when=move || {dashboard_open() == true} <Outlet />
fallback=move || view! { <Search /> }
>
<Dashboard />
</Show>
<Personal /> <Personal />
<PlayBar status=play_status/> <PlayBar status=play_status/>
<Queue status=play_status/> <Queue status=play_status/>

View File

@ -4,29 +4,31 @@ use leptos_icons::*;
use crate::components::upload::*; use crate::components::upload::*;
#[component] #[component]
pub fn Sidebar(setter: WriteSignal<bool>, active: ReadSignal<bool>, upload_open: RwSignal<bool>) -> impl IntoView { pub fn Sidebar(upload_open: RwSignal<bool>) -> impl IntoView {
let open_dashboard = move |_| { use leptos_router::use_location;
setter.update(|value| *value = true); let location = use_location();
log!("open dashboard");
}; let on_dashboard = Signal::derive(
let open_search = move |_| { move || location.pathname.get().starts_with("/dashboard") || location.pathname.get() == "/",
setter.update(|value| *value = false); );
log!("open search");
}; let on_search = Signal::derive(
move || location.pathname.get().starts_with("/search"),
);
view! { view! {
<div class="sidebar-container"> <div class="sidebar-container">
<div class="sidebar-top-container"> <div class="sidebar-top-container">
<h2 class="header">LibreTunes</h2> <h2 class="header">LibreTunes</h2>
<UploadBtn dialog_open=upload_open /> <UploadBtn dialog_open=upload_open />
<div class="buttons" on:click=open_dashboard style={move || if active() {"color: #e1e3e1"} else {""}} > <a class="buttons" href="/dashboard" style={move || if on_dashboard() {"color: #e1e3e1"} else {""}} >
<Icon icon=icondata::OcHomeFillLg /> <Icon icon=icondata::OcHomeFillLg />
<h1>Dashboard</h1> <h1>Dashboard</h1>
</div> </a>
<div class="buttons" on:click=open_search style={move || if !active() {"color: #e1e3e1"} else {""}}> <a class="buttons" href="/search" style={move || if on_search() {"color: #e1e3e1"} else {""}}>
<Icon icon=icondata::BiSearchRegular /> <Icon icon=icondata::BiSearchRegular />
<h1>Search</h1> <h1>Search</h1>
</div> </a>
</div> </div>
<Bottom /> <Bottom />

View File

@ -177,6 +177,8 @@ pub struct Album {
pub title: String, pub title: String,
/// The album's release date /// The album's release date
pub release_date: Option<Date>, pub release_date: Option<Date>,
/// The path to the album's image file
pub image_path: Option<String>,
} }
impl Album { impl Album {

View File

@ -12,6 +12,7 @@ diesel::table! {
id -> Int4, id -> Int4,
title -> Varchar, title -> Varchar,
release_date -> Nullable<Date>, release_date -> Nullable<Date>,
image_path -> Nullable<Varchar>,
} }
} }

View File

@ -48,6 +48,7 @@
transition: all 0.5s; transition: all 0.5s;
cursor: pointer; cursor: pointer;
color: grey; color: grey;
text-decoration: none;
} }
.buttons:hover { .buttons:hover {
color: white; color: white;