Create ArtistData, impl DashboardTile

This commit is contained in:
Ethan Girouard 2024-10-06 15:49:19 -04:00
parent c18bf277b9
commit c678d93661
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146
2 changed files with 33 additions and 0 deletions

32
src/artistdata.rs Normal file
View File

@ -0,0 +1,32 @@
use crate::components::dashboard_tile::DashboardTile;
/// Holds information about an artist
///
/// Intended to be used in the front-end
pub struct ArtistData {
/// Artist id
pub id: i32,
/// Artist name
pub name: String,
/// Path to artist image, relative to the root of the web server.
/// For example, `"/assets/images/Artist.jpg"`
pub image_path: String,
}
impl DashboardTile for ArtistData {
fn image_path(&self) -> String {
self.image_path.clone()
}
fn title(&self) -> String {
self.name.clone()
}
fn link(&self) -> String {
format!("/artist/{}", self.id)
}
fn description(&self) -> Option<String> {
Some("Artist".to_string())
}
}

View File

@ -2,6 +2,7 @@ pub mod app;
pub mod auth; pub mod auth;
pub mod songdata; pub mod songdata;
pub mod albumdata; pub mod albumdata;
pub mod artistdata;
pub mod playstatus; pub mod playstatus;
pub mod playbar; pub mod playbar;
pub mod database; pub mod database;