Compare commits
63 Commits
release-20
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71456ff4d1 | ||
|
|
1a3099d926 | ||
|
|
4ef4ee8d45 | ||
|
|
253067b417 | ||
|
|
8d5edc659f | ||
|
|
c122290f37 | ||
|
|
999cef34a7 | ||
|
|
93a43d1b38 | ||
|
|
91ca6ff96f | ||
|
|
8c0d35cca5 | ||
|
|
444ea4326d | ||
|
|
401ccb69b2 | ||
|
|
9cfea2aed5 | ||
|
|
ce212cb2d6 | ||
|
|
851d79029a | ||
|
|
ab27cf3eb4 | ||
|
|
7b4c9ff336 | ||
|
|
743596d701 | ||
|
|
598f038ea6 | ||
|
|
7f8c721115 | ||
|
|
ba7f1ffd91 | ||
|
|
daa24dd7ec | ||
|
|
45271b5060 | ||
|
|
4d02bc655d | ||
|
|
3c2ba477f5 | ||
|
|
6106d1cd22 | ||
|
|
50b83ebacf | ||
|
|
566308d889 | ||
|
|
e878d1fe33 | ||
|
|
d88084fb9a | ||
|
|
f8639f2967 | ||
|
|
7129c9a8eb | ||
|
|
91202e7cf8 | ||
|
|
3c2fec8b8c | ||
|
|
ec23285a6a | ||
|
|
f075a87668 | ||
|
|
3ce980239c | ||
|
|
d00fc41010 | ||
|
|
0636020a86 | ||
|
|
322e0ab4a3 | ||
|
|
89f0a5423d | ||
|
|
80f9e5cda2 | ||
|
|
a12265573c | ||
|
|
e45ec46793 | ||
|
|
0e075d6092 | ||
|
|
dbbc722f50 | ||
|
|
dd3b3f3504 | ||
|
|
bb9e06c9ed | ||
|
|
a834d185e3 | ||
|
|
4e81565ab6 | ||
|
|
795eef4bda | ||
|
|
3ad8424d17 | ||
|
|
83feb5a5cf | ||
|
|
0dd97f3d7e | ||
|
|
bb32c1f7f6 | ||
|
|
3bb2d68a65 | ||
|
|
fe117cdaec | ||
|
|
e062a3c8cd | ||
|
|
ae2c9c934d | ||
|
|
f7e1356eae | ||
|
|
98b1f059c7 | ||
|
|
a3735d0931 | ||
|
|
55f00729ee |
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -320,9 +320,11 @@ 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",
|
||||||
@@ -343,6 +345,7 @@ 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,6 +2,9 @@
|
|||||||
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"
|
||||||
|
|||||||
@@ -46,4 +46,7 @@ governor = "0.10.4"
|
|||||||
# Leptos
|
# Leptos
|
||||||
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"
|
||||||
|
|||||||
83
backend/src/bin/test_trackers.rs
Normal file
83
backend/src/bin/test_trackers.rs
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
use shared::xmlrpc::{RtorrentClient, RpcParam, parse_multicall_response};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let mut client = None;
|
||||||
|
for path in ["127.0.0.1:8000", "0.0.0.0:8000", "localhost:8000"] {
|
||||||
|
let test_client = RtorrentClient::new(path);
|
||||||
|
match test_client.call("system.client_version", &[]).await {
|
||||||
|
Ok(res) => {
|
||||||
|
println!("SUCCESS: Connected to rTorrent at {} (Version: {})", path, res);
|
||||||
|
client = Some(test_client);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
// println!("Failed to connect to {}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let client = match client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
println!("Could not connect to rTorrent on port 8000.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut hash = String::new();
|
||||||
|
match client.call("d.multicall2", &[RpcParam::from(""), RpcParam::from("main"), RpcParam::from("d.hash=")]).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
if let Ok(rows) = parse_multicall_response(&xml) {
|
||||||
|
if let Some(row) = rows.first() {
|
||||||
|
if let Some(h) = row.first() {
|
||||||
|
hash = h.clone();
|
||||||
|
println!("Using torrent hash: {}", hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error getting torrents: {:?}", e);
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if hash.is_empty() {
|
||||||
|
println!("No torrents found to test trackers.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now test Tracker fields one by one to see which one is failing
|
||||||
|
let fields = vec![
|
||||||
|
"t.url=",
|
||||||
|
"t.is_enabled=",
|
||||||
|
"t.group=",
|
||||||
|
"t.scrape_complete=",
|
||||||
|
"t.scrape_incomplete=",
|
||||||
|
"t.scrape_downloaded=",
|
||||||
|
"t.activity_date_last=",
|
||||||
|
"t.normal_interval=",
|
||||||
|
"t.message=",
|
||||||
|
];
|
||||||
|
|
||||||
|
for field in &fields {
|
||||||
|
let params = vec![
|
||||||
|
RpcParam::from(hash.as_str()),
|
||||||
|
RpcParam::from(""),
|
||||||
|
RpcParam::from(*field),
|
||||||
|
];
|
||||||
|
|
||||||
|
print!("Testing field {:<22} : ", field);
|
||||||
|
match client.call("t.multicall", ¶ms).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
if xml.contains("faultCode") {
|
||||||
|
println!("FAILED");
|
||||||
|
} else {
|
||||||
|
println!("SUCCESS");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => println!("ERROR: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ use rust_embed::RustEmbed;
|
|||||||
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod setup;
|
pub mod setup;
|
||||||
|
pub mod notifications;
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "../frontend/dist"]
|
#[folder = "../frontend/dist"]
|
||||||
|
|||||||
54
backend/src/handlers/notifications.rs
Normal file
54
backend/src/handlers/notifications.rs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
use axum::{
|
||||||
|
extract::{State, Query},
|
||||||
|
http::StatusCode,
|
||||||
|
};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use shared::{AppEvent, SystemNotification, NotificationLevel};
|
||||||
|
use crate::AppState;
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct TorrentFinishedQuery {
|
||||||
|
pub name: String,
|
||||||
|
pub hash: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn torrent_finished_handler(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
Query(params): Query<TorrentFinishedQuery>,
|
||||||
|
) -> StatusCode {
|
||||||
|
tracing::info!("WEBHOOK: Received notification from rTorrent. Name: {:?}, Hash: {:?}", params.name, params.hash);
|
||||||
|
|
||||||
|
let torrent_name = if params.name.is_empty() || params.name == "$d.name=" {
|
||||||
|
"Bilinmeyen Torrent".to_string()
|
||||||
|
} else {
|
||||||
|
params.name.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = format!("Torrent tamamlandı: {}", torrent_name);
|
||||||
|
|
||||||
|
// 1. Send to active SSE clients (for Toast)
|
||||||
|
let notification = SystemNotification {
|
||||||
|
level: NotificationLevel::Success,
|
||||||
|
message: message.clone(),
|
||||||
|
};
|
||||||
|
let _ = state.event_bus.send(AppEvent::Notification(notification));
|
||||||
|
|
||||||
|
// 2. Send Web Push Notification (for Background)
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
|
{
|
||||||
|
let push_store = state.push_store.clone();
|
||||||
|
let title = "Torrent Tamamlandı".to_string();
|
||||||
|
let body = message;
|
||||||
|
let name_for_log = torrent_name.clone();
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
tracing::info!("Attempting to send Web Push notification for torrent: {}", name_for_log);
|
||||||
|
match crate::push::send_push_notification(&push_store, &title, &body).await {
|
||||||
|
Ok(_) => tracing::info!("Web Push notification task completed for: {}", name_for_log),
|
||||||
|
Err(e) => tracing::error!("Failed to send Web Push notification for {}: {:?}", name_for_log, e),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusCode::OK
|
||||||
|
}
|
||||||
@@ -60,6 +60,7 @@ async fn auth_middleware(
|
|||||||
|| path.starts_with("/api/server_fns/get_setup_status")
|
|| path.starts_with("/api/server_fns/get_setup_status")
|
||||||
|| path.starts_with("/api/server_fns/Setup")
|
|| path.starts_with("/api/server_fns/Setup")
|
||||||
|| path.starts_with("/api/server_fns/setup")
|
|| path.starts_with("/api/server_fns/setup")
|
||||||
|
|| path.starts_with("/api/internal/")
|
||||||
|| path.starts_with("/swagger-ui")
|
|| path.starts_with("/swagger-ui")
|
||||||
|| path.starts_with("/api-docs")
|
|| path.starts_with("/api-docs")
|
||||||
|| !path.starts_with("/api/")
|
|| !path.starts_with("/api/")
|
||||||
@@ -242,12 +243,14 @@ 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::warn!(
|
tracing::error!(
|
||||||
"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::warn!(
|
tracing::error!(
|
||||||
"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);
|
||||||
@@ -258,7 +261,11 @@ 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) => tracing::error!("Socket exists but failed to connect to rTorrent: {}", e),
|
Err(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +320,7 @@ async fn main() {
|
|||||||
let loop_interval = if active_clients > 0 {
|
let loop_interval = if active_clients > 0 {
|
||||||
Duration::from_secs(1)
|
Duration::from_secs(1)
|
||||||
} else {
|
} else {
|
||||||
Duration::from_secs(30)
|
Duration::from_secs(60)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. Fetch Torrents
|
// 1. Fetch Torrents
|
||||||
@@ -434,6 +441,7 @@ async fn main() {
|
|||||||
let db_for_ctx = db.clone();
|
let db_for_ctx = db.clone();
|
||||||
let app = app
|
let app = app
|
||||||
.route("/api/events", get(sse::sse_handler))
|
.route("/api/events", get(sse::sse_handler))
|
||||||
|
.route("/api/internal/torrent-finished", post(handlers::notifications::torrent_finished_handler))
|
||||||
.route("/api/server_fns/{*fn_name}", post({
|
.route("/api/server_fns/{*fn_name}", post({
|
||||||
let scgi_path = scgi_path_for_ctx.clone();
|
let scgi_path = scgi_path_for_ctx.clone();
|
||||||
let db = db_for_ctx.clone();
|
let db = db_for_ctx.clone();
|
||||||
|
|||||||
@@ -191,11 +191,21 @@ pub async fn send_push_notification(
|
|||||||
tracing::debug!("Push notification sent to: {}", subscription.endpoint);
|
tracing::debug!("Push notification sent to: {}", subscription.endpoint);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("Failed to send push notification to {}: {}", subscription.endpoint, e);
|
let err_msg = format!("{:?}", e);
|
||||||
|
tracing::error!("Delivery failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
|
// Always remove on delivery failure (Gone, Unauthorized, etc.)
|
||||||
|
tracing::info!("Removing problematic subscription after delivery failure: {}", subscription.endpoint);
|
||||||
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => tracing::error!("Failed to build push message: {}", e),
|
Err(e) => {
|
||||||
|
let err_msg = format!("{:?}", e);
|
||||||
|
tracing::error!("Encryption/Build failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
|
// Always remove on encryption failure
|
||||||
|
tracing::info!("Removing problematic subscription after encryption failure: {}", subscription.endpoint);
|
||||||
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => tracing::error!("Failed to build VAPID signature: {}", e),
|
Err(e) => tracing::error!("Failed to build VAPID signature: {}", e),
|
||||||
|
|||||||
@@ -51,6 +51,21 @@ mod fields {
|
|||||||
|
|
||||||
pub const IDX_LABEL: usize = 12;
|
pub const IDX_LABEL: usize = 12;
|
||||||
pub const CMD_LABEL: &str = "d.custom1=";
|
pub const CMD_LABEL: &str = "d.custom1=";
|
||||||
|
|
||||||
|
pub const IDX_RATIO: usize = 13;
|
||||||
|
pub const CMD_RATIO: &str = "d.ratio=";
|
||||||
|
|
||||||
|
pub const IDX_UPLOADED: usize = 14;
|
||||||
|
pub const CMD_UPLOADED: &str = "d.up.total=";
|
||||||
|
|
||||||
|
pub const IDX_WASTED: usize = 15;
|
||||||
|
pub const CMD_WASTED: &str = "d.skip.total=";
|
||||||
|
|
||||||
|
pub const IDX_SAVE_PATH: usize = 16;
|
||||||
|
pub const CMD_SAVE_PATH: &str = "d.base_path=";
|
||||||
|
|
||||||
|
pub const IDX_FREE_DISK: usize = 17;
|
||||||
|
pub const CMD_FREE_DISK: &str = "d.free_diskspace=";
|
||||||
}
|
}
|
||||||
|
|
||||||
use fields::*;
|
use fields::*;
|
||||||
@@ -72,6 +87,11 @@ const RTORRENT_FIELDS: &[&str] = &[
|
|||||||
CMD_CREATION_DATE,
|
CMD_CREATION_DATE,
|
||||||
CMD_HASHING,
|
CMD_HASHING,
|
||||||
CMD_LABEL,
|
CMD_LABEL,
|
||||||
|
CMD_RATIO,
|
||||||
|
CMD_UPLOADED,
|
||||||
|
CMD_WASTED,
|
||||||
|
CMD_SAVE_PATH,
|
||||||
|
CMD_FREE_DISK,
|
||||||
];
|
];
|
||||||
|
|
||||||
fn parse_long(s: Option<&String>) -> i64 {
|
fn parse_long(s: Option<&String>) -> i64 {
|
||||||
@@ -98,6 +118,11 @@ fn from_rtorrent_row(row: Vec<String>) -> Torrent {
|
|||||||
let added_date = parse_long(row.get(IDX_CREATION_DATE));
|
let added_date = parse_long(row.get(IDX_CREATION_DATE));
|
||||||
let is_hashing = parse_long(row.get(IDX_HASHING));
|
let is_hashing = parse_long(row.get(IDX_HASHING));
|
||||||
let label_raw = parse_string(row.get(IDX_LABEL));
|
let label_raw = parse_string(row.get(IDX_LABEL));
|
||||||
|
let ratio = parse_long(row.get(IDX_RATIO)) as f64 / 1000.0;
|
||||||
|
let uploaded = parse_long(row.get(IDX_UPLOADED));
|
||||||
|
let wasted = parse_long(row.get(IDX_WASTED));
|
||||||
|
let save_path = parse_string(row.get(IDX_SAVE_PATH));
|
||||||
|
let free_disk_space = parse_long(row.get(IDX_FREE_DISK));
|
||||||
|
|
||||||
let label = if label_raw.is_empty() {
|
let label = if label_raw.is_empty() {
|
||||||
None
|
None
|
||||||
@@ -144,6 +169,11 @@ fn from_rtorrent_row(row: Vec<String>) -> Torrent {
|
|||||||
error_message: message,
|
error_message: message,
|
||||||
added_date,
|
added_date,
|
||||||
label,
|
label,
|
||||||
|
ratio,
|
||||||
|
uploaded,
|
||||||
|
wasted,
|
||||||
|
save_path,
|
||||||
|
free_disk_space,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ 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 -->
|
||||||
<script data-trunk rel="rust" src="Cargo.toml" data-wasm-opt="0" data-preload="false"></script>
|
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="0" />
|
||||||
<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,70 +3,76 @@
|
|||||||
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--background: 0 0% 100%;
|
--radius: 0.625rem;
|
||||||
--foreground: 240 10% 3.9%;
|
--background: oklch(1 0 0);
|
||||||
--card: 0 0% 100%;
|
--foreground: oklch(0.145 0 0);
|
||||||
--card-foreground: 240 10% 3.9%;
|
--card: oklch(1 0 0);
|
||||||
--popover: 0 0% 100%;
|
--card-foreground: oklch(0.145 0 0);
|
||||||
--popover-foreground: 240 10% 3.9%;
|
--popover: oklch(1 0 0);
|
||||||
--primary: 240 5.9% 10%;
|
--popover-foreground: oklch(0.145 0 0);
|
||||||
--primary-foreground: 0 0% 98%;
|
--primary: oklch(0.205 0 0);
|
||||||
--secondary: 240 4.8% 95.9%;
|
--primary-foreground: oklch(0.985 0 0);
|
||||||
--secondary-foreground: 240 5.9% 10%;
|
--secondary: oklch(0.97 0 0);
|
||||||
--muted: 240 4.8% 95.9%;
|
--secondary-foreground: oklch(0.205 0 0);
|
||||||
--muted-foreground: 240 3.8% 46.1%;
|
--muted: oklch(0.97 0 0);
|
||||||
--accent: 240 4.8% 95.9%;
|
--muted-foreground: oklch(0.556 0 0);
|
||||||
--accent-foreground: 240 5.9% 10%;
|
--accent: oklch(0.97 0 0);
|
||||||
--destructive: 0 84.2% 60.2%;
|
--accent-foreground: oklch(0.205 0 0);
|
||||||
--destructive-foreground: 0 0% 98%;
|
--destructive: oklch(0.577 0.245 27.325);
|
||||||
--border: 240 5.9% 90%;
|
--border: oklch(0.922 0 0);
|
||||||
--input: 240 5.9% 90%;
|
--input: oklch(0.922 0 0);
|
||||||
--ring: 240 5.9% 10%;
|
--ring: oklch(0.708 0 0);
|
||||||
--radius: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
--background: 240 10% 3.9%;
|
--background: oklch(0.145 0 0);
|
||||||
--foreground: 0 0% 98%;
|
--foreground: oklch(0.985 0 0);
|
||||||
--card: 240 10% 3.9%;
|
--card: oklch(0.205 0 0);
|
||||||
--card-foreground: 0 0% 98%;
|
--card-foreground: oklch(0.985 0 0);
|
||||||
--popover: 240 10% 3.9%;
|
--popover: oklch(0.205 0 0);
|
||||||
--popover-foreground: 0 0% 98%;
|
--popover-foreground: oklch(0.985 0 0);
|
||||||
--primary: 0 0% 98%;
|
--primary: oklch(0.922 0 0);
|
||||||
--primary-foreground: 240 5.9% 10%;
|
--primary-foreground: oklch(0.205 0 0);
|
||||||
--secondary: 240 3.7% 15.9%;
|
--secondary: oklch(0.269 0 0);
|
||||||
--secondary-foreground: 0 0% 98%;
|
--secondary-foreground: oklch(0.985 0 0);
|
||||||
--muted: 240 3.7% 15.9%;
|
--muted: oklch(0.269 0 0);
|
||||||
--muted-foreground: 240 5% 64.9%;
|
--muted-foreground: oklch(0.708 0 0);
|
||||||
--accent: 240 3.7% 15.9%;
|
--accent: oklch(0.269 0 0);
|
||||||
--accent-foreground: 0 0% 98%;
|
--accent-foreground: oklch(0.985 0 0);
|
||||||
--destructive: 0 62.8% 30.6%;
|
--destructive: oklch(0.704 0.191 22.216);
|
||||||
--destructive-foreground: 0 0% 98%;
|
--border: oklch(1 0 0 / 10%);
|
||||||
--border: 240 3.7% 15.9%;
|
--input: oklch(1 0 0 / 15%);
|
||||||
--input: 240 3.7% 15.9%;
|
--ring: oklch(0.556 0 0);
|
||||||
--ring: 240 4.9% 83.9%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--color-background: hsl(var(--background));
|
--animate-shimmer: shimmer 2s infinite;
|
||||||
--color-foreground: hsl(var(--foreground));
|
|
||||||
--color-card: hsl(var(--card));
|
@keyframes shimmer {
|
||||||
--color-card-foreground: hsl(var(--card-foreground));
|
100% {
|
||||||
--color-popover: hsl(var(--popover));
|
transform: translateX(100%);
|
||||||
--color-popover-foreground: hsl(var(--popover-foreground));
|
}
|
||||||
--color-primary: hsl(var(--primary));
|
}
|
||||||
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
||||||
--color-secondary: hsl(var(--secondary));
|
--color-background: var(--background);
|
||||||
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
--color-foreground: var(--foreground);
|
||||||
--color-muted: hsl(var(--muted));
|
--color-card: var(--card);
|
||||||
--color-muted-foreground: hsl(var(--muted-foreground));
|
--color-card-foreground: var(--card-foreground);
|
||||||
--color-accent: hsl(var(--accent));
|
--color-popover: var(--popover);
|
||||||
--color-accent-foreground: hsl(var(--accent-foreground));
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
--color-destructive: hsl(var(--destructive));
|
--color-primary: var(--primary);
|
||||||
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
--color-border: hsl(var(--border));
|
--color-secondary: var(--secondary);
|
||||||
--color-input: hsl(var(--input));
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
--color-ring: hsl(var(--ring));
|
--color-muted: var(--muted);
|
||||||
|
--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);
|
||||||
@@ -77,6 +83,7 @@
|
|||||||
* {
|
* {
|
||||||
@apply border-border outline-ring/50;
|
@apply border-border outline-ring/50;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
@@ -89,4 +96,4 @@
|
|||||||
dialog {
|
dialog {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ use crate::components::auth::setup::Setup;
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use leptos_router::components::{Router, Routes, Route};
|
use leptos_router::components::{Router, Routes, Route};
|
||||||
use leptos_router::hooks::use_navigate;
|
use leptos_router::hooks::{use_navigate, use_location};
|
||||||
use crate::components::ui::toast::Toaster;
|
use crate::components::ui::toast::Toaster;
|
||||||
use crate::components::hooks::use_theme_mode::ThemeMode;
|
use crate::components::hooks::use_theme_mode::ThemeMode;
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ pub fn App() -> impl IntoView {
|
|||||||
fn InnerApp() -> impl IntoView {
|
fn InnerApp() -> impl IntoView {
|
||||||
crate::store::provide_torrent_store();
|
crate::store::provide_torrent_store();
|
||||||
let store = use_context::<crate::store::TorrentStore>();
|
let store = use_context::<crate::store::TorrentStore>();
|
||||||
|
let _loc = use_location();
|
||||||
|
|
||||||
let is_loading = signal(true);
|
let is_loading = signal(true);
|
||||||
let is_authenticated = signal(false);
|
let is_authenticated = signal(false);
|
||||||
@@ -48,14 +49,10 @@ 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;
|
||||||
@@ -67,15 +64,12 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -110,7 +104,6 @@ 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());
|
||||||
}
|
}
|
||||||
@@ -134,10 +127,8 @@ 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,5 +1,9 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use crate::components::ui::context_menu::*;
|
use crate::components::ui::context_menu::{
|
||||||
|
ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger,
|
||||||
|
};
|
||||||
|
use crate::components::ui::button_action::ButtonAction;
|
||||||
|
use crate::components::ui::button::ButtonVariant;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn TorrentContextMenu(
|
pub fn TorrentContextMenu(
|
||||||
@@ -7,72 +11,61 @@ pub fn TorrentContextMenu(
|
|||||||
torrent_hash: String,
|
torrent_hash: String,
|
||||||
on_action: Callback<(String, String)>,
|
on_action: Callback<(String, String)>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let hash = StoredValue::new(torrent_hash);
|
let hash_c1 = torrent_hash.clone();
|
||||||
|
let hash_c2 = torrent_hash.clone();
|
||||||
|
let hash_c3 = torrent_hash.clone();
|
||||||
|
let hash_c4 = torrent_hash.clone();
|
||||||
|
|
||||||
let menu_action = move |action: &'static str| {
|
let on_action_stored = StoredValue::new(on_action);
|
||||||
on_action.run((action.to_string(), hash.get_value()));
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenuTrigger>
|
<ContextMenuTrigger>
|
||||||
{children()}
|
{children()}
|
||||||
</ContextMenuTrigger>
|
</ContextMenuTrigger>
|
||||||
|
<ContextMenuContent class="w-56 p-1.5">
|
||||||
<ContextMenuContent class="w-56">
|
<ContextMenuItem on:click={let h = hash_c1; move |_| {
|
||||||
<ContextMenuAction
|
on_action_stored.get_value().run(("start".to_string(), h.clone()));
|
||||||
class="px-2 py-1.5 hover:bg-accent hover:text-accent-foreground rounded-sm"
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
on:click=move |_| menu_action("start")
|
}}>
|
||||||
>
|
"Başlat"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 h-4 w-4 opacity-70">
|
</ContextMenuItem>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z" />
|
<ContextMenuItem on:click={let h = hash_c2; move |_| {
|
||||||
</svg>
|
on_action_stored.get_value().run(("stop".to_string(), h.clone()));
|
||||||
"Start"
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
</ContextMenuAction>
|
}}>
|
||||||
|
"Durdur"
|
||||||
|
</ContextMenuItem>
|
||||||
|
|
||||||
|
<div class="my-1.5 h-px bg-border/50" />
|
||||||
|
|
||||||
|
// --- Modern Hold-to-Action Buttons ---
|
||||||
|
<div class="space-y-1">
|
||||||
|
<ButtonAction
|
||||||
|
variant=ButtonVariant::Ghost
|
||||||
|
class="w-full justify-start h-8 px-2 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive transition-none"
|
||||||
|
hold_duration=800
|
||||||
|
on_action={let h = hash_c3; move || {
|
||||||
|
on_action_stored.get_value().run(("delete".to_string(), h.clone()));
|
||||||
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
"Sil (Basılı Tut)"
|
||||||
|
</ButtonAction>
|
||||||
|
|
||||||
<ContextMenuAction
|
<ButtonAction
|
||||||
class="px-2 py-1.5 hover:bg-accent hover:text-accent-foreground rounded-sm"
|
variant=ButtonVariant::Destructive
|
||||||
on:click=move |_| menu_action("stop")
|
class="w-full justify-start h-8 px-2 text-xs font-bold"
|
||||||
>
|
hold_duration=1200
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 h-4 w-4 opacity-70">
|
on_action={let h = hash_c4; move || {
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25v13.5m-7.5-13.5v13.5" />
|
on_action_stored.get_value().run(("delete_with_data".to_string(), h.clone()));
|
||||||
</svg>
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
"Stop"
|
}}
|
||||||
</ContextMenuAction>
|
>
|
||||||
|
"Verilerle Sil (Basılı Tut)"
|
||||||
<ContextMenuAction
|
</ButtonAction>
|
||||||
class="px-2 py-1.5 hover:bg-accent hover:text-accent-foreground rounded-sm"
|
</div>
|
||||||
on:click=move |_| menu_action("recheck")
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 h-4 w-4 opacity-70">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" />
|
|
||||||
</svg>
|
|
||||||
"Recheck"
|
|
||||||
</ContextMenuAction>
|
|
||||||
|
|
||||||
<div class="-mx-1 my-1 h-px bg-border" />
|
|
||||||
|
|
||||||
<ContextMenuAction
|
|
||||||
class="px-2 py-1.5 text-destructive hover:bg-destructive/10 hover:text-destructive rounded-sm"
|
|
||||||
on:click=move |_| menu_action("delete")
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 h-4 w-4 opacity-70">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.164h-2.34c-1.18 0-2.09.984-2.09 2.164v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
|
|
||||||
</svg>
|
|
||||||
"Remove"
|
|
||||||
</ContextMenuAction>
|
|
||||||
|
|
||||||
<ContextMenuHoldAction
|
|
||||||
class="text-destructive hover:bg-destructive/10 hover:text-destructive"
|
|
||||||
on_hold_complete=move |_| menu_action("delete_with_data")
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 h-4 w-4 opacity-70">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m6 4.125l2.25 2.25m0 0l2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25-2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
|
|
||||||
</svg>
|
|
||||||
"Remove with Data"
|
|
||||||
<span class="ml-auto text-[10px] opacity-50">"Hold"</span>
|
|
||||||
</ContextMenuHoldAction>
|
|
||||||
</ContextMenuContent>
|
</ContextMenuContent>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
91
frontend/src/components/demos/demo_shimmer.rs
Normal file
91
frontend/src/components/demos/demo_shimmer.rs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
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
frontend/src/components/demos/mod.rs
Normal file
1
frontend/src/components/demos/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod demo_shimmer;
|
||||||
@@ -1,5 +1,31 @@
|
|||||||
use leptos::prelude::*;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
pub fn use_random_id_for(prefix: &str) -> String {
|
const PREFIX: &str = "rust_ui"; // Must NOT contain "/" or "-"
|
||||||
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()
|
||||||
|
}
|
||||||
@@ -6,24 +6,12 @@ pub fn Footer() -> impl IntoView {
|
|||||||
let year = chrono::Local::now().format("%Y").to_string();
|
let year = chrono::Local::now().format("%Y").to_string();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<footer class="mt-auto px-4 py-6 md:px-8">
|
<footer class="mt-auto pb-6 px-4">
|
||||||
<Separator class="mb-6 opacity-50" />
|
<Separator class="mb-4 opacity-30" />
|
||||||
<div class="flex flex-col items-center justify-between gap-4 md:flex-row">
|
<div class="flex items-center justify-center gap-2 text-[10px] uppercase tracking-widest text-muted-foreground/60 font-medium">
|
||||||
<p class="text-center text-sm leading-loose text-muted-foreground md:text-left">
|
<span>{format!("© {} VibeTorrent", year)}</span>
|
||||||
{format!("© {} VibeTorrent. Tüm hakları saklıdır.", year)}
|
<span class="size-1 rounded-full bg-muted-foreground/30" />
|
||||||
</p>
|
<span>"v3.0.0-beta"</span>
|
||||||
<div class="flex items-center gap-4 text-sm font-medium text-muted-foreground">
|
|
||||||
<a
|
|
||||||
href="https://git.karatatar.com/admin/vibetorrent"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
class="underline underline-offset-4 hover:text-foreground transition-colors"
|
|
||||||
>
|
|
||||||
"Gitea"
|
|
||||||
</a>
|
|
||||||
<span class="size-1 rounded-full bg-muted-foreground/30" />
|
|
||||||
<span class="text-[10px] tracking-widest uppercase opacity-70">"v3.0.0-beta"</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use leptos::task::spawn_local;
|
|||||||
use crate::components::ui::sidenav::*;
|
use crate::components::ui::sidenav::*;
|
||||||
use crate::components::ui::button::{Button, ButtonVariant, ButtonSize};
|
use crate::components::ui::button::{Button, ButtonVariant, ButtonSize};
|
||||||
use crate::components::ui::theme_toggle::ThemeToggle;
|
use crate::components::ui::theme_toggle::ThemeToggle;
|
||||||
|
use crate::components::ui::switch::Switch;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Sidebar() -> impl IntoView {
|
pub fn Sidebar() -> impl IntoView {
|
||||||
@@ -65,6 +66,19 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
username().chars().next().unwrap_or('?').to_uppercase().to_string()
|
username().chars().next().unwrap_or('?').to_uppercase().to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let on_push_toggle = move |checked: bool| {
|
||||||
|
spawn_local(async move {
|
||||||
|
if checked {
|
||||||
|
crate::store::subscribe_to_push_notifications().await;
|
||||||
|
} else {
|
||||||
|
crate::store::unsubscribe_from_push_notifications().await;
|
||||||
|
}
|
||||||
|
if let Ok(enabled) = crate::store::is_push_subscribed().await {
|
||||||
|
store.push_enabled.set(enabled);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<SidenavHeader>
|
<SidenavHeader>
|
||||||
<div class="flex items-center gap-2 px-2 py-4">
|
<div class="flex items-center gap-2 px-2 py-4">
|
||||||
@@ -133,35 +147,49 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
</SidenavContent>
|
</SidenavContent>
|
||||||
|
|
||||||
<SidenavFooter>
|
<SidenavFooter>
|
||||||
<div class="flex items-center gap-3 p-2 rounded-lg border bg-muted/30 shadow-xs overflow-hidden">
|
<div class="flex flex-col gap-4 p-4">
|
||||||
<div class="h-8 w-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-xs font-medium shrink-0 border border-primary-foreground/10">
|
// Push Notification Toggle
|
||||||
{first_letter}
|
<div class="flex items-center justify-between px-2 py-1 bg-muted/20 rounded-md border border-border/50">
|
||||||
|
<div class="flex flex-col gap-0.5">
|
||||||
|
<span class="text-[10px] font-bold uppercase tracking-wider text-foreground/70">"Bildirimler"</span>
|
||||||
|
<span class="text-[9px] text-muted-foreground">"Web Push"</span>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked=Signal::from(store.push_enabled)
|
||||||
|
on_checked_change=Callback::new(on_push_toggle)
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 overflow-hidden">
|
|
||||||
<div class="font-medium text-[11px] truncate text-foreground leading-tight">{username}</div>
|
<div class="flex items-center gap-3 p-2 rounded-lg border bg-muted/30 shadow-xs overflow-hidden">
|
||||||
<div class="text-[9px] text-muted-foreground truncate opacity-70">"Yönetici"</div>
|
<div class="h-8 w-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-xs font-medium shrink-0 border border-primary-foreground/10">
|
||||||
</div>
|
{first_letter}
|
||||||
|
</div>
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex-1 overflow-hidden">
|
||||||
<ThemeToggle />
|
<div class="font-medium text-[11px] truncate text-foreground leading-tight">{username}</div>
|
||||||
|
<div class="text-[9px] text-muted-foreground truncate opacity-70">"Yönetici"</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button
|
<div class="flex items-center gap-1">
|
||||||
variant=ButtonVariant::Ghost
|
<ThemeToggle />
|
||||||
size=ButtonSize::Icon
|
|
||||||
class="size-7 text-destructive hover:bg-destructive/10"
|
<Button
|
||||||
on:click=move |_| {
|
variant=ButtonVariant::Ghost
|
||||||
spawn_local(async move {
|
size=ButtonSize::Icon
|
||||||
if shared::server_fns::auth::logout().await.is_ok() {
|
class="size-7 text-destructive hover:bg-destructive/10"
|
||||||
let window = web_sys::window().expect("window should exist");
|
on:click=move |_| {
|
||||||
let _ = window.location().set_href("/login");
|
spawn_local(async move {
|
||||||
}
|
if shared::server_fns::auth::logout().await.is_ok() {
|
||||||
});
|
let window = web_sys::window().expect("window should exist");
|
||||||
}
|
let _ = window.location().set_href("/login");
|
||||||
>
|
}
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
});
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15M12 9l-3 3m0 0l3 3m-3-3h12.75" />
|
}
|
||||||
</svg>
|
>
|
||||||
</Button>
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15M12 9l-3 3m0 0l3 3m-3-3h12.75" />
|
||||||
|
</svg>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SidenavFooter>
|
</SidenavFooter>
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use icons::PanelLeft;
|
use icons::{PanelLeft, Plus};
|
||||||
use crate::components::torrent::add_torrent::AddTorrentDialog;
|
use crate::components::torrent::add_torrent::AddTorrentDialogContent;
|
||||||
use crate::components::ui::button::{Button, ButtonVariant, ButtonSize};
|
use crate::components::ui::button::{ButtonVariant, ButtonSize};
|
||||||
use crate::components::ui::sheet::{Sheet, SheetContent, SheetTrigger, SheetDirection};
|
use crate::components::ui::sheet::{Sheet, SheetContent, SheetTrigger, SheetDirection};
|
||||||
|
use crate::components::ui::dialog::{Dialog, DialogContent, DialogTrigger};
|
||||||
use crate::components::layout::sidebar::Sidebar;
|
use crate::components::layout::sidebar::Sidebar;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Toolbar() -> impl IntoView {
|
pub fn Toolbar() -> impl IntoView {
|
||||||
let show_add_modal = signal(false);
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="flex min-h-14 h-auto items-center border-b border-border bg-background px-4" style="padding-top: env(safe-area-inset-top);">
|
<div class="flex min-h-14 h-auto items-center border-b border-border bg-background px-4" style="padding-top: env(safe-area-inset-top);">
|
||||||
// Sol kısım: Menü butonu (Mobil) + Add Torrent
|
// Sol kısım: Menü butonu (Mobil) + Add Torrent
|
||||||
@@ -33,25 +32,24 @@ pub fn Toolbar() -> impl IntoView {
|
|||||||
</Sheet>
|
</Sheet>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
<Dialog>
|
||||||
on:click=move |_| show_add_modal.1.set(true)
|
<DialogTrigger
|
||||||
class="gap-2"
|
variant=ButtonVariant::Default
|
||||||
>
|
class="gap-2"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4 md:w-5 md:h-5">
|
>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
<Plus class="w-4 h-4 md:w-5 md:h-5" />
|
||||||
</svg>
|
<span class="hidden sm:inline">"Add Torrent"</span>
|
||||||
<span class="hidden sm:inline">"Add Torrent"</span>
|
<span class="sm:hidden">"Add"</span>
|
||||||
<span class="sm:hidden">"Add"</span>
|
</DialogTrigger>
|
||||||
</Button>
|
<DialogContent id="add-torrent-dialog" class="sm:max-w-[425px]">
|
||||||
|
<AddTorrentDialogContent />
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
// Sağ kısım boş
|
// Sağ kısım boş
|
||||||
<div class="flex flex-1 items-center justify-end gap-2">
|
<div class="flex flex-1 items-center justify-end gap-2">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Show when=move || show_add_modal.0.get()>
|
|
||||||
<AddTorrentDialog on_close=Callback::new(move |()| show_add_modal.1.set(false)) />
|
|
||||||
</Show>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ 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,17 +1,15 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use crate::components::ui::input::{Input, InputType};
|
use crate::components::ui::input::{Input, InputType};
|
||||||
use crate::store::TorrentStore;
|
|
||||||
use crate::api;
|
use crate::api;
|
||||||
|
use crate::components::ui::button::Button;
|
||||||
use crate::components::ui::button::{Button, ButtonVariant};
|
use crate::components::ui::dialog::{
|
||||||
|
DialogBody, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose
|
||||||
|
};
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn AddTorrentDialog(
|
pub fn AddTorrentDialogContent() -> impl IntoView {
|
||||||
on_close: Callback<()>,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let _store = use_context::<TorrentStore>().expect("TorrentStore not provided");
|
|
||||||
|
|
||||||
let uri = RwSignal::new(String::new());
|
let uri = RwSignal::new(String::new());
|
||||||
let is_loading = signal(false);
|
let is_loading = signal(false);
|
||||||
let error_msg = signal(Option::<String>::None);
|
let error_msg = signal(Option::<String>::None);
|
||||||
@@ -21,20 +19,30 @@ pub fn AddTorrentDialog(
|
|||||||
let uri_val = uri.get();
|
let uri_val = uri.get();
|
||||||
|
|
||||||
if uri_val.is_empty() {
|
if uri_val.is_empty() {
|
||||||
error_msg.1.set(Some("Please enter a Magnet URI or URL".to_string()));
|
error_msg.1.set(Some("Lütfen bir Magnet URI veya URL girin".to_string()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_loading.1.set(true);
|
is_loading.1.set(true);
|
||||||
error_msg.1.set(None);
|
error_msg.1.set(None);
|
||||||
|
|
||||||
let on_close = on_close.clone();
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match api::torrent::add(&uri_val).await {
|
match api::torrent::add(&uri_val).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
log::info!("Torrent added successfully");
|
log::info!("Torrent added successfully");
|
||||||
crate::store::toast_success("Torrent başarıyla eklendi");
|
crate::store::toast_success("Torrent başarıyla eklendi");
|
||||||
on_close.run(());
|
|
||||||
|
// Programmatically close the dialog by triggering the close button
|
||||||
|
if let Some(doc) = web_sys::window().and_then(|w| w.document()) {
|
||||||
|
if let Some(el) = doc.get_element_by_id("add-torrent-dialog") {
|
||||||
|
if let Some(close_btn) = el.query_selector("[data-dialog-close]").ok().flatten() {
|
||||||
|
let _ = close_btn.dyn_into::<web_sys::HtmlElement>().map(|btn| btn.click());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uri.set(String::new());
|
||||||
|
is_loading.1.set(false);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to add torrent: {:?}", e);
|
log::error!("Failed to add torrent: {:?}", e);
|
||||||
@@ -45,29 +53,16 @@ pub fn AddTorrentDialog(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let handle_backdrop = {
|
|
||||||
let on_close = on_close.clone();
|
|
||||||
move |e: web_sys::MouseEvent| {
|
|
||||||
e.stop_propagation();
|
|
||||||
on_close.run(());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
// Backdrop overlay
|
<DialogBody>
|
||||||
<div
|
<DialogHeader>
|
||||||
class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm"
|
<DialogTitle>"Add Torrent"</DialogTitle>
|
||||||
on:click=handle_backdrop
|
<DialogDescription>
|
||||||
/>
|
"Enter a Magnet link or a .torrent file URL."
|
||||||
// Dialog panel
|
</DialogDescription>
|
||||||
<div class="fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-card p-6 shadow-lg rounded-lg sm:max-w-[425px]">
|
</DialogHeader>
|
||||||
// Header
|
|
||||||
<div class="flex flex-col space-y-1.5 text-center sm:text-left">
|
|
||||||
<h2 class="text-lg font-semibold leading-none tracking-tight">"Add Torrent"</h2>
|
|
||||||
<p class="text-sm text-muted-foreground">"Enter a Magnet link or a .torrent file URL."</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form on:submit=handle_submit class="space-y-4">
|
<form on:submit=handle_submit class="space-y-4 pt-4">
|
||||||
<Input
|
<Input
|
||||||
r#type=InputType::Text
|
r#type=InputType::Text
|
||||||
placeholder="magnet:?xt=urn:btih:..."
|
placeholder="magnet:?xt=urn:btih:..."
|
||||||
@@ -81,14 +76,10 @@ pub fn AddTorrentDialog(
|
|||||||
</div>
|
</div>
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<div class="flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2">
|
<DialogFooter class="pt-2">
|
||||||
<Button
|
<DialogClose>
|
||||||
variant=ButtonVariant::Ghost
|
|
||||||
attr:r#type="button"
|
|
||||||
on:click=move |_| on_close.run(())
|
|
||||||
>
|
|
||||||
"Cancel"
|
"Cancel"
|
||||||
</Button>
|
</DialogClose>
|
||||||
<Button
|
<Button
|
||||||
attr:r#type="submit"
|
attr:r#type="submit"
|
||||||
attr:disabled=move || is_loading.0.get()
|
attr:disabled=move || is_loading.0.get()
|
||||||
@@ -102,21 +93,8 @@ pub fn AddTorrentDialog(
|
|||||||
leptos::either::Either::Right(view! { "Add" })
|
leptos::either::Either::Right(view! { "Add" })
|
||||||
}}
|
}}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</DialogFooter>
|
||||||
</form>
|
</form>
|
||||||
|
</DialogBody>
|
||||||
// Close button (X)
|
|
||||||
<Button
|
|
||||||
variant=ButtonVariant::Ghost
|
|
||||||
class="absolute right-2 top-2 size-8 p-0 opacity-70 hover:opacity-100"
|
|
||||||
on:click=move |_| on_close.run(())
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4">
|
|
||||||
<path d="M18 6 6 18"></path>
|
|
||||||
<path d="m6 6 12 12"></path>
|
|
||||||
</svg>
|
|
||||||
<span class="sr-only">"Close"</span>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
260
frontend/src/components/torrent/details.rs
Normal file
260
frontend/src/components/torrent/details.rs
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
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() }
|
||||||
|
}
|
||||||
216
frontend/src/components/torrent/files.rs
Normal file
216
frontend/src/components/torrent/files.rs
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
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,2 +1,5 @@
|
|||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod add_torrent;
|
pub mod add_torrent;
|
||||||
|
pub mod details;
|
||||||
|
pub mod files;
|
||||||
|
pub mod trackers;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use icons::{ArrowUpDown, Inbox, Settings2, Play, Square, Trash2, Ellipsis, ArrowUp, ArrowDown, Check, ListFilter};
|
use icons::{ArrowUpDown, Inbox, Settings2, Play, Square, Trash2, Ellipsis, ArrowUp, ArrowDown, Check, ListFilter};
|
||||||
use crate::store::{get_action_messages, show_toast};
|
use crate::store::{get_action_messages, show_toast};
|
||||||
@@ -217,7 +218,9 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="h-full bg-background relative flex flex-col overflow-hidden px-4 py-4 gap-4">
|
<div class="h-full bg-background flex flex-row overflow-hidden">
|
||||||
|
// 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">
|
||||||
@@ -230,70 +233,76 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Show when=move || has_selection.get()>
|
<Show when=move || has_selection.get()>
|
||||||
<DropdownMenu>
|
<div class="flex items-center gap-2">
|
||||||
<DropdownMenuTrigger class="w-[140px] h-9 gap-2">
|
<DropdownMenu>
|
||||||
<Ellipsis class="size-4" />
|
<DropdownMenuTrigger class="w-[140px] h-9 gap-2">
|
||||||
{move || format!("Toplu İşlem ({})", selected_count.get())}
|
<Ellipsis class="size-4" />
|
||||||
</DropdownMenuTrigger>
|
{move || format!("Toplu İşlem ({})", selected_count.get())}
|
||||||
<DropdownMenuContent class="w-48">
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuLabel>"Seçili Torrentler"</DropdownMenuLabel>
|
<DropdownMenuContent class="w-48">
|
||||||
<DropdownMenuGroup class="mt-2">
|
<DropdownMenuLabel>"Seçili Torrentler"</DropdownMenuLabel>
|
||||||
<DropdownMenuItem on:click=move |_| bulk_action("start")>
|
<DropdownMenuGroup class="mt-2">
|
||||||
<Play class="mr-2 size-4" /> "Başlat"
|
<DropdownMenuItem on:click=move |_| bulk_action("start")>
|
||||||
</DropdownMenuItem>
|
<Play class="mr-2 size-4" /> "Başlat"
|
||||||
<DropdownMenuItem on:click=move |_| bulk_action("stop")>
|
</DropdownMenuItem>
|
||||||
<Square class="mr-2 size-4" /> "Durdur"
|
<DropdownMenuItem on:click=move |_| bulk_action("stop")>
|
||||||
</DropdownMenuItem>
|
<Square class="mr-2 size-4" /> "Durdur"
|
||||||
|
</DropdownMenuItem>
|
||||||
<div class="my-1 h-px bg-border" />
|
|
||||||
|
<div class="my-1 h-px bg-border" />
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger class="w-full text-left">
|
<DropdownMenuItem class="text-destructive focus:bg-destructive/10 cursor-pointer" on:click=move |_| {
|
||||||
<div class="inline-flex gap-2 items-center w-full rounded-sm px-2 py-1.5 text-sm transition-colors text-destructive hover:bg-destructive/10 focus:bg-destructive/10 cursor-pointer">
|
if let Some(trigger) = document().get_element_by_id("bulk-delete-trigger") {
|
||||||
<Trash2 class="size-4" /> "Toplu Sil..."
|
let _ = trigger.dyn_into::<web_sys::HtmlElement>().map(|el: web_sys::HtmlElement| el.click());
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<Trash2 class="mr-2 size-4" /> "Toplu Sil..."
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuGroup>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
|
<AlertDialog>
|
||||||
|
<AlertDialogTrigger attr:id="bulk-delete-trigger" class="hidden">""</AlertDialogTrigger>
|
||||||
|
<AlertDialogContent class="sm:max-w-[425px]">
|
||||||
|
<AlertDialogBody>
|
||||||
|
<AlertDialogHeader class="space-y-3">
|
||||||
|
<AlertDialogTitle class="text-destructive flex items-center gap-2 text-xl">
|
||||||
|
<Trash2 class="size-6" />
|
||||||
|
"Toplu Silme Onayı"
|
||||||
|
</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription class="text-sm leading-relaxed text-left">
|
||||||
|
{move || format!("Seçili {} adet torrent silinecek. Lütfen silme yöntemini seçin:", selected_count.get())}
|
||||||
|
<div class="mt-4 p-4 bg-destructive/5 rounded-lg border border-destructive/10 text-xs text-destructive/80 font-medium">
|
||||||
|
"⚠️ Dikkat: Verilerle birlikte silme işlemi dosyaları diskten de kalıcı olarak kaldıracaktır."
|
||||||
|
</div>
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter class="mt-6">
|
||||||
|
<div class="flex flex-col-reverse sm:flex-row gap-3 w-full sm:justify-end">
|
||||||
|
<AlertDialogClose class="sm:flex-1 md:flex-none">"Vazgeç"</AlertDialogClose>
|
||||||
|
<div class="flex flex-col sm:flex-row gap-2">
|
||||||
|
<Button
|
||||||
|
variant=ButtonVariant::Secondary
|
||||||
|
class="w-full sm:w-auto font-medium"
|
||||||
|
on:click=move |_| bulk_action("delete")
|
||||||
|
>
|
||||||
|
"Sadece Sil"
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant=ButtonVariant::Destructive
|
||||||
|
class="w-full sm:w-auto font-bold"
|
||||||
|
on:click=move |_| bulk_action("delete_with_data")
|
||||||
|
>
|
||||||
|
"Verilerle Sil"
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogFooter>
|
||||||
<AlertDialogContent class="sm:max-w-[425px]">
|
</AlertDialogBody>
|
||||||
<AlertDialogBody>
|
</AlertDialogContent>
|
||||||
<AlertDialogHeader class="space-y-3">
|
</AlertDialog>
|
||||||
<AlertDialogTitle class="text-destructive flex items-center gap-2 text-xl">
|
</div>
|
||||||
<Trash2 class="size-6" />
|
|
||||||
"Toplu Silme Onayı"
|
|
||||||
</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription class="text-sm leading-relaxed">
|
|
||||||
{move || format!("Seçili {} adet torrent silinecek. Lütfen silme yöntemini seçin:", selected_count.get())}
|
|
||||||
<div class="mt-4 p-4 bg-destructive/5 rounded-lg border border-destructive/10 text-xs text-destructive/80 font-medium">
|
|
||||||
"⚠️ Dikkat: Verilerle birlikte silme işlemi dosyaları diskten de kalıcı olarak kaldıracaktır."
|
|
||||||
</div>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter class="mt-6">
|
|
||||||
<div class="flex flex-col-reverse sm:flex-row gap-3 w-full sm:justify-end">
|
|
||||||
<AlertDialogClose class="sm:flex-1 md:flex-none">"Vazgeç"</AlertDialogClose>
|
|
||||||
<div class="flex flex-col sm:flex-row gap-2">
|
|
||||||
<Button
|
|
||||||
variant=ButtonVariant::Secondary
|
|
||||||
class="w-full sm:w-auto font-medium"
|
|
||||||
on:click=move |_| bulk_action("delete")
|
|
||||||
>
|
|
||||||
"Sadece Sil"
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant=ButtonVariant::Destructive
|
|
||||||
class="w-full sm:w-auto font-bold"
|
|
||||||
on:click=move |_| bulk_action("delete_with_data")
|
|
||||||
>
|
|
||||||
"Verilerle Sil"
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogBody>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</DropdownMenuGroup>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
// Mobile Sort Menu
|
// Mobile Sort Menu
|
||||||
@@ -535,16 +544,20 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hidden md:flex items-center justify-between px-2 py-1 text-[11px] text-muted-foreground bg-muted/20 border rounded-md">
|
<div class="flex items-center justify-between px-2 py-1.5 text-[10px] md:text-[11px] text-muted-foreground bg-muted/20 border rounded-md">
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-3 md:gap-4">
|
||||||
<span>{move || format!("Toplam: {} torrent", filtered_hashes.get().len())}</span>
|
<span>{move || format!("Toplam: {} torrent", filtered_hashes.get().len())}</span>
|
||||||
<Show when=move || has_selection.get()>
|
<Show when=move || has_selection.get()>
|
||||||
<span class="text-primary font-medium">{move || format!("{} torrent seçili", selected_count.get())}</span>
|
<span class="text-primary font-bold">{move || format!("{} seçili", selected_count.get())}</span>
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
<div>"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()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,10 +599,12 @@ 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">
|
||||||
<Checkbox
|
<div on:click=move |e| e.stop_propagation()>
|
||||||
checked=is_selected
|
<Checkbox
|
||||||
on_checked_change=on_select
|
checked=is_selected
|
||||||
/>
|
on_checked_change=on_select
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</DataTableCell>
|
</DataTableCell>
|
||||||
|
|
||||||
{move || visible_columns.get().contains("Name").then({
|
{move || visible_columns.get().contains("Name").then({
|
||||||
@@ -719,17 +734,23 @@ 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-1 min-w-0">
|
<div class="flex items-start gap-3 flex-1 min-w-0">
|
||||||
<h3 class="text-sm font-bold leading-tight line-clamp-2 break-all">{t_name.clone()}</h3>
|
<div on:click=move |e| e.stop_propagation() class="mt-0.5">
|
||||||
|
<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]">
|
<Badge variant=status_variant class="uppercase tracking-wider text-[10px] shrink-0">
|
||||||
{format!("{:?}", t.status)}
|
{format!("{:?}", t.status)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
121
frontend/src/components/torrent/trackers.rs
Normal file
121
frontend/src/components/torrent/trackers.rs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use crate::components::ui::table::*;
|
||||||
|
use crate::components::ui::shimmer::*;
|
||||||
|
use shared::TorrentTracker;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn TorrentTrackersTab(hash: String) -> impl IntoView {
|
||||||
|
let hash_clone = hash.clone();
|
||||||
|
|
||||||
|
let trackers_resource = Resource::new(
|
||||||
|
move || hash_clone.clone(),
|
||||||
|
|h| async move { shared::server_fns::torrent::get_trackers(h).await.unwrap_or_default() }
|
||||||
|
);
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<Suspense fallback=move || view! { <TrackersFallback /> }>
|
||||||
|
{move || {
|
||||||
|
let trackers = trackers_resource.get().unwrap_or_default();
|
||||||
|
|
||||||
|
if trackers.is_empty() {
|
||||||
|
return view! {
|
||||||
|
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
||||||
|
<icons::Settings2 class="size-12 mb-3 text-muted-foreground" />
|
||||||
|
<p class="text-sm font-medium">"Bu torrent için izleyici bulunamadı."</p>
|
||||||
|
</div>
|
||||||
|
}.into_any();
|
||||||
|
}
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div class="h-full overflow-auto">
|
||||||
|
<TableWrapper class="bg-card/50 whitespace-nowrap">
|
||||||
|
<Table>
|
||||||
|
<TableHeader class="sticky top-0 bg-muted/80 backdrop-blur-sm z-10">
|
||||||
|
<TableRow class="hover:bg-transparent text-xs">
|
||||||
|
<TableHead>"İsim"</TableHead>
|
||||||
|
<TableHead class="text-center">"Tür"</TableHead>
|
||||||
|
<TableHead class="text-center">"Etkin"</TableHead>
|
||||||
|
<TableHead class="text-center">"Grup"</TableHead>
|
||||||
|
<TableHead class="text-center">"Ortaklar"</TableHead>
|
||||||
|
<TableHead class="text-center">"Eşler"</TableHead>
|
||||||
|
<TableHead class="text-center">"İndirilen"</TableHead>
|
||||||
|
<TableHead class="text-center">"Son Güncelleme"</TableHead>
|
||||||
|
<TableHead class="text-center">"Sıklık"</TableHead>
|
||||||
|
<TableHead class="text-center">"Özel"</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<For
|
||||||
|
each=move || trackers.clone()
|
||||||
|
key=|t| t.url.clone()
|
||||||
|
children=move |t| {
|
||||||
|
let t_type = if t.url.starts_with("http") { "http" }
|
||||||
|
else if t.url.starts_with("udp") { "udp" }
|
||||||
|
else if t.url.starts_with("dht") { "dht" }
|
||||||
|
else { "diğer" };
|
||||||
|
let is_enabled = if t.is_enabled { "evet" } else { "hayır" };
|
||||||
|
|
||||||
|
// Format timestamp difference for last update
|
||||||
|
let now = chrono::Utc::now().timestamp();
|
||||||
|
let diff = now - t.last_updated;
|
||||||
|
let last_update_str = if t.last_updated == 0 {
|
||||||
|
"Güncellenmedi".to_string()
|
||||||
|
} else if diff >= 0 {
|
||||||
|
format_duration_short(diff)
|
||||||
|
} else {
|
||||||
|
"N/A".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let url_clone = t.url.clone();
|
||||||
|
view! {
|
||||||
|
<TableRow class="hover:bg-muted/50 transition-colors group text-xs text-muted-foreground">
|
||||||
|
<TableCell class="font-medium text-foreground max-w-[200px] md:max-w-md truncate" attr:title=url_clone>
|
||||||
|
{t.url.clone()}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell class="text-center">{t_type}</TableCell>
|
||||||
|
<TableCell class="text-center">{is_enabled}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.group}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.seeders}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.peers}</TableCell>
|
||||||
|
<TableCell class="text-center">{t.downloaded}</TableCell>
|
||||||
|
<TableCell class="text-center">{last_update_str}</TableCell>
|
||||||
|
<TableCell class="text-center">{format_duration_short(t.interval)}</TableCell>
|
||||||
|
<TableCell class="text-center">"bilinmiyor"</TableCell> // Özel flag isn't cleanly via XMLRPC per tracker usually
|
||||||
|
</TableRow>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableWrapper>
|
||||||
|
</div>
|
||||||
|
}.into_any()
|
||||||
|
}}
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
fn TrackersFallback() -> impl IntoView {
|
||||||
|
view! {
|
||||||
|
<Shimmer loading=Signal::derive(|| true) class="space-y-2">
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
<div class="h-10 w-full bg-muted/20 rounded-md"></div>
|
||||||
|
</Shimmer>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn format_duration_short(seconds: i64) -> String {
|
||||||
|
if seconds <= 0 { return "0sn".to_string(); }
|
||||||
|
let days = seconds / 86400;
|
||||||
|
let hours = (seconds % 86400) / 3600;
|
||||||
|
let minutes = (seconds % 3600) / 60;
|
||||||
|
let secs = seconds % 60;
|
||||||
|
|
||||||
|
if days > 0 { format!("{}g {}s", days, hours) }
|
||||||
|
else if hours > 0 { format!("{}s {}dk", hours, minutes) }
|
||||||
|
else if minutes > 0 { format!("{}dk {}sn", minutes, secs) }
|
||||||
|
else { format!("{}sn", secs) }
|
||||||
|
}
|
||||||
72
frontend/src/components/ui/button_action.rs
Normal file
72
frontend/src/components/ui/button_action.rs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use tailwind_fuse::tw_merge;
|
||||||
|
use crate::components::ui::button::{Button, ButtonVariant};
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn ButtonAction(
|
||||||
|
children: Children,
|
||||||
|
#[prop(into)] on_action: Callback<()>,
|
||||||
|
#[prop(optional, into)] class: String,
|
||||||
|
#[prop(default = 1000)] hold_duration: u64,
|
||||||
|
#[prop(default = ButtonVariant::Default)] variant: ButtonVariant,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let is_holding = RwSignal::new(false);
|
||||||
|
let generation = StoredValue::new(0u64);
|
||||||
|
|
||||||
|
let on_down = move |_| {
|
||||||
|
generation.update_value(|g| *g += 1);
|
||||||
|
is_holding.set(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
let on_up = move |_| is_holding.set(false);
|
||||||
|
|
||||||
|
Effect::new(move |_| {
|
||||||
|
if is_holding.get() {
|
||||||
|
let current_gen = generation.get_value();
|
||||||
|
leptos::task::spawn_local(async move {
|
||||||
|
gloo_timers::future::TimeoutFuture::new(hold_duration as u32).await;
|
||||||
|
// Double validation: Is user still holding AND is it the SAME hold attempt?
|
||||||
|
if is_holding.get_untracked() && generation.get_value() == current_gen {
|
||||||
|
on_action.run(());
|
||||||
|
is_holding.set(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let merged_class = move || tw_merge!(
|
||||||
|
"relative overflow-hidden transition-all active:scale-[0.98]",
|
||||||
|
class.clone()
|
||||||
|
);
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<style>
|
||||||
|
"@keyframes button-hold-progress {
|
||||||
|
from { width: 0%; }
|
||||||
|
to { width: 100%; }
|
||||||
|
}
|
||||||
|
.animate-button-hold {
|
||||||
|
animation: button-hold-progress var(--button-hold-duration) linear forwards;
|
||||||
|
}"
|
||||||
|
</style>
|
||||||
|
<Button
|
||||||
|
variant=variant
|
||||||
|
class=merged_class()
|
||||||
|
attr:style=format!("--button-hold-duration: {}ms", hold_duration)
|
||||||
|
on:mousedown=on_down
|
||||||
|
on:mouseup=on_up
|
||||||
|
on:mouseleave=on_up
|
||||||
|
on:touchstart=move |_| is_holding.set(true)
|
||||||
|
on:touchend=move |_| is_holding.set(false)
|
||||||
|
>
|
||||||
|
// Progress Overlay
|
||||||
|
<Show when=move || is_holding.get()>
|
||||||
|
<div class="absolute inset-0 bg-white/20 dark:bg-black/20 pointer-events-none animate-button-hold" />
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<span class="relative z-10 flex items-center justify-center gap-2">
|
||||||
|
{children()}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,13 +3,17 @@ 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"}
|
||||||
clx! {CardHeader, div, "@container/card-header flex flex-col items-start gap-1.5 px-6 [.border-b]:pb-6"}
|
// 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 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::*;
|
||||||
@@ -78,76 +78,6 @@ pub fn ContextMenuAction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn ContextMenuHoldAction(
|
|
||||||
children: Children,
|
|
||||||
#[prop(into)] on_hold_complete: Callback<()>,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
#[prop(default = 1000)] hold_duration: u64,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let is_holding = RwSignal::new(false);
|
|
||||||
let progress = RwSignal::new(0.0);
|
|
||||||
|
|
||||||
let on_mousedown = move |_| {
|
|
||||||
is_holding.set(true);
|
|
||||||
progress.set(0.0);
|
|
||||||
};
|
|
||||||
|
|
||||||
let on_mouseup = move |_| {
|
|
||||||
is_holding.set(false);
|
|
||||||
progress.set(0.0);
|
|
||||||
};
|
|
||||||
|
|
||||||
Effect::new(move |_| {
|
|
||||||
if is_holding.get() {
|
|
||||||
let start_time = js_sys::Date::now();
|
|
||||||
let duration = hold_duration as f64;
|
|
||||||
|
|
||||||
leptos::task::spawn_local(async move {
|
|
||||||
while is_holding.get_untracked() {
|
|
||||||
let now = js_sys::Date::now();
|
|
||||||
let elapsed = now - start_time;
|
|
||||||
let p = (elapsed / duration).min(1.0);
|
|
||||||
progress.set(p * 100.0);
|
|
||||||
|
|
||||||
if p >= 1.0 {
|
|
||||||
on_hold_complete.run(());
|
|
||||||
is_holding.set(false);
|
|
||||||
close_context_menu();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
gloo_timers::future::TimeoutFuture::new(16).await; // ~60fps
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let class = tw_merge!(
|
|
||||||
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors overflow-hidden",
|
|
||||||
class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div
|
|
||||||
class=class
|
|
||||||
on:mousedown=on_mousedown
|
|
||||||
on:mouseup=on_mouseup
|
|
||||||
on:mouseleave=on_mouseup
|
|
||||||
on:touchstart=move |_| on_mousedown(web_sys::MouseEvent::new("mousedown").unwrap())
|
|
||||||
on:touchend=move |_| on_mouseup(web_sys::MouseEvent::new("mouseup").unwrap())
|
|
||||||
>
|
|
||||||
// Progress background
|
|
||||||
<div
|
|
||||||
class="absolute inset-y-0 left-0 bg-destructive/20 transition-all duration-75 ease-linear pointer-events-none"
|
|
||||||
style=move || format!("width: {}%;", progress.get())
|
|
||||||
/>
|
|
||||||
<span class="relative z-10 flex items-center gap-2 w-full">
|
|
||||||
{children()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
}.into_any()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct ContextMenuContext {
|
struct ContextMenuContext {
|
||||||
target_id: String,
|
target_id: String,
|
||||||
@@ -209,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(());
|
||||||
}
|
}
|
||||||
@@ -285,12 +215,20 @@ 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 = x - menuRect.width;
|
left = Math.max(0, 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 = y - menuRect.height;
|
top = Math.max(0, 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`;
|
||||||
@@ -298,106 +236,153 @@ 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;
|
||||||
|
}}
|
||||||
}}
|
}}
|
||||||
}});
|
}});
|
||||||
|
|
||||||
menu.setAttribute('data-state', 'open');
|
trigger.addEventListener('touchend', () => {{
|
||||||
menu.style.visibility = 'hidden';
|
if (touchTimer) {{
|
||||||
menu.style.pointerEvents = 'auto';
|
clearTimeout(touchTimer);
|
||||||
|
touchTimer = null;
|
||||||
// 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
|
|
||||||
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
|
trigger.addEventListener('touchcancel', () => {{
|
||||||
document.addEventListener('keydown', (e) => {{
|
if (touchTimer) {{
|
||||||
if (e.key === 'Escape' && isOpen) {{
|
clearTimeout(touchTimer);
|
||||||
e.preventDefault();
|
touchTimer = null;
|
||||||
closeMenu();
|
}}
|
||||||
}}
|
}});
|
||||||
}});
|
|
||||||
}};
|
|
||||||
|
|
||||||
if (document.readyState === 'loading') {{
|
// Close when action is clicked
|
||||||
document.addEventListener('DOMContentLoaded', setupContextMenu);
|
const actions = menu.querySelectorAll('[data-context-close]');
|
||||||
}} else {{
|
actions.forEach(action => {{
|
||||||
setupContextMenu();
|
action.addEventListener('click', () => {{
|
||||||
}}
|
closeMenu();
|
||||||
}})();
|
}});
|
||||||
"#,
|
}});
|
||||||
target_id_for_script,
|
|
||||||
target_id_for_script,
|
// Handle ESC key
|
||||||
)}
|
document.addEventListener('keydown', (e) => {{
|
||||||
</script>
|
if (e.key === 'Escape' && isOpen) {{
|
||||||
}.into_any()
|
e.preventDefault();
|
||||||
|
closeMenu();
|
||||||
|
}}
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {{
|
||||||
|
document.addEventListener('DOMContentLoaded', setupContextMenu);
|
||||||
|
}} else {{
|
||||||
|
setupContextMenu();
|
||||||
|
}}
|
||||||
|
}})();
|
||||||
|
"#,
|
||||||
|
target_id_for_script,
|
||||||
|
target_id_for_script,
|
||||||
|
)}
|
||||||
|
</script>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
|||||||
@@ -72,13 +72,13 @@ pub fn DialogTrigger(
|
|||||||
pub fn DialogContent(
|
pub fn DialogContent(
|
||||||
children: Children,
|
children: Children,
|
||||||
#[prop(optional, into)] class: String,
|
#[prop(optional, into)] class: String,
|
||||||
|
#[prop(optional, into)] id: Option<String>,
|
||||||
#[prop(into, optional)] hide_close_button: Option<bool>,
|
#[prop(into, optional)] hide_close_button: Option<bool>,
|
||||||
#[prop(default = true)] close_on_backdrop_click: bool,
|
#[prop(default = true)] close_on_backdrop_click: bool,
|
||||||
#[prop(default = "Dialog")] data_name_prefix: &'static str,
|
#[prop(default = "Dialog")] data_name_prefix: &'static str,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let ctx = expect_context::<DialogContext>();
|
let ctx = expect_context::<DialogContext>();
|
||||||
let merged_class = tw_merge!(
|
let merged_class = tw_merge!(
|
||||||
// "flex flex-col gap-4", // TODO 🐛 Bug when I try to have this.. Using DialogBody instead.
|
|
||||||
"relative bg-background border rounded-2xl shadow-lg p-6 w-full max-w-[calc(100%-2rem)] max-h-[85vh] fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] z-100 transition-all duration-200 data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100",
|
"relative bg-background border rounded-2xl shadow-lg p-6 w-full max-w-[calc(100%-2rem)] max-h-[85vh] fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] z-100 transition-all duration-200 data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100",
|
||||||
class
|
class
|
||||||
);
|
);
|
||||||
@@ -88,10 +88,14 @@ pub fn DialogContent(
|
|||||||
|
|
||||||
let target_id_clone = ctx.target_id.clone();
|
let target_id_clone = ctx.target_id.clone();
|
||||||
let backdrop_id = format!("{}_backdrop", ctx.target_id);
|
let backdrop_id = format!("{}_backdrop", ctx.target_id);
|
||||||
let target_id_for_script = ctx.target_id.clone();
|
|
||||||
let backdrop_id_for_script = backdrop_id.clone();
|
let backdrop_id_for_script = backdrop_id.clone();
|
||||||
let backdrop_behavior = if close_on_backdrop_click { "auto" } else { "manual" };
|
let backdrop_behavior = if close_on_backdrop_click { "auto" } else { "manual" };
|
||||||
|
|
||||||
|
// Use provided id or fallback to random target_id
|
||||||
|
let final_id = id.unwrap_or_else(|| ctx.target_id.clone());
|
||||||
|
let final_id_for_script = final_id.clone();
|
||||||
|
let trigger_id_for_script = ctx.target_id.clone();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<script src="/lock_scroll.js"></script>
|
<script src="/lock_scroll.js"></script>
|
||||||
|
|
||||||
@@ -105,7 +109,7 @@ pub fn DialogContent(
|
|||||||
<div
|
<div
|
||||||
data-name=content_data_name
|
data-name=content_data_name
|
||||||
class=merged_class
|
class=merged_class
|
||||||
id=ctx.target_id
|
id=final_id
|
||||||
data-target="target__dialog"
|
data-target="target__dialog"
|
||||||
data-state="closed"
|
data-state="closed"
|
||||||
data-backdrop=backdrop_behavior
|
data-backdrop=backdrop_behavior
|
||||||
@@ -147,9 +151,7 @@ pub fn DialogContent(
|
|||||||
dialog.setAttribute('data-initialized', 'true');
|
dialog.setAttribute('data-initialized', 'true');
|
||||||
|
|
||||||
const openDialog = () => {{
|
const openDialog = () => {{
|
||||||
// Lock scrolling
|
if (window.ScrollLock) window.ScrollLock.lock();
|
||||||
window.ScrollLock.lock();
|
|
||||||
|
|
||||||
dialog.setAttribute('data-state', 'open');
|
dialog.setAttribute('data-state', 'open');
|
||||||
backdrop.setAttribute('data-state', 'open');
|
backdrop.setAttribute('data-state', 'open');
|
||||||
dialog.style.pointerEvents = 'auto';
|
dialog.style.pointerEvents = 'auto';
|
||||||
@@ -161,28 +163,18 @@ pub fn DialogContent(
|
|||||||
backdrop.setAttribute('data-state', 'closed');
|
backdrop.setAttribute('data-state', 'closed');
|
||||||
dialog.style.pointerEvents = 'none';
|
dialog.style.pointerEvents = 'none';
|
||||||
backdrop.style.pointerEvents = 'none';
|
backdrop.style.pointerEvents = 'none';
|
||||||
|
|
||||||
// Unlock scrolling after animation
|
|
||||||
window.ScrollLock.unlock(200);
|
window.ScrollLock.unlock(200);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// Open dialog when trigger is clicked
|
|
||||||
trigger.addEventListener('click', openDialog);
|
trigger.addEventListener('click', openDialog);
|
||||||
|
dialog.querySelectorAll('[data-dialog-close]').forEach(btn => {{
|
||||||
// Close buttons
|
|
||||||
const closeButtons = dialog.querySelectorAll('[data-dialog-close]');
|
|
||||||
closeButtons.forEach(btn => {{
|
|
||||||
btn.addEventListener('click', closeDialog);
|
btn.addEventListener('click', closeDialog);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
// Close on backdrop click (if data-backdrop="auto")
|
|
||||||
backdrop.addEventListener('click', () => {{
|
backdrop.addEventListener('click', () => {{
|
||||||
if (dialog.getAttribute('data-backdrop') === 'auto') {{
|
if (dialog.getAttribute('data-backdrop') === 'auto') {{
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}}
|
}}
|
||||||
}});
|
}});
|
||||||
|
|
||||||
// Handle ESC key to close
|
|
||||||
document.addEventListener('keydown', (e) => {{
|
document.addEventListener('keydown', (e) => {{
|
||||||
if (e.key === 'Escape' && dialog.getAttribute('data-state') === 'open') {{
|
if (e.key === 'Escape' && dialog.getAttribute('data-state') === 'open') {{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -190,17 +182,12 @@ pub fn DialogContent(
|
|||||||
}}
|
}}
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
setupDialog();
|
||||||
if (document.readyState === 'loading') {{
|
|
||||||
document.addEventListener('DOMContentLoaded', setupDialog);
|
|
||||||
}} else {{
|
|
||||||
setupDialog();
|
|
||||||
}}
|
|
||||||
}})();
|
}})();
|
||||||
"#,
|
"#,
|
||||||
target_id_for_script,
|
final_id_for_script,
|
||||||
backdrop_id_for_script,
|
backdrop_id_for_script,
|
||||||
target_id_for_script,
|
trigger_id_for_script,
|
||||||
)}
|
)}
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ pub mod accordion;
|
|||||||
pub mod alert_dialog;
|
pub mod alert_dialog;
|
||||||
pub mod badge;
|
pub mod badge;
|
||||||
pub mod button;
|
pub mod button;
|
||||||
|
pub mod button_action;
|
||||||
pub mod card;
|
pub mod card;
|
||||||
pub mod checkbox;
|
pub mod checkbox;
|
||||||
pub mod context_menu;
|
pub mod context_menu;
|
||||||
@@ -13,10 +14,14 @@ 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 table;
|
pub mod table;
|
||||||
|
pub mod tabs;
|
||||||
pub mod theme_toggle;
|
pub mod theme_toggle;
|
||||||
pub mod toast;
|
pub mod toast;
|
||||||
102
frontend/src/components/ui/scroll_area.rs
Normal file
102
frontend/src/components/ui/scroll_area.rs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
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,8 +16,6 @@ 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 ✨ */
|
||||||
/* ========================================================== */
|
/* ========================================================== */
|
||||||
|
|||||||
52
frontend/src/components/ui/shimmer.rs
Normal file
52
frontend/src/components/ui/shimmer.rs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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>
|
||||||
|
}
|
||||||
|
}
|
||||||
42
frontend/src/components/ui/switch.rs
Normal file
42
frontend/src/components/ui/switch.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use tailwind_fuse::tw_merge;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn Switch(
|
||||||
|
#[prop(into)] checked: Signal<bool>,
|
||||||
|
#[prop(into, optional)] on_checked_change: Option<Callback<bool>>,
|
||||||
|
#[prop(into, optional)] class: String,
|
||||||
|
#[prop(into, optional)] disabled: Signal<bool>,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let checked_val = move || checked.get();
|
||||||
|
let disabled_val = move || disabled.get();
|
||||||
|
|
||||||
|
let track_class = move || tw_merge!(
|
||||||
|
"inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
if checked_val() { "bg-primary" } else { "bg-input" },
|
||||||
|
class.clone()
|
||||||
|
);
|
||||||
|
|
||||||
|
let thumb_class = move || tw_merge!(
|
||||||
|
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",
|
||||||
|
if checked_val() { "translate-x-4" } else { "translate-x-0" }
|
||||||
|
);
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
role="switch"
|
||||||
|
aria-checked=move || checked_val().to_string()
|
||||||
|
disabled=disabled_val
|
||||||
|
class=track_class
|
||||||
|
on:click=move |e| {
|
||||||
|
e.prevent_default();
|
||||||
|
if let Some(cb) = on_checked_change {
|
||||||
|
cb.run(!checked_val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span class=thumb_class />
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
}
|
||||||
108
frontend/src/components/ui/tabs.rs
Normal file
108
frontend/src/components/ui/tabs.rs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
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>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -170,9 +170,10 @@ pub fn Toaster(#[prop(default = SonnerPosition::default())] position: SonnerPosi
|
|||||||
<div
|
<div
|
||||||
class=tw_merge!(
|
class=tw_merge!(
|
||||||
"fixed z-[100] flex gap-3 pointer-events-none w-full sm:w-[400px]",
|
"fixed z-[100] flex gap-3 pointer-events-none w-full sm:w-[400px]",
|
||||||
|
"left-1/2 -translate-x-1/2 sm:left-auto sm:translate-x-0 px-4 sm:px-0", // Mobile centering fix
|
||||||
if is_bottom { "flex-col-reverse" } else { "flex-col" },
|
if is_bottom { "flex-col-reverse" } else { "flex-col" },
|
||||||
container_class,
|
container_class,
|
||||||
"pb-[env(safe-area-inset-bottom)] pt-[env(safe-area-inset-top)] px-4 sm:px-0"
|
"pb-[env(safe-area-inset-bottom)] pt-[env(safe-area-inset-top)]"
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
<For
|
<For
|
||||||
|
|||||||
@@ -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::STANDARD as BASE64};
|
use base64::{Engine as _, engine::general_purpose::{URL_SAFE_NO_PAD as BASE64_URL, STANDARD as BASE64}};
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
use crate::components::ui::toast::{ToastType, toast};
|
use crate::components::ui::toast::{ToastType, toast};
|
||||||
|
|
||||||
@@ -24,8 +25,6 @@ pub fn show_toast(level: NotificationLevel, message: impl Into<String>) {
|
|||||||
toast(msg, variant);
|
toast(msg, variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub fn toast_success(message: impl Into<String>) { show_toast(NotificationLevel::Success, message); }
|
pub fn toast_success(message: impl Into<String>) { show_toast(NotificationLevel::Success, message); }
|
||||||
pub fn toast_error(message: impl Into<String>) { show_toast(NotificationLevel::Error, message); }
|
pub fn toast_error(message: impl Into<String>) { show_toast(NotificationLevel::Error, message); }
|
||||||
|
|
||||||
@@ -54,6 +53,7 @@ pub struct TorrentStore {
|
|||||||
pub global_stats: RwSignal<GlobalStats>,
|
pub global_stats: RwSignal<GlobalStats>,
|
||||||
pub user: RwSignal<Option<String>>,
|
pub user: RwSignal<Option<String>>,
|
||||||
pub selected_torrent: RwSignal<Option<String>>,
|
pub selected_torrent: RwSignal<Option<String>>,
|
||||||
|
pub push_enabled: RwSignal<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide_torrent_store() {
|
pub fn provide_torrent_store() {
|
||||||
@@ -63,12 +63,20 @@ pub fn provide_torrent_store() {
|
|||||||
let global_stats = RwSignal::new(GlobalStats::default());
|
let global_stats = RwSignal::new(GlobalStats::default());
|
||||||
let user = RwSignal::new(Option::<String>::None);
|
let user = RwSignal::new(Option::<String>::None);
|
||||||
let selected_torrent = RwSignal::new(Option::<String>::None);
|
let selected_torrent = RwSignal::new(Option::<String>::None);
|
||||||
|
let push_enabled = RwSignal::new(false);
|
||||||
|
|
||||||
let show_browser_notification = crate::utils::notification::use_app_notification();
|
let show_browser_notification = crate::utils::notification::use_app_notification();
|
||||||
|
|
||||||
let store = TorrentStore { torrents, filter, search_query, global_stats, user, selected_torrent };
|
let store = TorrentStore { torrents, filter, search_query, global_stats, user, selected_torrent, push_enabled };
|
||||||
provide_context(store);
|
provide_context(store);
|
||||||
|
|
||||||
|
// Initial check for push status
|
||||||
|
spawn_local(async move {
|
||||||
|
if let Ok(enabled) = is_push_subscribed().await {
|
||||||
|
push_enabled.set(enabled);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let global_stats_for_sse = global_stats;
|
let global_stats_for_sse = global_stats;
|
||||||
let torrents_for_sse = torrents;
|
let torrents_for_sse = torrents;
|
||||||
let show_browser_notification = show_browser_notification.clone();
|
let show_browser_notification = show_browser_notification.clone();
|
||||||
@@ -79,17 +87,12 @@ pub fn provide_torrent_store() {
|
|||||||
let mut disconnect_notified = false;
|
let mut disconnect_notified = false;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
||||||
log::debug!("SSE: Creating EventSource...");
|
|
||||||
let es_result = EventSource::new("/api/events");
|
let es_result = EventSource::new("/api/events");
|
||||||
match es_result {
|
match es_result {
|
||||||
Ok(mut es) => {
|
Ok(mut es) => {
|
||||||
log::debug!("SSE: EventSource created, subscribing...");
|
|
||||||
if let Ok(mut stream) = es.subscribe("message") {
|
if let Ok(mut stream) = es.subscribe("message") {
|
||||||
log::debug!("SSE: Subscribed to message channel");
|
|
||||||
let mut got_first_message = false;
|
let mut got_first_message = false;
|
||||||
while let Some(Ok((_, msg))) = stream.next().await {
|
while let Some(Ok((_, msg))) = stream.next().await {
|
||||||
log::debug!("SSE: Received message");
|
|
||||||
if !got_first_message {
|
if !got_first_message {
|
||||||
got_first_message = true;
|
got_first_message = true;
|
||||||
backoff_ms = 1000;
|
backoff_ms = 1000;
|
||||||
@@ -101,47 +104,30 @@ pub fn provide_torrent_store() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(data_str) = msg.data().as_string() {
|
if let Some(data_str) = msg.data().as_string() {
|
||||||
// Decode Base64
|
if let Ok(bytes) = BASE64.decode(&data_str) {
|
||||||
match BASE64.decode(&data_str) {
|
if let Ok(event) = rmp_serde::from_slice::<AppEvent>(&bytes) {
|
||||||
Ok(bytes) => {
|
match event {
|
||||||
// Deserialize MessagePack
|
AppEvent::FullList(list, _) => {
|
||||||
match rmp_serde::from_slice::<AppEvent>(&bytes) {
|
torrents_for_sse.update(|map| {
|
||||||
Ok(event) => {
|
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
||||||
match event {
|
map.retain(|hash, _| new_hashes.contains(hash));
|
||||||
AppEvent::FullList(list, _) => {
|
for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); }
|
||||||
log::info!("SSE: Received FullList with {} torrents", list.len());
|
});
|
||||||
torrents_for_sse.update(|map| {
|
}
|
||||||
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
AppEvent::Update(patch) => {
|
||||||
map.retain(|hash, _| new_hashes.contains(hash));
|
if let Some(hash) = patch.hash.clone() {
|
||||||
for new_torrent in list {
|
torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } });
|
||||||
map.insert(new_torrent.hash.clone(), new_torrent);
|
}
|
||||||
}
|
}
|
||||||
});
|
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
|
||||||
log::debug!("SSE: torrents map now has {} entries", torrents_for_sse.with(|m| m.len()));
|
AppEvent::Notification(n) => {
|
||||||
}
|
show_toast(n.level.clone(), n.message.clone());
|
||||||
AppEvent::Update(patch) => {
|
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
||||||
let hash_opt = patch.hash.clone();
|
show_browser_notification("VibeTorrent", &n.message);
|
||||||
if let Some(hash) = hash_opt {
|
|
||||||
torrents_for_sse.update(|map| {
|
|
||||||
if let Some(t) = map.get_mut(&hash) {
|
|
||||||
t.apply(patch);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
|
|
||||||
AppEvent::Notification(n) => {
|
|
||||||
show_toast(n.level.clone(), n.message.clone());
|
|
||||||
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
|
||||||
show_browser_notification("VibeTorrent", &n.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => log::error!("SSE: Failed to deserialize MessagePack: {}", e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => log::error!("SSE: Failed to decode Base64: {}", e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,13 +144,106 @@ pub fn provide_torrent_store() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log::debug!("SSE: Reconnecting in {}ms...", backoff_ms);
|
|
||||||
gloo_timers::future::TimeoutFuture::new(backoff_ms).await;
|
gloo_timers::future::TimeoutFuture::new(backoff_ms).await;
|
||||||
backoff_ms = std::cmp::min(backoff_ms * 2, 30000);
|
backoff_ms = std::cmp::min(backoff_ms * 2, 30000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn subscribe_to_push_notifications() {
|
pub async fn is_push_subscribed() -> Result<bool, String> {
|
||||||
// ...
|
let window = web_sys::window().ok_or("no window")?;
|
||||||
|
let navigator = window.navigator();
|
||||||
|
let sw_container = navigator.service_worker();
|
||||||
|
|
||||||
|
let registration = wasm_bindgen_futures::JsFuture::from(sw_container.ready().map_err(|e| format!("{:?}", e))?)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("{:?}", e))?
|
||||||
|
.dyn_into::<web_sys::ServiceWorkerRegistration>()
|
||||||
|
.map_err(|_| "not a registration")?;
|
||||||
|
|
||||||
|
let push_manager = registration.push_manager().map_err(|e| format!("{:?}", e))?;
|
||||||
|
let subscription = wasm_bindgen_futures::JsFuture::from(push_manager.get_subscription().map_err(|e| format!("{:?}", e))?)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
|
|
||||||
|
Ok(!subscription.is_null())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe_to_push_notifications() {
|
||||||
|
let window = web_sys::window().expect("no window");
|
||||||
|
let navigator = window.navigator();
|
||||||
|
let sw_container = navigator.service_worker();
|
||||||
|
|
||||||
|
let registration = match wasm_bindgen_futures::JsFuture::from(sw_container.ready().expect("sw not ready")).await {
|
||||||
|
Ok(reg) => reg.dyn_into::<web_sys::ServiceWorkerRegistration>().expect("not a reg"),
|
||||||
|
Err(e) => { log::error!("SW Ready Error: {:?}", e); return; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1. Get Public Key from Backend
|
||||||
|
let public_key_res: Result<String, _> = shared::server_fns::push::get_public_key().await;
|
||||||
|
let public_key = match public_key_res {
|
||||||
|
Ok(key) => key,
|
||||||
|
Err(e) => { log::error!("Failed to get public key: {:?}", e); return; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2. Convert base64 key to Uint8Array
|
||||||
|
let decoded_key = BASE64_URL.decode(public_key.trim()).expect("invalid public key");
|
||||||
|
let key_array = js_sys::Uint8Array::from(&decoded_key[..]);
|
||||||
|
|
||||||
|
// 3. Prepare Options
|
||||||
|
let options = web_sys::PushSubscriptionOptionsInit::new();
|
||||||
|
options.set_user_visible_only(true);
|
||||||
|
options.set_application_server_key(&key_array.into());
|
||||||
|
|
||||||
|
// 4. Subscribe
|
||||||
|
let push_manager = registration.push_manager().expect("no push manager");
|
||||||
|
match wasm_bindgen_futures::JsFuture::from(push_manager.subscribe_with_options(&options).expect("subscribe failed")).await {
|
||||||
|
Ok(subscription) => {
|
||||||
|
let sub_js = subscription.clone();
|
||||||
|
|
||||||
|
// Use JS to extract JSON string representation
|
||||||
|
let json_str = js_sys::JSON::stringify(&sub_js).expect("stringify failed").as_string().expect("not a string");
|
||||||
|
let sub_obj: serde_json::Value = serde_json::from_str(&json_str).expect("serde from str failed");
|
||||||
|
|
||||||
|
let endpoint = sub_obj["endpoint"].as_str().expect("no endpoint").to_string();
|
||||||
|
let p256dh = sub_obj["keys"]["p256dh"].as_str().expect("no p256dh").to_string();
|
||||||
|
let auth = sub_obj["keys"]["auth"].as_str().expect("no auth").to_string();
|
||||||
|
|
||||||
|
// 5. Save to Backend
|
||||||
|
match shared::server_fns::push::subscribe_push(endpoint, p256dh, auth).await {
|
||||||
|
Ok(_) => {
|
||||||
|
log::info!("Push subscription saved successfully");
|
||||||
|
toast_success("Bildirimler aktif edildi");
|
||||||
|
}
|
||||||
|
Err(e) => log::error!("Failed to save subscription: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => log::error!("Subscription Error: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn unsubscribe_from_push_notifications() {
|
||||||
|
let window = web_sys::window().expect("no window");
|
||||||
|
let sw_container = window.navigator().service_worker();
|
||||||
|
|
||||||
|
let registration = wasm_bindgen_futures::JsFuture::from(sw_container.ready().expect("sw not ready")).await
|
||||||
|
.unwrap().dyn_into::<web_sys::ServiceWorkerRegistration>().unwrap();
|
||||||
|
|
||||||
|
let push_manager = registration.push_manager().unwrap();
|
||||||
|
if let Ok(sub_future) = push_manager.get_subscription() {
|
||||||
|
if let Ok(subscription) = wasm_bindgen_futures::JsFuture::from(sub_future).await {
|
||||||
|
if !subscription.is_null() {
|
||||||
|
let sub = subscription.dyn_into::<web_sys::PushSubscription>().unwrap();
|
||||||
|
let endpoint = sub.endpoint();
|
||||||
|
|
||||||
|
// 1. Unsubscribe in Browser
|
||||||
|
let _ = wasm_bindgen_futures::JsFuture::from(sub.unsubscribe().unwrap()).await;
|
||||||
|
|
||||||
|
// 2. Remove from Backend
|
||||||
|
let _ = shared::server_fns::push::unsubscribe_push(endpoint).await;
|
||||||
|
log::info!("Push subscription removed");
|
||||||
|
show_toast(NotificationLevel::Info, "Bildirimler kapatıldı");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = "vibetorrent-v2";
|
const CACHE_NAME = "vibetorrent-v3";
|
||||||
const ASSETS_TO_CACHE = [
|
const ASSETS_TO_CACHE = [
|
||||||
"/",
|
"/",
|
||||||
"/index.html",
|
"/index.html",
|
||||||
@@ -51,6 +51,11 @@ 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(
|
||||||
@@ -75,10 +80,12 @@ 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
|
||||||
const responseToCache = response.clone();
|
if (response && response.status === 200) {
|
||||||
caches.open(CACHE_NAME).then((cache) => {
|
const responseToCache = response.clone();
|
||||||
cache.put(event.request, responseToCache);
|
caches.open(CACHE_NAME).then((cache) => {
|
||||||
});
|
cache.put(event.request, responseToCache);
|
||||||
|
});
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
372
package-lock.json
generated
Normal file
372
package-lock.json
generated
Normal file
@@ -0,0 +1,372 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
package.json
Normal file
8
package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"@tailwindcss/cli": "^4.1.18",
|
||||||
|
"tailwindcss": "^4.1.18",
|
||||||
|
"tw-animate-css": "^1.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,11 @@ pub struct Torrent {
|
|||||||
pub error_message: String,
|
pub error_message: String,
|
||||||
pub added_date: i64,
|
pub added_date: i64,
|
||||||
pub label: Option<String>,
|
pub label: Option<String>,
|
||||||
|
pub ratio: f64,
|
||||||
|
pub uploaded: i64,
|
||||||
|
pub wasted: i64,
|
||||||
|
pub save_path: String,
|
||||||
|
pub free_disk_space: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema)]
|
||||||
@@ -121,6 +126,13 @@ pub struct TorrentTracker {
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
pub is_enabled: bool,
|
||||||
|
pub group: i64,
|
||||||
|
pub seeders: i64,
|
||||||
|
pub peers: i64,
|
||||||
|
pub downloaded: i64,
|
||||||
|
pub last_updated: i64,
|
||||||
|
pub interval: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
|
||||||
|
|||||||
@@ -83,12 +83,19 @@ impl ScgiRequest {
|
|||||||
|
|
||||||
pub async fn send_request(socket_path: &str, request: ScgiRequest) -> Result<Bytes, ScgiError> {
|
pub async fn send_request(socket_path: &str, request: ScgiRequest) -> Result<Bytes, ScgiError> {
|
||||||
let perform_request = async {
|
let perform_request = async {
|
||||||
let mut stream = UnixStream::connect(socket_path).await?;
|
|
||||||
let data = request.encode();
|
let data = request.encode();
|
||||||
stream.write_all(&data).await?;
|
|
||||||
|
|
||||||
let mut response = Vec::new();
|
let mut response = Vec::new();
|
||||||
stream.read_to_end(&mut response).await?;
|
|
||||||
|
if socket_path.contains(':') {
|
||||||
|
let mut stream = tokio::net::TcpStream::connect(socket_path).await?;
|
||||||
|
stream.write_all(&data).await?;
|
||||||
|
stream.read_to_end(&mut response).await?;
|
||||||
|
} else {
|
||||||
|
let mut stream = tokio::net::UnixStream::connect(socket_path).await?;
|
||||||
|
stream.write_all(&data).await?;
|
||||||
|
stream.read_to_end(&mut response).await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok::<Vec<u8>, std::io::Error>(response)
|
Ok::<Vec<u8>, std::io::Error>(response)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,3 +20,13 @@ pub async fn subscribe_push(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| ServerFnError::new(format!("Failed to save subscription: {}", e)))
|
.map_err(|e| ServerFnError::new(format!("Failed to save subscription: {}", e)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[server(UnsubscribePush, "/api/server_fns")]
|
||||||
|
pub async fn unsubscribe_push(endpoint: String) -> Result<(), ServerFnError> {
|
||||||
|
let db_ctx = expect_context::<crate::DbContext>();
|
||||||
|
db_ctx
|
||||||
|
.db
|
||||||
|
.remove_push_subscription(&endpoint)
|
||||||
|
.await
|
||||||
|
.map_err(|e| ServerFnError::new(format!("Failed to remove subscription: {}", e)))
|
||||||
|
}
|
||||||
|
|||||||
@@ -193,8 +193,12 @@ pub async fn get_trackers(hash: String) -> Result<Vec<TorrentTracker>, ServerFnE
|
|||||||
RpcParam::from(hash.as_str()),
|
RpcParam::from(hash.as_str()),
|
||||||
RpcParam::from(""),
|
RpcParam::from(""),
|
||||||
RpcParam::from("t.url="),
|
RpcParam::from("t.url="),
|
||||||
RpcParam::from("t.activity_date_last="),
|
RpcParam::from("t.is_enabled="),
|
||||||
RpcParam::from("t.message="),
|
RpcParam::from("t.group="),
|
||||||
|
RpcParam::from("t.scrape_complete="),
|
||||||
|
RpcParam::from("t.scrape_incomplete="),
|
||||||
|
RpcParam::from("t.scrape_downloaded="),
|
||||||
|
RpcParam::from("t.normal_interval="),
|
||||||
];
|
];
|
||||||
|
|
||||||
let xml = client
|
let xml = client
|
||||||
@@ -205,14 +209,23 @@ pub async fn get_trackers(hash: String) -> Result<Vec<TorrentTracker>, ServerFnE
|
|||||||
let rows = parse_multicall_response(&xml)
|
let rows = parse_multicall_response(&xml)
|
||||||
.map_err(|e| ServerFnError::new(format!("Parse error: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("Parse error: {}", e)))?;
|
||||||
|
|
||||||
Ok(rows
|
let result: Vec<TorrentTracker> = rows
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|row| TorrentTracker {
|
.map(|row| TorrentTracker {
|
||||||
url: row.get(0).cloned().unwrap_or_default(),
|
url: row.get(0).cloned().unwrap_or_default(),
|
||||||
status: "Unknown".to_string(),
|
is_enabled: row.get(1).and_then(|s| s.parse::<i64>().ok()).unwrap_or(0) != 0,
|
||||||
message: row.get(2).cloned().unwrap_or_default(),
|
group: row.get(2).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
seeders: row.get(3).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
peers: row.get(4).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
downloaded: row.get(5).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
interval: row.get(6).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
last_updated: 0,
|
||||||
|
status: "Unknown".to_string(), // Can derive from activity later, or keep unknown
|
||||||
|
message: "".to_string(),
|
||||||
})
|
})
|
||||||
.collect())
|
.collect();
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[server(SetFilePriority, "/api/server_fns")]
|
#[server(SetFilePriority, "/api/server_fns")]
|
||||||
@@ -225,6 +238,7 @@ pub async fn set_file_priority(
|
|||||||
let ctx = expect_context::<crate::ServerContext>();
|
let ctx = expect_context::<crate::ServerContext>();
|
||||||
let client = RtorrentClient::new(&ctx.scgi_socket_path);
|
let client = RtorrentClient::new(&ctx.scgi_socket_path);
|
||||||
|
|
||||||
|
// rTorrent f.set_priority takes: target = "HASH:fINDEX", value = priority
|
||||||
let target = format!("{}:f{}", hash, file_index);
|
let target = format!("{}:f{}", hash, file_index);
|
||||||
let params = vec![
|
let params = vec![
|
||||||
RpcParam::from(target.as_str()),
|
RpcParam::from(target.as_str()),
|
||||||
@@ -232,10 +246,11 @@ pub async fn set_file_priority(
|
|||||||
];
|
];
|
||||||
|
|
||||||
client
|
client
|
||||||
.call("f.set_priority", ¶ms)
|
.call("f.priority.set", ¶ms)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| ServerFnError::new(format!("RPC error: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?;
|
||||||
|
|
||||||
|
// Notify rTorrent to update its internal priority state
|
||||||
let _ = client
|
let _ = client
|
||||||
.call("d.update_priorities", &[RpcParam::from(hash.as_str())])
|
.call("d.update_priorities", &[RpcParam::from(hash.as_str())])
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
26
test_rpc.rs
Normal file
26
test_rpc.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use shared::xmlrpc::{RtorrentClient, RpcParam, parse_multicall_response};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let client = RtorrentClient::new("/tmp/rtorrent.sock");
|
||||||
|
|
||||||
|
// Hardcode a known hash from the UI, e.g. "C3315ABFAD70C54505813D1303C1457900C5B795" (from first image)
|
||||||
|
let hash = "C3315ABFAD70C54505813D1303C1457900C5B795";
|
||||||
|
|
||||||
|
let params = vec![
|
||||||
|
RpcParam::from(hash),
|
||||||
|
RpcParam::from(""),
|
||||||
|
RpcParam::from("t.url="),
|
||||||
|
];
|
||||||
|
|
||||||
|
match client.call("t.multicall", ¶ms).await {
|
||||||
|
Ok(xml) => {
|
||||||
|
println!("Response XML:\n{}", xml);
|
||||||
|
match parse_multicall_response(&xml) {
|
||||||
|
Ok(rows) => println!("Rows ({})", rows.len()),
|
||||||
|
Err(e) => println!("Parse error: {:?}", e),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => println!("Error: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
2
ui_config.toml
Normal file
2
ui_config.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
base_color = "neutral"
|
||||||
|
base_path_components = "backend/src/components"
|
||||||
Reference in New Issue
Block a user