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

View File

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

View File

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

View File

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

View File

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