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