Compare commits
3 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec76ddb041 | ||
|
|
51ff2cd673 | ||
|
|
b2f856f80f |
0
backend/src/components/mod.rs
Normal file
0
backend/src/components/mod.rs
Normal file
@@ -1,3 +1,4 @@
|
|||||||
|
mod components;
|
||||||
mod diff;
|
mod diff;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
#[cfg(feature = "push-notifications")]
|
#[cfg(feature = "push-notifications")]
|
||||||
|
|||||||
@@ -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" data-preload="false" />
|
||||||
<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" />
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@import "tw-animate-css";
|
@import "tw-animate-css";
|
||||||
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.625rem;
|
--radius: 0.625rem;
|
||||||
--background: oklch(1 0 0);
|
--background: oklch(1 0 0);
|
||||||
@@ -45,7 +44,6 @@
|
|||||||
--ring: oklch(0.556 0 0);
|
--ring: oklch(0.556 0 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
--color-foreground: var(--foreground);
|
--color-foreground: var(--foreground);
|
||||||
@@ -82,10 +80,10 @@
|
|||||||
|
|
||||||
button:not(:disabled),
|
button:not(:disabled),
|
||||||
[role="button"]:not(:disabled) {
|
[role="button"]:not(:disabled) {
|
||||||
cursor: pointer;
|
@apply cursor-pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog {
|
dialog {
|
||||||
margin: auto;
|
@apply m-auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,34 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
||||||
use crate::components::ui::input::{Input, InputType};
|
use crate::components::ui::auto_form::{AutoForm, AutoFormField};
|
||||||
|
|
||||||
use crate::components::ui::button::Button;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Login() -> impl IntoView {
|
pub fn Login() -> impl IntoView {
|
||||||
let username = RwSignal::new(String::new());
|
|
||||||
let password = RwSignal::new(String::new());
|
|
||||||
let error = signal(Option::<String>::None);
|
let error = signal(Option::<String>::None);
|
||||||
let loading = signal(false);
|
let loading = signal(false);
|
||||||
|
|
||||||
let handle_login = move |ev: web_sys::SubmitEvent| {
|
let fields = vec![
|
||||||
ev.prevent_default();
|
AutoFormField::Text {
|
||||||
|
name: "username".to_string(),
|
||||||
|
label: "Kullanıcı Adı".to_string(),
|
||||||
|
placeholder: Some("Kullanıcı adınız".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "password".to_string(),
|
||||||
|
label: "Şifre".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let on_submit = move |data: std::collections::HashMap<String, String>| {
|
||||||
loading.1.set(true);
|
loading.1.set(true);
|
||||||
error.1.set(None);
|
error.1.set(None);
|
||||||
|
|
||||||
let user = username.get();
|
let user = data.get("username").cloned().unwrap_or_default();
|
||||||
let pass = password.get();
|
let pass = data.get("password").cloned().unwrap_or_default();
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match shared::server_fns::auth::login(user, pass).await {
|
match shared::server_fns::auth::login(user, pass).await {
|
||||||
@@ -49,45 +59,18 @@ pub fn Login() -> impl IntoView {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent class="pt-4">
|
<CardContent class="pt-4">
|
||||||
<form on:submit=handle_login class="space-y-4">
|
<AutoForm
|
||||||
<div class="space-y-2">
|
fields=fields
|
||||||
<label class="text-sm font-medium leading-none">"Kullanıcı Adı"</label>
|
submit_label="Giriş Yap"
|
||||||
<Input
|
on_submit=on_submit
|
||||||
r#type=InputType::Text
|
loading=loading.0.into()
|
||||||
placeholder="Kullanıcı adınız"
|
/>
|
||||||
bind_value=username
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when=move || error.0.get().is_some()>
|
<Show when=move || error.0.get().is_some()>
|
||||||
<div class="rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
<div class="mt-4 rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
||||||
{move || error.0.get().unwrap_or_default()}
|
{move || error.0.get().unwrap_or_default()}
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<div class="pt-2">
|
|
||||||
<Button
|
|
||||||
class="w-full"
|
|
||||||
attr:r#type="submit"
|
|
||||||
attr:disabled=move || loading.0.get()
|
|
||||||
>
|
|
||||||
<Show when=move || loading.0.get() fallback=|| view! { "Giriş Yap" }.into_any()>
|
|
||||||
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
|
||||||
"Giriş Yapılıyor..."
|
|
||||||
</Show>
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Show>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,38 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
use crate::components::ui::card::{Card, CardHeader, CardContent};
|
||||||
use crate::components::ui::input::{Input, InputType};
|
use crate::components::ui::auto_form::{AutoForm, AutoFormField};
|
||||||
|
|
||||||
use crate::components::ui::button::Button;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Setup() -> impl IntoView {
|
pub fn Setup() -> impl IntoView {
|
||||||
let username = RwSignal::new(String::new());
|
|
||||||
let password = RwSignal::new(String::new());
|
|
||||||
let confirm_password = RwSignal::new(String::new());
|
|
||||||
let error = signal(Option::<String>::None);
|
let error = signal(Option::<String>::None);
|
||||||
let loading = signal(false);
|
let loading = signal(false);
|
||||||
|
|
||||||
let handle_setup = move |ev: web_sys::SubmitEvent| {
|
let fields = vec![
|
||||||
ev.prevent_default();
|
AutoFormField::Text {
|
||||||
|
name: "username".to_string(),
|
||||||
|
label: "Yönetici Kullanıcı Adı".to_string(),
|
||||||
|
placeholder: Some("admin".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "password".to_string(),
|
||||||
|
label: "Şifre".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
AutoFormField::Password {
|
||||||
|
name: "confirm_password".to_string(),
|
||||||
|
label: "Şifre Onay".to_string(),
|
||||||
|
placeholder: Some("******".to_string()),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
let pass = password.get();
|
let on_submit = move |data: std::collections::HashMap<String, String>| {
|
||||||
let confirm = confirm_password.get();
|
let user = data.get("username").cloned().unwrap_or_default();
|
||||||
|
let pass = data.get("password").cloned().unwrap_or_default();
|
||||||
|
let confirm = data.get("confirm_password").cloned().unwrap_or_default();
|
||||||
|
|
||||||
if pass != confirm {
|
if pass != confirm {
|
||||||
error.1.set(Some("Şifreler eşleşmiyor".to_string()));
|
error.1.set(Some("Şifreler eşleşmiyor".to_string()));
|
||||||
@@ -32,8 +47,6 @@ pub fn Setup() -> impl IntoView {
|
|||||||
loading.1.set(true);
|
loading.1.set(true);
|
||||||
error.1.set(None);
|
error.1.set(None);
|
||||||
|
|
||||||
let user = username.get();
|
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match shared::server_fns::auth::setup(user, pass).await {
|
match shared::server_fns::auth::setup(user, pass).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -64,54 +77,18 @@ pub fn Setup() -> impl IntoView {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent class="pt-4">
|
<CardContent class="pt-4">
|
||||||
<form on:submit=handle_setup class="space-y-4">
|
<AutoForm
|
||||||
<div class="space-y-2">
|
fields=fields
|
||||||
<label class="text-sm font-medium leading-none">"Yönetici Kullanıcı Adı"</label>
|
submit_label="Kurulumu Tamamla"
|
||||||
<Input
|
on_submit=on_submit
|
||||||
r#type=InputType::Text
|
loading=loading.0.into()
|
||||||
placeholder="admin"
|
/>
|
||||||
bind_value=username
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-sm font-medium leading-none">"Şifre Onay"</label>
|
|
||||||
<Input
|
|
||||||
r#type=InputType::Password
|
|
||||||
placeholder="******"
|
|
||||||
bind_value=confirm_password
|
|
||||||
disabled=loading.0.get()
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when=move || error.0.get().is_some() fallback=|| ()>
|
<Show when=move || error.0.get().is_some() fallback=|| ()>
|
||||||
<div class="rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
<div class="mt-4 rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive">
|
||||||
<span>{move || error.0.get().unwrap_or_default()}</span>
|
<span>{move || error.0.get().unwrap_or_default()}</span>
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<div class="pt-2">
|
|
||||||
<Button
|
|
||||||
class="w-full"
|
|
||||||
attr:r#type="submit"
|
|
||||||
attr:disabled=move || loading.0.get()
|
|
||||||
>
|
|
||||||
<Show when=move || loading.0.get() fallback=|| view! { "Kurulumu Tamamla" }.into_any()>
|
|
||||||
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
|
||||||
"Kuruluyor..."
|
|
||||||
</Show>
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Show>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,16 +24,10 @@ pub fn TorrentContextMenu(
|
|||||||
{children()}
|
{children()}
|
||||||
</ContextMenuTrigger>
|
</ContextMenuTrigger>
|
||||||
<ContextMenuContent class="w-56 p-1.5">
|
<ContextMenuContent class="w-56 p-1.5">
|
||||||
<ContextMenuItem on:click={let h = hash_c1; move |_| {
|
<ContextMenuItem on:click={let h = hash_c1; move |_| on_action_stored.get_value().run(("start".to_string(), h.clone()))}>
|
||||||
on_action_stored.get_value().run(("start".to_string(), h.clone()));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}}>
|
|
||||||
"Başlat"
|
"Başlat"
|
||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
<ContextMenuItem on:click={let h = hash_c2; move |_| {
|
<ContextMenuItem on:click={let h = hash_c2; move |_| on_action_stored.get_value().run(("stop".to_string(), h.clone()))}>
|
||||||
on_action_stored.get_value().run(("stop".to_string(), h.clone()));
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
|
||||||
}}>
|
|
||||||
"Durdur"
|
"Durdur"
|
||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
|
|
||||||
|
|||||||
93
frontend/src/components/ui/auto_form.rs
Normal file
93
frontend/src/components/ui/auto_form.rs
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use tailwind_fuse::tw_merge;
|
||||||
|
use crate::components::ui::button::Button;
|
||||||
|
use crate::components::ui::input::{Input, InputType};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum AutoFormField {
|
||||||
|
Text {
|
||||||
|
name: String,
|
||||||
|
label: String,
|
||||||
|
placeholder: Option<String>,
|
||||||
|
required: bool,
|
||||||
|
},
|
||||||
|
Password {
|
||||||
|
name: String,
|
||||||
|
label: String,
|
||||||
|
placeholder: Option<String>,
|
||||||
|
required: bool,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn AutoForm(
|
||||||
|
#[prop(into)] fields: Vec<AutoFormField>,
|
||||||
|
#[prop(into)] submit_label: String,
|
||||||
|
#[prop(into)] on_submit: Callback<std::collections::HashMap<String, String>>,
|
||||||
|
#[prop(optional)] loading: Signal<bool>,
|
||||||
|
#[prop(optional, into)] class: String,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let field_values = fields.iter().map(|f| {
|
||||||
|
let name = match f {
|
||||||
|
AutoFormField::Text { name, .. } => name,
|
||||||
|
AutoFormField::Password { name, .. } => name,
|
||||||
|
};
|
||||||
|
(name.clone(), RwSignal::new(String::new()))
|
||||||
|
}).collect::<std::collections::HashMap<String, RwSignal<String>>>();
|
||||||
|
|
||||||
|
let handle_submit = {
|
||||||
|
let field_values = field_values.clone();
|
||||||
|
move |ev: web_sys::SubmitEvent| {
|
||||||
|
ev.prevent_default();
|
||||||
|
let mut data = std::collections::HashMap::new();
|
||||||
|
for (name, signal) in &field_values {
|
||||||
|
data.insert(name.clone(), signal.get());
|
||||||
|
}
|
||||||
|
on_submit.run(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<form on:submit=handle_submit class=tw_merge!("space-y-4", class)>
|
||||||
|
{fields.into_iter().map(|field| {
|
||||||
|
let (name, label, placeholder, r#type, required) = match field {
|
||||||
|
AutoFormField::Text { name, label, placeholder, required } => (name, label, placeholder, InputType::Text, required),
|
||||||
|
AutoFormField::Password { name, label, placeholder, required } => (name, label, placeholder, InputType::Password, required),
|
||||||
|
};
|
||||||
|
|
||||||
|
let signal = field_values.get(&name).cloned().unwrap();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
r#type=r#type
|
||||||
|
placeholder=placeholder.unwrap_or_default()
|
||||||
|
bind_value=signal
|
||||||
|
required=required
|
||||||
|
disabled=loading.get()
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}).collect_view()}
|
||||||
|
|
||||||
|
<div class="pt-2">
|
||||||
|
<Button
|
||||||
|
class="w-full"
|
||||||
|
attr:r#type="submit"
|
||||||
|
attr:disabled=move || loading.get()
|
||||||
|
>
|
||||||
|
<Show when=move || loading.get() fallback=move || {
|
||||||
|
let label = submit_label.clone();
|
||||||
|
view! { <span>{label}</span> }.into_any()
|
||||||
|
}>
|
||||||
|
<span class="animate-spin mr-2 h-4 w-4 border-2 border-current border-t-transparent rounded-full"></span>
|
||||||
|
"İşleniyor..."
|
||||||
|
</Show>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod accordion;
|
pub mod accordion;
|
||||||
pub mod alert_dialog;
|
pub mod alert_dialog;
|
||||||
|
pub mod auto_form;
|
||||||
pub mod badge;
|
pub mod badge;
|
||||||
pub mod button;
|
pub mod button;
|
||||||
pub mod button_action;
|
pub mod button_action;
|
||||||
|
|||||||
26
frontend/src/components/ui/progress.rs
Normal file
26
frontend/src/components/ui/progress.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use leptos::prelude::*;
|
||||||
|
use tailwind_fuse::tw_merge;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn Progress(
|
||||||
|
#[prop(into)] value: Signal<f64>,
|
||||||
|
#[prop(optional, into)] class: String,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let progress_style = move || format!("transform: translateX(-{}%);", 100.0 - value.get().clamp(0.0, 100.0));
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div
|
||||||
|
data-name="Progress"
|
||||||
|
class=tw_merge!(
|
||||||
|
"relative h-2 w-full overflow-hidden rounded-full bg-primary/20",
|
||||||
|
class
|
||||||
|
)
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
data-name="ProgressIndicator"
|
||||||
|
class="h-full w-full flex-1 bg-primary transition-all duration-500 ease-in-out"
|
||||||
|
style=progress_style
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
1369
package-lock.json
generated
1369
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"dependencies": {
|
||||||
"dependencies": {
|
"@tailwindcss/cli": "^4.1.18",
|
||||||
"@tailwindcss/cli": "^4.1.18",
|
"tailwindcss": "^4.1.18",
|
||||||
"tailwindcss": "^4.1.18",
|
"tw-animate-css": "^1.4.0"
|
||||||
"tw-animate-css": "^1.4.0"
|
},
|
||||||
}
|
"type": "module"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user