diff --git a/frontend/src/components/torrent/table.rs b/frontend/src/components/torrent/table.rs index 6166c85..ebcde0e 100644 --- a/frontend/src/components/torrent/table.rs +++ b/frontend/src/components/torrent/table.rs @@ -24,6 +24,27 @@ fn format_speed(bytes_per_sec: i64) -> String { format!("{}/s", format_bytes(bytes_per_sec)) } +fn format_duration(seconds: i64) -> String { + if seconds <= 0 { + return "∞".to_string(); + } + + let days = seconds / 86400; + let hours = (seconds % 86400) / 3600; + let minutes = (seconds % 3600) / 60; + let secs = seconds % 60; + + if days > 0 { + format!("{}d {}h", days, hours) + } else if hours > 0 { + format!("{}h {}m", hours, minutes) + } else if minutes > 0 { + format!("{}m {}s", minutes, secs) + } else { + format!("{}s", secs) + } +} + fn format_date(timestamp: i64) -> String { if timestamp <= 0 { return "-".to_string(); @@ -325,82 +346,85 @@ pub fn TorrentTable() -> impl IntoView { -
- // Transparent overlay to close sort dropdown - -
-
+
+ // Transparent overlay to close sort dropdown + +
+
-
- "Torrents" +
+ "Torrents" -
-
- - - - "Sort" -
-
{move || filtered_torrents().into_iter().map(|t| { + > + {label} + + + {move || match current_dir() { + SortDirection::Ascending => "▲", + SortDirection::Descending => "▼", + }} + + + + + } + }).collect::>() + } + +
+
+ +
+ {move || filtered_torrents().into_iter().map(|t| { let progress_class = if t.percent_complete >= 100.0 { "progress-success" } else { "progress-primary" }; let status_str = format!("{:?}", t.status); let status_badge_class = match t.status {