Create AlbumData, impl DashboardTile
This commit is contained in:
parent
097b1fc491
commit
c18bf277b9
39
src/albumdata.rs
Normal file
39
src/albumdata.rs
Normal 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)))
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
pub mod app;
|
pub mod app;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod songdata;
|
pub mod songdata;
|
||||||
|
pub mod albumdata;
|
||||||
pub mod playstatus;
|
pub mod playstatus;
|
||||||
pub mod playbar;
|
pub mod playbar;
|
||||||
pub mod database;
|
pub mod database;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user