refactored managarr table initializer so a mutable app reference can be passed
This commit is contained in:
@@ -2,9 +2,9 @@ use add_series_ui::AddSeriesUi;
|
||||
use delete_series_ui::DeleteSeriesUi;
|
||||
use edit_series_ui::EditSeriesUi;
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::{Constraint, Rect},
|
||||
widgets::{Cell, Row},
|
||||
Frame,
|
||||
};
|
||||
use series_details_ui::SeriesDetailsUi;
|
||||
|
||||
@@ -16,15 +16,15 @@ use crate::utils::convert_to_gb;
|
||||
use crate::{
|
||||
app::App,
|
||||
models::{
|
||||
Route,
|
||||
servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, LIBRARY_BLOCKS},
|
||||
sonarr_models::{Series, SeriesStatus},
|
||||
Route,
|
||||
},
|
||||
ui::{
|
||||
DrawUi,
|
||||
styles::ManagarrStyle,
|
||||
utils::{get_width_from_percentage, layout_block_top_border},
|
||||
widgets::managarr_table::ManagarrTable,
|
||||
DrawUi,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -86,16 +86,16 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
} else {
|
||||
Series::default()
|
||||
};
|
||||
let quality_profile_map = &app.data.sonarr_data.quality_profile_map;
|
||||
let language_profile_map = &app.data.sonarr_data.language_profiles_map;
|
||||
let tags_map = &app.data.sonarr_data.tags_map;
|
||||
let content = Some(&mut app.data.sonarr_data.series);
|
||||
let quality_profile_map = app.data.sonarr_data.quality_profile_map.clone();
|
||||
let language_profile_map = app.data.sonarr_data.language_profiles_map.clone();
|
||||
let tags_map = app.data.sonarr_data.tags_map.clone();
|
||||
let ui_scroll_tick_count = app.ui_scroll_tick_count;
|
||||
|
||||
let series_table_row_mapping = |series: &Series| {
|
||||
series.title.scroll_left_or_reset(
|
||||
get_width_from_percentage(area, 23),
|
||||
*series == current_selection,
|
||||
app.ui_scroll_tick_count == 0,
|
||||
ui_scroll_tick_count == 0,
|
||||
);
|
||||
let monitored = if series.monitored { "🏷" } else { "" };
|
||||
let certification = series.certification.clone().unwrap_or_default();
|
||||
@@ -139,40 +139,43 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
]),
|
||||
)
|
||||
};
|
||||
let series_table = ManagarrTable::new(content, series_table_row_mapping)
|
||||
.block(layout_block_top_border())
|
||||
.loading(app.is_loading)
|
||||
.sorting(active_sonarr_block == ActiveSonarrBlock::SeriesSortPrompt)
|
||||
.searching(active_sonarr_block == ActiveSonarrBlock::SearchSeries)
|
||||
.filtering(active_sonarr_block == ActiveSonarrBlock::FilterSeries)
|
||||
.search_produced_empty_results(active_sonarr_block == ActiveSonarrBlock::SearchSeriesError)
|
||||
.filter_produced_empty_results(active_sonarr_block == ActiveSonarrBlock::FilterSeriesError)
|
||||
.headers([
|
||||
"Title",
|
||||
"Year",
|
||||
"Network",
|
||||
"Status",
|
||||
"Rating",
|
||||
"Type",
|
||||
"Quality Profile",
|
||||
"Language",
|
||||
"Size",
|
||||
"Monitored",
|
||||
"Tags",
|
||||
])
|
||||
.constraints([
|
||||
Constraint::Percentage(20),
|
||||
Constraint::Percentage(4),
|
||||
Constraint::Percentage(14),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(11),
|
||||
Constraint::Percentage(8),
|
||||
Constraint::Percentage(7),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(12),
|
||||
]);
|
||||
let series_table = ManagarrTable::new(
|
||||
app,
|
||||
|app| Some(&mut app.data.sonarr_data.series),
|
||||
series_table_row_mapping,
|
||||
)
|
||||
.block(layout_block_top_border())
|
||||
.sorting(active_sonarr_block == ActiveSonarrBlock::SeriesSortPrompt)
|
||||
.searching(active_sonarr_block == ActiveSonarrBlock::SearchSeries)
|
||||
.filtering(active_sonarr_block == ActiveSonarrBlock::FilterSeries)
|
||||
.search_produced_empty_results(active_sonarr_block == ActiveSonarrBlock::SearchSeriesError)
|
||||
.filter_produced_empty_results(active_sonarr_block == ActiveSonarrBlock::FilterSeriesError)
|
||||
.headers([
|
||||
"Title",
|
||||
"Year",
|
||||
"Network",
|
||||
"Status",
|
||||
"Rating",
|
||||
"Type",
|
||||
"Quality Profile",
|
||||
"Language",
|
||||
"Size",
|
||||
"Monitored",
|
||||
"Tags",
|
||||
])
|
||||
.constraints([
|
||||
Constraint::Percentage(20),
|
||||
Constraint::Percentage(4),
|
||||
Constraint::Percentage(14),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(11),
|
||||
Constraint::Percentage(8),
|
||||
Constraint::Percentage(7),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(12),
|
||||
]);
|
||||
|
||||
if [
|
||||
ActiveSonarrBlock::SearchSeries,
|
||||
|
||||
Reference in New Issue
Block a user