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 url = format!(
"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_plugin_fs::FsExt;
use tokio::sync::Mutex;
use std::collections::HashMap;
mod app_state;
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]
async fn swap(
store: &str,
@ -107,6 +117,7 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
swap,
count,
inventory,
data_door::pull_data,
data_door::push_data,
])

View file

@ -75,11 +75,11 @@
<form>
<div style="display: contents">
<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>
</div>
<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>
</div>
</div>

View file

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