Added tabs and navigation for movie info
This commit is contained in:
+35
-5
@@ -5,31 +5,46 @@ use strum::EnumIter;
|
||||
|
||||
use crate::app::models::{ScrollableText, StatefulTable, TabRoute, TabState};
|
||||
use crate::app::App;
|
||||
use crate::network::radarr_network::{DownloadRecord, Movie, RadarrEvent};
|
||||
use crate::network::radarr_network::{
|
||||
DiskSpace, DownloadRecord, Movie, MovieHistoryItem, RadarrEvent,
|
||||
};
|
||||
|
||||
pub struct RadarrData {
|
||||
pub free_space: u64,
|
||||
pub total_space: u64,
|
||||
pub disk_space_vec: Vec<DiskSpace>,
|
||||
pub version: String,
|
||||
pub start_time: DateTime<Utc>,
|
||||
pub movies: StatefulTable<Movie>,
|
||||
pub downloads: StatefulTable<DownloadRecord>,
|
||||
pub quality_profile_map: HashMap<u64, String>,
|
||||
pub movie_details: ScrollableText,
|
||||
pub movie_history: StatefulTable<MovieHistoryItem>,
|
||||
pub main_tabs: TabState,
|
||||
pub movie_info_tabs: TabState,
|
||||
}
|
||||
|
||||
impl RadarrData {
|
||||
pub fn reset_movie_info_tab(&mut self) {
|
||||
self.movie_details = ScrollableText::default();
|
||||
self.movie_history = StatefulTable::default();
|
||||
self.movie_info_tabs.index = 0;
|
||||
}
|
||||
|
||||
pub fn reset_main_tab_index(&mut self) {
|
||||
self.main_tabs.index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RadarrData {
|
||||
fn default() -> RadarrData {
|
||||
RadarrData {
|
||||
free_space: u64::default(),
|
||||
total_space: u64::default(),
|
||||
disk_space_vec: Vec::new(),
|
||||
version: String::default(),
|
||||
start_time: DateTime::default(),
|
||||
movies: StatefulTable::default(),
|
||||
downloads: StatefulTable::default(),
|
||||
quality_profile_map: HashMap::default(),
|
||||
movie_details: ScrollableText::default(),
|
||||
movie_history: StatefulTable::default(),
|
||||
main_tabs: TabState::new(vec![
|
||||
TabRoute {
|
||||
title: "Library".to_owned(),
|
||||
@@ -40,6 +55,16 @@ impl Default for RadarrData {
|
||||
route: ActiveRadarrBlock::Downloads.into(),
|
||||
},
|
||||
]),
|
||||
movie_info_tabs: TabState::new(vec![
|
||||
TabRoute {
|
||||
title: "Details".to_owned(),
|
||||
route: ActiveRadarrBlock::MovieDetails.into(),
|
||||
},
|
||||
TabRoute {
|
||||
title: "History".to_owned(),
|
||||
route: ActiveRadarrBlock::MovieHistory.into(),
|
||||
},
|
||||
]),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +78,7 @@ pub enum ActiveRadarrBlock {
|
||||
Logs,
|
||||
Movies,
|
||||
MovieDetails,
|
||||
MovieHistory,
|
||||
Downloads,
|
||||
SearchMovie,
|
||||
SortOptions,
|
||||
@@ -71,6 +97,10 @@ impl App {
|
||||
self.is_loading = true;
|
||||
self.dispatch(RadarrEvent::GetMovieDetails.into()).await
|
||||
}
|
||||
ActiveRadarrBlock::MovieHistory => {
|
||||
self.is_loading = true;
|
||||
self.dispatch(RadarrEvent::GetMovieHistory.into()).await
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user