Create AlbumData, impl DashboardTile

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

39
src/albumdata.rs Normal file
View File

@ -0,0 +1,39 @@
use crate::models::Artist;
use crate::components::dashboard_tile::DashboardTile;
use time::Date;
/// Holds information about an album
///
/// Intended to be used in the front-end
pub struct AlbumData {
/// Album id
pub id: i32,
/// Album title
pub title: String,
/// Album artists
pub artists: Vec<Artist>,
/// Album release date
pub release_date: Option<Date>,
/// Path to album image, relative to the root of the web server.
/// For example, `"/assets/images/Album.jpg"`
pub image_path: String,
}
impl DashboardTile for AlbumData {
fn image_path(&self) -> String {
self.image_path.clone()
}
fn title(&self) -> String {
self.title.clone()
}
fn link(&self) -> String {
format!("/album/{}", self.id)
}
fn description(&self) -> Option<String> {
Some(format!("Album • {}", Artist::display_list(&self.artists)))
}
}

View File

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