Compare commits

..

No commits in common. "be9b5ed8553e39a1175b2ee4670b50c14d7efcaa" and "7cc7f03e5c1a89b1bda09b64185caa69abc812dc" have entirely different histories.

13 changed files with 57 additions and 68 deletions

View file

@ -1,4 +0,0 @@
max_width = 80
tab_spaces = 8
indentation_style = "Tabs"
newline_style = "Unix"

View file

@ -1,2 +0,0 @@
[rustfmt]
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]

View file

@ -1,4 +1,3 @@
edition = "2024"
max_width = 80 max_width = 80
hard_tabs = true hard_tabs = true
tab_spaces = 8 tab_spaces = 8

View file

@ -1,7 +1,9 @@
use bkbh::leptos::cafe::Cafe;
use leptos::prelude::*; use leptos::prelude::*;
use bkbh::leptos::cafe::Cafe;
fn main() { fn main() {
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
leptos::mount::mount_to_body(|| view! { <Cafe /> }); leptos::mount::mount_to_body(
|| view! { <Cafe /> }
);
} }

View file

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

View file

@ -1,8 +0,0 @@
use leptos::prelude::*;
#[component]
pub fn Angel() -> impl IntoView {
view! {
<p>Hi</p>
}
}

View file

@ -1,10 +1,10 @@
use crate::commands::*;
use crate::types::*;
use leptos::form::FromFormData;
use leptos::prelude::*; use leptos::prelude::*;
use crate::commands::*;
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 {
@ -13,7 +13,6 @@ pub fn Cafe() -> impl IntoView {
<Reception <Reception
acc=acc.0 acc=acc.0
/> />
<InvForm />
} }
} }
@ -52,6 +51,18 @@ fn Reception(acc: ReadSignal<Account>) -> impl IntoView {
} }
} }
#[component]
fn StoreLogo(store: Store) -> impl IntoView {
view! {
<img
src=format!("assets/{}.svg", Into::<String>::into(&store))
class="logo"
// FIXME: Implement fmt::Display for Store
alt=format!("{:?}", store)
/>
}
}
#[component] #[component]
fn SwapButton(store: Store) -> impl IntoView { fn SwapButton(store: Store) -> impl IntoView {
view! { view! {
@ -63,7 +74,7 @@ fn SwapButton(store: Store) -> impl IntoView {
} }
class="column" class="column"
> >
<super::store::Logo store=store /> <StoreLogo store=store />
</button> </button>
} }
} }
@ -78,7 +89,7 @@ fn StoreInput(store: Store) -> impl IntoView {
<label <label
for=txt.clone() for=txt.clone()
> >
<super::store::Logo store=store /> <StoreLogo store=store />
</label> </label>
<input <input
type="number" type="number"

View file

@ -1,3 +1 @@
pub mod angel;
pub mod cafe; pub mod cafe;
pub mod store;

View file

@ -1,14 +0,0 @@
use crate::types::*;
use leptos::prelude::*;
#[component]
pub fn Logo(store: Store) -> impl IntoView {
view! {
<img
src=format!("assets/{}.svg", Into::<String>::into(&store))
class="logo"
// FIXME: Implement fmt::Display for Store
alt=format!("{:?}", store)
/>
}
}

View file

@ -1,16 +1,16 @@
pub mod commands; pub mod commands;
#[cfg(feature = "leptos")]
pub mod leptos;
#[cfg(feature = "server")] #[cfg(feature = "server")]
pub mod server; pub mod server;
#[cfg(feature = "leptos")]
pub mod leptos;
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();

View file

@ -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 ring_compat::signature::ed25519::SigningKey;
use rusqlite::{Connection, DatabaseName}; use rusqlite::{Connection, DatabaseName};
use ring_compat::signature::ed25519::SigningKey;
use tauri::{Manager, State}; use tauri::{Manager, State};
use tokio::sync::Mutex; use tokio::sync::Mutex;
@ -62,8 +62,7 @@ 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")) client.username(include_str!("cloud_user.txt")).map_err(|_| ())?;
.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"))
@ -77,7 +76,8 @@ 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).map_err(|e| println!("{:?}", e))?; client.upload(true)
.map_err(|e| println!("{:?}", e))?;
Ok(client) Ok(client)
} }
@ -96,21 +96,22 @@ 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().map_err(|e| println!("{:?}", e))?; let _perf = client.perform()
.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 let path = app.path().resolve(&filename, tauri::path::BaseDirectory::Temp)
.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).map_err(|e| println!("{:?}", e))?; let buf = std::fs::read(&path)
.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().map_err(|e| println!("{:?}", e))?; let _perf = client.perform()
.map_err(|e| println!("{:?}", e))?;
Ok(()) Ok(())
} }

View file

@ -1,7 +1,7 @@
use chrono::offset::Utc; use chrono::offset::Utc;
use std::collections::HashMap; use std::collections::HashMap;
use tauri::State;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tauri::State;
use crate::types::*; use crate::types::*;
@ -29,7 +29,7 @@ fn parse_inventory(data: HashMap<String, String>) -> Result<Inventory, ()> {
}; };
let v = VoucherInventory { store, count }; let v = VoucherInventory { store, count };
vouchers.push(v); vouchers.push(v);
} },
} }
} }
unimplemented!() unimplemented!()
@ -47,10 +47,15 @@ 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(())
} }

View file

@ -1,6 +1,6 @@
#[cfg(feature = "server")] #[cfg(feature = "server")]
use rusqlite::{types::ToSqlOutput, ToSql}; use rusqlite::{types::ToSqlOutput, ToSql};
use serde::{Deserialize, Serialize}; use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum Store { pub enum Store {
@ -43,7 +43,9 @@ 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(&format!("00{}", fs)[0..2]) Some(fs) => i64::from_str(
&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))
@ -105,8 +107,7 @@ 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)
} }
} }