Added footer to public page. Leptos upgraded to 0.6.13

main
Josef Rokos 8 months ago
parent 9f9b716781
commit a5cfc96814

1717
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
[package] [package]
name = "rezervator" name = "rezervator"
version = "1.1.0" version = "1.1.2"
edition = "2021" edition = "2021"
[lib] [lib]
@ -9,21 +9,22 @@ crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
actix-files = { version = "0.6.2", optional = true } actix-files = { version = "0.6.2", optional = true }
actix-web = { version = "4.5.1", optional = true, features = ["macros"] } actix-web = { version = "4.5.1", optional = true, features = ["macros"] }
actix-session = { version = "0.9.0", optional = true, features = ["cookie-session"] } actix-session = { version = "0.10.0", optional = true, features = ["cookie-session"] }
actix-multipart = { version = "0.6.1", optional = true } actix-multipart = { version = "0.7.2", optional = true }
console_error_panic_hook = "0.1.7" console_error_panic_hook = "0.1.7"
cfg-if = "1" cfg-if = "1"
leptos = { version = "0.6.11" } leptos = { version = "0.6.13" }
leptos_meta = { version = "0.6.11" } leptos_meta = { version = "0.6.13" }
leptos_actix = { version = "0.6.11", optional = true } leptos_actix = { version = "0.6.13", optional = true }
server_fn = { version = "0.6.11", features = ["multipart"] } server_fn = { version = "0.6.13", features = ["multipart"] }
leptos_router = { version = "0.6.11" } leptos_router = { version = "0.6.13" }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
wasm-bindgen = "=0.2.92" serde_json = "1.0.117"
wasm-bindgen = "=0.2.93"
web-sys = { version = "0.3.69", features = ["Navigator"] } web-sys = { version = "0.3.69", features = ["Navigator"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
chrono = { version = "0.4.38", features = ["serde"]} chrono = { version = "0.4.38", features = ["serde"]}
sqlx = { version = "0.7.4", optional = true, features = ["runtime-tokio-rustls", "postgres", "chrono", "rust_decimal", "uuid"] } sqlx = { version = "0.8.0", optional = true, features = ["runtime-tokio-rustls", "postgres", "chrono", "rust_decimal", "uuid"] }
rust_decimal = "1.35.0" rust_decimal = "1.35.0"
uuid = {version = "1.8.0", features = ["v4", "serde"]} uuid = {version = "1.8.0", features = ["v4", "serde"]}
validator = {version = "0.16.1", features = ["derive"]} validator = {version = "0.16.1", features = ["derive"]}
@ -34,7 +35,7 @@ toml = "0.8.12"
log = "0.4.21" log = "0.4.21"
env_logger = "0.11.3" env_logger = "0.11.3"
getopts = "0.2.21" getopts = "0.2.21"
leptos-use = "0.10.8" leptos-use = "0.12.0"
lettre = {version = "0.11.6", features = ["tokio1-native-tls", "smtp-transport", "file-transport"], optional = true} lettre = {version = "0.11.6", features = ["tokio1-native-tls", "smtp-transport", "file-transport"], optional = true}
leptos-captcha = "0.2.0" leptos-captcha = "0.2.0"
charts-rs = { version = "0.3.5", optional = true} charts-rs = { version = "0.3.5", optional = true}

@ -75,6 +75,9 @@ body {
background-color: var(--bs-body-bg); background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(67, 89, 113, 0); -webkit-tap-highlight-color: rgba(67, 89, 113, 0);
display: flex;
flex-direction: column;
min-height: 100vh;
} }
hr { hr {
@ -15228,7 +15231,7 @@ html:not(.layout-menu-fixed) .menu-inner-shadow {
.layout-navbar, .layout-navbar,
.content-footer { .content-footer {
flex: 0 0 auto;
} }
.layout-page { .layout-page {
@ -16743,3 +16746,7 @@ html:not(.layout-footer-fixed) .content-wrapper {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
main {
flex: 1;
}

@ -62,6 +62,19 @@ impl DialogHelper {
} }
} }
#[component]
fn app_footer() -> impl IntoView {
let loc = use_location();
view! {
<footer class="content-footer footer bg-footer-theme" style={move || if loc.pathname.get().starts_with("/admin") {"display: none;"} else {"display: block;"}}>
<div class="mb-2 mb-md-0" >
<a href="https://rezervovator.cz" target="_blank"><img src="/rezervovator_l.svg" width="110"/></a> {format!(" v {}", env!("CARGO_PKG_VERSION"))}
</div>
</footer>
}
}
#[component] #[component]
pub fn App() -> impl IntoView { pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc. // Provides context that manages stylesheets, titles, meta tags, etc.
@ -111,6 +124,7 @@ pub fn App() -> impl IntoView {
}/> }/>
</Routes> </Routes>
</main> </main>
<AppFooter/>
</Router> </Router>
} }
} }

