Export json
This commit is contained in:
parent
068785b4c8
commit
b171f39eaa
|
|
@ -14,6 +14,7 @@ eframe = { version = "0.33", default-features = false, features = [
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use serde_json;
|
||||||
|
|
||||||
use eframe::egui::{self};
|
use eframe::egui::{self};
|
||||||
use plate_tool_lib::csv::{
|
use plate_tool_lib::csv::{
|
||||||
records_to_csv, records_to_echo_client_csv, transfer_to_records, TransferRecord,
|
records_to_csv, records_to_echo_client_csv, transfer_to_records, TransferRecord,
|
||||||
|
|
@ -160,7 +162,13 @@ impl eframe::App for PlateToolEframe {
|
||||||
save_file(bytes, Some("transfers.csv"));
|
save_file(bytes, Some("transfers.csv"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui.button("Export as JSON").clicked() {}
|
if ui.button("Export as JSON").clicked() {
|
||||||
|
let data = serde_json::to_string_pretty(&self.main_state);
|
||||||
|
if let Ok(data) = data {
|
||||||
|
let bytes: &[u8] = data.as_bytes();
|
||||||
|
save_file(bytes, Some("plate_tool_state.json"));
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ui.menu_button("Import", |ui| {
|
ui.menu_button("Import", |ui| {
|
||||||
if ui.button("Import from JSON").clicked() {}
|
if ui.button("Import from JSON").clicked() {}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,19 @@ pub fn open_new_plate_modal(modal_state: &mut ModalState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn open_new_plate_modal_with_default_type(
|
||||||
|
modal_state: &mut ModalState,
|
||||||
|
plate_type: plate_tool_lib::plate::PlateType,
|
||||||
|
) {
|
||||||
|
// Do not close another modal
|
||||||
|
if matches!(modal_state, ModalState::None) {
|
||||||
|
*modal_state = ModalState::NewPlate(NewPlateModalState {
|
||||||
|
plate_type: plate_type,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct EditPlateModalState {
|
pub struct EditPlateModalState {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue