Improved logging, UI tweaks.
This commit is contained in:
Generated
+1
-1
@@ -2963,7 +2963,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rezervator"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-multipart",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rezervator"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
@@ -88,7 +88,7 @@ browserquery = "defaults"
|
||||
# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
|
||||
watch = false
|
||||
# The environment Leptos will run in, usually either "DEV" or "PROD"
|
||||
env = "DEV"
|
||||
env = "PROD"
|
||||
# The features to use when compiling the bin target
|
||||
#
|
||||
# Optional. Can be over-ridden with the command line parameter --bin-features
|
||||
|
||||
+9
-1
@@ -7,8 +7,12 @@ div.header_banner {
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.header_banner_text {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
h1.header_banner {
|
||||
font-size: xxx-large;
|
||||
font-size: x-large;
|
||||
color: white;
|
||||
text-shadow: -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000;
|
||||
}
|
||||
@@ -17,4 +21,8 @@ h1.header_banner {
|
||||
div.header_banner {
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
h1.header_banner {
|
||||
font-size: xxx-large;
|
||||
}
|
||||
}
|
||||
@@ -23,3 +23,6 @@ path = "Maildir"
|
||||
#password = "password"
|
||||
#tls = true
|
||||
#accept_all_certs = true
|
||||
|
||||
[logging]
|
||||
severity = "debug"
|
||||
|
||||
@@ -14,6 +14,7 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
||||
use std::str::FromStr;
|
||||
use std::collections::HashMap;
|
||||
use log::warn;
|
||||
use log::info;
|
||||
use crate::backend::data::{ReservationSum, ReservationState, ResWithProperty, Customer, Message, MessageType, ChartData, ResAllView};
|
||||
use crate::backend::get_pool;
|
||||
use crate::backend::get_mailing;
|
||||
@@ -239,6 +240,8 @@ pub async fn get_public_form_data(day: NaiveDate) -> Result<ApiResponse<Vec<Publ
|
||||
let props = get_props(Some("active = true".to_string())).await?;
|
||||
let reservations = reservations_for_day(&day).await?;
|
||||
|
||||
info!("Loading public form data");
|
||||
|
||||
Ok(ApiResponse::Data(props.into_iter().map(|p| PublicFormData {
|
||||
property: p,
|
||||
hours: hours.clone(),
|
||||
@@ -344,6 +347,8 @@ pub async fn create_reservation(reservation: CrReservation, pow: String) -> Resu
|
||||
warn!("Notification not send: {}", e);
|
||||
}
|
||||
|
||||
info!("Reservation created");
|
||||
|
||||
Ok(ApiResponse::Data(reservation.date()))
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,8 @@ pub async fn logout() -> Result<(), ServerFnError> {
|
||||
let session = extract::<Session>().await?;
|
||||
session.clear();
|
||||
|
||||
info!("User logged out");
|
||||
|
||||
redirect("/login");
|
||||
Ok(())
|
||||
}
|
||||
@@ -150,6 +152,7 @@ pub async fn admin_check() -> Result<bool, ServerFnError> {
|
||||
|
||||
#[server]
|
||||
pub async fn get_user() -> Result<Option<User>, ServerFnError> {
|
||||
info!("Get user");
|
||||
Ok(logged_in_user().await)
|
||||
}
|
||||
|
||||
@@ -231,6 +234,8 @@ pub async fn change_pwd(new_pw: PwdChange) -> Result<ApiResponse<()>, ServerFnEr
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
info!("Password changed for user: {}", new_pw.login());
|
||||
|
||||
Ok(ApiResponse::Data(()))
|
||||
}
|
||||
|
||||
|
||||
+17
-1
@@ -107,6 +107,18 @@ impl Mailing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
#[derive(Deserialize)]
|
||||
pub struct Logging {
|
||||
severity: String
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
impl Logging {
|
||||
pub fn severity(&self) -> &str {
|
||||
&self.severity
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
#[derive(Deserialize)]
|
||||
@@ -114,7 +126,8 @@ pub struct Configuration {
|
||||
session: Session,
|
||||
network: Network,
|
||||
database: Database,
|
||||
mailing: Mailing
|
||||
mailing: Mailing,
|
||||
logging: Logging
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
@@ -131,6 +144,9 @@ impl Configuration {
|
||||
pub fn mailing(&self) -> &Mailing {
|
||||
&self.mailing
|
||||
}
|
||||
pub fn logging(&self) -> &Logging {
|
||||
&self.logging
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
|
||||
+14
-1
@@ -2,6 +2,7 @@ use std::error::Error;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use chrono::ParseError;
|
||||
use leptos::ServerFnError;
|
||||
use log::error;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub enum AppError {
|
||||
@@ -28,6 +29,10 @@ impl AppError {
|
||||
}
|
||||
}
|
||||
|
||||
fn log_error(error: &dyn ToString) {
|
||||
error!("Application error: {}", error.to_string());
|
||||
}
|
||||
|
||||
impl Display for AppError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.as_string())
|
||||
@@ -38,6 +43,7 @@ impl Error for AppError {}
|
||||
|
||||
impl From<ServerFnError> for AppError {
|
||||
fn from(value: ServerFnError) -> Self {
|
||||
log_error(&value);
|
||||
AppError::ServerError(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -45,12 +51,14 @@ impl From<ServerFnError> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<sqlx::Error> for AppError {
|
||||
fn from(value: sqlx::Error) -> Self {
|
||||
log_error(&value);
|
||||
AppError::FatalError(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseError> for AppError {
|
||||
fn from(_value: ParseError) -> Self {
|
||||
fn from(value: ParseError) -> Self {
|
||||
log_error(&value);
|
||||
AppError::HourParseError
|
||||
}
|
||||
}
|
||||
@@ -58,6 +66,7 @@ impl From<ParseError> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<lettre::address::AddressError> for AppError {
|
||||
fn from(value: lettre::address::AddressError) -> Self {
|
||||
log_error(&value);
|
||||
AppError::MailAddrParseErr(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -65,6 +74,7 @@ impl From<lettre::address::AddressError> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<lettre::error::Error> for AppError {
|
||||
fn from(value: lettre::error::Error) -> Self {
|
||||
log_error(&value);
|
||||
AppError::MailSendError(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -72,6 +82,7 @@ impl From<lettre::error::Error> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<lettre::transport::smtp::Error> for AppError {
|
||||
fn from(value: lettre::transport::smtp::Error) -> Self {
|
||||
log_error(&value);
|
||||
AppError::MailSendError(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -79,6 +90,7 @@ impl From<lettre::transport::smtp::Error> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<lettre::transport::file::Error> for AppError {
|
||||
fn from(value: lettre::transport::file::Error) -> Self {
|
||||
log_error(&value);
|
||||
AppError::MailSendError(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -86,6 +98,7 @@ impl From<lettre::transport::file::Error> for AppError {
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<std::io::Error> for AppError {
|
||||
fn from(value: std::io::Error) -> Self {
|
||||
log_error(&value);
|
||||
AppError::FileIOError(value.to_string())
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,8 @@ lazy_static! {
|
||||
("Update text", "Upravit text"),
|
||||
("Update title", "Upravit titulek"),
|
||||
("Are you sure you want to delete banner?", "Opravdu chcete smazat banner?"),
|
||||
("Delete banner", "Smazat banner")
|
||||
("Delete banner", "Smazat banner"),
|
||||
("Appearance", "Vzhled")
|
||||
])),
|
||||
("sk", HashMap::from( [
|
||||
("Dashboard", "Prehlad"),
|
||||
|
||||
+2
-2
@@ -42,12 +42,12 @@ async fn main() -> std::io::Result<()> {
|
||||
Pow::init_random().expect("Cannot init captcha");
|
||||
|
||||
let cfg_path = matches.opt_str("c").unwrap_or("config.toml".to_string());
|
||||
let srv_conf = load_config(&cfg_path);
|
||||
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("debug")).init();
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or(srv_conf.logging().severity())).init();
|
||||
info!("Starting server");
|
||||
|
||||
let conf = get_configuration(None).await.unwrap();
|
||||
let srv_conf = load_config(&cfg_path);
|
||||
// Generate the list of routes in your Leptos App
|
||||
let routes = generate_route_list(|| view! { <App/> });
|
||||
let key = Key::from(srv_conf.session().key());
|
||||
|
||||
@@ -104,8 +104,8 @@ pub fn appearance() -> impl IntoView {
|
||||
{trl("Delete")}
|
||||
</button>
|
||||
<br/><br/>
|
||||
<div>
|
||||
{app.text.unwrap_or("<< TEXT >>".to_string())}
|
||||
<div inner_html={app.text.unwrap_or("<< TEXT >>".to_string())}>
|
||||
|
||||
</div>
|
||||
<a class="dropdown-item" href="javascript:void(0);" on:click=move |_| text_edit.show()>
|
||||
<i class="bx bx-edit-alt me-1"></i> {trl("Edit text")}</a>
|
||||
|
||||
+2
-2
@@ -133,8 +133,8 @@ pub fn Public() -> impl IntoView {
|
||||
</div>
|
||||
</Show>
|
||||
<div>
|
||||
<div>
|
||||
{app.text.unwrap_or("".to_string())}
|
||||
<div class="header_banner_text" inner_html={app.text.unwrap_or("".to_string())}>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user