@ -77,8 +77,8 @@ cfg_if! { if #[cfg(feature = "ssr")] {
} }
if let Ok(Some(mut field)) = data.try_next().await { if let Ok(Some(mut field)) = data.try_next().await {
let content_disp = field.content_disposition().clone(); let content_disp = field.content_disposition();
let file_name = content_disp.get_filename().unwrap(); let file_name = content_disp.unwrap().get_filename().unwrap().to_string();
if file_name.is_empty() { if file_name.is_empty() {
return Redirect::to("/admin/appearance").see_other(); return Redirect::to("/admin/appearance").see_other();
@ -90,8 +90,8 @@ cfg_if! { if #[cfg(feature = "ssr")] {
let c = chunk.unwrap(); let c = chunk.unwrap();
let _ = file.write_all(&c); let _ = file.write_all(&c);
} }
let _ = set_banner_name(file_name, &app_data.db_pool).await; let _ = set_banner_name(&file_name, &app_data.db_pool).await;
let _ = modify_style(file_name).await; let _ = modify_style(&file_name).await;
} }
Redirect::to("/admin/appearance").see_other() Redirect::to("/admin/appearance").see_other()

@ -10,7 +10,12 @@ cfg_if! { if #[cfg(feature = "ssr")] {
use std::ops::DerefMut; use std::ops::DerefMut;
use leptos::expect_context; use leptos::expect_context;
use leptos_actix::extract; use leptos_actix::extract;
use actix_session::Session; use actix_web::cookie::Cookie;
use actix_web::cookie::SameSite;
use leptos_actix::ResponseOptions;
use actix_web::http::header;
use actix_web::http::header::HeaderValue;
use actix_web::HttpRequest;
pub async fn find_customer_by_email(email: &str, tx: &mut Transaction<'_, Postgres>) -> Option<Customer> { pub async fn find_customer_by_email(email: &str, tx: &mut Transaction<'_, Postgres>) -> Option<Customer> {
let customer = query_as::<_, Customer>("SELECT * FROM customer WHERE email = $1") let customer = query_as::<_, Customer>("SELECT * FROM customer WHERE email = $1")
@ -54,8 +59,19 @@ cfg_if! { if #[cfg(feature = "ssr")] {
} }
pub async fn remember_customer(customer: Customer) -> Result<(), ServerFnError> { pub async fn remember_customer(customer: Customer) -> Result<(), ServerFnError> {
let session: Session = extract().await?; let cookie = Cookie::build("customer", serde_json::to_string(&customer).unwrap_or("".to_string()))
session.insert("customer", customer)?; .http_only(true)
.secure(true)
.same_site(SameSite::Lax)
.permanent()
.path("/")
.finish();
let response = expect_context::<ResponseOptions>();
if let Ok(cookie) = HeaderValue::from_str(&cookie.to_string()) {
response.insert_header(header::SET_COOKIE, cookie);
}
Ok(()) Ok(())
} }
}} }}
@ -78,14 +94,12 @@ pub async fn get_customers() -> Result<ApiResponse<Vec<Customer>>, ServerFnError
#[server] #[server]
pub async fn get_remembered() -> Result<Option<Customer>, ServerFnError> { pub async fn get_remembered() -> Result<Option<Customer>, ServerFnError> {
use actix_session::*; let request: HttpRequest = extract().await?;
use leptos_actix::extract;
let session = extract::<Session>().await;
if session.is_err() { if let Some(cv) = request.cookie("customer").map(|c| c.value().to_string()) {
return Ok(None); Ok(Some(serde_json::from_str(&cv).unwrap_or(Customer::default())))
} else {
Ok(None)
} }
Ok(session.unwrap().get::<Customer>("customer").unwrap_or(None))
} }
Loading…
Cancel
Save