Compare commits
1 Commits
main
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2f856f80f |
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -320,11 +320,9 @@ dependencies = [
|
|||||||
"dotenvy",
|
"dotenvy",
|
||||||
"futures",
|
"futures",
|
||||||
"governor",
|
"governor",
|
||||||
"icons",
|
|
||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"leptos",
|
"leptos",
|
||||||
"leptos_axum",
|
"leptos_axum",
|
||||||
"leptos_ui",
|
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"openssl",
|
"openssl",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
@@ -345,7 +343,6 @@ dependencies = [
|
|||||||
"tower_governor",
|
"tower_governor",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"tw_merge",
|
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"utoipa-swagger-ui",
|
"utoipa-swagger-ui",
|
||||||
"web-push",
|
"web-push",
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
members = ["backend", "frontend", "shared"]
|
members = ["backend", "frontend", "shared"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[[workspace.metadata.leptos]]
|
|
||||||
tailwind-input-file = "frontend/input.css"
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
# En küçük binary boyutu
|
# En küçük binary boyutu
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
|
|||||||
@@ -47,6 +47,3 @@ governor = "0.10.4"
|
|||||||
leptos = { version = "0.8.15", features = ["nightly"] }
|
leptos = { version = "0.8.15", features = ["nightly"] }
|
||||||
leptos_axum = { version = "0.8.7" }
|
leptos_axum = { version = "0.8.7" }
|
||||||
jsonwebtoken = "9"
|
jsonwebtoken = "9"
|
||||||
tw_merge = { version = "0.1.17", features = ["variant"] }
|
|
||||||
icons = { version = "0.18.0", features = ["leptos"] }
|
|
||||||
leptos_ui = "0.3.20"
|
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -243,14 +243,12 @@ async fn main() {
|
|||||||
let socket_path = std::path::Path::new(&args.socket);
|
let socket_path = std::path::Path::new(&args.socket);
|
||||||
if !socket_path.exists() {
|
if !socket_path.exists() {
|
||||||
tracing::error!("CRITICAL: rTorrent socket not found at {:?}.", socket_path);
|
tracing::error!("CRITICAL: rTorrent socket not found at {:?}.", socket_path);
|
||||||
tracing::error!(
|
tracing::warn!(
|
||||||
"HINT: Make sure rTorrent is running and the SCGI socket is enabled in .rtorrent.rc"
|
"HINT: Make sure rTorrent is running and the SCGI socket is enabled in .rtorrent.rc"
|
||||||
);
|
);
|
||||||
tracing::error!(
|
tracing::warn!(
|
||||||
"HINT: You can configure the socket path via --socket ARG or RTORRENT_SOCKET ENV."
|
"HINT: You can configure the socket path via --socket ARG or RTORRENT_SOCKET ENV."
|
||||||
);
|
);
|
||||||
tracing::error!("FATAL: VibeTorrent cannot start without a running rTorrent instance. Exiting.");
|
|
||||||
std::process::exit(1);
|
|
||||||
} else {
|
} else {
|
||||||
tracing::info!("Socket file exists. Testing connection...");
|
tracing::info!("Socket file exists. Testing connection...");
|
||||||
let client = xmlrpc::RtorrentClient::new(&args.socket);
|
let client = xmlrpc::RtorrentClient::new(&args.socket);
|
||||||
@@ -261,11 +259,7 @@ async fn main() {
|
|||||||
let version = xmlrpc::parse_string_response(&xml).unwrap_or(xml);
|
let version = xmlrpc::parse_string_response(&xml).unwrap_or(xml);
|
||||||
tracing::info!("Connected to rTorrent successfully. Version: {}", version);
|
tracing::info!("Connected to rTorrent successfully. Version: {}", version);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => tracing::error!("Socket exists but failed to connect to rTorrent: {}", e),
|
||||||
tracing::error!("CRITICAL: Socket exists but failed to connect to rTorrent: {}", e);
|
|
||||||
tracing::error!("FATAL: Ensure rTorrent is fully started and the socket has correct permissions. Exiting.");
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,21 +51,6 @@ 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::*;
|
||||||
@@ -87,11 +72,6 @@ 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 {
|
||||||
@@ -118,11 +98,6 @@ 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
|
||||||
@@ -169,11 +144,6 @@ 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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ stage = "build"
|
|||||||
command = "sh"
|
command = "sh"
|
||||||
command_arguments = ["-c", "npx @tailwindcss/cli -i input.css -o public/tailwind.css"]
|
command_arguments = ["-c", "npx @tailwindcss/cli -i input.css -o public/tailwind.css"]
|
||||||
|
|
||||||
[[hooks]]
|
|
||||||
stage = "post_build"
|
|
||||||
command = "sh"
|
|
||||||
command_arguments = ["-c", "sed -i '' -e 's/<link rel=\"modulepreload\"[^>]*>//g' -e 's/<link rel=\"preload\"[^>]*>//g' \"$TRUNK_STAGING_DIR/index.html\" || sed -i -e 's/<link rel=\"modulepreload\"[^>]*>//g' -e 's/<link rel=\"preload\"[^>]*>//g' \"$TRUNK_STAGING_DIR/index.html\""]
|
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "index.html"
|
target = "index.html"
|
||||||
dist = "dist"
|
dist = "dist"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
|
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
|
||||||
|
|
||||||
<!-- Trunk Assets -->
|
<!-- Trunk Assets -->
|
||||||
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="0" />
|
<script data-trunk rel="rust" src="Cargo.toml" data-wasm-opt="0" data-preload="false"></script>
|
||||||
<link data-trunk rel="css" href="public/tailwind.css" />
|
<link data-trunk rel="css" href="public/tailwind.css" />
|
||||||
<link data-trunk rel="copy-file" href="manifest.json" />
|
<link data-trunk rel="copy-file" href="manifest.json" />
|
||||||
<link data-trunk rel="copy-file" href="icon-192.png" />
|
<link data-trunk rel="copy-file" href="icon-192.png" />
|
||||||
|
|||||||
@@ -3,76 +3,70 @@
|
|||||||
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.625rem;
|
--background: 0 0% 100%;
|
||||||
--background: oklch(1 0 0);
|
--foreground: 240 10% 3.9%;
|
||||||
--foreground: oklch(0.145 0 0);
|
--card: 0 0% 100%;
|
||||||
--card: oklch(1 0 0);
|
--card-foreground: 240 10% 3.9%;
|
||||||
--card-foreground: oklch(0.145 0 0);
|
--popover: 0 0% 100%;
|
||||||
--popover: oklch(1 0 0);
|
--popover-foreground: 240 10% 3.9%;
|
||||||
--popover-foreground: oklch(0.145 0 0);
|
--primary: 240 5.9% 10%;
|
||||||
--primary: oklch(0.205 0 0);
|
--primary-foreground: 0 0% 98%;
|
||||||
--primary-foreground: oklch(0.985 0 0);
|
--secondary: 240 4.8% 95.9%;
|
||||||
--secondary: oklch(0.97 0 0);
|
--secondary-foreground: 240 5.9% 10%;
|
||||||
--secondary-foreground: oklch(0.205 0 0);
|
--muted: 240 4.8% 95.9%;
|
||||||
--muted: oklch(0.97 0 0);
|
--muted-foreground: 240 3.8% 46.1%;
|
||||||
--muted-foreground: oklch(0.556 0 0);
|
--accent: 240 4.8% 95.9%;
|
||||||
--accent: oklch(0.97 0 0);
|
--accent-foreground: 240 5.9% 10%;
|
||||||
--accent-foreground: oklch(0.205 0 0);
|
--destructive: 0 84.2% 60.2%;
|
||||||
--destructive: oklch(0.577 0.245 27.325);
|
--destructive-foreground: 0 0% 98%;
|
||||||
--border: oklch(0.922 0 0);
|
--border: 240 5.9% 90%;
|
||||||
--input: oklch(0.922 0 0);
|
--input: 240 5.9% 90%;
|
||||||
--ring: oklch(0.708 0 0);
|
--ring: 240 5.9% 10%;
|
||||||
|
--radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
--background: oklch(0.145 0 0);
|
--background: 240 10% 3.9%;
|
||||||
--foreground: oklch(0.985 0 0);
|
--foreground: 0 0% 98%;
|
||||||
--card: oklch(0.205 0 0);
|
--card: 240 10% 3.9%;
|
||||||
--card-foreground: oklch(0.985 0 0);
|
--card-foreground: 0 0% 98%;
|
||||||
--popover: oklch(0.205 0 0);
|
--popover: 240 10% 3.9%;
|
||||||
--popover-foreground: oklch(0.985 0 0);
|
--popover-foreground: 0 0% 98%;
|
||||||
--primary: oklch(0.922 0 0);
|
--primary: 0 0% 98%;
|
||||||
--primary-foreground: oklch(0.205 0 0);
|
--primary-foreground: 240 5.9% 10%;
|
||||||
--secondary: oklch(0.269 0 0);
|
--secondary: 240 3.7% 15.9%;
|
||||||
--secondary-foreground: oklch(0.985 0 0);
|
--secondary-foreground: 0 0% 98%;
|
||||||
--muted: oklch(0.269 0 0);
|
--muted: 240 3.7% 15.9%;
|
||||||
--muted-foreground: oklch(0.708 0 0);
|
--muted-foreground: 240 5% 64.9%;
|
||||||
--accent: oklch(0.269 0 0);
|
--accent: 240 3.7% 15.9%;
|
||||||
--accent-foreground: oklch(0.985 0 0);
|
--accent-foreground: 0 0% 98%;
|
||||||
--destructive: oklch(0.704 0.191 22.216);
|
--destructive: 0 62.8% 30.6%;
|
||||||
--border: oklch(1 0 0 / 10%);
|
--destructive-foreground: 0 0% 98%;
|
||||||
--input: oklch(1 0 0 / 15%);
|
--border: 240 3.7% 15.9%;
|
||||||
--ring: oklch(0.556 0 0);
|
--input: 240 3.7% 15.9%;
|
||||||
|
--ring: 240 4.9% 83.9%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--animate-shimmer: shimmer 2s infinite;
|
--color-background: hsl(var(--background));
|
||||||
|
--color-foreground: hsl(var(--foreground));
|
||||||
@keyframes shimmer {
|
--color-card: hsl(var(--card));
|
||||||
100% {
|
--color-card-foreground: hsl(var(--card-foreground));
|
||||||
transform: translateX(100%);
|
--color-popover: hsl(var(--popover));
|
||||||
}
|
--color-popover-foreground: hsl(var(--popover-foreground));
|
||||||
}
|
--color-primary: hsl(var(--primary));
|
||||||
|
--color-primary-foreground: hsl(var(--primary-foreground));
|
||||||
--color-background: var(--background);
|
--color-secondary: hsl(var(--secondary));
|
||||||
--color-foreground: var(--foreground);
|
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
||||||
--color-card: var(--card);
|
--color-muted: hsl(var(--muted));
|
||||||
--color-card-foreground: var(--card-foreground);
|
--color-muted-foreground: hsl(var(--muted-foreground));
|
||||||
--color-popover: var(--popover);
|
--color-accent: hsl(var(--accent));
|
||||||
--color-popover-foreground: var(--popover-foreground);
|
--color-accent-foreground: hsl(var(--accent-foreground));
|
||||||
--color-primary: var(--primary);
|
--color-destructive: hsl(var(--destructive));
|
||||||
--color-primary-foreground: var(--primary-foreground);
|
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
||||||
--color-secondary: var(--secondary);
|
--color-border: hsl(var(--border));
|
||||||
--color-secondary-foreground: var(--secondary-foreground);
|
--color-input: hsl(var(--input));
|
||||||
--color-muted: var(--muted);
|
--color-ring: hsl(var(--ring));
|
||||||
--color-muted-foreground: var(--muted-foreground);
|
|
||||||
--color-accent: var(--accent);
|
|
||||||
--color-accent-foreground: var(--accent-foreground);
|
|
||||||
--color-destructive: var(--destructive);
|
|
||||||
--color-destructive-foreground: var(--destructive-foreground);
|
|
||||||
--color-border: var(--border);
|
|
||||||
--color-input: var(--input);
|
|
||||||
--color-ring: var(--ring);
|
|
||||||
--radius-sm: calc(var(--radius) - 4px);
|
--radius-sm: calc(var(--radius) - 4px);
|
||||||
--radius-md: calc(var(--radius) - 2px);
|
--radius-md: calc(var(--radius) - 2px);
|
||||||
--radius-lg: var(--radius);
|
--radius-lg: var(--radius);
|
||||||
@@ -83,7 +77,6 @@
|
|||||||
* {
|
* {
|
||||||
@apply border-border outline-ring/50;
|
@apply border-border outline-ring/50;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -49,10 +49,14 @@ fn InnerApp() -> impl IntoView {
|
|||||||
|
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
|
log::info!("App initialization started...");
|
||||||
|
gloo_console::log!("APP INIT: Checking setup status...");
|
||||||
|
|
||||||
// Check if setup is needed via Server Function
|
// Check if setup is needed via Server Function
|
||||||
match shared::server_fns::auth::get_setup_status().await {
|
match shared::server_fns::auth::get_setup_status().await {
|
||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
if !status.completed {
|
if !status.completed {
|
||||||
|
log::info!("Setup not completed");
|
||||||
needs_setup.1.set(true);
|
needs_setup.1.set(true);
|
||||||
is_loading.1.set(false);
|
is_loading.1.set(false);
|
||||||
return;
|
return;
|
||||||
@@ -64,12 +68,15 @@ fn InnerApp() -> impl IntoView {
|
|||||||
// Check authentication via GetUser Server Function
|
// Check authentication via GetUser Server Function
|
||||||
match shared::server_fns::auth::get_user().await {
|
match shared::server_fns::auth::get_user().await {
|
||||||
Ok(Some(user_info)) => {
|
Ok(Some(user_info)) => {
|
||||||
|
log::info!("Authenticated as {}", user_info.username);
|
||||||
if let Some(s) = store {
|
if let Some(s) = store {
|
||||||
s.user.set(Some(user_info.username));
|
s.user.set(Some(user_info.username));
|
||||||
}
|
}
|
||||||
is_authenticated.1.set(true);
|
is_authenticated.1.set(true);
|
||||||
}
|
}
|
||||||
Ok(None) => {}
|
Ok(None) => {
|
||||||
|
log::info!("Not authenticated");
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Auth check failed: {:?}", e);
|
log::error!("Auth check failed: {:?}", e);
|
||||||
}
|
}
|
||||||
@@ -104,6 +111,7 @@ fn InnerApp() -> impl IntoView {
|
|||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/setup", Default::default());
|
navigate("/setup", Default::default());
|
||||||
} else if authenticated {
|
} else if authenticated {
|
||||||
|
log::info!("Already authenticated, redirecting to home");
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/", Default::default());
|
navigate("/", Default::default());
|
||||||
}
|
}
|
||||||
@@ -127,8 +135,10 @@ fn InnerApp() -> impl IntoView {
|
|||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if !is_loading.0.get() {
|
if !is_loading.0.get() {
|
||||||
if needs_setup.0.get() {
|
if needs_setup.0.get() {
|
||||||
|
log::info!("Setup not completed, redirecting to setup");
|
||||||
navigate("/setup", Default::default());
|
navigate("/setup", Default::default());
|
||||||
} else if !is_authenticated.0.get() {
|
} else if !is_authenticated.0.get() {
|
||||||
|
log::info!("Not authenticated, redirecting to login");
|
||||||
navigate("/login", Default::default());
|
navigate("/login", Default::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,34 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
||||||
use crate::components::ui::input::{Input, InputType};
|
use crate::components::ui::auto_form::{AutoForm, AutoFormField};
|
||||||
|
|
||||||
use crate::components::ui::button::Button;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Login() -> impl IntoView {
|
pub fn Login() -> impl IntoView {
|
||||||
let username = RwSignal::new(String::new());
|
|
||||||
let password = RwSignal::new(String::new());
|
|
||||||
let error = signal(Option::<String>::None);
|
let error = signal(Option::<String>::None);
|
||||||
let loading = signal(false);
|
let loading = signal(false);
|
||||||
|
|
||||||
let handle_login = move |ev: web_sys::SubmitEvent| {
|
let fields = vec![
|
||||||
ev.prevent_default();
|
AutoFormField::Text {
|
||||||
|
name: "username".to_string(),
|
||||||
|
label: "Kullanıcı Adı".to_string(),
|
||||||
|
placeholder: Some("Kullanıcı adınız".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "password".to_string(),
|
||||||
|
label: "Şifre".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let on_submit = move |data: std::collections::HashMap<String, String>| {
|
||||||
loading.1.set(true);
|
loading.1.set(true);
|
||||||
error.1.set(None);
|
error.1.set(None);
|
||||||
|
|
||||||
let user = username.get();
|
let user = data.get("username").cloned().unwrap_or_default();
|
||||||
let pass = password.get();
|
let pass = data.get("password").cloned().unwrap_or_default();
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match shared::server_fns::auth::login(user, pass).await {
|
match shared::server_fns::auth::login(user, pass).await {
|
||||||
@@ -49,45 +59,18 @@ pub fn Login() -> impl IntoView {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent class="pt-4">
|
<CardContent class="pt-4">
|
||||||
<form on:submit=handle_login class="space-y-4">
|
<AutoForm
|
||||||
<div class="space-y-2">
|
fields=fields
|
||||||
<label class="text-sm font-medium leading-none">"Kullanıcı Adı"</label>
|
submit_label="Giriş Yap"
|
||||||
<Input
|
on_submit=on_submit
|
||||||
r#type=InputType::Text
|
loading=loading.0.into()
|
||||||
placeholder="Kullanıcı adınız"
|
/>
|
||||||
bind_value=username
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when=move || error.0.get().is_some()>
|
<Show when=move || error.0.get().is_some()>
|
||||||
<div class="rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
<div class="mt-4 rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
||||||
{move || error.0.get().unwrap_or_default()}
|
{move || error.0.get().unwrap_or_default()}
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<div class="pt-2">
|
|
||||||
<Button
|
|
||||||
class="w-full"
|
|
||||||
attr:r#type="submit"
|
|
||||||
attr:disabled=move || loading.0.get()
|
|
||||||
>
|
|
||||||
<Show when=move || loading.0.get() fallback=|| view! { "Giriş Yap" }.into_any()>
|
|
||||||
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
|
||||||
"Giriş Yapılıyor..."
|
|
||||||
</Show>
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Show>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,38 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
||||||
use crate::components::ui::input::{Input, InputType};
|
use crate::components::ui::auto_form::{AutoForm, AutoFormField};
|
||||||
|
|
||||||
use crate::components::ui::button::Button;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Setup() -> impl IntoView {
|
pub fn Setup() -> impl IntoView {
|
||||||
let username = RwSignal::new(String::new());
|
|
||||||
let password = RwSignal::new(String::new());
|
|
||||||
let confirm_password = RwSignal::new(String::new());
|
|
||||||
let error = signal(Option::<String>::None);
|
let error = signal(Option::<String>::None);
|
||||||
let loading = signal(false);
|
let loading = signal(false);
|
||||||
|
|
||||||
let handle_setup = move |ev: web_sys::SubmitEvent| {
|
let fields = vec![
|
||||||
ev.prevent_default();
|
AutoFormField::Text {
|
||||||
|
name: "username".to_string(),
|
||||||
|
label: "Yönetici Kullanıcı Adı".to_string(),
|
||||||
|
placeholder: Some("admin".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "password".to_string(),
|
||||||
|
label: "Şifre".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "confirm_password".to_string(),
|
||||||
|
label: "Şifre Onay".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
let pass = password.get();
|
let on_submit = move |data: std::collections::HashMap<String, String>| {
|
||||||
let confirm = confirm_password.get();
|
let user = data.get("username").cloned().unwrap_or_default();
|
||||||
|
let pass = data.get("password").cloned().unwrap_or_default();
|
||||||
|
let confirm = data.get("confirm_password").cloned().unwrap_or_default();
|
||||||
|
|
||||||
if pass != confirm {
|
if pass != confirm {
|
||||||
error.1.set(Some("Şifreler eşleşmiyor".to_string()));
|
error.1.set(Some("Şifreler eşleşmiyor".to_string()));
|
||||||
@@ -32,8 +47,6 @@ pub fn Setup() -> impl IntoView {
|
|||||||
loading.1.set(true);
|
loading.1.set(true);
|
||||||
error.1.set(None);
|
error.1.set(None);
|
||||||
|
|
||||||
let user = username.get();
|
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match shared::server_fns::auth::setup(user, pass).await {
|
match shared::server_fns::auth::setup(user, pass).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -64,54 +77,18 @@ pub fn Setup() -> impl IntoView {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent class="pt-4">
|
<CardContent class="pt-4">
|
||||||
<form on:submit=handle_setup class="space-y-4">
|
<AutoForm
|
||||||
<div class="space-y-2">
|
fields=fields
|
||||||
<label class="text-sm font-medium leading-none">"Yönetici Kullanıcı Adı"</label>
|
submit_label="Kurulumu Tamamla"
|
||||||
<Input
|
on_submit=on_submit
|
||||||
r#type=InputType::Text
|
loading=loading.0.into()
|
||||||
placeholder="admin"
|
/>
|
||||||
bind_value=username
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre Onay"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=confirm_password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when=move || error.0.get().is_some() fallback=|| ()>
|
<Show when=move || error.0.get().is_some() fallback=|| ()>
|
||||||
<div class="rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
<div class="mt-4 rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
||||||
<span>{move || error.0.get().unwrap_or_default()}</span>
|
<span>{move || error.0.get().unwrap_or_default()}</span>
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<div class="pt-2">
|
|
||||||
<Button
|
|
||||||
class="w-full"
|
|
||||||
attr:r#type="submit"
|
|
||||||
attr:disabled=move || loading.0.get()
|
|
||||||
>
|
|
||||||
<Show when=move || loading.0.get() fallback=|| view! { "Kurulumu Tamamla" }.into_any()>
|
|
||||||
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
|
||||||
"Kuruluyor..."
|
|
||||||
</Show>
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Show>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,16 +24,10 @@ pub fn TorrentContextMenu(
|
|||||||
{children()}
|
{children()}
|
||||||
</ContextMenuTrigger>
|
</ContextMenuTrigger>
|
||||||
<ContextMenuContent class="w-56 p-1.5">
|
<ContextMenuContent class="w-56 p-1.5">
|
||||||
<ContextMenuItem on:click={let h = hash_c1; move |_| {
|
<ContextMenuItem on:click={let h = hash_c1; move |_| on_action_stored.get_value().run(("start".to_string(), h.clone()))}>
|
||||||
on_action_stored.get_value().run(("start".to_string(), h.clone()));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}}>
|
|
||||||
"Başlat"
|
"Başlat"
|
||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
<ContextMenuItem on:click={let h = hash_c2; move |_| {
|
<ContextMenuItem on:click={let h = hash_c2; move |_| on_action_stored.get_value().run(("stop".to_string(), h.clone()))}>
|
||||||
on_action_stored.get_value().run(("stop".to_string(), h.clone()));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}}>
|
|
||||||
"Durdur"
|
"Durdur"
|
||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
|
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use leptos::task::spawn_local;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::components::ui::button::{Button, ButtonVariant};
|
|
||||||
use crate::components::ui::card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle};
|
|
||||||
use crate::components::ui::shimmer::Shimmer;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct CardData {
|
|
||||||
pub title: String,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Simulates a database fetch with 1 second delay
|
|
||||||
#[server]
|
|
||||||
pub async fn fetch_card_data() -> Result<CardData, ServerFnError> {
|
|
||||||
// Simulate network/database latency (only on server)
|
|
||||||
#[cfg(feature = "ssr")]
|
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
|
||||||
|
|
||||||
Ok(CardData {
|
|
||||||
title: "Fetched Title".to_string(),
|
|
||||||
description: "This content was fetched from the server after a 1 second simulated delay. The shimmer effect automatically showed during the loading period.".to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn DemoShimmer() -> impl IntoView {
|
|
||||||
// Loading state
|
|
||||||
let loading = RwSignal::new(false);
|
|
||||||
|
|
||||||
// Store fetched data
|
|
||||||
let card_data = RwSignal::new(None::<CardData>);
|
|
||||||
|
|
||||||
// Fetch handler using spawn_local for reliable repeated calls
|
|
||||||
let on_fetch = move |_| {
|
|
||||||
spawn_local(async move {
|
|
||||||
loading.set(true);
|
|
||||||
let result = fetch_card_data().await;
|
|
||||||
if let Ok(data) = result {
|
|
||||||
card_data.set(Some(data));
|
|
||||||
}
|
|
||||||
loading.set(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<Button variant=ButtonVariant::Outline on:click=move |_| loading.set(!loading.get())>
|
|
||||||
"Toggle Loading"
|
|
||||||
</Button>
|
|
||||||
<Button variant=ButtonVariant::Default on:click=on_fetch>
|
|
||||||
"Fetch Data (1s)"
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Shimmer loading=Signal::from(loading)>
|
|
||||||
<Card class="max-w-lg lg:max-w-2xl">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>
|
|
||||||
{move || {
|
|
||||||
card_data.get().map(|data| data.title).unwrap_or_else(|| "Card Title".to_string())
|
|
||||||
}}
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<CardContent>
|
|
||||||
<CardDescription>
|
|
||||||
{move || {
|
|
||||||
card_data
|
|
||||||
.get()
|
|
||||||
.map(|data| data.description)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
"Click 'Toggle Loading' for manual control, or 'Fetch Data' to simulate a real server call with 1 second delay."
|
|
||||||
.to_string()
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
</CardDescription>
|
|
||||||
</CardContent>
|
|
||||||
|
|
||||||
<CardFooter class="justify-end">
|
|
||||||
<Button variant=ButtonVariant::Outline>"Cancel"</Button>
|
|
||||||
<Button>"Confirm"</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</Shimmer>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod demo_shimmer;
|
|
||||||
@@ -1,31 +1,5 @@
|
|||||||
use std::collections::hash_map::DefaultHasher;
|
use leptos::prelude::*;
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
|
|
||||||
const PREFIX: &str = "rust_ui"; // Must NOT contain "/" or "-"
|
pub fn use_random_id_for(prefix: &str) -> String {
|
||||||
|
format!("{}_{}", prefix, js_sys::Math::random().to_string().replace(".", ""))
|
||||||
pub fn use_random_id() -> String {
|
|
||||||
format!("_{PREFIX}_{}", generate_hash())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn use_random_id_for(element: &str) -> String {
|
|
||||||
format!("{}_{PREFIX}_{}", element, generate_hash())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn use_random_transition_name() -> String {
|
|
||||||
let random_id = use_random_id();
|
|
||||||
format!("view-transition-name: {random_id}")
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* ✨ FUNCTIONS ✨ */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
static COUNTER: AtomicUsize = AtomicUsize::new(1);
|
|
||||||
|
|
||||||
fn generate_hash() -> u64 {
|
|
||||||
let mut hasher = DefaultHasher::new();
|
|
||||||
let counter = COUNTER.fetch_add(1, Ordering::SeqCst);
|
|
||||||
counter.hash(&mut hasher);
|
|
||||||
hasher.finish()
|
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,3 @@ pub mod torrent;
|
|||||||
pub mod auth;
|
pub mod auth;
|
||||||
// pub mod toast; (Removed)
|
// pub mod toast; (Removed)
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod demos;
|
|
||||||
|
|||||||
@@ -1,260 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use crate::components::ui::tabs::*;
|
|
||||||
use crate::components::ui::skeleton::*;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TorrentDetailsPanel() -> impl IntoView {
|
|
||||||
let store = use_context::<crate::store::TorrentStore>().expect("store not provided");
|
|
||||||
|
|
||||||
let selected_torrent = Memo::new(move |_| {
|
|
||||||
let hash = store.selected_torrent.get()?;
|
|
||||||
store.torrents.with(|map| map.get(&hash).cloned())
|
|
||||||
});
|
|
||||||
|
|
||||||
let is_open = Signal::derive(move || store.selected_torrent.get().is_some());
|
|
||||||
|
|
||||||
view! {
|
|
||||||
// Mobil overlay backdrop
|
|
||||||
<div
|
|
||||||
class=move || if is_open.get() {
|
|
||||||
"fixed inset-0 bg-black/40 z-30 md:hidden backdrop-blur-sm transition-opacity duration-300 opacity-100"
|
|
||||||
} else {
|
|
||||||
"fixed inset-0 bg-black/0 z-30 md:hidden pointer-events-none transition-opacity duration-300 opacity-0"
|
|
||||||
}
|
|
||||||
on:click=move |_| store.selected_torrent.set(None)
|
|
||||||
/>
|
|
||||||
|
|
||||||
// Panel — masaüstünde sağ kolonda sabit, mobilde sağdan açılan overlay
|
|
||||||
<div class=move || {
|
|
||||||
if is_open.get() {
|
|
||||||
// Açık: masaüstünde görünür, mobilde sağdan gelir
|
|
||||||
"w-full md:w-[380px] md:min-w-[380px] shrink-0 \
|
|
||||||
flex flex-col border-l border-border bg-card \
|
|
||||||
fixed top-0 right-0 bottom-0 z-40 \
|
|
||||||
translate-x-0 \
|
|
||||||
md:static md:z-auto md:translate-x-0 \
|
|
||||||
transition-transform duration-300 ease-out shadow-2xl md:shadow-none"
|
|
||||||
} else {
|
|
||||||
// Kapalı: masaüstünde gizli, mobilde sağa kayar
|
|
||||||
"w-full md:w-0 shrink-0 overflow-hidden border-none \
|
|
||||||
fixed top-0 right-0 bottom-0 z-40 \
|
|
||||||
translate-x-full \
|
|
||||||
md:static md:z-auto md:translate-x-0 \
|
|
||||||
transition-transform duration-300 ease-in pointer-events-none"
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
// İpucu: panel kapalıyken içeriği render etme
|
|
||||||
<Show when=move || is_open.get()>
|
|
||||||
// Başlık
|
|
||||||
<div class="px-4 py-3 border-b flex items-center justify-between shrink-0 bg-card">
|
|
||||||
<div class="flex flex-col gap-0.5 min-w-0 flex-1">
|
|
||||||
<Show
|
|
||||||
when=move || selected_torrent.get().is_some()
|
|
||||||
fallback=move || view! { <Skeleton class="h-5 w-40" /> }
|
|
||||||
>
|
|
||||||
<h2 class="font-bold text-sm truncate leading-tight">
|
|
||||||
{move || selected_torrent.get().map(|t| t.name).unwrap_or_default()}
|
|
||||||
</h2>
|
|
||||||
</Show>
|
|
||||||
<Show
|
|
||||||
when=move || selected_torrent.get().is_some()
|
|
||||||
fallback=move || view! { <Skeleton class="h-3 w-20 mt-1" /> }
|
|
||||||
>
|
|
||||||
<p class="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold flex items-center gap-1.5">
|
|
||||||
{move || selected_torrent.get().map(|t| format!("{:?}", t.status)).unwrap_or_default()}
|
|
||||||
<span class="bg-primary/20 text-primary px-1 py-0.5 rounded text-[9px] lowercase">
|
|
||||||
{move || selected_torrent.get().map(|t| format!("{:.1}%", t.percent_complete)).unwrap_or_default()}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
// Kapat butonu
|
|
||||||
<button
|
|
||||||
class="rounded-full p-1.5 hover:bg-muted transition-colors text-muted-foreground hover:text-foreground shrink-0 ml-2"
|
|
||||||
on:click=move |_| store.selected_torrent.set(None)
|
|
||||||
>
|
|
||||||
<icons::X class="size-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
// Sekmeler + içerik
|
|
||||||
<div class="flex-1 overflow-hidden flex flex-col min-h-0">
|
|
||||||
<Tabs default_value="general" class="flex-1 h-full min-h-0 flex flex-col">
|
|
||||||
<TabsList class="w-full justify-start rounded-none border-b bg-transparent p-0 shrink-0 px-2">
|
|
||||||
<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 text-xs h-9"
|
|
||||||
>
|
|
||||||
"Genel"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
value="files"
|
|
||||||
class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none text-xs h-9"
|
|
||||||
>
|
|
||||||
"Dosyalar"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
value="trackers"
|
|
||||||
class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none text-xs h-9"
|
|
||||||
>
|
|
||||||
"İzleyiciler"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
value="peers"
|
|
||||||
class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none text-xs h-9"
|
|
||||||
>
|
|
||||||
"Eşler"
|
|
||||||
</TabsTrigger>
|
|
||||||
</TabsList>
|
|
||||||
|
|
||||||
<crate::components::ui::scroll_area::ScrollArea class="flex-1 min-h-0">
|
|
||||||
<TabsContent value="general" class="p-4 space-y-5 animate-in fade-in duration-200">
|
|
||||||
<crate::components::ui::shimmer::Shimmer
|
|
||||||
loading=Signal::derive(move || selected_torrent.get().is_none())
|
|
||||||
shimmer_color="rgba(0,0,0,0.06)"
|
|
||||||
background_color="rgba(0,0,0,0.04)"
|
|
||||||
>
|
|
||||||
{move || {
|
|
||||||
let t = selected_torrent.get().unwrap_or_else(|| shared::Torrent {
|
|
||||||
hash: "----------------------------------------".to_string(),
|
|
||||||
name: "Yükleniyor...".to_string(),
|
|
||||||
size: 0,
|
|
||||||
completed: 0,
|
|
||||||
down_rate: 0,
|
|
||||||
up_rate: 0,
|
|
||||||
eta: 0,
|
|
||||||
percent_complete: 0.0,
|
|
||||||
status: shared::TorrentStatus::Downloading,
|
|
||||||
error_message: "".to_string(),
|
|
||||||
added_date: 0,
|
|
||||||
label: None,
|
|
||||||
ratio: 0.0,
|
|
||||||
uploaded: 0,
|
|
||||||
wasted: 0,
|
|
||||||
save_path: "Yükleniyor...".to_string(),
|
|
||||||
free_disk_space: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="flex flex-col gap-5">
|
|
||||||
// Aktarım
|
|
||||||
<div>
|
|
||||||
<h3 class="text-[10px] font-bold border-b pb-1.5 mb-3 uppercase tracking-widest text-muted-foreground">"Aktarım"</h3>
|
|
||||||
<div class="grid grid-cols-2 gap-3">
|
|
||||||
<InfoItem label="Kalan" value=format_duration(t.eta) />
|
|
||||||
<InfoItem label="Paylaşım Oranı" value=format!("{:.3}", t.ratio) />
|
|
||||||
<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="Gönderilen" value=format_bytes(t.uploaded) />
|
|
||||||
<InfoItem label="Gönderme Hızı" value=format_speed(t.up_rate) class="text-green-500" />
|
|
||||||
<InfoItem label="Boşa Giden" value=format_bytes(t.wasted) />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
// Genel
|
|
||||||
<div>
|
|
||||||
<h3 class="text-[10px] font-bold border-b pb-1.5 mb-3 uppercase tracking-widest text-muted-foreground">"Genel"</h3>
|
|
||||||
<div class="flex flex-col gap-3">
|
|
||||||
<InfoItem label="Kaydedilen Yer" value=t.save_path class="break-all font-mono text-xs" />
|
|
||||||
<div class="grid grid-cols-2 gap-3">
|
|
||||||
<InfoItem label="Boş Disk Alanı" value=format_bytes(t.free_disk_space) />
|
|
||||||
<InfoItem label="Oluşturulma Tarihi" value=format_date(t.added_date) />
|
|
||||||
</div>
|
|
||||||
<InfoItem label="Hash" value=t.hash class="break-all font-mono text-[10px]" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
</crate::components::ui::shimmer::Shimmer>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="files" class="h-full">
|
|
||||||
{move || match selected_torrent.get() {
|
|
||||||
Some(t) => leptos::either::Either::Left(view! {
|
|
||||||
<div class="h-full">
|
|
||||||
<crate::components::torrent::files::TorrentFilesTab hash=t.hash />
|
|
||||||
</div>
|
|
||||||
}),
|
|
||||||
None => leptos::either::Either::Right(view! {
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60 gap-2">
|
|
||||||
<icons::File class="size-10 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"Dosya yükleniyor..."</p>
|
|
||||||
</div>
|
|
||||||
}),
|
|
||||||
}}
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="trackers" class="h-full">
|
|
||||||
{move || match selected_torrent.get() {
|
|
||||||
Some(t) => leptos::either::Either::Left(view! {
|
|
||||||
<div class="h-full">
|
|
||||||
<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 gap-2">
|
|
||||||
<icons::Settings2 class="size-10 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"İzleyici yükleniyor..."</p>
|
|
||||||
</div>
|
|
||||||
}),
|
|
||||||
}}
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="peers" class="h-full">
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60 gap-2">
|
|
||||||
<icons::Users class="size-10 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"Eş listesi yakında eklenecek"</p>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
</crate::components::ui::scroll_area::ScrollArea>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn InfoItem(
|
|
||||||
label: &'static str,
|
|
||||||
value: String,
|
|
||||||
#[prop(optional)] class: &'static str
|
|
||||||
) -> impl IntoView {
|
|
||||||
view! {
|
|
||||||
<div class=tailwind_fuse::tw_merge!("flex flex-col gap-0.5", class)>
|
|
||||||
<span class="text-[9px] font-semibold text-muted-foreground uppercase tracking-wider opacity-70">{label}</span>
|
|
||||||
<span class="text-xs font-medium leading-tight">{value}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_bytes(bytes: i64) -> String {
|
|
||||||
const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
||||||
if bytes < 1024 { return format!("{} B", bytes); }
|
|
||||||
let i = (bytes as f64).log2().div_euclid(10.0) as usize;
|
|
||||||
format!("{:.1} {}", (bytes as f64) / 1024_f64.powi(i as i32), UNITS[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_speed(bytes_per_sec: i64) -> String {
|
|
||||||
if bytes_per_sec == 0 { return "0 B/s".to_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!("{}g {}s", days, hours) }
|
|
||||||
else if hours > 0 { format!("{}s {}d", hours, minutes) }
|
|
||||||
else if minutes > 0 { format!("{}d {}sn", minutes, secs) }
|
|
||||||
else { format!("{}sn", secs) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_date(timestamp: i64) -> String {
|
|
||||||
if timestamp <= 0 { return "N/A".to_string(); }
|
|
||||||
let dt = chrono::DateTime::from_timestamp(timestamp, 0);
|
|
||||||
match dt { Some(dt) => dt.format("%d/%m/%Y %H:%M").to_string(), None => "N/A".to_string() }
|
|
||||||
}
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use crate::components::ui::table::*;
|
|
||||||
use crate::components::ui::badge::*;
|
|
||||||
use crate::components::ui::shimmer::*;
|
|
||||||
use crate::components::ui::context_menu::*;
|
|
||||||
use shared::TorrentFile;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|
|
||||||
let hash_clone = hash.clone();
|
|
||||||
|
|
||||||
// Fetch files resource
|
|
||||||
let files_resource = Resource::new(
|
|
||||||
move || hash_clone.clone(),
|
|
||||||
|h| async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Callback to trigger a refetch — safe, doesn't destroy existing components
|
|
||||||
let on_refresh = Callback::new(move |_: ()| {
|
|
||||||
files_resource.refetch();
|
|
||||||
});
|
|
||||||
|
|
||||||
let stored_hash = StoredValue::new(hash);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<Suspense fallback=move || view! { <FilesFallback /> }>
|
|
||||||
{move || {
|
|
||||||
let files = files_resource.get().unwrap_or_default();
|
|
||||||
|
|
||||||
if files.is_empty() {
|
|
||||||
return view! {
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
|
||||||
<icons::File class="size-12 mb-3 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"Bu torrent için dosya bulunamadı."</p>
|
|
||||||
</div>
|
|
||||||
}.into_any();
|
|
||||||
}
|
|
||||||
|
|
||||||
let files_len = files.len();
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="space-y-4">
|
|
||||||
<TableWrapper class="bg-card/50">
|
|
||||||
<Table>
|
|
||||||
<TableHeader class="sticky top-0 bg-muted/80 backdrop-blur-sm z-10">
|
|
||||||
<TableRow class="hover:bg-transparent">
|
|
||||||
<TableHead class="w-12 text-center text-xs">"#"</TableHead>
|
|
||||||
<TableHead class="text-xs">"Dosya Adı"</TableHead>
|
|
||||||
<TableHead class="w-24 text-right text-xs">"Boyut"</TableHead>
|
|
||||||
<TableHead class="w-24 text-right text-xs">"Tamamlanan"</TableHead>
|
|
||||||
<TableHead class="w-24 text-center text-xs">"Öncelik"</TableHead>
|
|
||||||
</TableRow>
|
|
||||||
</TableHeader>
|
|
||||||
<TableBody>
|
|
||||||
<For
|
|
||||||
each=move || files.clone()
|
|
||||||
key=|f| f.index
|
|
||||||
children={move |f| {
|
|
||||||
let p_hash = stored_hash.get_value();
|
|
||||||
view! {
|
|
||||||
<FileRow
|
|
||||||
file=f
|
|
||||||
hash=p_hash
|
|
||||||
on_refresh=on_refresh.clone()
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</TableWrapper>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between text-xs text-muted-foreground px-1">
|
|
||||||
<span>{format!("Toplam {} dosya", files_len)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}.into_any()
|
|
||||||
}}
|
|
||||||
</Suspense>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl IntoView {
|
|
||||||
let f_idx = file.index;
|
|
||||||
let path_clone = file.path.clone();
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
async move {
|
|
||||||
let res = shared::server_fns::torrent::set_file_priority(h, idx, p).await;
|
|
||||||
if let Err(e) = &res {
|
|
||||||
crate::store::show_toast(shared::NotificationLevel::Error, format!("Öncelik değiştirilemedi: {:?}", e));
|
|
||||||
} else {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<FileContextMenu
|
|
||||||
torrent_hash=hash
|
|
||||||
file_index=f_idx
|
|
||||||
set_priority=set_priority
|
|
||||||
>
|
|
||||||
<TableRow class="hover:bg-muted/50 transition-colors group">
|
|
||||||
<TableCell class="text-center text-xs text-muted-foreground">{file.index}</TableCell>
|
|
||||||
<TableCell class="font-medium text-xs break-all max-w-[200px] md:max-w-md" attr:title=move || path_clone.clone()>
|
|
||||||
{file.path.clone()}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell class="text-right text-xs text-muted-foreground whitespace-nowrap">
|
|
||||||
{format_bytes(file.size)}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell class="text-right text-xs whitespace-nowrap">
|
|
||||||
<span class="text-primary font-medium">{format_bytes(file.completed_chunks)}</span>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell class="text-center">
|
|
||||||
{
|
|
||||||
let (variant, label) = match file.priority {
|
|
||||||
0 => (BadgeVariant::Destructive, "İndirme"),
|
|
||||||
2 => (BadgeVariant::Success, "Yüksek"),
|
|
||||||
_ => (BadgeVariant::Secondary, "Normal"),
|
|
||||||
};
|
|
||||||
view! { <Badge variant=variant class="text-[10px] uppercase">{label}</Badge> }
|
|
||||||
}
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</FileContextMenu>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn FileContextMenu(
|
|
||||||
children: Children,
|
|
||||||
torrent_hash: String,
|
|
||||||
file_index: u32,
|
|
||||||
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let hash_c1 = torrent_hash.clone();
|
|
||||||
let hash_c2 = torrent_hash.clone();
|
|
||||||
let hash_c3 = torrent_hash.clone();
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<ContextMenu>
|
|
||||||
<ContextMenuTrigger>
|
|
||||||
{children()}
|
|
||||||
</ContextMenuTrigger>
|
|
||||||
|
|
||||||
<ContextMenuContent class="w-48">
|
|
||||||
<ContextMenuLabel>"Dosya Önceliği"</ContextMenuLabel>
|
|
||||||
<ContextMenuGroup>
|
|
||||||
<ContextMenuItem on:click={
|
|
||||||
let h = hash_c1;
|
|
||||||
let sp = set_priority.clone();
|
|
||||||
move |_| {
|
|
||||||
sp.dispatch((h.clone(), file_index, 2));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
<icons::ChevronsUp class="text-green-500" />
|
|
||||||
<span>"Yüksek"</span>
|
|
||||||
</ContextMenuItem>
|
|
||||||
|
|
||||||
<ContextMenuItem on:click={
|
|
||||||
let h = hash_c2;
|
|
||||||
let sp = set_priority.clone();
|
|
||||||
move |_| {
|
|
||||||
sp.dispatch((h.clone(), file_index, 1));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
<icons::Minus class="text-blue-500" />
|
|
||||||
<span>"Normal"</span>
|
|
||||||
</ContextMenuItem>
|
|
||||||
|
|
||||||
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
|
|
||||||
let h = hash_c3;
|
|
||||||
let sp = set_priority.clone();
|
|
||||||
move |_| {
|
|
||||||
sp.dispatch((h.clone(), file_index, 0));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
<icons::X />
|
|
||||||
<span>"İndirme (Kapalı)"</span>
|
|
||||||
</ContextMenuItem>
|
|
||||||
</ContextMenuGroup>
|
|
||||||
</ContextMenuContent>
|
|
||||||
</ContextMenu>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn FilesFallback() -> 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_bytes(bytes: i64) -> String {
|
|
||||||
const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
||||||
if bytes < 1024 { return format!("{} B", bytes); }
|
|
||||||
let i = (bytes as f64).log2().div_euclid(10.0) as usize;
|
|
||||||
format!("{:.1} {}", (bytes as f64) / 1024_f64.powi(i as i32), UNITS[i])
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,2 @@
|
|||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod add_torrent;
|
pub mod add_torrent;
|
||||||
pub mod details;
|
|
||||||
pub mod files;
|
|
||||||
pub mod trackers;
|
|
||||||
|
|||||||
@@ -218,9 +218,7 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="h-full bg-background flex flex-row overflow-hidden">
|
<div class="h-full bg-background relative flex flex-col overflow-hidden px-4 py-4 gap-4">
|
||||||
// Sol: liste alanı
|
|
||||||
<div class="flex-1 min-w-0 flex flex-col overflow-hidden px-4 py-4 gap-4">
|
|
||||||
// --- TOPBAR ---
|
// --- TOPBAR ---
|
||||||
<div class="flex items-center justify-between gap-4">
|
<div class="flex items-center justify-between gap-4">
|
||||||
<div class="flex items-center gap-2 flex-1 max-w-md">
|
<div class="flex items-center gap-2 flex-1 max-w-md">
|
||||||
@@ -251,6 +249,7 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
|
|
||||||
<div class="my-1 h-px bg-border" />
|
<div class="my-1 h-px bg-border" />
|
||||||
|
|
||||||
|
// Trigger the hidden AlertDialog from this menu item
|
||||||
<DropdownMenuItem class="text-destructive focus:bg-destructive/10 cursor-pointer" on:click=move |_| {
|
<DropdownMenuItem class="text-destructive focus:bg-destructive/10 cursor-pointer" on:click=move |_| {
|
||||||
if let Some(trigger) = document().get_element_by_id("bulk-delete-trigger") {
|
if let Some(trigger) = document().get_element_by_id("bulk-delete-trigger") {
|
||||||
let _ = trigger.dyn_into::<web_sys::HtmlElement>().map(|el: web_sys::HtmlElement| el.click());
|
let _ = trigger.dyn_into::<web_sys::HtmlElement>().map(|el: web_sys::HtmlElement| el.click());
|
||||||
@@ -262,6 +261,7 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
|
// Hidden AlertDialog moved outside the DropdownMenuContent to ensure proper centering
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger attr:id="bulk-delete-trigger" class="hidden">""</AlertDialogTrigger>
|
<AlertDialogTrigger attr:id="bulk-delete-trigger" class="hidden">""</AlertDialogTrigger>
|
||||||
<AlertDialogContent class="sm:max-w-[425px]">
|
<AlertDialogContent class="sm:max-w-[425px]">
|
||||||
@@ -554,10 +554,6 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
<div class="opacity-50">"VibeTorrent v3"</div>
|
<div class="opacity-50">"VibeTorrent v3"</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
// Sağ: sabit detay paneli
|
|
||||||
<crate::components::torrent::details::TorrentDetailsPanel />
|
|
||||||
</div>
|
|
||||||
}.into_any()
|
}.into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,12 +595,10 @@ fn TorrentRow(
|
|||||||
on:click=move |_| store.selected_torrent.set(Some(stored_hash.get_value()))
|
on:click=move |_| store.selected_torrent.set(Some(stored_hash.get_value()))
|
||||||
>
|
>
|
||||||
<DataTableCell class="w-12 px-4">
|
<DataTableCell class="w-12 px-4">
|
||||||
<div on:click=move |e| e.stop_propagation()>
|
<Checkbox
|
||||||
<Checkbox
|
checked=is_selected
|
||||||
checked=is_selected
|
on_checked_change=on_select
|
||||||
on_checked_change=on_select
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</DataTableCell>
|
</DataTableCell>
|
||||||
|
|
||||||
{move || visible_columns.get().contains("Name").then({
|
{move || visible_columns.get().contains("Name").then({
|
||||||
@@ -734,23 +728,17 @@ fn TorrentCard(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
on:click=move |_| {
|
on:click=move |_| {
|
||||||
|
let current = is_selected.get();
|
||||||
|
on_select.run(!current);
|
||||||
store.selected_torrent.set(Some(stored_hash.get_value()));
|
store.selected_torrent.set(Some(stored_hash.get_value()));
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div class="p-4 space-y-3">
|
<div class="p-4 space-y-3">
|
||||||
<div class="flex justify-between items-start gap-3">
|
<div class="flex justify-between items-start gap-3">
|
||||||
<div class="flex items-start gap-3 flex-1 min-w-0">
|
<div class="flex-1 min-w-0">
|
||||||
<div on:click=move |e| e.stop_propagation() class="mt-0.5">
|
<h3 class="text-sm font-bold leading-tight line-clamp-2 break-all">{t_name.clone()}</h3>
|
||||||
<Checkbox
|
|
||||||
checked=is_selected
|
|
||||||
on_checked_change=on_select
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 min-w-0">
|
|
||||||
<h3 class="text-sm font-bold leading-tight line-clamp-2 break-all">{t_name.clone()}</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<Badge variant=status_variant class="uppercase tracking-wider text-[10px] shrink-0">
|
<Badge variant=status_variant class="uppercase tracking-wider text-[10px]">
|
||||||
{format!("{:?}", t.status)}
|
{format!("{:?}", t.status)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
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) }
|
|
||||||
}
|
|
||||||
93
frontend/src/components/ui/auto_form.rs
Normal file
93
frontend/src/components/ui/auto_form.rs
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use tailwind_fuse::tw_merge;
|
||||||
|
use crate::components::ui::button::Button;
|
||||||
|
use crate::components::ui::input::{Input, InputType};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum AutoFormField {
|
||||||
|
Text {
|
||||||
|
name: String,
|
||||||
|
label: String,
|
||||||
|
placeholder: Option<String>,
|
||||||
|
required: bool,
|
||||||
|
},
|
||||||
|
Password {
|
||||||
|
name: String,
|
||||||
|
label: String,
|
||||||
|
placeholder: Option<String>,
|
||||||
|
required: bool,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn AutoForm(
|
||||||
|
#[prop(into)] fields: Vec<AutoFormField>,
|
||||||
|
#[prop(into)] submit_label: String,
|
||||||
|
#[prop(into)] on_submit: Callback<std::collections::HashMap<String, String>>,
|
||||||
|
#[prop(optional)] loading: Signal<bool>,
|
||||||
|
#[prop(optional, into)] class: String,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let field_values = fields.iter().map(|f| {
|
||||||
|
let name = match f {
|
||||||
|
AutoFormField::Text { name, .. } => name,
|
||||||
|
AutoFormField::Password { name, .. } => name,
|
||||||
|
};
|
||||||
|
(name.clone(), RwSignal::new(String::new()))
|
||||||
|
}).collect::<std::collections::HashMap<String, RwSignal<String>>>();
|
||||||
|
|
||||||
|
let handle_submit = {
|
||||||
|
let field_values = field_values.clone();
|
||||||
|
move |ev: web_sys::SubmitEvent| {
|
||||||
|
ev.prevent_default();
|
||||||
|
let mut data = std::collections::HashMap::new();
|
||||||
|
for (name, signal) in &field_values {
|
||||||
|
data.insert(name.clone(), signal.get());
|
||||||
|
}
|
||||||
|
on_submit.run(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<form on:submit=handle_submit class=tw_merge!("space-y-4", class)>
|
||||||
|
{fields.into_iter().map(|field| {
|
||||||
|
let (name, label, placeholder, r#type, required) = match field {
|
||||||
|
AutoFormField::Text { name, label, placeholder, required } => (name, label, placeholder, InputType::Text, required),
|
||||||
|
AutoFormField::Password { name, label, placeholder, required } => (name, label, placeholder, InputType::Password, required),
|
||||||
|
};
|
||||||
|
|
||||||
|
let signal = field_values.get(&name).cloned().unwrap();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
r#type=r#type
|
||||||
|
placeholder=placeholder.unwrap_or_default()
|
||||||
|
bind_value=signal
|
||||||
|
required=required
|
||||||
|
disabled=loading.get()
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}).collect_view()}
|
||||||
|
|
||||||
|
<div class="pt-2">
|
||||||
|
<Button
|
||||||
|
class="w-full"
|
||||||
|
attr:r#type="submit"
|
||||||
|
attr:disabled=move || loading.get()
|
||||||
|
>
|
||||||
|
<Show when=move || loading.get() fallback=move || {
|
||||||
|
let label = submit_label.clone();
|
||||||
|
view! { <span>{label}</span> }.into_any()
|
||||||
|
}>
|
||||||
|
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
||||||
|
"İşleniyor..."
|
||||||
|
</Show>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,17 +3,13 @@ use leptos_ui::clx;
|
|||||||
|
|
||||||
mod components {
|
mod components {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
clx! {Card, div, "bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-6 shadow-sm"}
|
clx! {Card, div, "bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-6 shadow-sm"}
|
||||||
// TODO. Change data-slot=card-action by data-name="CardAction".
|
clx! {CardHeader, div, "@container/card-header flex flex-col items-start gap-1.5 px-6 [.border-b]:pb-6"}
|
||||||
clx! {CardHeader, div, "@container/card-header flex flex-col items-start gap-1.5 px-6 [.border-b]:pb-6 sm:grid sm:auto-rows-min sm:grid-rows-[auto_auto] has-data-[slot=card-action]:sm:grid-cols-[1fr_auto]"}
|
|
||||||
clx! {CardTitle, h2, "leading-none font-semibold"}
|
clx! {CardTitle, h2, "leading-none font-semibold"}
|
||||||
clx! {CardContent, div, "px-6"}
|
clx! {CardContent, div, "px-6"}
|
||||||
clx! {CardDescription, p, "text-muted-foreground text-sm"}
|
clx! {CardDescription, p, "text-muted-foreground text-sm"}
|
||||||
clx! {CardFooter, footer, "flex items-center px-6 [.border-t]:pt-6", "gap-2"}
|
clx! {CardFooter, footer, "flex items-center px-6 [.border-t]:pt-6", "gap-2"}
|
||||||
|
|
||||||
clx! {CardAction, div, "self-start sm:col-start-2 sm:row-span-2 sm:row-start-1 sm:justify-self-end"}
|
|
||||||
clx! {CardList, ul, "flex flex-col gap-4"}
|
|
||||||
clx! {CardItem, li, "flex items-center [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use components::*;
|
pub use components::*;
|
||||||
@@ -139,7 +139,7 @@ pub fn ContextMenuTrigger(
|
|||||||
class=trigger_class
|
class=trigger_class
|
||||||
data-name="ContextMenuTrigger"
|
data-name="ContextMenuTrigger"
|
||||||
data-context-trigger=ctx.target_id
|
data-context-trigger=ctx.target_id
|
||||||
on:contextmenu=move |_e: web_sys::MouseEvent| {
|
on:contextmenu=move |e: web_sys::MouseEvent| {
|
||||||
if let Some(cb) = on_open {
|
if let Some(cb) = on_open {
|
||||||
cb.run(());
|
cb.run(());
|
||||||
}
|
}
|
||||||
@@ -215,20 +215,12 @@ pub fn ContextMenuContent(
|
|||||||
|
|
||||||
// Adjust if menu would go off right edge
|
// Adjust if menu would go off right edge
|
||||||
if (x + menuRect.width > viewportWidth) {{
|
if (x + menuRect.width > viewportWidth) {{
|
||||||
left = Math.max(0, x - menuRect.width);
|
left = x - menuRect.width;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Adjust if menu would go off bottom edge
|
// Adjust if menu would go off bottom edge
|
||||||
if (y + menuRect.height > viewportHeight) {{
|
if (y + menuRect.height > viewportHeight) {{
|
||||||
top = Math.max(0, y - menuRect.height);
|
top = y - menuRect.height;
|
||||||
}}
|
|
||||||
|
|
||||||
// Adjust for CSS transformed containing block
|
|
||||||
const offsetParent = menu.offsetParent;
|
|
||||||
if (offsetParent && offsetParent !== document.body && offsetParent !== document.documentElement) {{
|
|
||||||
const parentRect = offsetParent.getBoundingClientRect();
|
|
||||||
left -= parentRect.left;
|
|
||||||
top -= parentRect.top;
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
menu.style.left = `${{left}}px`;
|
menu.style.left = `${{left}}px`;
|
||||||
@@ -236,152 +228,105 @@ pub fn ContextMenuContent(
|
|||||||
menu.style.transformOrigin = 'top left';
|
menu.style.transformOrigin = 'top left';
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const openMenu = (x, y) => {{
|
const openMenu = (x, y) => {{
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
|
|
||||||
// Close any other open context menus
|
// Close any other open context menus
|
||||||
const allMenus = document.querySelectorAll('[data-target="target__context"]');
|
const allMenus = document.querySelectorAll('[data-target="target__context"]');
|
||||||
allMenus.forEach(m => {{
|
allMenus.forEach(m => {{
|
||||||
if (m !== menu && m.getAttribute('data-state') === 'open') {{
|
if (m !== menu && m.getAttribute('data-state') === 'open') {{
|
||||||
m.setAttribute('data-state', 'closed');
|
m.setAttribute('data-state', 'closed');
|
||||||
m.style.pointerEvents = 'none';
|
m.style.pointerEvents = 'none';
|
||||||
}}
|
|
||||||
}});
|
|
||||||
|
|
||||||
menu.setAttribute('data-state', 'open');
|
|
||||||
menu.style.visibility = 'hidden';
|
|
||||||
menu.style.pointerEvents = 'auto';
|
|
||||||
|
|
||||||
// Force reflow
|
|
||||||
menu.offsetHeight;
|
|
||||||
|
|
||||||
updatePosition(x, y);
|
|
||||||
menu.style.visibility = 'visible';
|
|
||||||
|
|
||||||
// Lock scroll
|
|
||||||
if (window.ScrollLock) {{
|
|
||||||
window.ScrollLock.lock();
|
|
||||||
}}
|
|
||||||
|
|
||||||
setTimeout(() => {{
|
|
||||||
document.addEventListener('click', handleClickOutside);
|
|
||||||
document.addEventListener('contextmenu', handleContextOutside);
|
|
||||||
}}, 0);
|
|
||||||
}};
|
|
||||||
|
|
||||||
const closeMenu = () => {{
|
|
||||||
isOpen = false;
|
|
||||||
menu.setAttribute('data-state', 'closed');
|
|
||||||
menu.style.pointerEvents = 'none';
|
|
||||||
document.removeEventListener('click', handleClickOutside);
|
|
||||||
document.removeEventListener('contextmenu', handleContextOutside);
|
|
||||||
|
|
||||||
// Dispatch custom event for Leptos to listen to
|
|
||||||
menu.dispatchEvent(new CustomEvent('contextmenuclose', {{ bubbles: false }}));
|
|
||||||
|
|
||||||
if (window.ScrollLock) {{
|
|
||||||
window.ScrollLock.unlock(200);
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
const handleClickOutside = (e) => {{
|
|
||||||
if (!menu.contains(e.target)) {{
|
|
||||||
closeMenu();
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
const handleContextOutside = (e) => {{
|
|
||||||
if (!trigger.contains(e.target)) {{
|
|
||||||
closeMenu();
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
// Right-click on trigger (desktop)
|
|
||||||
trigger.addEventListener('contextmenu', (e) => {{
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
if (isOpen) {{
|
|
||||||
closeMenu();
|
|
||||||
}}
|
|
||||||
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', () => {{
|
menu.setAttribute('data-state', 'open');
|
||||||
if (touchTimer) {{
|
menu.style.visibility = 'hidden';
|
||||||
clearTimeout(touchTimer);
|
menu.style.pointerEvents = 'auto';
|
||||||
touchTimer = null;
|
|
||||||
}}
|
|
||||||
}});
|
|
||||||
|
|
||||||
trigger.addEventListener('touchcancel', () => {{
|
// Force reflow
|
||||||
if (touchTimer) {{
|
menu.offsetHeight;
|
||||||
clearTimeout(touchTimer);
|
|
||||||
touchTimer = null;
|
|
||||||
}}
|
|
||||||
}});
|
|
||||||
|
|
||||||
// Close when action is clicked
|
updatePosition(x, y);
|
||||||
const actions = menu.querySelectorAll('[data-context-close]');
|
menu.style.visibility = 'visible';
|
||||||
actions.forEach(action => {{
|
|
||||||
action.addEventListener('click', () => {{
|
|
||||||
closeMenu();
|
|
||||||
}});
|
|
||||||
}});
|
|
||||||
|
|
||||||
// Handle ESC key
|
// Lock scroll
|
||||||
document.addEventListener('keydown', (e) => {{
|
if (window.ScrollLock) {{
|
||||||
if (e.key === 'Escape' && isOpen) {{
|
window.ScrollLock.lock();
|
||||||
e.preventDefault();
|
}}
|
||||||
closeMenu();
|
|
||||||
}}
|
setTimeout(() => {{
|
||||||
}});
|
document.addEventListener('click', handleClickOutside);
|
||||||
|
document.addEventListener('contextmenu', handleContextOutside);
|
||||||
|
}}, 0);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (document.readyState === 'loading') {{
|
const closeMenu = () => {{
|
||||||
document.addEventListener('DOMContentLoaded', setupContextMenu);
|
isOpen = false;
|
||||||
}} else {{
|
menu.setAttribute('data-state', 'closed');
|
||||||
setupContextMenu();
|
menu.style.pointerEvents = 'none';
|
||||||
}}
|
document.removeEventListener('click', handleClickOutside);
|
||||||
}})();
|
document.removeEventListener('contextmenu', handleContextOutside);
|
||||||
"#,
|
|
||||||
target_id_for_script,
|
// Dispatch custom event for Leptos to listen to
|
||||||
target_id_for_script,
|
menu.dispatchEvent(new CustomEvent('contextmenuclose', {{ bubbles: false }}));
|
||||||
)}
|
|
||||||
</script>
|
if (window.ScrollLock) {{
|
||||||
|
window.ScrollLock.unlock(200);
|
||||||
|
}}
|
||||||
|
}};
|
||||||
|
|
||||||
|
const handleClickOutside = (e) => {{
|
||||||
|
if (!menu.contains(e.target)) {{
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
}};
|
||||||
|
|
||||||
|
const handleContextOutside = (e) => {{
|
||||||
|
if (!trigger.contains(e.target)) {{
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
}};
|
||||||
|
|
||||||
|
// Right-click on trigger
|
||||||
|
trigger.addEventListener('contextmenu', (e) => {{
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if (isOpen) {{
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
openMenu(e.clientX, e.clientY);
|
||||||
|
}});
|
||||||
|
|
||||||
|
// Close when action is clicked
|
||||||
|
const actions = menu.querySelectorAll('[data-context-close]');
|
||||||
|
actions.forEach(action => {{
|
||||||
|
action.addEventListener('click', () => {{
|
||||||
|
closeMenu();
|
||||||
|
}});
|
||||||
|
}});
|
||||||
|
|
||||||
|
// Handle ESC key
|
||||||
|
document.addEventListener('keydown', (e) => {{
|
||||||
|
if (e.key === 'Escape' && isOpen) {{
|
||||||
|
e.preventDefault();
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {{
|
||||||
|
document.addEventListener('DOMContentLoaded', setupContextMenu);
|
||||||
|
}} else {{
|
||||||
|
setupContextMenu();
|
||||||
|
}}
|
||||||
|
}})();
|
||||||
|
"#,
|
||||||
|
target_id_for_script,
|
||||||
|
target_id_for_script,
|
||||||
|
)}
|
||||||
|
</script>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod accordion;
|
pub mod accordion;
|
||||||
pub mod alert_dialog;
|
pub mod alert_dialog;
|
||||||
|
pub mod auto_form;
|
||||||
pub mod badge;
|
pub mod badge;
|
||||||
pub mod button;
|
pub mod button;
|
||||||
pub mod button_action;
|
pub mod button_action;
|
||||||
@@ -14,14 +15,11 @@ pub mod input;
|
|||||||
pub mod multi_select;
|
pub mod multi_select;
|
||||||
pub mod select;
|
pub mod select;
|
||||||
pub mod separator;
|
pub mod separator;
|
||||||
pub mod scroll_area;
|
|
||||||
pub mod sheet;
|
pub mod sheet;
|
||||||
pub mod sidenav;
|
pub mod sidenav;
|
||||||
pub mod skeleton;
|
pub mod skeleton;
|
||||||
pub mod shimmer;
|
|
||||||
pub mod svg_icon;
|
pub mod svg_icon;
|
||||||
pub mod switch;
|
pub mod switch;
|
||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod tabs;
|
|
||||||
pub mod theme_toggle;
|
pub mod theme_toggle;
|
||||||
pub mod toast;
|
pub mod toast;
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use leptos_ui::void;
|
|
||||||
use tw_merge::*;
|
|
||||||
|
|
||||||
// Removed unused fake components
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* ✨ COMPONENTS ✨ */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn ScrollArea(children: Children, #[prop(into, optional)] class: String) -> impl IntoView {
|
|
||||||
let merged_class = tw_merge!("relative overflow-hidden", class);
|
|
||||||
view! {
|
|
||||||
<div data-name="ScrollArea" class=merged_class>
|
|
||||||
<ScrollAreaViewport class="pr-3 pb-3 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border/60 [&::-webkit-scrollbar-thumb]:rounded-full hover:[&::-webkit-scrollbar-thumb]:bg-border/80">{children()}</ScrollAreaViewport>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn ScrollAreaViewport(children: Children, #[prop(into, optional)] class: String) -> impl IntoView {
|
|
||||||
let merged_class = tw_merge!(
|
|
||||||
"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 overflow-auto",
|
|
||||||
class
|
|
||||||
);
|
|
||||||
view! {
|
|
||||||
<div data-name="ScrollAreaViewport" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* 🧬 ENUMS 🧬 */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
// Real scrollbars are now utilized in the viewport directly.
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* 🧬 STRUCT 🧬 */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn SnapScrollArea(
|
|
||||||
#[prop(into, default = SnapAreaVariant::default())] variant: SnapAreaVariant,
|
|
||||||
#[prop(into, optional)] class: String,
|
|
||||||
children: Children,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let snap_item = SnapAreaClass { variant };
|
|
||||||
let merged_class = snap_item.with_class(class);
|
|
||||||
view! {
|
|
||||||
<div data-name="SnapScrollArea" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(TwClass, Default)]
|
|
||||||
#[tw(class = "")]
|
|
||||||
pub struct SnapAreaClass {
|
|
||||||
variant: SnapAreaVariant,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(TwVariant)]
|
|
||||||
pub enum SnapAreaVariant {
|
|
||||||
// * snap-x by default
|
|
||||||
#[tw(default, class = "overflow-x-auto snap-x")]
|
|
||||||
Center,
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* 🧬 STRUCT 🧬 */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn SnapItem(
|
|
||||||
#[prop(into, default = SnapVariant::default())] variant: SnapVariant,
|
|
||||||
#[prop(into, optional)] class: String,
|
|
||||||
children: Children,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let snap_item = SnapItemClass { variant };
|
|
||||||
let merged_class = snap_item.with_class(class);
|
|
||||||
view! {
|
|
||||||
<div data-name="SnapItem" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(TwClass, Default)]
|
|
||||||
#[tw(class = "shrink-0")]
|
|
||||||
pub struct SnapItemClass {
|
|
||||||
variant: SnapVariant,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(TwVariant)]
|
|
||||||
pub enum SnapVariant {
|
|
||||||
// * snap-center by default
|
|
||||||
#[tw(default, class = "snap-center")]
|
|
||||||
Center,
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,8 @@ mod components {
|
|||||||
clx! {SheetFooter, footer, "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"}
|
clx! {SheetFooter, footer, "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub use components::*;
|
||||||
|
|
||||||
/* ========================================================== */
|
/* ========================================================== */
|
||||||
/* ✨ CONTEXT ✨ */
|
/* ✨ CONTEXT ✨ */
|
||||||
/* ========================================================== */
|
/* ========================================================== */
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use tw_merge::*;
|
|
||||||
|
|
||||||
use crate::components::hooks::use_random::use_random_id_for;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Shimmer(
|
|
||||||
/// Controls shimmer visibility (works with any bool signal)
|
|
||||||
#[prop(into)]
|
|
||||||
loading: Signal<bool>,
|
|
||||||
|
|
||||||
/// Color of the shimmer wave (default: "rgba(255,255,255,0.15)")
|
|
||||||
#[prop(into, optional)]
|
|
||||||
shimmer_color: Option<String>,
|
|
||||||
|
|
||||||
/// Background color of shimmer blocks (default: "rgba(255,255,255,0.08)")
|
|
||||||
#[prop(into, optional)]
|
|
||||||
background_color: Option<String>,
|
|
||||||
|
|
||||||
/// Animation duration in seconds (default: 1.5)
|
|
||||||
#[prop(optional)]
|
|
||||||
duration: Option<f64>,
|
|
||||||
|
|
||||||
/// Fallback border-radius for text elements in px (default: 4)
|
|
||||||
#[prop(optional)]
|
|
||||||
fallback_border_radius: Option<f64>,
|
|
||||||
|
|
||||||
/// Additional classes
|
|
||||||
#[prop(into, optional)]
|
|
||||||
class: String,
|
|
||||||
|
|
||||||
/// Children to wrap
|
|
||||||
children: Children,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let shimmer_id = use_random_id_for("Shimmer");
|
|
||||||
let merged_class = tw_merge!("relative", class);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div
|
|
||||||
id=shimmer_id
|
|
||||||
class=merged_class
|
|
||||||
data-name="Shimmer"
|
|
||||||
data-shimmer-loading=move || loading.get().to_string()
|
|
||||||
data-shimmer-color=shimmer_color
|
|
||||||
data-shimmer-bg-color=background_color
|
|
||||||
data-shimmer-duration=duration.map(|d| d.to_string())
|
|
||||||
data-shimmer-fallback-radius=fallback_border_radius.map(|r| r.to_string())
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
use leptos::context::Provider;
|
|
||||||
use leptos::prelude::*;
|
|
||||||
use tw_merge::tw_merge;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TabsContext {
|
|
||||||
pub active_tab: RwSignal<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Tabs(
|
|
||||||
#[prop(into)] default_value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let active_tab = RwSignal::new(default_value);
|
|
||||||
let ctx = TabsContext { active_tab };
|
|
||||||
|
|
||||||
let merged_class = tw_merge!("w-full", &class);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<Provider value=ctx>
|
|
||||||
<div data-name="Tabs" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
</Provider>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsList(
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let merged_class = tw_merge!(
|
|
||||||
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div data-name="TabsList" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsTrigger(
|
|
||||||
#[prop(into)] value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let ctx = expect_context::<TabsContext>();
|
|
||||||
let v_clone = value.clone();
|
|
||||||
|
|
||||||
let is_active = Memo::new(move |_| ctx.active_tab.get() == v_clone);
|
|
||||||
|
|
||||||
let merged_class = move || tw_merge!(
|
|
||||||
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none",
|
|
||||||
if is_active.get() {
|
|
||||||
"bg-background text-foreground shadow-sm"
|
|
||||||
} else {
|
|
||||||
"hover:bg-background/50 hover:text-foreground"
|
|
||||||
},
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<button
|
|
||||||
data-name="TabsTrigger"
|
|
||||||
type="button"
|
|
||||||
class=merged_class
|
|
||||||
data-state=move || if is_active.get() { "active" } else { "inactive" }
|
|
||||||
on:click=move |_| ctx.active_tab.set(value.clone())
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsContent(
|
|
||||||
#[prop(into)] value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let ctx = expect_context::<TabsContext>();
|
|
||||||
let v_clone = value.clone();
|
|
||||||
|
|
||||||
let is_active = Memo::new(move |_| ctx.active_tab.get() == v_clone);
|
|
||||||
|
|
||||||
let merged_class = move || tw_merge!(
|
|
||||||
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
||||||
if !is_active.get() { "hidden" } else { "" },
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div
|
|
||||||
data-name="TabsContent"
|
|
||||||
class=merged_class
|
|
||||||
data-state=move || if is_active.get() { "active" } else { "inactive" }
|
|
||||||
tabindex=move || if is_active.get() { "0" } else { "-1" }
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,8 @@ use leptos::task::spawn_local;
|
|||||||
use shared::{AppEvent, GlobalStats, NotificationLevel, Torrent};
|
use shared::{AppEvent, GlobalStats, NotificationLevel, Torrent};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use struct_patch::traits::Patch;
|
use struct_patch::traits::Patch;
|
||||||
use base64::{Engine as _, engine::general_purpose::{URL_SAFE_NO_PAD as BASE64_URL, STANDARD as BASE64}};
|
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD as BASE64_URL};
|
||||||
|
use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
use crate::components::ui::toast::{ToastType, toast};
|
use crate::components::ui::toast::{ToastType, toast};
|
||||||
@@ -191,7 +192,7 @@ pub async fn subscribe_to_push_notifications() {
|
|||||||
let key_array = js_sys::Uint8Array::from(&decoded_key[..]);
|
let key_array = js_sys::Uint8Array::from(&decoded_key[..]);
|
||||||
|
|
||||||
// 3. Prepare Options
|
// 3. Prepare Options
|
||||||
let options = web_sys::PushSubscriptionOptionsInit::new();
|
let mut options = web_sys::PushSubscriptionOptionsInit::new();
|
||||||
options.set_user_visible_only(true);
|
options.set_user_visible_only(true);
|
||||||
options.set_application_server_key(&key_array.into());
|
options.set_application_server_key(&key_array.into());
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = "vibetorrent-v3";
|
const CACHE_NAME = "vibetorrent-v2";
|
||||||
const ASSETS_TO_CACHE = [
|
const ASSETS_TO_CACHE = [
|
||||||
"/",
|
"/",
|
||||||
"/index.html",
|
"/index.html",
|
||||||
@@ -51,11 +51,6 @@ self.addEventListener("activate", (event) => {
|
|||||||
self.addEventListener("fetch", (event) => {
|
self.addEventListener("fetch", (event) => {
|
||||||
const url = new URL(event.request.url);
|
const url = new URL(event.request.url);
|
||||||
|
|
||||||
// Skip unsupported schemes (like chrome-extension://)
|
|
||||||
if (!url.protocol.startsWith("http")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Network-first strategy for API calls
|
// Network-first strategy for API calls
|
||||||
if (url.pathname.startsWith("/api/")) {
|
if (url.pathname.startsWith("/api/")) {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
@@ -80,12 +75,10 @@ self.addEventListener("fetch", (event) => {
|
|||||||
fetch(event.request)
|
fetch(event.request)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Cache the latest version of the HTML
|
// Cache the latest version of the HTML
|
||||||
if (response && response.status === 200) {
|
const responseToCache = response.clone();
|
||||||
const responseToCache = response.clone();
|
caches.open(CACHE_NAME).then((cache) => {
|
||||||
caches.open(CACHE_NAME).then((cache) => {
|
cache.put(event.request, responseToCache);
|
||||||
cache.put(event.request, responseToCache);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
372
package-lock.json
generated
372
package-lock.json
generated
@@ -1,372 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "vibetorrent-v3",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"dependencies": {
|
|
||||||
"@tailwindcss/cli": "^4.1.18",
|
|
||||||
"tailwindcss": "^4.1.18",
|
|
||||||
"tw-animate-css": "^1.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/gen-mapping": {
|
|
||||||
"version": "0.3.13",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
|
||||||
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/sourcemap-codec": "^1.5.0",
|
|
||||||
"@jridgewell/trace-mapping": "^0.3.24"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/remapping": {
|
|
||||||
"version": "2.3.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
|
|
||||||
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/gen-mapping": "^0.3.5",
|
|
||||||
"@jridgewell/trace-mapping": "^0.3.24"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/resolve-uri": {
|
|
||||||
"version": "3.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
|
||||||
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/sourcemap-codec": {
|
|
||||||
"version": "1.5.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
|
||||||
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/trace-mapping": {
|
|
||||||
"version": "0.3.31",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
|
||||||
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/resolve-uri": "^3.1.0",
|
|
||||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher": {
|
|
||||||
"version": "2.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz",
|
|
||||||
"integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"detect-libc": "^2.0.3",
|
|
||||||
"is-glob": "^4.0.3",
|
|
||||||
"node-addon-api": "^7.0.0",
|
|
||||||
"picomatch": "^4.0.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@parcel/watcher-android-arm64": "2.5.6",
|
|
||||||
"@parcel/watcher-darwin-arm64": "2.5.6",
|
|
||||||
"@parcel/watcher-darwin-x64": "2.5.6",
|
|
||||||
"@parcel/watcher-freebsd-x64": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-arm-glibc": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-arm-musl": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-arm64-glibc": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-arm64-musl": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-x64-glibc": "2.5.6",
|
|
||||||
"@parcel/watcher-linux-x64-musl": "2.5.6",
|
|
||||||
"@parcel/watcher-win32-arm64": "2.5.6",
|
|
||||||
"@parcel/watcher-win32-ia32": "2.5.6",
|
|
||||||
"@parcel/watcher-win32-x64": "2.5.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-darwin-arm64": {
|
|
||||||
"version": "2.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.6.tgz",
|
|
||||||
"integrity": "sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/cli": {
|
|
||||||
"version": "4.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.1.18.tgz",
|
|
||||||
"integrity": "sha512-sMZ+lZbDyxwjD2E0L7oRUjJ01Ffjtme5OtjvvnC+cV4CEDcbqzbp25TCpxHj6kWLU9+DlqJOiNgSOgctC2aZmg==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@parcel/watcher": "^2.5.1",
|
|
||||||
"@tailwindcss/node": "4.1.18",
|
|
||||||
"@tailwindcss/oxide": "4.1.18",
|
|
||||||
"enhanced-resolve": "^5.18.3",
|
|
||||||
"mri": "^1.2.0",
|
|
||||||
"picocolors": "^1.1.1",
|
|
||||||
"tailwindcss": "4.1.18"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"tailwindcss": "dist/index.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/node": {
|
|
||||||
"version": "4.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.18.tgz",
|
|
||||||
"integrity": "sha512-DoR7U1P7iYhw16qJ49fgXUlry1t4CpXeErJHnQ44JgTSKMaZUdf17cfn5mHchfJ4KRBZRFA/Coo+MUF5+gOaCQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/remapping": "^2.3.4",
|
|
||||||
"enhanced-resolve": "^5.18.3",
|
|
||||||
"jiti": "^2.6.1",
|
|
||||||
"lightningcss": "1.30.2",
|
|
||||||
"magic-string": "^0.30.21",
|
|
||||||
"source-map-js": "^1.2.1",
|
|
||||||
"tailwindcss": "4.1.18"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide": {
|
|
||||||
"version": "4.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.18.tgz",
|
|
||||||
"integrity": "sha512-EgCR5tTS5bUSKQgzeMClT6iCY3ToqE1y+ZB0AKldj809QXk1Y+3jB0upOYZrn9aGIzPtUsP7sX4QQ4XtjBB95A==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@tailwindcss/oxide-android-arm64": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-darwin-arm64": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-darwin-x64": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-freebsd-x64": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-linux-arm64-gnu": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-linux-arm64-musl": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-linux-x64-gnu": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-linux-x64-musl": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-wasm32-wasi": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-win32-arm64-msvc": "4.1.18",
|
|
||||||
"@tailwindcss/oxide-win32-x64-msvc": "4.1.18"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-darwin-arm64": {
|
|
||||||
"version": "4.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.18.tgz",
|
|
||||||
"integrity": "sha512-Gc2q4Qhs660bhjyBSKgq6BYvwDz4G+BuyJ5H1xfhmDR3D8HnHCmT/BSkvSL0vQLy/nkMLY20PQ2OoYMO15Jd0A==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/detect-libc": {
|
|
||||||
"version": "2.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
|
||||||
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/enhanced-resolve": {
|
|
||||||
"version": "5.19.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.19.0.tgz",
|
|
||||||
"integrity": "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"graceful-fs": "^4.2.4",
|
|
||||||
"tapable": "^2.3.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.13.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/graceful-fs": {
|
|
||||||
"version": "4.2.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
|
||||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
|
||||||
"license": "ISC"
|
|
||||||
},
|
|
||||||
"node_modules/is-extglob": {
|
|
||||||
"version": "2.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
|
||||||
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-glob": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"is-extglob": "^2.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/jiti": {
|
|
||||||
"version": "2.6.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz",
|
|
||||||
"integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"bin": {
|
|
||||||
"jiti": "lib/jiti-cli.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss": {
|
|
||||||
"version": "1.30.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.2.tgz",
|
|
||||||
"integrity": "sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ==",
|
|
||||||
"license": "MPL-2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"detect-libc": "^2.0.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"lightningcss-android-arm64": "1.30.2",
|
|
||||||
"lightningcss-darwin-arm64": "1.30.2",
|
|
||||||
"lightningcss-darwin-x64": "1.30.2",
|
|
||||||
"lightningcss-freebsd-x64": "1.30.2",
|
|
||||||
"lightningcss-linux-arm-gnueabihf": "1.30.2",
|
|
||||||
"lightningcss-linux-arm64-gnu": "1.30.2",
|
|
||||||
"lightningcss-linux-arm64-musl": "1.30.2",
|
|
||||||
"lightningcss-linux-x64-gnu": "1.30.2",
|
|
||||||
"lightningcss-linux-x64-musl": "1.30.2",
|
|
||||||
"lightningcss-win32-arm64-msvc": "1.30.2",
|
|
||||||
"lightningcss-win32-x64-msvc": "1.30.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-darwin-arm64": {
|
|
||||||
"version": "1.30.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.30.2.tgz",
|
|
||||||
"integrity": "sha512-ylTcDJBN3Hp21TdhRT5zBOIi73P6/W0qwvlFEk22fkdXchtNTOU4Qc37SkzV+EKYxLouZ6M4LG9NfZ1qkhhBWA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"license": "MPL-2.0",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/magic-string": {
|
|
||||||
"version": "0.30.21",
|
|
||||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
|
||||||
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mri": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/node-addon-api": {
|
|
||||||
"version": "7.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
|
|
||||||
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/picocolors": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
|
||||||
"license": "ISC"
|
|
||||||
},
|
|
||||||
"node_modules/picomatch": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/source-map-js": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
|
||||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tailwindcss": {
|
|
||||||
"version": "4.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
|
||||||
"integrity": "sha512-4+Z+0yiYyEtUVCScyfHCxOYP06L5Ne+JiHhY2IjR2KWMIWhJOYZKLSGZaP5HkZ8+bY0cxfzwDE5uOmzFXyIwxw==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/tapable": {
|
|
||||||
"version": "2.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz",
|
|
||||||
"integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/webpack"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tw-animate-css": {
|
|
||||||
"version": "1.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz",
|
|
||||||
"integrity": "sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/Wombosvideo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
|
||||||
"@tailwindcss/cli": "^4.1.18",
|
|
||||||
"tailwindcss": "^4.1.18",
|
|
||||||
"tw-animate-css": "^1.4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,11 +42,6 @@ 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)]
|
||||||
@@ -126,13 +121,6 @@ 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,19 +83,12 @@ 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,12 +193,8 @@ 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.is_enabled="),
|
RpcParam::from("t.activity_date_last="),
|
||||||
RpcParam::from("t.group="),
|
RpcParam::from("t.message="),
|
||||||
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
|
||||||
@@ -209,23 +205,14 @@ 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)))?;
|
||||||
|
|
||||||
let result: Vec<TorrentTracker> = rows
|
Ok(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(),
|
||||||
is_enabled: row.get(1).and_then(|s| s.parse::<i64>().ok()).unwrap_or(0) != 0,
|
status: "Unknown".to_string(),
|
||||||
group: row.get(2).and_then(|s| s.parse().ok()).unwrap_or(0),
|
message: row.get(2).cloned().unwrap_or_default(),
|
||||||
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")]
|
||||||
@@ -238,7 +225,6 @@ 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()),
|
||||||
@@ -246,11 +232,10 @@ pub async fn set_file_priority(
|
|||||||
];
|
];
|
||||||
|
|
||||||
client
|
client
|
||||||
.call("f.priority.set", ¶ms)
|
.call("f.set_priority", ¶ms)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("RPC error: {}", 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
26
test_rpc.rs
@@ -1,26 +0,0 @@
|
|||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
base_color = "neutral"
|
|
||||||
base_path_components = "backend/src/components"
|
|
||||||
Reference in New Issue
Block a user