Take over some changes from dev but keep everything in a working state
This commit is contained in:
parent
234f78aa40
commit
a0d4fcda92
@ -6,7 +6,8 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.39"
|
||||
clap = { version = "4.5.28", features = ["derive"] }
|
||||
leptos = { version = "0.7.5", features = ["csr"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
leptos = { version = "0.7", features = ["csr"] }
|
||||
console_error_panic_hook = "0.1.7"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
gloo-net = "0.6.0"
|
||||
|
||||
28
src/lib.rs
28
src/lib.rs
@ -1,28 +0,0 @@
|
||||
use crate::session_date_calculator::{Day, NthWeekday};
|
||||
use chrono::Weekday;
|
||||
use clap::Parser;
|
||||
|
||||
pub mod session_date_calculator;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct StartArgs {
|
||||
/// on which days of the month there are sessions
|
||||
#[arg(long = "sessions", num_args = 1..)]
|
||||
pub session_days: Vec<NthWeekday>
|
||||
}
|
||||
|
||||
pub fn localize_day(day: &Day) -> String {
|
||||
format!(
|
||||
"{}, {}",
|
||||
match day.weekday {
|
||||
Weekday::Mon => "Montag",
|
||||
Weekday::Tue => "Dienstag",
|
||||
Weekday::Wed => "Mittwoch",
|
||||
Weekday::Thu => "Donnerstag",
|
||||
Weekday::Fri => "Freitag",
|
||||
Weekday::Sat => "Samstag",
|
||||
Weekday::Sun => "Sonntag",
|
||||
},
|
||||
day.date.format("%d.%m.%Y")
|
||||
)
|
||||
}
|
||||
19
src/main.rs
19
src/main.rs
@ -1,5 +1,8 @@
|
||||
mod webpage;
|
||||
mod session_date_calculator;
|
||||
|
||||
use crate::session_date_calculator::Day;
|
||||
use chrono::Weekday;
|
||||
use leptos::prelude::*;
|
||||
|
||||
fn main() {
|
||||
@ -7,3 +10,19 @@ fn main() {
|
||||
|
||||
mount_to_body(webpage::App);
|
||||
}
|
||||
|
||||
pub fn localize_day(day: &Day) -> String {
|
||||
format!(
|
||||
"{}, {}",
|
||||
match day.weekday {
|
||||
Weekday::Mon => "Montag",
|
||||
Weekday::Tue => "Dienstag",
|
||||
Weekday::Wed => "Mittwoch",
|
||||
Weekday::Thu => "Donnerstag",
|
||||
Weekday::Fri => "Freitag",
|
||||
Weekday::Sat => "Samstag",
|
||||
Weekday::Sun => "Sonntag",
|
||||
},
|
||||
day.date.format("%d.%m.%Y")
|
||||
)
|
||||
}
|
||||
@ -1,10 +1,11 @@
|
||||
use chrono::{Datelike, Days, Local, NaiveDate, ParseWeekdayError, Weekday};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::num::ParseIntError;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
|
||||
pub struct NthWeekday {
|
||||
pub n: u8,
|
||||
pub weekday: Weekday,
|
||||
|
||||
@ -1,11 +1,30 @@
|
||||
use leptos::prelude::*;
|
||||
use leptos::server_fn::request::browser::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub motd: String,
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
let (count, set_count) = signal(0);
|
||||
|
||||
let config = LocalResource::new(load_config);
|
||||
|
||||
view! {
|
||||
<button on:click=move |_| { *set_count.write() += 1 }>"Click me: " {count}</button>
|
||||
<p>"Double count: " {move || count.get() * 2}</p>
|
||||
<div style="background-color: #292b29; color: #ffffff; font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0;">
|
||||
<div style="background-color: #196e0a; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); text-align: center; max-width: 400px; width: 100%;">
|
||||
<h1>"Anstehende Proben Termine"</h1>
|
||||
<p>"TODO motd"</p>
|
||||
<button on:click=move |_| { *set_count.write() += 1 }>"Click counter (" {count} ")"</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async fn load_config() -> std::result::Result<Config, gloo_net::Error> {
|
||||
Request::get("/config.json").send().await?.json::<Config>().await
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user