router and home page
This commit is contained in:
@ -137,7 +137,7 @@ pub fn build_table(files: Vec<(String, String, Option<Result<String, HttpError>>
|
||||
rsx! { p { "Upload failed, reason : {msg}" } }
|
||||
}
|
||||
} }
|
||||
None => { rsx! { p { "Waiting for file to be uploaded" } } }
|
||||
None => { rsx! { p { "Uploading ..." } } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,10 +62,15 @@ fn show_file_info(file_id: String, file_info: &FetchedInfo) -> Element {
|
||||
p { "Position in the deletion queue : ",
|
||||
match file_info.deletion_pos {
|
||||
Some(pos) => pos.to_string(),
|
||||
None => "unknown".to_string()
|
||||
None => "files aren't deleted for a week after the time of upload".to_string()
|
||||
}
|
||||
}
|
||||
a { class: "height-20px text-blue-800 underline", href: "/upload/{file_id}/dl", "click here to download the file"}
|
||||
a {
|
||||
class: "height-20px text-blue-800 underline",
|
||||
rel: "noopener noreferrer",
|
||||
href: "/upload/{file_id}/dl",
|
||||
"click here to download the file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,8 +61,12 @@ async fn get_upload_stats() -> Result<UploadServerStats, HttpError> {
|
||||
}
|
||||
|
||||
fn render_stats(stats : &UploadServerStats) -> Element {
|
||||
let soft_percentage = stats.used_space as f32 / stats.total_limit_soft as f32;
|
||||
let hard_percentage = stats.used_space as f32 / stats.total_limit_hard as f32;
|
||||
let mut soft_percentage = stats.used_space as f32 / stats.total_limit_soft as f32;
|
||||
let mut hard_percentage = stats.used_space as f32 / stats.total_limit_hard as f32;
|
||||
|
||||
soft_percentage = (soft_percentage * 1000f32).round() / 1000f32;
|
||||
hard_percentage = (hard_percentage * 1000f32).round() / 1000f32;
|
||||
|
||||
|
||||
rsx! {
|
||||
h1 {class: "text-4xl font-bold", "Server info"}
|
||||
|
||||
@ -22,13 +22,13 @@ impl ServerConfig {
|
||||
}
|
||||
|
||||
pub struct ClientConfig {
|
||||
pub upload_max_size: usize,
|
||||
pub upload_max_size: u64,
|
||||
}
|
||||
|
||||
impl ClientConfig {
|
||||
pub fn load() -> Self {
|
||||
Self {
|
||||
upload_max_size: 1024 * 1024 * 1024 * 1, //1GB for testing
|
||||
upload_max_size: 1024 * 1024 * 1024 * 50,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
src/main.rs
24
src/main.rs
@ -1,21 +1,26 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::components::upload::{FileInfo, UploadFile, UploadStats};
|
||||
use tracing::Level;
|
||||
|
||||
pub mod config;
|
||||
|
||||
use crate::components::toast::ToastProvider;
|
||||
|
||||
use crate::views::{Upload, UploadInfo, Home};
|
||||
|
||||
mod components;
|
||||
mod views;
|
||||
|
||||
//#[derive(Debug, Clone, Routable, PartialEq)]
|
||||
//#[rustfmt::skip]
|
||||
//enum Route {
|
||||
// #[route("/upload")]
|
||||
// Upload { },
|
||||
//}
|
||||
#[derive(Debug, Clone, Routable, PartialEq)]
|
||||
#[rustfmt::skip]
|
||||
enum Route {
|
||||
#[route("/")]
|
||||
Home { },
|
||||
#[route("/upload/:file")]
|
||||
UploadInfo { file: String },
|
||||
#[route("/upload")]
|
||||
Upload { },
|
||||
}
|
||||
|
||||
|
||||
const FAVICON: Asset = asset!("/assets/favicon.ico");
|
||||
@ -34,10 +39,7 @@ fn App() -> Element {
|
||||
div {
|
||||
class: "h-screen w-screen bg-zinc-900 text-white",
|
||||
ToastProvider {
|
||||
UploadFile { }
|
||||
FileInfo {file: "ULI0GZWJQH9BGEZR1VZ1"}
|
||||
UploadStats { }
|
||||
// Router::<Route> {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
21
src/views/home.rs
Normal file
21
src/views/home.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use dioxus::prelude::*;
|
||||
use crate::Route;
|
||||
|
||||
#[component]
|
||||
pub fn Home() -> Element {
|
||||
rsx! {
|
||||
div { class : "flex flex-col text-3xl px-2",
|
||||
Link {
|
||||
to : Route::Upload { },
|
||||
class: "height-20px text-blue-700 underline py-1",
|
||||
"Upload"
|
||||
}
|
||||
a {
|
||||
class: "height-20px text-blue-700 underline py-1",
|
||||
href : "https://git.tmoron.fr/tom",
|
||||
"gitea"
|
||||
}
|
||||
p { class : "text-sm text-gray-600", "I konw, you're impressed by my design skills." }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,5 @@
|
||||
//mod upload;
|
||||
//pub use upload::Upload;
|
||||
mod upload;
|
||||
pub use upload::{Upload, UploadInfo};
|
||||
|
||||
mod home;
|
||||
pub use home::Home;
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
use dioxus::{
|
||||
fullstack::{FileStream},
|
||||
prelude::*,
|
||||
};
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
use crate::config::ServerConfig;
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
use httpserver::models::{GetFile,NewFile};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use httpserver::DB;
|
||||
use crate::components::upload::{ FileInfo, UploadFile, UploadStats };
|
||||
|
||||
|
||||
use dioxus_primitives::toast::{
|
||||
ToastOptions,
|
||||
consume_toast
|
||||
};
|
||||
#[component]
|
||||
pub fn Upload() -> Element {
|
||||
rsx! {
|
||||
UploadFile { }
|
||||
UploadStats { }
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn UploadInfo(file: String) -> Element {
|
||||
rsx! {
|
||||
FileInfo{ file : file }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user