Mostly completed tags implementation; still need to add the UI option for the Add Movie popup, and I still need to fix the REALLY FAST horizontal scrolling issue (I'm thinking just %2 everything to slow it down). Oh, and also need to convert the quality profile Hashmap into a BiMap
This commit is contained in:
@@ -70,7 +70,8 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.current_selection_clone()
|
||||
.current_selection()
|
||||
.clone()
|
||||
};
|
||||
|
||||
let chunks = vertical_chunks_with_margin(
|
||||
@@ -82,12 +83,21 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
area,
|
||||
1,
|
||||
);
|
||||
let block_content = app.data.radarr_data.search.as_str();
|
||||
let block_content = &app.data.radarr_data.search.text;
|
||||
let offset = *app.data.radarr_data.search.offset.borrow();
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchInput => {
|
||||
draw_text_box(f, chunks[0], Some("Add Movie"), block_content, true, false);
|
||||
draw_text_box(
|
||||
f,
|
||||
chunks[0],
|
||||
Some("Add Movie"),
|
||||
block_content,
|
||||
offset,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
f.render_widget(layout_block(), chunks[1]);
|
||||
|
||||
let mut help_text = Text::from("<esc> close");
|
||||
@@ -184,7 +194,7 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
""
|
||||
};
|
||||
|
||||
movie.title.scroll_or_reset(
|
||||
movie.title.scroll_left_or_reset(
|
||||
get_width_from_percentage(area, 27),
|
||||
*movie == current_selection,
|
||||
);
|
||||
@@ -208,7 +218,15 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
}
|
||||
}
|
||||
|
||||
draw_text_box(f, chunks[0], Some("Add Movie"), block_content, false, false);
|
||||
draw_text_box(
|
||||
f,
|
||||
chunks[0],
|
||||
Some("Add Movie"),
|
||||
block_content,
|
||||
offset,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_confirmation_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, prompt_area: Rect) {
|
||||
@@ -260,13 +278,13 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
let title = "Add Movie";
|
||||
let (movie_title, movie_overview) = if let Route::Radarr(_, Some(_)) = app.get_current_route() {
|
||||
(
|
||||
app
|
||||
&app
|
||||
.data
|
||||
.radarr_data
|
||||
.collection_movies
|
||||
.current_selection()
|
||||
.title
|
||||
.stationary_style(),
|
||||
.text,
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -277,13 +295,13 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
)
|
||||
} else {
|
||||
(
|
||||
app
|
||||
&app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.current_selection()
|
||||
.title
|
||||
.stationary_style(),
|
||||
.text,
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
|
||||
@@ -75,7 +75,8 @@ pub(super) fn draw_collection_details<B: Backend>(
|
||||
.data
|
||||
.radarr_data
|
||||
.collection_movies
|
||||
.current_selection_clone()
|
||||
.current_selection()
|
||||
.clone()
|
||||
};
|
||||
let mut help_text =
|
||||
Text::from("<↑↓> scroll table | <enter> show overview/add movie | <esc> close");
|
||||
@@ -151,7 +152,7 @@ pub(super) fn draw_collection_details<B: Backend>(
|
||||
} else {
|
||||
""
|
||||
};
|
||||
movie.title.scroll_or_reset(
|
||||
movie.title.scroll_left_or_reset(
|
||||
get_width_from_percentage(chunks[1], 20),
|
||||
current_selection == *movie,
|
||||
);
|
||||
@@ -212,7 +213,8 @@ fn draw_movie_overview<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_
|
||||
.data
|
||||
.radarr_data
|
||||
.collection_movies
|
||||
.current_selection_clone()
|
||||
.current_selection()
|
||||
.clone()
|
||||
.overview,
|
||||
);
|
||||
overview.patch_style(style_default());
|
||||
|
||||
@@ -140,7 +140,8 @@ fn draw_edit_confirmation_prompt<B: Backend>(
|
||||
f,
|
||||
chunks[4],
|
||||
"Path",
|
||||
&app.data.radarr_data.edit_path,
|
||||
&app.data.radarr_data.edit_path.text,
|
||||
*app.data.radarr_data.edit_path.offset.borrow(),
|
||||
*selected_block == ActiveRadarrBlock::EditMoviePathInput,
|
||||
active_radarr_block == ActiveRadarrBlock::EditMoviePathInput,
|
||||
);
|
||||
@@ -148,7 +149,8 @@ fn draw_edit_confirmation_prompt<B: Backend>(
|
||||
f,
|
||||
chunks[5],
|
||||
"Tags",
|
||||
&app.data.radarr_data.edit_tags,
|
||||
&app.data.radarr_data.edit_tags.text,
|
||||
*app.data.radarr_data.edit_tags.offset.borrow(),
|
||||
*selected_block == ActiveRadarrBlock::EditMovieTagsInput,
|
||||
active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput,
|
||||
);
|
||||
|
||||
+42
-26
@@ -158,6 +158,7 @@ pub(super) fn draw_radarr_context_row<B: Backend>(f: &mut Frame<'_, B>, app: &Ap
|
||||
|
||||
fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let quality_profile_map = &app.data.radarr_data.quality_profile_map;
|
||||
let tags_map = &app.data.radarr_data.tags_map;
|
||||
let downloads_vec = &app.data.radarr_data.downloads.items;
|
||||
let content = if !app.data.radarr_data.filtered_movies.items.is_empty()
|
||||
&& !app.data.radarr_data.is_filtering
|
||||
@@ -208,7 +209,21 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let (hours, minutes) = convert_runtime(movie.runtime.as_u64().unwrap());
|
||||
let file_size: f64 = convert_to_gb(movie.size_on_disk.as_u64().unwrap());
|
||||
let certification = movie.certification.clone().unwrap_or_else(|| "".to_owned());
|
||||
let tags = "";
|
||||
let quality_profile = quality_profile_map
|
||||
.get(&movie.quality_profile_id.as_u64().unwrap())
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
let tags = movie
|
||||
.tags
|
||||
.iter()
|
||||
.map(|tag_id| {
|
||||
tags_map
|
||||
.get_by_left(&tag_id.as_u64().unwrap())
|
||||
.unwrap()
|
||||
.clone()
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ");
|
||||
|
||||
Row::new(vec![
|
||||
Cell::from(movie.title.to_owned()),
|
||||
@@ -218,14 +233,9 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
Cell::from(certification),
|
||||
Cell::from(movie.original_language.name.to_owned()),
|
||||
Cell::from(format!("{:.2} GB", file_size)),
|
||||
Cell::from(
|
||||
quality_profile_map
|
||||
.get(&movie.quality_profile_id.as_u64().unwrap())
|
||||
.unwrap()
|
||||
.to_owned(),
|
||||
),
|
||||
Cell::from(quality_profile),
|
||||
Cell::from(monitored.to_owned()),
|
||||
Cell::from(tags.to_owned()),
|
||||
Cell::from(tags),
|
||||
])
|
||||
.style(determine_row_style(downloads_vec, movie))
|
||||
},
|
||||
@@ -322,20 +332,23 @@ fn draw_search_box<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect)
|
||||
|
||||
f.render_widget(input, chunks[0]);
|
||||
} else {
|
||||
let (block_title, block_content) = match app.get_current_route() {
|
||||
let default_content = String::default();
|
||||
let (block_title, offset, block_content) = match app.get_current_route() {
|
||||
Route::Radarr(active_radarr_block, _) => match active_radarr_block {
|
||||
_ if SEARCH_BLOCKS.contains(active_radarr_block) => {
|
||||
("Search", app.data.radarr_data.search.as_str())
|
||||
}
|
||||
_ => ("", ""),
|
||||
_ if SEARCH_BLOCKS.contains(active_radarr_block) => (
|
||||
"Search",
|
||||
*app.data.radarr_data.search.offset.borrow(),
|
||||
&app.data.radarr_data.search.text,
|
||||
),
|
||||
_ => ("", 0, &default_content),
|
||||
},
|
||||
_ => ("", ""),
|
||||
_ => ("", 0, &default_content),
|
||||
};
|
||||
|
||||
let input = Paragraph::new(block_content)
|
||||
let input = Paragraph::new(block_content.as_str())
|
||||
.style(style_default())
|
||||
.block(title_block_centered(block_title));
|
||||
show_cursor(f, chunks[0], block_content);
|
||||
show_cursor(f, chunks[0], offset, block_content);
|
||||
|
||||
f.render_widget(input, chunks[0]);
|
||||
}
|
||||
@@ -360,20 +373,23 @@ fn draw_filter_box<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect)
|
||||
|
||||
f.render_widget(input, chunks[0]);
|
||||
} else {
|
||||
let (block_title, block_content) = match app.get_current_route() {
|
||||
let default_content = String::default();
|
||||
let (block_title, offset, block_content) = match app.get_current_route() {
|
||||
Route::Radarr(active_radarr_block, _) => match active_radarr_block {
|
||||
_ if FILTER_BLOCKS.contains(active_radarr_block) => {
|
||||
("Filter", app.data.radarr_data.filter.as_str())
|
||||
}
|
||||
_ => ("", ""),
|
||||
_ if FILTER_BLOCKS.contains(active_radarr_block) => (
|
||||
"Filter",
|
||||
*app.data.radarr_data.filter.offset.borrow(),
|
||||
&app.data.radarr_data.filter.text,
|
||||
),
|
||||
_ => ("", 0, &default_content),
|
||||
},
|
||||
_ => ("", ""),
|
||||
_ => ("", 0, &default_content),
|
||||
};
|
||||
|
||||
let input = Paragraph::new(block_content)
|
||||
let input = Paragraph::new(block_content.as_str())
|
||||
.style(style_default())
|
||||
.block(title_block_centered(block_title));
|
||||
show_cursor(f, chunks[0], block_content);
|
||||
show_cursor(f, chunks[0], offset, block_content);
|
||||
|
||||
f.render_widget(input, chunks[0]);
|
||||
}
|
||||
@@ -413,7 +429,7 @@ fn draw_downloads<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let current_selection = if app.data.radarr_data.downloads.items.is_empty() {
|
||||
DownloadRecord::default()
|
||||
} else {
|
||||
app.data.radarr_data.downloads.current_selection_clone()
|
||||
app.data.radarr_data.downloads.current_selection().clone()
|
||||
};
|
||||
|
||||
draw_table(
|
||||
@@ -456,7 +472,7 @@ fn draw_downloads<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
} = download_record;
|
||||
|
||||
let path = output_path.clone().unwrap_or_default();
|
||||
path.scroll_or_reset(
|
||||
path.scroll_left_or_reset(
|
||||
get_width_from_percentage(area, 18),
|
||||
current_selection == *download_record,
|
||||
);
|
||||
|
||||
@@ -113,7 +113,7 @@ fn draw_refresh_and_scan_prompt<B: Backend>(
|
||||
"Refresh and Scan",
|
||||
format!(
|
||||
"Do you want to trigger a refresh and disk scan for the movie: {}?",
|
||||
app.data.radarr_data.movies.current_selection_clone().title
|
||||
app.data.radarr_data.movies.current_selection().title
|
||||
)
|
||||
.as_str(),
|
||||
&app.data.radarr_data.prompt_confirm,
|
||||
@@ -223,7 +223,12 @@ fn draw_movie_history<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_a
|
||||
let current_selection = if app.data.radarr_data.movie_history.items.is_empty() {
|
||||
MovieHistoryItem::default()
|
||||
} else {
|
||||
app.data.radarr_data.movie_history.current_selection_clone()
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.movie_history
|
||||
.current_selection()
|
||||
.clone()
|
||||
};
|
||||
let block = layout_block_top_border();
|
||||
|
||||
@@ -263,7 +268,7 @@ fn draw_movie_history<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_a
|
||||
event_type,
|
||||
} = movie_history_item;
|
||||
|
||||
movie_history_item.source_title.scroll_or_reset(
|
||||
movie_history_item.source_title.scroll_left_or_reset(
|
||||
get_width_from_percentage(content_area, 34),
|
||||
current_selection == *movie_history_item,
|
||||
);
|
||||
@@ -362,7 +367,8 @@ fn draw_movie_releases<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_
|
||||
.data
|
||||
.radarr_data
|
||||
.movie_releases
|
||||
.current_selection_clone()
|
||||
.current_selection()
|
||||
.clone()
|
||||
};
|
||||
let current_route = *app.get_current_route();
|
||||
let mut table_headers_vec = vec![
|
||||
@@ -432,7 +438,7 @@ fn draw_movie_releases<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_
|
||||
..
|
||||
} = release;
|
||||
let age = format!("{} days", age.as_u64().unwrap_or(0));
|
||||
title.scroll_or_reset(
|
||||
title.scroll_left_or_reset(
|
||||
get_width_from_percentage(content_area, 30),
|
||||
current_selection == *release
|
||||
&& current_route != ActiveRadarrBlock::ManualSearchConfirmPrompt.into(),
|
||||
@@ -488,12 +494,12 @@ fn draw_manual_search_confirm_prompt<B: Backend>(
|
||||
let prompt = if current_selection.rejected {
|
||||
format!(
|
||||
"Do you really want to download the rejected release: {}?",
|
||||
current_selection.title.stationary_style()
|
||||
¤t_selection.title.text
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"Do you want to download the release: {}?",
|
||||
current_selection.title.stationary_style()
|
||||
¤t_selection.title.text
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user