Functional tags implementation for adding movies! Still need to fix weird loading bug when searching a movie that shows an error too soon before results are loaded, need to fix the horizontal scrolling issue, and I need to change the quality profile map to use the BiMap
This commit is contained in:
+17
-5
@@ -77,7 +77,7 @@ impl RadarrData {
|
||||
self.filtered_collections = StatefulTable::default();
|
||||
}
|
||||
|
||||
pub fn reset_edit_movie(&mut self) {
|
||||
pub fn reset_add_edit_movie_fields(&mut self) {
|
||||
self.edit_monitored = None;
|
||||
self.edit_path = HorizontallyScrollableText::default();
|
||||
self.edit_tags = HorizontallyScrollableText::default();
|
||||
@@ -288,6 +288,7 @@ pub enum ActiveRadarrBlock {
|
||||
AddMovieSelectQualityProfile,
|
||||
AddMovieSelectMonitor,
|
||||
AddMovieConfirmPrompt,
|
||||
AddMovieTagsInput,
|
||||
AutomaticallySearchMoviePrompt,
|
||||
Collections,
|
||||
CollectionDetails,
|
||||
@@ -321,7 +322,7 @@ pub enum ActiveRadarrBlock {
|
||||
ViewMovieOverview,
|
||||
}
|
||||
|
||||
pub const ADD_MOVIE_BLOCKS: [ActiveRadarrBlock; 7] = [
|
||||
pub const ADD_MOVIE_BLOCKS: [ActiveRadarrBlock; 8] = [
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
@@ -329,6 +330,7 @@ pub const ADD_MOVIE_BLOCKS: [ActiveRadarrBlock; 7] = [
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
];
|
||||
pub const EDIT_MOVIE_BLOCKS: [ActiveRadarrBlock; 7] = [
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
@@ -373,7 +375,8 @@ impl ActiveRadarrBlock {
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability => {
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile => ActiveRadarrBlock::AddMovieConfirmPrompt,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile => ActiveRadarrBlock::AddMovieTagsInput,
|
||||
ActiveRadarrBlock::AddMovieTagsInput => ActiveRadarrBlock::AddMovieConfirmPrompt,
|
||||
_ => ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
}
|
||||
}
|
||||
@@ -402,7 +405,8 @@ impl ActiveRadarrBlock {
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile => {
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieConfirmPrompt => ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieTagsInput => ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieConfirmPrompt => ActiveRadarrBlock::AddMovieTagsInput,
|
||||
_ => ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
}
|
||||
}
|
||||
@@ -803,7 +807,7 @@ mod tests {
|
||||
..RadarrData::default()
|
||||
};
|
||||
|
||||
radarr_data.reset_edit_movie();
|
||||
radarr_data.reset_add_edit_movie_fields();
|
||||
|
||||
assert_edit_movie_reset!(radarr_data);
|
||||
}
|
||||
@@ -921,6 +925,10 @@ mod tests {
|
||||
|
||||
let active_block = active_block.next_add_prompt_block();
|
||||
|
||||
assert_eq!(active_block, ActiveRadarrBlock::AddMovieTagsInput);
|
||||
|
||||
let active_block = active_block.next_add_prompt_block();
|
||||
|
||||
assert_eq!(active_block, ActiveRadarrBlock::AddMovieConfirmPrompt);
|
||||
|
||||
let active_block = active_block.next_add_prompt_block();
|
||||
@@ -969,6 +977,10 @@ mod tests {
|
||||
|
||||
let active_block = active_block.previous_add_prompt_block();
|
||||
|
||||
assert_eq!(active_block, ActiveRadarrBlock::AddMovieTagsInput);
|
||||
|
||||
let active_block = active_block.previous_add_prompt_block();
|
||||
|
||||
assert_eq!(
|
||||
active_block,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
|
||||
@@ -120,6 +120,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_top(),
|
||||
ActiveRadarrBlock::AddMovieSearchInput => self.app.data.radarr_data.search.scroll_home(),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => self.app.data.radarr_data.edit_tags.scroll_home(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -151,6 +152,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::AddMovieSearchInput => self.app.data.radarr_data.search.reset_offset(),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => self.app.data.radarr_data.edit_tags.reset_offset(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -163,6 +165,9 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
ActiveRadarrBlock::AddMovieSearchInput => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.search)
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.edit_tags)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -210,7 +215,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
|
||||
self.app.data.radarr_data.populate_movie_preferences_lists();
|
||||
self.app.data.radarr_data.selected_block = ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
self.app.data.radarr_data.selected_block = ActiveRadarrBlock::AddMovieSelectMonitor;
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt => match self.app.data.radarr_data.selected_block {
|
||||
@@ -227,11 +232,21 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile => self
|
||||
.app
|
||||
.push_navigation_stack((self.app.data.radarr_data.selected_block, *self.context).into()),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
self.app.push_navigation_stack(
|
||||
(self.app.data.radarr_data.selected_block, *self.context).into(),
|
||||
);
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
| ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile => self.app.pop_navigation_stack(),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -250,25 +265,31 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.reset_movie_preferences_selections();
|
||||
self.app.data.radarr_data.reset_add_edit_movie_fields();
|
||||
self.app.data.radarr_data.prompt_confirm = false;
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
| ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
| ActiveRadarrBlock::AddMovieAlreadyInLibrary => self.app.pop_navigation_stack(),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
let key = self.key;
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::AddMovieSearchInput {
|
||||
handle_text_box_keys!(self, key, self.app.data.radarr_data.search)
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchInput => {
|
||||
handle_text_box_keys!(self, key, self.app.data.radarr_data.search)
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
handle_text_box_keys!(self, key, self.app.data.radarr_data.edit_tags)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,6 +431,15 @@ mod tests {
|
||||
search
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_tags_input_home_end_keys() {
|
||||
test_text_box_home_end_keys!(
|
||||
AddMovieHandler,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
edit_tags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_left_right_action {
|
||||
@@ -440,6 +470,15 @@ mod tests {
|
||||
search
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_tags_input_left_right_keys() {
|
||||
test_text_box_left_right_keys!(
|
||||
AddMovieHandler,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
edit_tags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
@@ -619,7 +658,8 @@ mod tests {
|
||||
#[values(
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieTagsInput
|
||||
)]
|
||||
selected_block: ActiveRadarrBlock,
|
||||
) {
|
||||
@@ -646,6 +686,10 @@ mod tests {
|
||||
&(selected_block, Some(ActiveRadarrBlock::CollectionDetails)).into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
|
||||
if selected_block == ActiveRadarrBlock::AddMovieTagsInput {
|
||||
assert!(app.should_ignore_quit_key);
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -653,7 +697,8 @@ mod tests {
|
||||
#[values(
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieTagsInput
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
@@ -673,6 +718,10 @@ mod tests {
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
|
||||
if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput {
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +731,8 @@ mod tests {
|
||||
|
||||
use crate::app::radarr::radarr_test_utils::create_test_radarr_data;
|
||||
use crate::{
|
||||
assert_movie_preferences_selections_reset, assert_search_reset, simple_stateful_iterable_vec,
|
||||
assert_edit_movie_reset, assert_movie_preferences_selections_reset, assert_search_reset,
|
||||
simple_stateful_iterable_vec,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
@@ -709,6 +759,29 @@ mod tests {
|
||||
assert_search_reset!(app.data.radarr_data);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_input_esc() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_search_results_esc() {
|
||||
let mut app = App::default();
|
||||
@@ -781,6 +854,30 @@ mod tests {
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
assert_movie_preferences_selections_reset!(app.data.radarr_data);
|
||||
assert_edit_movie_reset!(app.data.radarr_data);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_tags_input_esc() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -846,6 +943,22 @@ mod tests {
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "Tes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_tags_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.edit_tags = "Test".to_owned().into();
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags.text, "Tes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_search_input_char_key() {
|
||||
let mut app = App::default();
|
||||
@@ -860,5 +973,20 @@ mod tests {
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "h");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_tags_input_char_key() {
|
||||
let mut app = App::default();
|
||||
|
||||
AddMovieHandler::with(
|
||||
&Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags.text, "h");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for CollectionDetailsHandler<'a>
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
self.app.data.radarr_data.selected_block = ActiveRadarrBlock::EditMovieToggleMonitored;
|
||||
self.app.data.radarr_data.populate_movie_preferences_lists();
|
||||
}
|
||||
}
|
||||
@@ -183,6 +184,7 @@ mod tests {
|
||||
.set_items(vec![CollectionMovie::default()]);
|
||||
app.data.radarr_data.quality_profile_map =
|
||||
HashMap::from([(1, "B - Test 2".to_owned()), (0, "A - Test 1".to_owned())]);
|
||||
app.data.radarr_data.selected_block = ActiveRadarrBlock::AddMovieConfirmPrompt;
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -201,6 +203,10 @@ mod tests {
|
||||
.into()
|
||||
);
|
||||
assert!(!app.data.radarr_data.movie_monitor_list.items.is_empty());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block,
|
||||
ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
);
|
||||
assert!(!app
|
||||
.data
|
||||
.radarr_data
|
||||
|
||||
@@ -186,7 +186,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for EditMovieHandler<'a> {
|
||||
}
|
||||
ActiveRadarrBlock::EditMoviePrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.radarr_data.reset_edit_movie();
|
||||
self.app.data.radarr_data.reset_add_edit_movie_fields();
|
||||
self.app.data.radarr_data.prompt_confirm = false;
|
||||
}
|
||||
ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
@@ -587,7 +587,7 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditMovieHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
@@ -595,7 +595,7 @@ mod tests {
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1564,7 +1564,8 @@ mod tests {
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary,
|
||||
ActiveRadarrBlock::AddMovieTagsInput
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
|
||||
@@ -794,7 +794,7 @@ impl<'a> Network<'a> {
|
||||
.await;
|
||||
|
||||
self
|
||||
.handle_request::<AddMovieBody, ()>(request_props, |_, _| ())
|
||||
.handle_request::<AddMovieBody, Value>(request_props, |_, _| ())
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -921,7 +921,6 @@ impl<'a> Network<'a> {
|
||||
.clone();
|
||||
let missing_tags_vec = edit_tags
|
||||
.split(',')
|
||||
.into_iter()
|
||||
.filter(|&tag| !tag.is_empty() && tags_map.get_by_right(tag.trim()).is_none())
|
||||
.collect::<Vec<&str>>();
|
||||
|
||||
@@ -936,7 +935,6 @@ impl<'a> Network<'a> {
|
||||
.edit_tags
|
||||
.text
|
||||
.split(',')
|
||||
.into_iter()
|
||||
.filter(|tag| !tag.is_empty())
|
||||
.map(|tag| {
|
||||
*app
|
||||
@@ -1028,6 +1026,10 @@ fn get_movie_status(has_file: bool, downloads_vec: &[DownloadRecord], movie_id:
|
||||
if download.status == "downloading" {
|
||||
return "Downloading".to_owned();
|
||||
}
|
||||
|
||||
if download.status == "completed" {
|
||||
return "Awaiting Import".to_owned();
|
||||
}
|
||||
}
|
||||
|
||||
return "Missing".to_owned();
|
||||
@@ -2399,6 +2401,22 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_movie_status_awaiting_import() {
|
||||
assert_str_eq!(
|
||||
get_movie_status(
|
||||
false,
|
||||
&[DownloadRecord {
|
||||
movie_id: 1.into(),
|
||||
status: "completed".to_owned(),
|
||||
..DownloadRecord::default()
|
||||
}],
|
||||
1.into()
|
||||
),
|
||||
"Awaiting Import"
|
||||
);
|
||||
}
|
||||
|
||||
async fn mock_radarr_api(
|
||||
method: RequestMethod,
|
||||
request_body: Option<Value>,
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::ui::utils::{
|
||||
use crate::ui::{
|
||||
draw_button, draw_drop_down_list, draw_drop_down_menu_button, draw_drop_down_popup,
|
||||
draw_error_popup, draw_error_popup_over, draw_medium_popup_over, draw_table, draw_text_box,
|
||||
TableProps,
|
||||
draw_text_box_with_label, TableProps,
|
||||
};
|
||||
use crate::utils::convert_runtime;
|
||||
use crate::App;
|
||||
@@ -37,7 +37,8 @@ pub(super) fn draw_add_movie_search_popup<B: Backend>(
|
||||
ActiveRadarrBlock::AddMoviePrompt
|
||||
| ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
| ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile => {
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
| ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
if context_option.is_some() {
|
||||
draw_medium_popup_over(
|
||||
f,
|
||||
@@ -112,7 +113,8 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
| ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
| ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
| ActiveRadarrBlock::AddMovieAlreadyInLibrary => {
|
||||
| ActiveRadarrBlock::AddMovieAlreadyInLibrary
|
||||
| ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
let mut help_text = Text::from("<enter> details | <esc> edit search");
|
||||
help_text.patch_style(style_help());
|
||||
let help_paragraph = Paragraph::new(help_text)
|
||||
@@ -259,7 +261,9 @@ fn draw_confirmation_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, prom
|
||||
draw_select_quality_profile_popup,
|
||||
);
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt => draw_confirmation_prompt(f, app, prompt_area),
|
||||
ActiveRadarrBlock::AddMoviePrompt | ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
draw_confirmation_prompt(f, app, prompt_area)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -336,7 +340,8 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Min(5),
|
||||
Constraint::Length(3),
|
||||
Constraint::Min(3),
|
||||
Constraint::Length(3),
|
||||
],
|
||||
prompt_area,
|
||||
@@ -348,7 +353,7 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
vec![Constraint::Percentage(50), Constraint::Percentage(50)],
|
||||
chunks[5],
|
||||
chunks[6],
|
||||
);
|
||||
|
||||
draw_drop_down_menu_button(
|
||||
@@ -374,6 +379,18 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
*selected_block == ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
);
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
draw_text_box_with_label(
|
||||
f,
|
||||
chunks[4],
|
||||
"Tags",
|
||||
&app.data.radarr_data.edit_tags.text,
|
||||
*app.data.radarr_data.edit_tags.offset.borrow(),
|
||||
*selected_block == ActiveRadarrBlock::AddMovieTagsInput,
|
||||
active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput,
|
||||
);
|
||||
}
|
||||
|
||||
draw_button(
|
||||
f,
|
||||
horizontal_chunks[0],
|
||||
|
||||
@@ -23,9 +23,9 @@ use crate::ui::radarr_ui::edit_movie_ui::draw_edit_movie_prompt;
|
||||
use crate::ui::radarr_ui::movie_details_ui::draw_movie_info_popup;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, horizontal_chunks, layout_block,
|
||||
layout_block_top_border, line_gauge_with_label, line_gauge_with_title, show_cursor, style_bold,
|
||||
style_default, style_failure, style_primary, style_success, style_unmonitored, style_warning,
|
||||
title_block, title_block_centered, vertical_chunks_with_margin,
|
||||
layout_block_top_border, line_gauge_with_label, line_gauge_with_title, show_cursor,
|
||||
style_awaiting_import, style_bold, style_default, style_failure, style_primary, style_success,
|
||||
style_unmonitored, style_warning, title_block, title_block_centered, vertical_chunks_with_margin,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_drop_down_list, draw_large_popup_over, draw_medium_popup_over, draw_popup, draw_popup_over,
|
||||
@@ -639,6 +639,10 @@ fn determine_row_style(downloads_vec: &[DownloadRecord], movie: &Movie) -> Style
|
||||
if download.status == "downloading" {
|
||||
return style_warning();
|
||||
}
|
||||
|
||||
if download.status == "completed" {
|
||||
return style_awaiting_import();
|
||||
}
|
||||
}
|
||||
|
||||
return style_failure();
|
||||
|
||||
@@ -13,8 +13,8 @@ use crate::models::radarr_models::{Credit, MovieHistoryItem, Release, ReleaseFie
|
||||
use crate::models::Route;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, layout_block_bottom_border, layout_block_top_border,
|
||||
spans_info_default, style_bold, style_default, style_failure, style_primary, style_success,
|
||||
style_warning, vertical_chunks,
|
||||
spans_info_default, style_awaiting_import, style_bold, style_default, style_failure,
|
||||
style_primary, style_success, style_warning, vertical_chunks,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_drop_down_list, draw_drop_down_popup, draw_prompt_box, draw_prompt_box_with_content,
|
||||
@@ -544,6 +544,7 @@ fn draw_manual_search_confirm_prompt<B: Backend>(
|
||||
fn determine_style_from_download_status(download_status: &str) -> Style {
|
||||
match download_status {
|
||||
"Downloaded" => style_success(),
|
||||
"Awaiting Import" => style_awaiting_import(),
|
||||
"Downloading" => style_warning(),
|
||||
"Missing" => style_failure(),
|
||||
_ => style_success(),
|
||||
|
||||
+5
-8
@@ -6,20 +6,13 @@ use tui::widgets::{Block, BorderType, Borders, LineGauge, Paragraph, Wrap};
|
||||
use tui::{symbols, Frame};
|
||||
|
||||
pub const COLOR_TEAL: Color = Color::Rgb(35, 50, 55);
|
||||
// pub const COLOR_CYAN: Color = Color::Rgb(0, 230, 230);
|
||||
pub const COLOR_CYAN: Color = Color::Cyan;
|
||||
// pub const COLOR_LIGHT_BLUE: Color = Color::Rgb(138, 196, 255);
|
||||
pub const COLOR_LIGHT_BLUE: Color = Color::LightBlue;
|
||||
// pub const COLOR_YELLOW: Color = Color::Rgb(249, 229, 113);
|
||||
pub const COLOR_YELLOW: Color = Color::Yellow;
|
||||
// pub const COLOR_GREEN: Color = Color::Rgb(72, 213, 150);
|
||||
pub const COLOR_GREEN: Color = Color::Green;
|
||||
// pub const COLOR_RED: Color = Color::Rgb(249, 140, 164);
|
||||
pub const COLOR_RED: Color = Color::Red;
|
||||
// pub const COLOR_ORANGE: Color = Color::Rgb(255, 170, 66);
|
||||
// pub const COLOR_WHITE: Color = Color::Rgb(255, 255, 255);
|
||||
pub const COLOR_ORANGE: Color = Color::Rgb(255, 170, 66);
|
||||
pub const COLOR_WHITE: Color = Color::White;
|
||||
// pub const COLOR_MAGENTA: Color = Color::Rgb(139, 0, 139);
|
||||
pub const COLOR_MAGENTA: Color = Color::Magenta;
|
||||
|
||||
pub fn horizontal_chunks(constraints: Vec<Constraint>, area: Rect) -> Vec<Rect> {
|
||||
@@ -191,6 +184,10 @@ pub fn style_failure() -> Style {
|
||||
Style::default().fg(COLOR_RED)
|
||||
}
|
||||
|
||||
pub fn style_awaiting_import() -> Style {
|
||||
Style::default().fg(COLOR_ORANGE)
|
||||
}
|
||||
|
||||
pub fn style_help() -> Style {
|
||||
Style::default().fg(COLOR_LIGHT_BLUE)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user