Send inventory to rust

This commit is contained in:
Bianca Fürstenau 2025-02-16 16:01:14 +01:00
parent 43bcfac938
commit e4dc811434
4 changed files with 16 additions and 6 deletions

View file

@ -55,7 +55,7 @@ impl easy::Handler for Collector {
} }
} }
pub fn data_client(file: &str) -> Result<Easy2<Collector>, ()> { fn data_client(file: &str) -> Result<Easy2<Collector>, ()> {
let mut client = Easy2::new(Collector(Vec::new(), Vec::new(), 0)); let mut client = Easy2::new(Collector(Vec::new(), Vec::new(), 0));
let url = format!( let url = format!(
"https://cloud.seebruecke.org/public.php/webdav/data/{}", "https://cloud.seebruecke.org/public.php/webdav/data/{}",

View file

@ -4,6 +4,7 @@ use rusqlite::{types::ToSqlOutput, Connection, ToSql};
use tauri::{Manager, State}; use tauri::{Manager, State};
use tauri_plugin_fs::FsExt; use tauri_plugin_fs::FsExt;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use std::collections::HashMap;
mod app_state; mod app_state;
mod data_door; mod data_door;
@ -49,6 +50,15 @@ impl ToSql for Store {
} }
} }
#[tauri::command]
async fn inventory(
data: HashMap<String, String>,
state: State<'_, Mutex<AppState>>,
) -> Result<(), ()> {
println!("{:?}", data);
Ok(())
}
#[tauri::command] #[tauri::command]
async fn swap( async fn swap(
store: &str, store: &str,
@ -107,6 +117,7 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![
swap, swap,
count, count,
inventory,
data_door::pull_data, data_door::pull_data,
data_door::push_data, data_door::push_data,
]) ])

View file

@ -75,11 +75,11 @@
<form> <form>
<div style="display: contents"> <div style="display: contents">
<div class="labelled-input"> <div class="labelled-input">
<input type="radio" id="cafe-inventory-acc-sumpf" name="cafe-inventory-acc" value="sumpf"> <input type="radio" id="cafe-inventory-acc-sumpf" name="cafe-inventory-acc" value="sumpf" required>
<label for="cafe-inventory-acc-sumpf">Sumpf</label> <label for="cafe-inventory-acc-sumpf">Sumpf</label>
</div> </div>
<div class="labelled-input"> <div class="labelled-input">
<input type="radio" id="cafe-inventory-acc-hs" name="cafe-inventory-acc" value="hs"> <input type="radio" id="cafe-inventory-acc-hs" name="cafe-inventory-acc" value="hs" required>
<label for="cafe-inventory-acc-hs">Heinersyndikat</label> <label for="cafe-inventory-acc-hs">Heinersyndikat</label>
</div> </div>
</div> </div>

View file

@ -33,9 +33,8 @@ async function increment(el) {
async function inventory() { async function inventory() {
const form = document.querySelector("#cafe-inventory form"); const form = document.querySelector("#cafe-inventory form");
const fd = new FormData(form); const fd = new FormData(form);
for (let item of fd) { const obj = Object.fromEntries(fd);
alert(item); await invoke("inventory", { data: obj });
}
} }
async function swap(s) { async function swap(s) {