feat: Full Lidarr system support for both the CLI and TUI

This commit is contained in:
2026-01-14 14:50:33 -07:00
parent c74d5936d2
commit 8b9467bd39
63 changed files with 4824 additions and 74 deletions
+4 -1
View File
@@ -26,6 +26,7 @@ use super::{
use crate::ui::lidarr_ui::downloads::DownloadsUi;
use crate::ui::lidarr_ui::indexers::IndexersUi;
use crate::ui::lidarr_ui::root_folders::RootFoldersUi;
use crate::ui::lidarr_ui::system::SystemUi;
use crate::{
app::App,
logos::LIDARR_LOGO,
@@ -43,11 +44,12 @@ mod history;
mod indexers;
mod library;
mod lidarr_ui_utils;
mod root_folders;
mod system;
#[cfg(test)]
#[path = "lidarr_ui_tests.rs"]
mod lidarr_ui_tests;
mod root_folders;
pub(super) struct LidarrUi;
@@ -66,6 +68,7 @@ impl DrawUi for LidarrUi {
_ if HistoryUi::accepts(route) => HistoryUi::draw(f, app, content_area),
_ if RootFoldersUi::accepts(route) => RootFoldersUi::draw(f, app, content_area),
_ if IndexersUi::accepts(route) => IndexersUi::draw(f, app, content_area),
_ if SystemUi::accepts(route) => SystemUi::draw(f, app, content_area),
_ => (),
}
}
@@ -3,7 +3,7 @@ source: src/ui/lidarr_ui/lidarr_ui_tests.rs
expression: output
---
╭ Artists ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Library │ Downloads │ History │ Root Folders │ Indexers
│ Library │ Downloads │ History │ Root Folders │ Indexers │ System
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Name ▼ Type Status Quality Profile Metadata Profile Albums Tracks Size Monitored Tags │
│=> Alex Person Continuing Lossless Standard 1 15/15 0.00 GB 🏷 alex │
@@ -3,7 +3,7 @@ source: src/ui/lidarr_ui/lidarr_ui_tests.rs
expression: output
---
╭ Artists ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Library │ Downloads │ History │ Root Folders │ Indexers
│ Library │ Downloads │ History │ Root Folders │ Indexers │ System
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Title Percent Complete Size Output Path Indexer Download Client │
│=> Test download title 50% 3.30 GB /nfs/music/alex/album kickass torrents transmission │
@@ -3,7 +3,7 @@ source: src/ui/lidarr_ui/lidarr_ui_tests.rs
expression: output
---
╭ Artists ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Library │ Downloads │ History │ Root Folders │ Indexers
│ Library │ Downloads │ History │ Root Folders │ Indexers │ System
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Source Title ▼ Event Type Quality Date │
│=> Test source title grabbed Lossless 2023-01-01 00:00:00 UTC │
@@ -3,7 +3,7 @@ source: src/ui/lidarr_ui/lidarr_ui_tests.rs
expression: output
---
╭ Artists ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Library │ Downloads │ History │ Root Folders │ Indexers
│ Library │ Downloads │ History │ Root Folders │ Indexers │ System
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Indexer RSS Automatic Search Interactive Search Priority Tags │
│=> Test Indexer Enabled Enabled Enabled 25 alex │
@@ -3,7 +3,7 @@ source: src/ui/lidarr_ui/lidarr_ui_tests.rs
expression: output
---
╭ Artists ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Library │ Downloads │ History │ Root Folders │ Indexers
│ Library │ Downloads │ History │ Root Folders │ Indexers │ System
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Path Free Space Unmapped Folders │
│=> /nfs 204800.00 GB 0 │
+204
View File
@@ -0,0 +1,204 @@
use crate::ui::styles::default_style;
use std::ops::Sub;
#[cfg(test)]
use crate::ui::ui_test_utils::test_utils::Utc;
#[cfg(not(test))]
use chrono::Utc;
use ratatui::layout::Layout;
use ratatui::text::{Span, Text};
use ratatui::widgets::{Cell, Row};
use ratatui::{
Frame,
layout::{Constraint, Rect},
widgets::ListItem,
};
use crate::app::App;
use crate::models::lidarr_models::LidarrTask;
use crate::models::servarr_data::lidarr::lidarr_data::ActiveLidarrBlock;
use crate::models::servarr_models::QueueEvent;
use crate::ui::lidarr_ui::system::system_details_ui::SystemDetailsUi;
use crate::ui::styles::ManagarrStyle;
use crate::ui::utils::{convert_to_minutes_hours_days, style_log_list_item};
use crate::ui::widgets::loading_block::LoadingBlock;
use crate::ui::widgets::managarr_table::ManagarrTable;
use crate::ui::widgets::selectable_list::SelectableList;
use crate::{
models::Route,
ui::{DrawUi, utils::title_block},
};
mod system_details_ui;
#[cfg(test)]
#[path = "system_ui_tests.rs"]
mod system_ui_tests;
pub(super) const TASK_TABLE_HEADERS: [&str; 4] =
["Name", "Interval", "Last Execution", "Next Execution"];
pub(super) const TASK_TABLE_CONSTRAINTS: [Constraint; 4] = [
Constraint::Percentage(30),
Constraint::Percentage(23),
Constraint::Percentage(23),
Constraint::Percentage(23),
];
pub(super) struct SystemUi;
impl DrawUi for SystemUi {
fn accepts(route: Route) -> bool {
let Route::Lidarr(active_lidarr_block, _) = route else {
return false;
};
SystemDetailsUi::accepts(route) || active_lidarr_block == ActiveLidarrBlock::System
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let route = app.get_current_route();
draw_system_ui_layout(f, app, area);
if SystemDetailsUi::accepts(route) {
SystemDetailsUi::draw(f, app, area);
}
}
}
fn draw_system_ui_layout(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let [activities_area, logs_area] =
Layout::vertical([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]).areas(area);
let [tasks_area, events_area] =
Layout::horizontal([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]).areas(activities_area);
draw_tasks(f, app, tasks_area);
draw_queued_events(f, app, events_area);
draw_logs(f, app, logs_area);
}
fn draw_tasks(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let tasks_row_mapping = |task: &LidarrTask| {
let task_props = extract_task_props(task);
Row::new(vec![
Cell::from(task_props.name),
Cell::from(task_props.interval),
Cell::from(task_props.last_execution),
Cell::from(task_props.next_execution),
])
.primary()
};
let tasks_table = ManagarrTable::new(Some(&mut app.data.lidarr_data.tasks), tasks_row_mapping)
.block(title_block("Tasks"))
.loading(app.is_loading)
.highlight_rows(false)
.headers(TASK_TABLE_HEADERS)
.constraints(TASK_TABLE_CONSTRAINTS);
f.render_widget(tasks_table, area);
}
pub(super) fn draw_queued_events(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let events_row_mapping = |event: &QueueEvent| {
let queued = convert_to_minutes_hours_days(Utc::now().sub(event.queued).num_minutes());
let queued_string = if queued != "now" {
format!("{queued} ago")
} else {
queued
};
let started_string = if event.started.is_some() {
let started =
convert_to_minutes_hours_days(Utc::now().sub(event.started.unwrap()).num_minutes());
if started != "now" {
format!("{started} ago")
} else {
started
}
} else {
String::new()
};
let duration = if event.duration.is_some() {
&event.duration.as_ref().unwrap()[..8]
} else {
""
};
Row::new(vec![
Cell::from(event.trigger.clone()),
Cell::from(event.status.clone()),
Cell::from(event.command_name.clone()),
Cell::from(queued_string),
Cell::from(started_string),
Cell::from(duration.to_owned()),
])
.primary()
};
let events_table = ManagarrTable::new(
Some(&mut app.data.lidarr_data.queued_events),
events_row_mapping,
)
.block(title_block("Queued Events"))
.loading(app.is_loading)
.highlight_rows(false)
.headers(["Trigger", "Status", "Name", "Queued", "Started", "Duration"])
.constraints([
Constraint::Percentage(13),
Constraint::Percentage(13),
Constraint::Percentage(30),
Constraint::Percentage(16),
Constraint::Percentage(14),
Constraint::Percentage(14),
]);
f.render_widget(events_table, area);
}
fn draw_logs(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let block = title_block("Logs");
if app.data.lidarr_data.logs.items.is_empty() {
f.render_widget(LoadingBlock::new(app.is_loading, block), area);
return;
}
let logs_box = SelectableList::new(&mut app.data.lidarr_data.logs, |log| {
let log_line = log.to_string();
let level = log_line.split('|').collect::<Vec<&str>>()[1].to_string();
style_log_list_item(ListItem::new(Text::from(Span::raw(log_line))), level)
})
.block(block)
.highlight_style(default_style());
f.render_widget(logs_box, area);
}
pub(super) struct TaskProps {
pub(super) name: String,
pub(super) interval: String,
pub(super) last_execution: String,
pub(super) next_execution: String,
}
pub(super) fn extract_task_props(task: &LidarrTask) -> TaskProps {
let interval = convert_to_minutes_hours_days(task.interval);
let next_execution =
convert_to_minutes_hours_days((task.next_execution - Utc::now()).num_minutes());
let last_execution =
convert_to_minutes_hours_days((Utc::now() - task.last_execution).num_minutes());
let last_execution_string = if last_execution != "now" {
format!("{last_execution} ago")
} else {
last_execution
};
TaskProps {
name: task.name.clone(),
interval,
last_execution: last_execution_string,
next_execution,
}
}
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,44 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,44 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-16 16:40:59 UTC|INFO|ImportListSyncService|No list items to process │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,44 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮
│Trigger Status Name Queued Started Duration │
│manual completed Refresh Monitored Downlo 4 minutes ago 4 minutes ago 00:03:03 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Name Interval Last Execution Next Execution │
│=> Backup 1 hour now 59 minutes │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ ╭────────────────────── Start Task ───────────────────────╮ │
│ │ Do you want to manually start this task: Backup? │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │╭────────────────────────────╮╭───────────────────────────╮│ │
│ ││ Yes ││ No ││ │
│ │╰────────────────────────────╯╰───────────────────────────╯│ │
│ ╰───────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Name Interval Last Execution Next Execution │
│=> Backup 1 hour now 59 minutes │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│The latest version of Sonarr is already installed │
│ │
│4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed) │
│--------------------------------------------------------------------------------------------------------------------------│
│New: │
│ * Cool new thing │
│Fixed: │
│ * Some bugs killed │
│ │
│ │
│3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed) │
│--------------------------------------------------------------------------------------------------------------------------│
│New: │
│ * Cool new thing (old) │
│ * Other cool new thing (old) │
│ │
│ │
│2.1.0 - 2023-04-15 02:02:53 UTC │
│--------------------------------------------------------------------------------------------------------------------------│
│Fixed: │
│ * Killed bug 1 │
│ * Fixed bug 2 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/lidarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │2025-12-16 16:40:59 UTC|INFO|ImportListSyncService|No list items to process │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰───────────────────│ │────────────────────╯
╭ Logs ───────────│ │────────────────────╮
│2025-12-16 16:40:59│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮ │
│ │Trigger Status Name Queued Started Duration │ │
│ │manual completed Refresh Monitored Downlo 4 minutes ago 4 minutes ago 00:03:03 │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰────────────────────────────────│ │────────────────────────────────╯
╭ Logs ────────────────────────│ │────────────────────────────────╮
│2025-12-16 16:40:59 UTC|INFO|Imp│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Name Interval Last Execution Next Execution │ │
│ │=> Backup 1 hour now 59 minutes │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ ╭────────────────────── Start Task ───────────────────────╮ │ │
│ │ │ Do you want to manually start this task: Backup? │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
╰───────────────────│ │ │ │────────────────────╯
╭ Logs ───────────│ │ │ │────────────────────╮
│2025-12-16 16:40:59│ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │╭────────────────────────────╮╭───────────────────────────╮│ │ │
│ │ ││ Yes ││ No ││ │ │
│ │ │╰────────────────────────────╯╰───────────────────────────╯│ │ │
│ │ ╰───────────────────────────────────────────────────────────╯ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Name Interval Last Execution Next Execution │ │
│ │=> Backup 1 hour now 59 minutes │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰───────────────────│ │────────────────────╯
╭ Logs ───────────│ │────────────────────╮
│2025-12-16 16:40:59│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │The latest version of Sonarr is already installed │ │
│ │ │ │
│ │4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed) │ │
│ │--------------------------------------------------------------------------------------------------------------------------│ │
│ │New: │ │
│ │ * Cool new thing │ │
│ │Fixed: │ │
│ │ * Some bugs killed │ │
│ │ │ │
│ │ │ │
│ │3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed) │ │
│ │--------------------------------------------------------------------------------------------------------------------------│ │
│ │New: │ │
│ │ * Cool new thing (old) │ │
│ │ * Other cool new thing (old) │ │
│ │ │ │
│ │ │ │
╰───────────────────│2.1.0 - 2023-04-15 02:02:53 UTC │────────────────────╯
╭ Logs ───────────│--------------------------------------------------------------------------------------------------------------------------│────────────────────╮
│2025-12-16 16:40:59│Fixed: │ │
│ │ * Killed bug 1 │ │
│ │ * Fixed bug 2 │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-16 16:40:59 UTC|INFO|ImportListSyncService|No list items to process │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/lidarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-16 16:40:59 UTC|INFO|ImportListSyncService|No list items to process │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,144 @@
use ratatui::Frame;
use ratatui::layout::Rect;
use ratatui::text::{Span, Text};
use ratatui::widgets::{Cell, ListItem, Paragraph, Row};
use crate::app::App;
use crate::models::Route;
use crate::models::lidarr_models::LidarrTask;
use crate::models::servarr_data::lidarr::lidarr_data::{ActiveLidarrBlock, SYSTEM_DETAILS_BLOCKS};
use crate::ui::lidarr_ui::system::{
TASK_TABLE_CONSTRAINTS, TASK_TABLE_HEADERS, draw_queued_events, extract_task_props,
};
use crate::ui::styles::ManagarrStyle;
use crate::ui::utils::{borderless_block, style_log_list_item, title_block};
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
use crate::ui::widgets::loading_block::LoadingBlock;
use crate::ui::widgets::managarr_table::ManagarrTable;
use crate::ui::widgets::popup::{Popup, Size};
use crate::ui::widgets::selectable_list::SelectableList;
use crate::ui::{DrawUi, draw_popup};
#[cfg(test)]
#[path = "system_details_ui_tests.rs"]
mod system_details_ui_tests;
pub(super) struct SystemDetailsUi;
impl DrawUi for SystemDetailsUi {
fn accepts(route: Route) -> bool {
let Route::Lidarr(active_lidarr_block, _) = route else {
return false;
};
SYSTEM_DETAILS_BLOCKS.contains(&active_lidarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
if let Route::Lidarr(active_lidarr_block, _) = app.get_current_route() {
match active_lidarr_block {
ActiveLidarrBlock::SystemLogs => {
draw_logs_popup(f, app);
}
ActiveLidarrBlock::SystemTasks | ActiveLidarrBlock::SystemTaskStartConfirmPrompt => {
draw_popup(f, app, draw_tasks_popup, Size::Large)
}
ActiveLidarrBlock::SystemQueuedEvents => {
draw_popup(f, app, draw_queued_events, Size::Medium)
}
ActiveLidarrBlock::SystemUpdates => {
draw_updates_popup(f, app);
}
_ => (),
}
}
}
}
fn draw_logs_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
let block = title_block("Log Details");
if app.data.lidarr_data.log_details.items.is_empty() {
let loading = LoadingBlock::new(app.is_loading, borderless_block());
let popup = Popup::new(loading).size(Size::Large).block(block).margin(1);
f.render_widget(popup, f.area());
return;
}
let logs_list = SelectableList::new(&mut app.data.lidarr_data.log_details, |log| {
let log_line = log.to_string();
let level = log.text.split('|').collect::<Vec<&str>>()[1].to_string();
style_log_list_item(ListItem::new(Text::from(Span::raw(log_line))), level)
})
.block(borderless_block());
let popup = Popup::new(logs_list)
.size(Size::Large)
.block(block)
.margin(1);
f.render_widget(popup, f.area());
}
fn draw_tasks_popup(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let tasks_row_mapping = |task: &LidarrTask| {
let task_props = extract_task_props(task);
Row::new(vec![
Cell::from(task_props.name),
Cell::from(task_props.interval),
Cell::from(task_props.last_execution),
Cell::from(task_props.next_execution),
])
.primary()
};
let tasks_table = ManagarrTable::new(Some(&mut app.data.lidarr_data.tasks), tasks_row_mapping)
.loading(app.is_loading)
.margin(1)
.headers(TASK_TABLE_HEADERS)
.constraints(TASK_TABLE_CONSTRAINTS);
f.render_widget(title_block("Tasks"), area);
f.render_widget(tasks_table, area);
if matches!(
app.get_current_route(),
Route::Lidarr(ActiveLidarrBlock::SystemTaskStartConfirmPrompt, _)
) {
let prompt = format!(
"Do you want to manually start this task: {}?",
app.data.lidarr_data.tasks.current_selection().name
);
let confirmation_prompt = ConfirmationPrompt::new()
.title("Start Task")
.prompt(&prompt)
.yes_no_value(app.data.lidarr_data.prompt_confirm);
f.render_widget(
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
f.area(),
);
}
}
fn draw_updates_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
let updates = app.data.lidarr_data.updates.get_text();
let block = title_block("Updates");
if !updates.is_empty() && !app.is_loading {
let updates_paragraph = Paragraph::new(Text::from(updates))
.block(borderless_block())
.scroll((app.data.lidarr_data.updates.offset, 0));
let popup = Popup::new(updates_paragraph)
.size(Size::Large)
.block(block)
.margin(1);
f.render_widget(popup, f.area());
} else {
let loading = LoadingBlock::new(app.is_loading, borderless_block());
let popup = Popup::new(loading).size(Size::Large).block(block).margin(1);
f.render_widget(popup, f.area());
}
}
@@ -0,0 +1,106 @@
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use crate::app::App;
use crate::models::servarr_data::lidarr::lidarr_data::{
ActiveLidarrBlock, SYSTEM_DETAILS_BLOCKS,
};
use crate::ui::DrawUi;
use crate::ui::lidarr_ui::system::system_details_ui::SystemDetailsUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
#[test]
fn test_system_details_ui_accepts() {
ActiveLidarrBlock::iter().for_each(|active_lidarr_block| {
if SYSTEM_DETAILS_BLOCKS.contains(&active_lidarr_block) {
assert!(SystemDetailsUi::accepts(active_lidarr_block.into()));
} else {
assert!(!SystemDetailsUi::accepts(active_lidarr_block.into()));
}
});
}
mod snapshot_tests {
use super::*;
use crate::models::ScrollableText;
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
#[rstest]
fn test_system_details_ui_popups(
#[values(
ActiveLidarrBlock::SystemLogs,
ActiveLidarrBlock::SystemQueuedEvents,
ActiveLidarrBlock::SystemTasks,
ActiveLidarrBlock::SystemTaskStartConfirmPrompt,
ActiveLidarrBlock::SystemUpdates
)]
active_lidarr_block: ActiveLidarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_lidarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(format!("popup_{active_lidarr_block}"), output);
}
#[rstest]
fn test_system_details_ui_loading(
#[values(
ActiveLidarrBlock::SystemLogs,
ActiveLidarrBlock::SystemQueuedEvents,
ActiveLidarrBlock::SystemTasks,
ActiveLidarrBlock::SystemUpdates
)]
active_lidarr_block: ActiveLidarrBlock,
) {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(active_lidarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(format!("loading_{active_lidarr_block}"), output);
}
#[test]
fn test_system_details_ui_updates_popup_loading_when_empty() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveLidarrBlock::SystemUpdates.into());
app.data.lidarr_data.updates = ScrollableText::with_string("".to_string());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[rstest]
fn test_system_details_ui_popups_empty(
#[values(
ActiveLidarrBlock::SystemLogs,
ActiveLidarrBlock::SystemQueuedEvents,
ActiveLidarrBlock::SystemTasks
)]
active_lidarr_block: ActiveLidarrBlock,
) {
let mut app = App::test_default();
app.push_navigation_stack(active_lidarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(format!("empty_{active_lidarr_block}"), output);
}
}
}
+123
View File
@@ -0,0 +1,123 @@
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use crate::app::App;
use crate::models::servarr_data::lidarr::lidarr_data::{
ActiveLidarrBlock, SYSTEM_DETAILS_BLOCKS,
};
use crate::ui::DrawUi;
use crate::ui::lidarr_ui::system::SystemUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
#[test]
fn test_system_ui_accepts() {
let mut system_ui_blocks = Vec::new();
system_ui_blocks.push(ActiveLidarrBlock::System);
system_ui_blocks.extend(SYSTEM_DETAILS_BLOCKS);
ActiveLidarrBlock::iter().for_each(|active_lidarr_block| {
if system_ui_blocks.contains(&active_lidarr_block) {
assert!(SystemUi::accepts(active_lidarr_block.into()));
} else {
assert!(!SystemUi::accepts(active_lidarr_block.into()));
}
});
}
mod snapshot_tests {
use crate::models::stateful_list::StatefulList;
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
use super::*;
#[test]
fn test_system_ui_renders_system_tab_loading() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveLidarrBlock::System.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_ui_renders_logs_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveLidarrBlock::System.into());
app.data.lidarr_data.logs = StatefulList::default();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_ui_renders_system_tab_task_and_events_loading() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveLidarrBlock::System.into());
app.is_loading = true;
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_ui_renders_system_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveLidarrBlock::System.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_ui_renders_system_tab_empty() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveLidarrBlock::System.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[rstest]
fn test_system_details_ui_renders_popups_over_system_ui(
#[values(
ActiveLidarrBlock::SystemLogs,
ActiveLidarrBlock::SystemQueuedEvents,
ActiveLidarrBlock::SystemTasks,
ActiveLidarrBlock::SystemTaskStartConfirmPrompt,
ActiveLidarrBlock::SystemUpdates
)]
active_lidarr_block: ActiveLidarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_lidarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(
format!("popups_over_system_ui_{active_lidarr_block}"),
output
);
}
}
}