Fmt
This commit is contained in:
parent
eda34db508
commit
be9b5ed855
12 changed files with 43 additions and 45 deletions
4
leptosfmt.toml
Normal file
4
leptosfmt.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
max_width = 80
|
||||||
|
tab_spaces = 8
|
||||||
|
indentation_style = "Tabs"
|
||||||
|
newline_style = "Unix"
|
2
rust-analyzer.toml
Normal file
2
rust-analyzer.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[rustfmt]
|
||||||
|
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]
|
|
@ -1,3 +1,4 @@
|
||||||
max_width = 80
|
edition = "2024"
|
||||||
hard_tabs = true
|
max_width = 80
|
||||||
|
hard_tabs = true
|
||||||
tab_spaces = 8
|
tab_spaces = 8
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use leptos::prelude::*;
|
|
||||||
use bkbh::leptos::cafe::Cafe;
|
use bkbh::leptos::cafe::Cafe;
|
||||||
|
use leptos::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
leptos::mount::mount_to_body(
|
leptos::mount::mount_to_body(|| view! { <Cafe /> });
|
||||||
|| view! { <Cafe /> }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use tauri_sys::Error;
|
|
||||||
use tauri_sys::core::invoke;
|
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use tauri_sys::core::invoke;
|
||||||
|
use tauri_sys::Error;
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
pub struct Swap {
|
pub struct Swap {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use leptos::prelude::*;
|
|
||||||
use crate::commands::*;
|
use crate::commands::*;
|
||||||
|
use crate::types::*;
|
||||||
|
use leptos::form::FromFormData;
|
||||||
|
use leptos::prelude::*;
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
use leptos::web_sys::FormData;
|
use leptos::web_sys::FormData;
|
||||||
use leptos::form::FromFormData;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::types::*;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Cafe() -> impl IntoView {
|
pub fn Cafe() -> impl IntoView {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod cafe;
|
|
||||||
pub mod angel;
|
pub mod angel;
|
||||||
|
pub mod cafe;
|
||||||
pub mod store;
|
pub mod store;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use leptos::prelude::*;
|
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
use leptos::prelude::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Logo(store: Store) -> impl IntoView {
|
pub fn Logo(store: Store) -> impl IntoView {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
#[cfg(feature = "server")]
|
|
||||||
pub mod server;
|
|
||||||
#[cfg(feature = "leptos")]
|
#[cfg(feature = "leptos")]
|
||||||
pub mod leptos;
|
pub mod leptos;
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
pub mod server;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
#[cfg(all(feature = "tauri", feature="server"))]
|
#[cfg(all(feature = "tauri", feature = "server"))]
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
|
use server::app_state::AppState;
|
||||||
use tauri::{Manager, State};
|
use tauri::{Manager, State};
|
||||||
use tauri_plugin_fs::FsExt;
|
use tauri_plugin_fs::FsExt;
|
||||||
use server::app_state::AppState;
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
let state = AppState::new();
|
let state = AppState::new();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use chrono::offset::Utc;
|
use chrono::offset::Utc;
|
||||||
use curl::{easy, easy::Easy2};
|
use curl::{easy, easy::Easy2};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use rusqlite::{Connection, DatabaseName};
|
|
||||||
use ring_compat::signature::ed25519::SigningKey;
|
use ring_compat::signature::ed25519::SigningKey;
|
||||||
|
use rusqlite::{Connection, DatabaseName};
|
||||||
use tauri::{Manager, State};
|
use tauri::{Manager, State};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ fn data_client(file: &str) -> Result<Easy2<Collector>, ()> {
|
||||||
file
|
file
|
||||||
);
|
);
|
||||||
client.url(&url).map_err(|_| ())?;
|
client.url(&url).map_err(|_| ())?;
|
||||||
client.username(include_str!("cloud_user.txt")).map_err(|_| ())?;
|
client.username(include_str!("cloud_user.txt"))
|
||||||
|
.map_err(|_| ())?;
|
||||||
client.http_auth(easy::Auth::new().auto(true))
|
client.http_auth(easy::Auth::new().auto(true))
|
||||||
.map_err(|_| ())?;
|
.map_err(|_| ())?;
|
||||||
client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem"))
|
client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem"))
|
||||||
|
@ -76,8 +77,7 @@ fn put_client(file: &str, payload: &[u8]) -> Result<Easy2<Collector>, ()> {
|
||||||
client.get_mut().1.extend_from_slice(payload);
|
client.get_mut().1.extend_from_slice(payload);
|
||||||
client.in_filesize(payload.len() as u64)
|
client.in_filesize(payload.len() as u64)
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
.map_err(|e| println!("{:?}", e))?;
|
||||||
client.upload(true)
|
client.upload(true).map_err(|e| println!("{:?}", e))?;
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,22 +96,21 @@ async fn push_key(id: &u64, key: &SigningKey) -> Result<(), ()> {
|
||||||
let file = format!("{:016X}.key", id);
|
let file = format!("{:016X}.key", id);
|
||||||
let v_key = key.verifying_key();
|
let v_key = key.verifying_key();
|
||||||
let client = put_client(&file, v_key.as_ref())?;
|
let client = put_client(&file, v_key.as_ref())?;
|
||||||
let _perf = client.perform()
|
let _perf = client.perform().map_err(|e| println!("{:?}", e))?;
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_db(id: &u64, db: &Connection, app: tauri::AppHandle) -> Result<(), ()> {
|
fn push_db(id: &u64, db: &Connection, app: tauri::AppHandle) -> Result<(), ()> {
|
||||||
let filename = format!("{:016X}.sqlite", id);
|
let filename = format!("{:016X}.sqlite", id);
|
||||||
let path = app.path().resolve(&filename, tauri::path::BaseDirectory::Temp)
|
let path = app
|
||||||
|
.path()
|
||||||
|
.resolve(&filename, tauri::path::BaseDirectory::Temp)
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
.map_err(|e| println!("{:?}", e))?;
|
||||||
db.backup(DatabaseName::Main, &path, None)
|
db.backup(DatabaseName::Main, &path, None)
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
.map_err(|e| println!("{:?}", e))?;
|
||||||
let buf = std::fs::read(&path)
|
let buf = std::fs::read(&path).map_err(|e| println!("{:?}", e))?;
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
|
||||||
let client = put_client(&filename, buf.as_ref())?;
|
let client = put_client(&filename, buf.as_ref())?;
|
||||||
let _perf = client.perform()
|
let _perf = client.perform().map_err(|e| println!("{:?}", e))?;
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use chrono::offset::Utc;
|
use chrono::offset::Utc;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::sync::Mutex;
|
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ fn parse_inventory(data: HashMap<String, String>) -> Result<Inventory, ()> {
|
||||||
match data.get(&format!("cafe-inventory-{}", s)) {
|
match data.get(&format!("cafe-inventory-{}", s)) {
|
||||||
None => (),
|
None => (),
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
let c = if c == "" {"0"} else {c};
|
let c = if c == "" { "0" } else { c };
|
||||||
let Ok(count) = c.parse() else {
|
let Ok(count) = c.parse() else {
|
||||||
println!("Invalid count '{}' for '{}' in inventory data.", c, s);
|
println!("Invalid count '{}' for '{}' in inventory data.", c, s);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let v = VoucherInventory { store, count };
|
let v = VoucherInventory { store, count };
|
||||||
vouchers.push(v);
|
vouchers.push(v);
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
@ -47,15 +47,10 @@ pub async fn inventory(
|
||||||
for v in inv.vouchers {
|
for v in inv.vouchers {
|
||||||
state.db.execute(
|
state.db.execute(
|
||||||
"INSERT INTO voucher_inventory VALUES ()",
|
"INSERT INTO voucher_inventory VALUES ()",
|
||||||
(
|
(inv.acc, v.store, v.count, now),
|
||||||
inv.acc,
|
|
||||||
v.store,
|
|
||||||
v.count,
|
|
||||||
now,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
.map_err(|e| println!("{:?}", e))?;
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/types.rs
13
src/types.rs
|
@ -1,6 +1,6 @@
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
use rusqlite::{types::ToSqlOutput, ToSql};
|
use rusqlite::{types::ToSqlOutput, ToSql};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
pub enum Store {
|
pub enum Store {
|
||||||
|
@ -43,12 +43,10 @@ impl std::str::FromStr for Cash {
|
||||||
.map_err(|e| println!("{:?}", e))?;
|
.map_err(|e| println!("{:?}", e))?;
|
||||||
let f = match split.get(1) {
|
let f = match split.get(1) {
|
||||||
None => 0,
|
None => 0,
|
||||||
Some(fs) => i64::from_str(
|
Some(fs) => i64::from_str(&format!("00{}", fs)[0..2])
|
||||||
&format!("00{}", fs)[0..2]
|
.map_err(|e| println!("{:?}", e))?,
|
||||||
)
|
|
||||||
.map_err(|e| println!("{:?}", e))?,
|
|
||||||
};
|
};
|
||||||
Ok(Cash(i*100+f))
|
Ok(Cash(i * 100 + f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +105,8 @@ impl std::fmt::Display for Account {
|
||||||
match *self {
|
match *self {
|
||||||
Account::Sumpf => "Sumpf",
|
Account::Sumpf => "Sumpf",
|
||||||
Account::Heinersyndikat => "Heinersyndikat",
|
Account::Heinersyndikat => "Heinersyndikat",
|
||||||
}.fmt(f)
|
}
|
||||||
|
.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue