Persist state on reload
This commit is contained in:
parent
282369346c
commit
e0ff131cd7
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
target = "wasm32-unknown-unknown"
|
|
@ -533,10 +533,10 @@ dependencies = [
|
|||
name = "plate-tool"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"regex",
|
||||
"serde",
|
||||
"uuid",
|
||||
"wasm-bindgen",
|
||||
"wasm-logger",
|
||||
|
@ -858,7 +858,9 @@ checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2"
|
|||
dependencies = [
|
||||
"getrandom",
|
||||
"rand",
|
||||
"serde",
|
||||
"uuid-macro-internal",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -9,10 +9,10 @@ edition = "2021"
|
|||
yew = { version = "0.20.0", features = ["csr"] }
|
||||
yewdux = "0.9"
|
||||
wasm-bindgen = "0.2"
|
||||
web-sys = { version = "0.3", features = ["FormData", "HtmlFormElement"] }
|
||||
web-sys = { version = "0.3", features = ["FormData", "HtmlFormElement", "HtmlDialogElement"] }
|
||||
log = "0.4"
|
||||
wasm-logger = "0.2"
|
||||
regex = "1"
|
||||
lazy_static = "1.4"
|
||||
uuid = { version = "1.3", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
uuid = { version = "1.3", features = ["v4", "fast-rng", "macro-diagnostics", "js", "serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
use yewdux::prelude::*;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use yewdux::{prelude::*, storage};
|
||||
use super::transfer_menu::RegionDisplay;
|
||||
use crate::data::plate_instances::PlateInstance;
|
||||
use crate::data::transfer::Transfer;
|
||||
use crate::data::plate::*;
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Store)]
|
||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize, Store)]
|
||||
#[store(storage = "session")]
|
||||
pub struct NewTransferState {
|
||||
pub source_region: RegionDisplay,
|
||||
pub destination_region: RegionDisplay,
|
||||
|
@ -12,7 +14,7 @@ pub struct NewTransferState {
|
|||
pub interleave_y: u8,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Clone)]
|
||||
#[derive(Default, PartialEq, Clone, Serialize, Deserialize)]
|
||||
pub struct MainState {
|
||||
pub source_plates: Vec<PlateInstance>,
|
||||
pub destination_plates: Vec<PlateInstance>,
|
||||
|
@ -21,11 +23,18 @@ pub struct MainState {
|
|||
|
||||
impl Store for MainState {
|
||||
fn new() -> Self {
|
||||
init_listener(storage::StorageListener::<Self>::new(storage::Area::Local));
|
||||
|
||||
storage::load(storage::Area::Local)
|
||||
.expect("Unable to load state")
|
||||
.unwrap_or_default()
|
||||
/*
|
||||
Self {
|
||||
source_plates: Vec::new(),
|
||||
destination_plates: Vec::new(),
|
||||
transfers: Vec::new(),
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
fn should_notify(&self, old: &Self) -> bool {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use yew::prelude::*;
|
||||
use yewdux::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
@ -86,7 +87,7 @@ pub fn TransferMenu() -> Html {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Default)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct RegionDisplay {
|
||||
pub text: String,
|
||||
pub col_start: u8,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct Plate {
|
||||
pub plate_type: PlateType,
|
||||
pub plate_format: PlateFormat,
|
||||
|
@ -17,13 +19,13 @@ impl Plate {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum PlateType {
|
||||
Source,
|
||||
Destination,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum PlateFormat {
|
||||
W6,
|
||||
W12,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use uuid::Uuid;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use super::plate::*;
|
||||
|
||||
#[derive(PartialEq, Clone)]
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
||||
pub struct PlateInstance {
|
||||
pub plate: Plate,
|
||||
id: Uuid,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use uuid::Uuid;
|
||||
use super::transfer_region::*;
|
||||
use super::plate_instances::*;
|
||||
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
#[derive(PartialEq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct Transfer {
|
||||
pub source_id: Uuid,
|
||||
pub dest_id: Uuid,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use super::plate::Plate;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Region {
|
||||
Rect((u8, u8), (u8, u8)),
|
||||
Point((u8, u8)),
|
||||
|
@ -17,7 +19,7 @@ impl TryFrom<Region> for ((u8, u8), (u8, u8)) {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct TransferRegion {
|
||||
pub source_plate: Plate,
|
||||
pub source_region: Region, // Even if it is just a point, we don't want corners.
|
||||
|
|
Loading…
Reference in New Issue