Compare commits

...

2 Commits

Author SHA1 Message Date
c29d5f5a9f fix typo in home, remove assets/tailwind.css 2026-04-17 11:45:36 +02:00
12ebb3f8d9 router and home page 2026-04-17 11:39:35 +02:00
10 changed files with 74 additions and 299 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ postgres/
serveurhttp
test
.env
public/
assets/tailwind.css

View File

@ -1,262 +0,0 @@
/*! tailwindcss v4.1.5 | MIT License | https://tailwindcss.com */
@layer properties;
@layer theme, base, components, utilities;
@layer theme {
:root, :host {
--font-sans: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji';
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
--color-blue-800: oklch(42.4% 0.199 265.638);
--color-zinc-900: oklch(21% 0.006 285.885);
--color-white: #fff;
--spacing: 0.25rem;
--text-4xl: 2.25rem;
--text-4xl--line-height: calc(2.5 / 2.25);
--font-weight-bold: 700;
--default-font-family: var(--font-sans);
--default-mono-font-family: var(--font-mono);
}
}
@layer base {
*, ::after, ::before, ::backdrop, ::file-selector-button {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0 solid;
}
html, :host {
line-height: 1.5;
-webkit-text-size-adjust: 100%;
tab-size: 4;
font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji');
font-feature-settings: var(--default-font-feature-settings, normal);
font-variation-settings: var(--default-font-variation-settings, normal);
-webkit-tap-highlight-color: transparent;
}
hr {
height: 0;
color: inherit;
border-top-width: 1px;
}
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
h1, h2, h3, h4, h5, h6 {
font-size: inherit;
font-weight: inherit;
}
a {
color: inherit;
-webkit-text-decoration: inherit;
text-decoration: inherit;
}
b, strong {
font-weight: bolder;
}
code, kbd, samp, pre {
font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace);
font-feature-settings: var(--default-mono-font-feature-settings, normal);
font-variation-settings: var(--default-mono-font-variation-settings, normal);
font-size: 1em;
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
table {
text-indent: 0;
border-color: inherit;
border-collapse: collapse;
}
:-moz-focusring {
outline: auto;
}
progress {
vertical-align: baseline;
}
summary {
display: list-item;
}
ol, ul, menu {
list-style: none;
}
img, svg, video, canvas, audio, iframe, embed, object {
display: block;
vertical-align: middle;
}
img, video {
max-width: 100%;
height: auto;
}
button, input, select, optgroup, textarea, ::file-selector-button {
font: inherit;
font-feature-settings: inherit;
font-variation-settings: inherit;
letter-spacing: inherit;
color: inherit;
border-radius: 0;
background-color: transparent;
opacity: 1;
}
:where(select:is([multiple], [size])) optgroup {
font-weight: bolder;
}
:where(select:is([multiple], [size])) optgroup option {
padding-inline-start: 20px;
}
::file-selector-button {
margin-inline-end: 4px;
}
::placeholder {
opacity: 1;
}
@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {
::placeholder {
color: currentcolor;
@supports (color: color-mix(in lab, red, red)) {
color: color-mix(in oklab, currentcolor 50%, transparent);
}
}
}
textarea {
resize: vertical;
}
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-date-and-time-value {
min-height: 1lh;
text-align: inherit;
}
::-webkit-datetime-edit {
display: inline-flex;
}
::-webkit-datetime-edit-fields-wrapper {
padding: 0;
}
::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {
padding-block: 0;
}
:-moz-ui-invalid {
box-shadow: none;
}
button, input:where([type='button'], [type='reset'], [type='submit']), ::file-selector-button {
appearance: button;
}
::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
height: auto;
}
[hidden]:where(:not([hidden='until-found'])) {
display: none !important;
}
}
@layer utilities {
.visible {
visibility: visible;
}
.static {
position: static;
}
.contents {
display: contents;
}
.flex {
display: flex;
}
.hidden {
display: none;
}
.table {
display: table;
}
.h-screen {
height: 100vh;
}
.w-screen {
width: 100vw;
}
.transform {
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
}
.flex-col {
flex-direction: column;
}
.bg-zinc-900 {
background-color: var(--color-zinc-900);
}
.p-1 {
padding: calc(var(--spacing) * 1);
}
.p-2 {
padding: calc(var(--spacing) * 2);
}
.px-2 {
padding-inline: calc(var(--spacing) * 2);
}
.text-4xl {
font-size: var(--text-4xl);
line-height: var(--tw-leading, var(--text-4xl--line-height));
}
.font-bold {
--tw-font-weight: var(--font-weight-bold);
font-weight: var(--font-weight-bold);
}
.text-blue-800 {
color: var(--color-blue-800);
}
.text-white {
color: var(--color-white);
}
.underline {
text-decoration-line: underline;
}
}
@property --tw-rotate-x {
syntax: "*";
inherits: false;
}
@property --tw-rotate-y {
syntax: "*";
inherits: false;
}
@property --tw-rotate-z {
syntax: "*";
inherits: false;
}
@property --tw-skew-x {
syntax: "*";
inherits: false;
}
@property --tw-skew-y {
syntax: "*";
inherits: false;
}
@property --tw-font-weight {
syntax: "*";
inherits: false;
}
@layer properties {
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
*, ::before, ::after, ::backdrop {
--tw-rotate-x: initial;
--tw-rotate-y: initial;
--tw-rotate-z: initial;
--tw-skew-x: initial;
--tw-skew-y: initial;
--tw-font-weight: initial;
}
}
}

View File

@ -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 ..." } } }
}
}
}

View File

@ -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"
}
}
}
}

View 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"}

View File

@ -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,
}
}
}

View File

@ -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
View 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 know, you're impressed by my design skills." }
}
}
}

View File

@ -1,2 +1,5 @@
//mod upload;
//pub use upload::Upload;
mod upload;
pub use upload::{Upload, UploadInfo};
mod home;
pub use home::Home;

View File

@ -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 }
}
}