Compare commits
10 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444ea4326d | ||
|
|
401ccb69b2 | ||
|
|
9cfea2aed5 | ||
|
|
ce212cb2d6 | ||
|
|
851d79029a | ||
|
|
ab27cf3eb4 | ||
|
|
7b4c9ff336 | ||
|
|
743596d701 | ||
|
|
598f038ea6 | ||
|
|
7f8c721115 |
83
backend/src/bin/test_trackers.rs
Normal file
83
backend/src/bin/test_trackers.rs
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
use shared::xmlrpc::{RtorrentClient, RpcParam, parse_multicall_response};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let mut client = None;
|
||||||
|
for path in ["127.0.0.1:8000", "0.0.0.0:8000", "localhost:8000"] {
|
||||||
|
let test_client = RtorrentClient::new(path);
|
||||||
|
match test_client.call("system.client_version", &[]).await {
|
||||||
|
Ok(res) => {
|
||||||
|
println!("SUCCESS: Connected to rTorrent at {} (Version: {})", path, res);
|
||||||
|
client = Some(test_client);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
// println!("Failed to connect to {}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let client = match client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
println!("Could not connect to rTorrent on port 8000.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut hash = String::new();
|
||||||
|
match client.call("d.multicall2", &[RpcParam::from(""), RpcParam::from("main"), RpcParam::from("d.hash=")]).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
if let Ok(rows) = parse_multicall_response(&xml) {
|
||||||
|
if let Some(row) = rows.first() {
|
||||||
|
if let Some(h) = row.first() {
|
||||||
|
hash = h.clone();
|
||||||
|
println!("Using torrent hash: {}", hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error getting torrents: {:?}", e);
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if hash.is_empty() {
|
||||||
|
println!("No torrents found to test trackers.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now test Tracker fields one by one to see which one is failing
|
||||||
|
let fields = vec![
|
||||||
|
"t.url=",
|
||||||
|
"t.is_enabled=",
|
||||||
|
"t.group=",
|
||||||
|
"t.scrape_complete=",
|
||||||
|
"t.scrape_incomplete=",
|
||||||
|
"t.scrape_downloaded=",
|
||||||
|
"t.activity_date_last=",
|
||||||
|
"t.normal_interval=",
|
||||||
|
"t.message=",
|
||||||
|
];
|
||||||
|
|
||||||
|
for field in &fields {
|
||||||
|
let params = vec![
|
||||||
|
RpcParam::from(hash.as_str()),
|
||||||
|
RpcParam::from(""),
|
||||||
|
RpcParam::from(*field),
|
||||||
|
];
|
||||||
|
|
||||||
|
print!("Testing field {:<22} : ", field);
|
||||||
|
match client.call("t.multicall", ¶ms).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
if xml.contains("faultCode") {
|
||||||
|
println!("FAILED");
|
||||||
|
} else {
|
||||||
|
println!("SUCCESS");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => println!("ERROR: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,6 +51,21 @@ mod fields {
|
|||||||
|
|
||||||
pub const IDX_LABEL: usize = 12;
|
pub const IDX_LABEL: usize = 12;
|
||||||
pub const CMD_LABEL: &str = "d.custom1=";
|
pub const CMD_LABEL: &str = "d.custom1=";
|
||||||
|
|
||||||
|
pub const IDX_RATIO: usize = 13;
|
||||||
|
pub const CMD_RATIO: &str = "d.ratio=";
|
||||||
|
|
||||||
|
pub const IDX_UPLOADED: usize = 14;
|
||||||
|
pub const CMD_UPLOADED: &str = "d.up.total=";
|
||||||
|
|
||||||
|
pub const IDX_WASTED: usize = 15;
|
||||||
|
pub const CMD_WASTED: &str = "d.skip.total=";
|
||||||
|
|
||||||
|
pub const IDX_SAVE_PATH: usize = 16;
|
||||||
|
pub const CMD_SAVE_PATH: &str = "d.base_path=";
|
||||||
|
|
||||||
|
pub const IDX_FREE_DISK: usize = 17;
|
||||||
|
pub const CMD_FREE_DISK: &str = "d.free_diskspace=";
|
||||||
}
|
}
|
||||||
|
|
||||||
use fields::*;
|
use fields::*;
|
||||||
@@ -72,6 +87,11 @@ const RTORRENT_FIELDS: &[&str] = &[
|
|||||||
CMD_CREATION_DATE,
|
CMD_CREATION_DATE,
|
||||||
CMD_HASHING,
|
CMD_HASHING,
|
||||||
CMD_LABEL,
|
CMD_LABEL,
|
||||||
|
CMD_RATIO,
|
||||||
|
CMD_UPLOADED,
|
||||||
|
CMD_WASTED,
|
||||||
|
CMD_SAVE_PATH,
|
||||||
|
CMD_FREE_DISK,
|
||||||
];
|
];
|
||||||
|
|
||||||
fn parse_long(s: Option<&String>) -> i64 {
|
fn parse_long(s: Option<&String>) -> i64 {
|
||||||
@@ -98,6 +118,11 @@ fn from_rtorrent_row(row: Vec<String>) -> Torrent {
|
|||||||
let added_date = parse_long(row.get(IDX_CREATION_DATE));
|
let added_date = parse_long(row.get(IDX_CREATION_DATE));
|
||||||
let is_hashing = parse_long(row.get(IDX_HASHING));
|
let is_hashing = parse_long(row.get(IDX_HASHING));
|
||||||
let label_raw = parse_string(row.get(IDX_LABEL));
|
let label_raw = parse_string(row.get(IDX_LABEL));
|
||||||
|
let ratio = parse_long(row.get(IDX_RATIO)) as f64 / 1000.0;
|
||||||
|
let uploaded = parse_long(row.get(IDX_UPLOADED));
|
||||||
|
let wasted = parse_long(row.get(IDX_WASTED));
|
||||||
|
let save_path = parse_string(row.get(IDX_SAVE_PATH));
|
||||||
|
let free_disk_space = parse_long(row.get(IDX_FREE_DISK));
|
||||||
|
|
||||||
let label = if label_raw.is_empty() {
|
let label = if label_raw.is_empty() {
|
||||||
None
|
None
|
||||||
@@ -144,6 +169,11 @@ fn from_rtorrent_row(row: Vec<String>) -> Torrent {
|
|||||||
error_message: message,
|
error_message: message,
|
||||||
added_date,
|
added_date,
|
||||||
label,
|
label,
|
||||||
|
ratio,
|
||||||
|
uploaded,
|
||||||
|
wasted,
|
||||||
|
save_path,
|
||||||
|
free_disk_space,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ pub fn TorrentDetailsSheet() -> impl IntoView {
|
|||||||
</SheetClose>
|
</SheetClose>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-1 overflow-hidden p-6">
|
<div class="flex-1 min-h-0 overflow-hidden p-6 flex flex-col">
|
||||||
<Tabs default_value="general" class="h-full flex flex-col">
|
<Tabs default_value="general" class="flex-1 min-h-0 flex flex-col">
|
||||||
<TabsList class="w-full justify-start rounded-none border-b bg-transparent p-0">
|
<TabsList class="w-full justify-start rounded-none border-b bg-transparent p-0">
|
||||||
<TabsTrigger value="general" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
<TabsTrigger value="general" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
||||||
"Genel"
|
"Genel"
|
||||||
@@ -68,7 +68,7 @@ pub fn TorrentDetailsSheet() -> impl IntoView {
|
|||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto mt-4 pb-12">
|
<div class="flex-1 min-h-0 overflow-y-auto mt-4 pb-12 pr-2">
|
||||||
<TabsContent value="general" class="space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300">
|
<TabsContent value="general" class="space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300">
|
||||||
<crate::components::ui::shimmer::Shimmer
|
<crate::components::ui::shimmer::Shimmer
|
||||||
loading=Signal::derive(move || selected_torrent.get().is_none())
|
loading=Signal::derive(move || selected_torrent.get().is_none())
|
||||||
@@ -89,16 +89,59 @@ pub fn TorrentDetailsSheet() -> impl IntoView {
|
|||||||
error_message: "".to_string(),
|
error_message: "".to_string(),
|
||||||
added_date: 0,
|
added_date: 0,
|
||||||
label: None,
|
label: None,
|
||||||
|
ratio: 0.0,
|
||||||
|
uploaded: 0,
|
||||||
|
wasted: 0,
|
||||||
|
save_path: "Yükleniyor...".to_string(),
|
||||||
|
free_disk_space: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<InfoItem label="İndirilen / Toplam" value=format!("{} / {}", format_bytes(t.completed), format_bytes(t.size)) />
|
// Aktarım
|
||||||
<InfoItem label="İndirme Hızı" value=format_speed(t.down_rate) class="text-blue-500" />
|
<div>
|
||||||
<InfoItem label="Gönderme Hızı" value=format_speed(t.up_rate) class="text-green-500" />
|
<h3 class="text-sm font-bold border-b pb-2 mb-4">"Aktarım"</h3>
|
||||||
<InfoItem label="Eklenme Tarihi" value=format_date(t.added_date) />
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
<InfoItem label="Kalan Süre" value=format_duration(t.eta) />
|
<InfoItem label="Geçen Süre" value="N/A".to_string() />
|
||||||
<InfoItem label="Hash" value=t.hash class="col-span-2 md:col-span-4 break-all font-mono text-xs" />
|
<InfoItem label="Kalan" value=format_duration(t.eta) />
|
||||||
|
<InfoItem label="Paylaşım Oranı" value=format!("{:.3}", t.ratio) />
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
|
|
||||||
|
<InfoItem label="İndirilen" value=format_bytes(t.completed) />
|
||||||
|
<InfoItem label="İndirme Hızı" value=format_speed(t.down_rate) class="text-blue-500" />
|
||||||
|
<InfoItem label="Boşa Giden" value=format_bytes(t.wasted) />
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
|
|
||||||
|
<InfoItem label="Gönderilen" value=format_bytes(t.uploaded) />
|
||||||
|
<InfoItem label="Gönderme Hızı" value=format_speed(t.up_rate) class="text-green-500" />
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
|
|
||||||
|
<InfoItem label="Ortaklar" value="0 / 0 bağlı".to_string() />
|
||||||
|
<InfoItem label="Eşler" value="0 / 0 bağlı".to_string() />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
// İzleyici
|
||||||
|
<div>
|
||||||
|
<h3 class="text-sm font-bold border-b pb-2 mb-4">"İzleyici"</h3>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<InfoItem label="İzleyici URL'si" value="İzleyiciler sekmesine bakınız".to_string() class="col-span-1 md:col-span-2 break-all text-xs" />
|
||||||
|
<InfoItem label="İzleyici Durumu" value="N/A".to_string() />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
// Genel
|
||||||
|
<div>
|
||||||
|
<h3 class="text-sm font-bold border-b pb-2 mb-4">"Genel"</h3>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<InfoItem label="Kaydedilen Yer" value=t.save_path class="col-span-1 md:col-span-2 break-all font-mono text-xs" />
|
||||||
|
<InfoItem label="Boş Disk Alanı" value=format_bytes(t.free_disk_space) />
|
||||||
|
<InfoItem label="Oluşturulma Tarihi" value=format_date(t.added_date) />
|
||||||
|
<InfoItem label="Hash" value=t.hash class="col-span-1 md:col-span-2 break-all font-mono text-xs" />
|
||||||
|
<InfoItem label="Yorum" value="Yok".to_string() class="col-span-1 md:col-span-2 break-words text-xs" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -108,7 +151,7 @@ pub fn TorrentDetailsSheet() -> impl IntoView {
|
|||||||
<TabsContent value="files" class="h-full">
|
<TabsContent value="files" class="h-full">
|
||||||
{move || match selected_torrent.get() {
|
{move || match selected_torrent.get() {
|
||||||
Some(t) => leptos::either::Either::Left(view! {
|
Some(t) => leptos::either::Either::Left(view! {
|
||||||
<div class="h-full overflow-y-auto pr-2 pb-8">
|
<div class="h-full">
|
||||||
<crate::components::torrent::files::TorrentFilesTab hash=t.hash />
|
<crate::components::torrent::files::TorrentFilesTab hash=t.hash />
|
||||||
</div>
|
</div>
|
||||||
}),
|
}),
|
||||||
@@ -122,10 +165,19 @@ pub fn TorrentDetailsSheet() -> impl IntoView {
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="trackers" class="h-full">
|
<TabsContent value="trackers" class="h-full">
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
{move || match selected_torrent.get() {
|
||||||
<icons::Settings2 class="size-12 mb-3 text-muted-foreground" />
|
Some(t) => leptos::either::Either::Left(view! {
|
||||||
<p class="text-sm font-medium">"İzleyici listesi yakında eklenecek"</p>
|
<div class="h-full">
|
||||||
</div>
|
<crate::components::torrent::trackers::TorrentTrackersTab hash=t.hash />
|
||||||
|
</div>
|
||||||
|
}),
|
||||||
|
None => leptos::either::Either::Right(view! {
|
||||||
|
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
||||||
|
<icons::Settings2 class="size-12 mb-3 text-muted-foreground" />
|
||||||
|
<p class="text-sm font-medium">"İzleyici yükleniyor..."</p>
|
||||||
|
</div>
|
||||||
|
}),
|
||||||
|
}}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="peers" class="h-full">
|
<TabsContent value="peers" class="h-full">
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|
|||||||
|h| async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
|
|h| async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Refresh action
|
// Callback to trigger a refetch — safe, doesn't destroy existing components
|
||||||
let refresh_files = Action::new(|h: &String| {
|
let on_refresh = Callback::new(move |_: ()| {
|
||||||
let h = h.clone();
|
files_resource.refetch();
|
||||||
async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let stored_hash = StoredValue::new(hash);
|
let stored_hash = StoredValue::new(hash);
|
||||||
@@ -26,10 +25,7 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|
|||||||
view! {
|
view! {
|
||||||
<Suspense fallback=move || view! { <FilesFallback /> }>
|
<Suspense fallback=move || view! { <FilesFallback /> }>
|
||||||
{move || {
|
{move || {
|
||||||
let files = match refresh_files.value().get() {
|
let files = files_resource.get().unwrap_or_default();
|
||||||
Some(f) => f,
|
|
||||||
None => files_resource.get().unwrap_or_default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if files.is_empty() {
|
if files.is_empty() {
|
||||||
return view! {
|
return view! {
|
||||||
@@ -61,12 +57,11 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|
|||||||
key=|f| f.index
|
key=|f| f.index
|
||||||
children={move |f| {
|
children={move |f| {
|
||||||
let p_hash = stored_hash.get_value();
|
let p_hash = stored_hash.get_value();
|
||||||
let r_files = refresh_files.clone();
|
|
||||||
view! {
|
view! {
|
||||||
<FileRow
|
<FileRow
|
||||||
file=f
|
file=f
|
||||||
hash=p_hash
|
hash=p_hash
|
||||||
refresh_action=r_files
|
on_refresh=on_refresh.clone()
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -86,11 +81,14 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<TorrentFile>>) -> impl IntoView {
|
fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl IntoView {
|
||||||
let f_idx = file.index;
|
let f_idx = file.index;
|
||||||
let path_clone = file.path.clone();
|
let path_clone = file.path.clone();
|
||||||
|
|
||||||
let set_priority = Action::new(|req: &(String, u32, u8)| {
|
// on_refresh is called AFTER the server responds, not before
|
||||||
|
let on_refresh_stored = StoredValue::new(on_refresh);
|
||||||
|
|
||||||
|
let set_priority = Action::new(move |req: &(String, u32, u8)| {
|
||||||
let (h, idx, p) = req.clone();
|
let (h, idx, p) = req.clone();
|
||||||
async move {
|
async move {
|
||||||
let res = shared::server_fns::torrent::set_file_priority(h, idx, p).await;
|
let res = shared::server_fns::torrent::set_file_priority(h, idx, p).await;
|
||||||
@@ -98,6 +96,8 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
|
|||||||
crate::store::show_toast(shared::NotificationLevel::Error, format!("Öncelik değiştirilemedi: {:?}", e));
|
crate::store::show_toast(shared::NotificationLevel::Error, format!("Öncelik değiştirilemedi: {:?}", e));
|
||||||
} else {
|
} else {
|
||||||
crate::store::show_toast(shared::NotificationLevel::Success, "Dosya önceliği güncellendi.".to_string());
|
crate::store::show_toast(shared::NotificationLevel::Success, "Dosya önceliği güncellendi.".to_string());
|
||||||
|
// Refetch AFTER the server has saved the priority
|
||||||
|
on_refresh_stored.get_value().run(());
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,6 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action<String, Vec<T
|
|||||||
<FileContextMenu
|
<FileContextMenu
|
||||||
torrent_hash=hash
|
torrent_hash=hash
|
||||||
file_index=f_idx
|
file_index=f_idx
|
||||||
refresh_action=refresh_action
|
|
||||||
set_priority=set_priority
|
set_priority=set_priority
|
||||||
>
|
>
|
||||||
<TableRow class="hover:bg-muted/50 transition-colors group">
|
<TableRow class="hover:bg-muted/50 transition-colors group">
|
||||||
@@ -141,7 +140,6 @@ fn FileContextMenu(
|
|||||||
children: Children,
|
children: Children,
|
||||||
torrent_hash: String,
|
torrent_hash: String,
|
||||||
file_index: u32,
|
file_index: u32,
|
||||||
refresh_action: Action<String, Vec<TorrentFile>>,
|
|
||||||
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
|
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let hash_c1 = torrent_hash.clone();
|
let hash_c1 = torrent_hash.clone();
|
||||||
@@ -159,11 +157,9 @@ fn FileContextMenu(
|
|||||||
<ContextMenuGroup>
|
<ContextMenuGroup>
|
||||||
<ContextMenuItem on:click={
|
<ContextMenuItem on:click={
|
||||||
let h = hash_c1;
|
let h = hash_c1;
|
||||||
let ra = refresh_action.clone();
|
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 2));
|
sp.dispatch((h.clone(), file_index, 2));
|
||||||
ra.dispatch(h.clone());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
@@ -173,11 +169,9 @@ fn FileContextMenu(
|
|||||||
|
|
||||||
<ContextMenuItem on:click={
|
<ContextMenuItem on:click={
|
||||||
let h = hash_c2;
|
let h = hash_c2;
|
||||||
let ra = refresh_action.clone();
|
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 1));
|
sp.dispatch((h.clone(), file_index, 1));
|
||||||
ra.dispatch(h.clone());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
@@ -187,11 +181,9 @@ fn FileContextMenu(
|
|||||||
|
|
||||||
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
|
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
|
||||||
let h = hash_c3;
|
let h = hash_c3;
|
||||||
let ra = refresh_action.clone();
|
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 0));
|
sp.dispatch((h.clone(), file_index, 0));
|
||||||
ra.dispatch(h.clone());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ pub mod table;
|
|||||||
pub mod add_torrent;
|
pub mod add_torrent;
|
||||||
pub mod details;
|
pub mod details;
|
||||||
pub mod files;
|
pub mod files;
|
||||||
|
pub mod trackers;
|
||||||
|
|||||||
121
frontend/src/components/torrent/trackers.rs
Normal file
121
frontend/src/components/torrent/trackers.rs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use crate::components::ui::table::*;
|
||||||
|
use crate::components::ui::shimmer::*;
|
||||||
|
use shared::TorrentTracker;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn TorrentTrackersTab(hash: String) -> impl IntoView {
|
||||||
|
let hash_clone = hash.clone();
|
||||||
|
|
||||||
|
let trackers_resource = Resource::new(
|
||||||
|
move || hash_clone.clone(),
|
||||||
|
|h| async move { shared::server_fns::torrent::get_trackers(h).await.unwrap_or_default() }
|
||||||
|
);
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<Suspense fallback=move || view! { <TrackersFallback /> }>
|
||||||
|
{move || {
|
||||||
|
let trackers = trackers_resource.get().unwrap_or_default();
|
||||||
|
|
||||||
|
if trackers.is_empty() {
|
||||||
|
return view! {
|
||||||
|
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
||||||
|
<icons::Settings2 class="size-12 mb-3 text-muted-foreground" />
|
||||||
|
<p class="text-sm font-medium">"Bu torrent için izleyici bulunamadı."</p>
|
||||||
|
</div>
|
||||||
|
}.into_any();
|
||||||
|
}
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div class="h-full overflow-auto">
|
||||||
|
<TableWrapper class="bg-card/50 whitespace-nowrap">
|
||||||
|
<Table>
|
||||||
|
<TableHeader class="sticky top-0 bg-muted/80 backdrop-blur-sm z-10">
|
||||||
|
<TableRow class="hover:bg-transparent text-xs">
|
||||||
|
<TableHead>"İsim"</TableHead>
|
||||||
|
<TableHead class="text-center">"Tür"</TableHead>
|
||||||
|
<TableHead class="text-center">"Etkin"</TableHead>
|
||||||
|
<TableHead class="text-center">"Grup"</TableHead>
|
||||||
|
<TableHead class="text-center">"Ortaklar"</TableHead>
|
||||||
|
<TableHead class="text-center">"Eşler"</TableHead>
|
||||||
|
<TableHead class="text-center">"İndirilen"</TableHead>
|
||||||
|
<TableHead class="text-center">"Son Güncelleme"</TableHead>
|
||||||
|
<TableHead class="text-center">"Sıklık"</TableHead>
|
||||||
|
<TableHead class="text-center">"Özel"</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<For
|
||||||
|
each=move || trackers.clone()
|
||||||
|
key=|t| t.url.clone()
|
||||||
|
children=move |t| {
|
||||||
|
let t_type = if t.url.starts_with("http") { "http" }
|
||||||
|
else if t.url.starts_with("udp") { "udp" }
|
||||||
|
else if t.url.starts_with("dht") { "dht" }
|
||||||
|
else { "diğer" };
|
||||||
|
let is_enabled = if t.is_enabled { "evet" } else { "hayır" };
|
||||||
|
|
||||||
|
// Format timestamp difference for last update
|
||||||
|
let now = chrono::Utc::now().timestamp();
|
||||||
|
let diff = now - t.last_updated;
|
||||||
|
let last_update_str = if t.last_updated == 0 {
|
||||||
|
"Güncellenmedi".to_string()
|
||||||
|
} else if diff >= 0 {
|
||||||
|
format_duration_short(diff)
|
||||||
|
} else {
|
||||||
|
"N/A".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let url_clone = t.url.clone();
|
||||||
|
view! {
|
||||||
|
<TableRow class="hover:bg-muted/50 transition-colors group text-xs text-muted-foreground">
|
||||||
|
<TableCell class="font-medium text-foreground max-w-[200px] md:max-w-md truncate" attr:title=url_clone>
|
||||||
|
{t.url.clone()}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell class="text-center">{t_type}</TableCell>
|
||||||
|
<TableCell class="text-center">{is_enabled}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.group}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.seeders}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.peers}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.downloaded}</TableCell>
|
||||||
|
<TableCell class="text-center">{last_update_str}</TableCell>
|
||||||
|
<TableCell class="text-center">{format_duration_short(t.interval)}</TableCell>
|
||||||
|
<TableCell class="text-center">"bilinmiyor"</TableCell> // Özel flag isn't cleanly via XMLRPC per tracker usually
|
||||||
|
</TableRow>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableWrapper>
|
||||||
|
</div>
|
||||||
|
}.into_any()
|
||||||
|
}}
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
fn TrackersFallback() -> impl IntoView {
|
||||||
|
view! {
|
||||||
|
<Shimmer loading=Signal::derive(|| true) class="space-y-2">
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
</Shimmer>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn format_duration_short(seconds: i64) -> String {
|
||||||
|
if seconds <= 0 { return "0sn".to_string(); }
|
||||||
|
let days = seconds / 86400;
|
||||||
|
let hours = (seconds % 86400) / 3600;
|
||||||
|
let minutes = (seconds % 3600) / 60;
|
||||||
|
let secs = seconds % 60;
|
||||||
|
|
||||||
|
if days > 0 { format!("{}g {}s", days, hours) }
|
||||||
|
else if hours > 0 { format!("{}s {}dk", hours, minutes) }
|
||||||
|
else if minutes > 0 { format!("{}dk {}sn", minutes, secs) }
|
||||||
|
else { format!("{}sn", secs) }
|
||||||
|
}
|
||||||
@@ -296,7 +296,7 @@ pub fn ContextMenuContent(
|
|||||||
}}
|
}}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// Right-click on trigger
|
// Right-click on trigger (desktop)
|
||||||
trigger.addEventListener('contextmenu', (e) => {{
|
trigger.addEventListener('contextmenu', (e) => {{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -307,6 +307,53 @@ pub fn ContextMenuContent(
|
|||||||
openMenu(e.clientX, e.clientY);
|
openMenu(e.clientX, e.clientY);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
// Long-press on trigger (mobile)
|
||||||
|
let touchTimer = null;
|
||||||
|
let touchStartX = 0;
|
||||||
|
let touchStartY = 0;
|
||||||
|
const LONG_PRESS_DURATION = 500;
|
||||||
|
const MOVE_THRESHOLD = 10;
|
||||||
|
|
||||||
|
trigger.addEventListener('touchstart', (e) => {{
|
||||||
|
const touch = e.touches[0];
|
||||||
|
touchStartX = touch.clientX;
|
||||||
|
touchStartY = touch.clientY;
|
||||||
|
|
||||||
|
touchTimer = setTimeout(() => {{
|
||||||
|
e.preventDefault();
|
||||||
|
if (isOpen) {{
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
openMenu(touchStartX, touchStartY);
|
||||||
|
}}, LONG_PRESS_DURATION);
|
||||||
|
}}, {{ passive: false }});
|
||||||
|
|
||||||
|
trigger.addEventListener('touchmove', (e) => {{
|
||||||
|
if (touchTimer) {{
|
||||||
|
const touch = e.touches[0];
|
||||||
|
const dx = Math.abs(touch.clientX - touchStartX);
|
||||||
|
const dy = Math.abs(touch.clientY - touchStartY);
|
||||||
|
if (dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD) {{
|
||||||
|
clearTimeout(touchTimer);
|
||||||
|
touchTimer = null;
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}});
|
||||||
|
|
||||||
|
trigger.addEventListener('touchend', () => {{
|
||||||
|
if (touchTimer) {{
|
||||||
|
clearTimeout(touchTimer);
|
||||||
|
touchTimer = null;
|
||||||
|
}}
|
||||||
|
}});
|
||||||
|
|
||||||
|
trigger.addEventListener('touchcancel', () => {{
|
||||||
|
if (touchTimer) {{
|
||||||
|
clearTimeout(touchTimer);
|
||||||
|
touchTimer = null;
|
||||||
|
}}
|
||||||
|
}});
|
||||||
|
|
||||||
// Close when action is clicked
|
// Close when action is clicked
|
||||||
const actions = menu.querySelectorAll('[data-context-close]');
|
const actions = menu.querySelectorAll('[data-context-close]');
|
||||||
actions.forEach(action => {{
|
actions.forEach(action => {{
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ pub struct Torrent {
|
|||||||
pub error_message: String,
|
pub error_message: String,
|
||||||
pub added_date: i64,
|
pub added_date: i64,
|
||||||
pub label: Option<String>,
|
pub label: Option<String>,
|
||||||
|
pub ratio: f64,
|
||||||
|
pub uploaded: i64,
|
||||||
|
pub wasted: i64,
|
||||||
|
pub save_path: String,
|
||||||
|
pub free_disk_space: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema)]
|
||||||
@@ -121,6 +126,13 @@ pub struct TorrentTracker {
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
pub is_enabled: bool,
|
||||||
|
pub group: i64,
|
||||||
|
pub seeders: i64,
|
||||||
|
pub peers: i64,
|
||||||
|
pub downloaded: i64,
|
||||||
|
pub last_updated: i64,
|
||||||
|
pub interval: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
|
||||||
|
|||||||
@@ -83,12 +83,19 @@ impl ScgiRequest {
|
|||||||
|
|
||||||
pub async fn send_request(socket_path: &str, request: ScgiRequest) -> Result<Bytes, ScgiError> {
|
pub async fn send_request(socket_path: &str, request: ScgiRequest) -> Result<Bytes, ScgiError> {
|
||||||
let perform_request = async {
|
let perform_request = async {
|
||||||
let mut stream = UnixStream::connect(socket_path).await?;
|
|
||||||
let data = request.encode();
|
let data = request.encode();
|
||||||
stream.write_all(&data).await?;
|
|
||||||
|
|
||||||
let mut response = Vec::new();
|
let mut response = Vec::new();
|
||||||
stream.read_to_end(&mut response).await?;
|
|
||||||
|
if socket_path.contains(':') {
|
||||||
|
let mut stream = tokio::net::TcpStream::connect(socket_path).await?;
|
||||||
|
stream.write_all(&data).await?;
|
||||||
|
stream.read_to_end(&mut response).await?;
|
||||||
|
} else {
|
||||||
|
let mut stream = tokio::net::UnixStream::connect(socket_path).await?;
|
||||||
|
stream.write_all(&data).await?;
|
||||||
|
stream.read_to_end(&mut response).await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok::<Vec<u8>, std::io::Error>(response)
|
Ok::<Vec<u8>, std::io::Error>(response)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -193,8 +193,12 @@ pub async fn get_trackers(hash: String) -> Result<Vec<TorrentTracker>, ServerFnE
|
|||||||
RpcParam::from(hash.as_str()),
|
RpcParam::from(hash.as_str()),
|
||||||
RpcParam::from(""),
|
RpcParam::from(""),
|
||||||
RpcParam::from("t.url="),
|
RpcParam::from("t.url="),
|
||||||
RpcParam::from("t.activity_date_last="),
|
RpcParam::from("t.is_enabled="),
|
||||||
RpcParam::from("t.message="),
|
RpcParam::from("t.group="),
|
||||||
|
RpcParam::from("t.scrape_complete="),
|
||||||
|
RpcParam::from("t.scrape_incomplete="),
|
||||||
|
RpcParam::from("t.scrape_downloaded="),
|
||||||
|
RpcParam::from("t.normal_interval="),
|
||||||
];
|
];
|
||||||
|
|
||||||
let xml = client
|
let xml = client
|
||||||
@@ -205,14 +209,23 @@ pub async fn get_trackers(hash: String) -> Result<Vec<TorrentTracker>, ServerFnE
|
|||||||
let rows = parse_multicall_response(&xml)
|
let rows = parse_multicall_response(&xml)
|
||||||
.map_err(|e| ServerFnError::new(format!("Parse error: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("Parse error: {}", e)))?;
|
||||||
|
|
||||||
Ok(rows
|
let result: Vec<TorrentTracker> = rows
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|row| TorrentTracker {
|
.map(|row| TorrentTracker {
|
||||||
url: row.get(0).cloned().unwrap_or_default(),
|
url: row.get(0).cloned().unwrap_or_default(),
|
||||||
status: "Unknown".to_string(),
|
is_enabled: row.get(1).and_then(|s| s.parse::<i64>().ok()).unwrap_or(0) != 0,
|
||||||
message: row.get(2).cloned().unwrap_or_default(),
|
group: row.get(2).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
seeders: row.get(3).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
peers: row.get(4).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
downloaded: row.get(5).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
interval: row.get(6).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
last_updated: 0,
|
||||||
|
status: "Unknown".to_string(), // Can derive from activity later, or keep unknown
|
||||||
|
message: "".to_string(),
|
||||||
})
|
})
|
||||||
.collect())
|
.collect();
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[server(SetFilePriority, "/api/server_fns")]
|
#[server(SetFilePriority, "/api/server_fns")]
|
||||||
@@ -225,6 +238,7 @@ pub async fn set_file_priority(
|
|||||||
let ctx = expect_context::<crate::ServerContext>();
|
let ctx = expect_context::<crate::ServerContext>();
|
||||||
let client = RtorrentClient::new(&ctx.scgi_socket_path);
|
let client = RtorrentClient::new(&ctx.scgi_socket_path);
|
||||||
|
|
||||||
|
// rTorrent f.set_priority takes: target = "HASH:fINDEX", value = priority
|
||||||
let target = format!("{}:f{}", hash, file_index);
|
let target = format!("{}:f{}", hash, file_index);
|
||||||
let params = vec![
|
let params = vec![
|
||||||
RpcParam::from(target.as_str()),
|
RpcParam::from(target.as_str()),
|
||||||
@@ -232,10 +246,11 @@ pub async fn set_file_priority(
|
|||||||
];
|
];
|
||||||
|
|
||||||
client
|
client
|
||||||
.call("f.set_priority", ¶ms)
|
.call("f.priority.set", ¶ms)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| ServerFnError::new(format!("RPC error: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?;
|
||||||
|
|
||||||
|
// Notify rTorrent to update its internal priority state
|
||||||
let _ = client
|
let _ = client
|
||||||
.call("d.update_priorities", &[RpcParam::from(hash.as_str())])
|
.call("d.update_priorities", &[RpcParam::from(hash.as_str())])
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
26
test_rpc.rs
Normal file
26
test_rpc.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use shared::xmlrpc::{RtorrentClient, RpcParam, parse_multicall_response};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let client = RtorrentClient::new("/tmp/rtorrent.sock");
|
||||||
|
|
||||||
|
// Hardcode a known hash from the UI, e.g. "C3315ABFAD70C54505813D1303C1457900C5B795" (from first image)
|
||||||
|
let hash = "C3315ABFAD70C54505813D1303C1457900C5B795";
|
||||||
|
|
||||||
|
let params = vec![
|
||||||
|
RpcParam::from(hash),
|
||||||
|
RpcParam::from(""),
|
||||||
|
RpcParam::from("t.url="),
|
||||||
|
];
|
||||||
|
|
||||||
|
match client.call("t.multicall", ¶ms).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
println!("Response XML:\n{}", xml);
|
||||||
|
match parse_multicall_response(&xml) {
|
||||||
|
Ok(rows) => println!("Rows ({})", rows.len()),
|
||||||
|
Err(e) => println!("Parse error: {:?}", e),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => println!("Error: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user