Compare commits

..

No commits in common. "5689cbd3d4187ac660f35e15ab4cb0cb9c5e696e" and "e8511c01b0320ac5472d456cabeeeb33f3e0cbfa" have entirely different histories.

14 changed files with 240 additions and 645 deletions

751
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@ edition = "2021"
[dependencies]
plate-tool-lib = { path = "../plate-tool-lib" }
yew = { version = "0.21.0", features = ["csr"] }
yewdux = "0.10"
yew = { version = "0.20.0", features = ["csr"] }
yewdux = "0.9"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["FormData", "HtmlFormElement",
"HtmlDialogElement", "Blob", "Url", "Window",
@ -28,9 +28,3 @@ rand = { version = "0.8", features = ["small_rng"] }
[dev-dependencies]
wasm-bindgen-test = "0.3.0"
[profile.release]
opt-level = 2
[profile.dev.package."*"]
opt-level = 2

View File

@ -41,16 +41,11 @@ div.plate_container {
}
}
div.plate_container--upper-left {
div.plate_container--heatmap-notice {
position: absolute;
top: 0.5em;
left: 0.5em;
display: flex;
flex-direction: column;
}
div.plate_container--heatmap-notice {
animation: 1s 1 attention_on_load;
}
}

View File

@ -57,35 +57,13 @@ td.current_select div.plate_cell_inner {
.W1536 {
th {
font-size: 0.9rem;
line-height: 0px;
}
tr:first-child {
th {
line-height: inherit;
}
}
td {
padding: 0;
}
td.current_select div.plate_cell_inner {
border: 2px solid black;
}
}
.W3456 {
th {
font-size: 0.6rem;
font-size: 0.9rem;
line-height: 0px;
}
tr:first-child {
th {
line-height: inherit;
}
}
td {
padding: 0;
}
td.current_select div.plate_cell_inner {
border: 2px solid black;
padding-bottom: 0.4rem;
}
}

View File

@ -4,7 +4,6 @@
<meta charset="utf-8" />
<link data-trunk rel="scss" href="assets/scss/index.scss">
<link data-trunk rel="copy-dir" href="assets/fonts">
<link data-trunk rel="rust" data-bin="plate-tool-web" />
<script data-trunk src="assets/js/screenshot_utility.js"></script>
<script data-trunk src="assets/js/html2canvas.js"></script>
<title>Plate Tool</title>

View File

@ -35,17 +35,6 @@ pub fn toggle_volume_heatmap_callback(
})
}
pub fn toggle_show_current_coordinates_callback(
main_dispatch: Dispatch<MainState>,
) -> Callback<web_sys::MouseEvent> {
let main_dispatch = main_dispatch.clone();
Callback::from(move |_| {
main_dispatch.reduce_mut(|state| {
state.preferences.show_current_coordinates ^= true;
})
})
}
pub fn change_csv_export_type_callback(
main_dispatch: Dispatch<MainState>,
) -> Callback<web_sys::MouseEvent> {

View File

@ -48,11 +48,6 @@ pub fn MainWindow() -> Html {
main_window_callbacks::toggle_volume_heatmap_callback(main_dispatch)
};
let toggle_show_current_coordinates_callback = {
let main_dispatch = main_dispatch.clone();
main_window_callbacks::toggle_show_current_coordinates_callback(main_dispatch)
};
let change_csv_export_type_callback = {
let main_dispatch = main_dispatch.clone();
main_window_callbacks::change_csv_export_type_callback(main_dispatch)
@ -114,7 +109,6 @@ pub fn MainWindow() -> Html {
<div>
<button onclick={toggle_in_transfer_hashes_callback}>{"Toggle transfer hashes"}</button>
<button onclick={toggle_volume_heatmap_callback}>{"Toggle volume heatmap"}</button>
<button onclick={toggle_show_current_coordinates_callback}>{"Toggle current coordinates view"}</button>
</div>
</div>
<div class="dropdown-sub">

View File

@ -41,8 +41,7 @@ pub fn NewPlateDialog(props: &NewPlateDialogProps) -> Html {
{
let dialog_ref = dialog_ref.clone();
use_effect_with(
dialog_ref,
use_effect_with_deps(
|dialog_ref| {
dialog_ref
.cast::<HtmlDialogElement>()
@ -50,6 +49,7 @@ pub fn NewPlateDialog(props: &NewPlateDialogProps) -> Html {
.show_modal()
.ok();
},
dialog_ref,
);
}

View File

@ -109,8 +109,7 @@ pub fn Plate(props: &PlateProps) -> Html {
let m_start_handle = m_start_handle.clone();
let m_end_handle = m_end_handle.clone();
let m_stat_handle = m_stat_handle.clone();
let send_coordinates = props.send_coordinates.clone();
plate_callbacks::mouse_callback(m_start_handle, m_end_handle, m_stat_handle, send_coordinates)
plate_callbacks::mouse_callback(m_start_handle, m_end_handle, m_stat_handle)
};
let mouseup_callback = {

View File

@ -15,7 +15,6 @@ pub fn mouse_callback(
m_start_handle: MStartHandle,
m_end_handle: MEndHandle,
m_stat_handle: MStatHandle,
send_coordinates: Option<Callback<(u8,u8)>>
) -> Callback<(u8, u8, MouseEventType)> {
Callback::from(move |(i, j, t)| match t {
MouseEventType::Mousedown => {
@ -24,9 +23,6 @@ pub fn mouse_callback(
m_stat_handle.set(true);
}
MouseEventType::Mouseenter => {
if let Some(cb) = send_coordinates.as_ref() {
cb.emit((i,j));
}
if *m_stat_handle {
m_end_handle.set(Some((i, j)));
}

View File

@ -1,5 +1,4 @@
#![allow(non_snake_case)]
use plate_tool_lib::util::num_to_letters;
use wasm_bindgen::prelude::Closure;
use wasm_bindgen::JsCast;
use yew::prelude::*;
@ -55,51 +54,27 @@ pub fn PlateContainer(props: &PlateContainerProps) -> Html {
onresize.forget(); // Magic!
let heatmap_enabled = main_state.preferences.volume_heatmap;
let show_current_coordinates = main_state.preferences.show_current_coordinates;
// (Row, Col)
let current_coordinates = use_state(|| (0, 0));
let send_coordinates = {
if show_current_coordinates {
let current_coordinates = current_coordinates.clone();
Some(Callback::from(move |coords| {
current_coordinates.set(coords)
}))
} else {
None
}
};
html! {
<div class="plate_container">
<div class="plate_container--upper-left" >
if heatmap_enabled {
<div class="plate_container--heatmap-notice" >
<h3>{"Volume Heatmap Enabled"}</h3>
</div>
}
if show_current_coordinates {
<div class="plate_container--location">
<h3>{format!("R:{} C:{}",
num_to_letters(current_coordinates.0).unwrap_or("".to_string()),
current_coordinates.1)}</h3>
</div>
}
</div>
if let Some(spi) = props.source_dims.clone() {
if let Some(dpi) = props.destination_dims.clone() {
<div class="plate_container--source">
<h2>{spi.name.clone()}</h2>
<h2>{"Source"}</h2>
<Plate source_plate={spi.clone()} destination_plate={dpi.clone()}
cell_height={cell_height} ptype={PlateType::Source}
send_coordinates={send_coordinates.clone()}
/>
cell_height={cell_height} ptype={PlateType::Source}/>
</div>
<div class="plate_container--destination">
<h2>{dpi.name.clone()}</h2>
<h2>{"Destination"}</h2>
<Plate source_plate={spi.clone()} destination_plate={dpi.clone()}
cell_height={cell_height} ptype={PlateType::Destination} send_coordinates={send_coordinates.clone()}/>
cell_height={cell_height} ptype={PlateType::Destination}/>
</div>
} else {
<h2>{"No Destination Plate Selected"}</h2>

View File

@ -10,7 +10,6 @@ pub struct PlateProps {
pub destination_plate: PlateInstance,
pub cell_height: f64,
pub ptype: PlateType,
pub send_coordinates: Option<Callback<(u8,u8)>>,
}
pub type MStartHandle = UseStateHandle<Option<(u8, u8)>>;

View File

@ -21,18 +21,11 @@ pub struct Preferences {
pub volume_heatmap: bool,
#[serde(default)]
pub csv_export_type: CsvExportType,
#[serde(default)]
pub show_current_coordinates: bool,
}
impl Default for Preferences {
fn default() -> Self {
Self {
in_transfer_hashes: true,
volume_heatmap: false,
csv_export_type: CsvExportType::Normal,
show_current_coordinates: false,
}
Self { in_transfer_hashes: true, volume_heatmap: false, csv_export_type: CsvExportType::Normal }
}
}
@ -78,11 +71,8 @@ pub struct MainState {
}
impl Store for MainState {
fn new(context: &yewdux::Context) -> Self {
init_listener(
storage::StorageListener::<Self>::new(storage::Area::Local),
context,
);
fn new() -> Self {
init_listener(storage::StorageListener::<Self>::new(storage::Area::Local));
storage::load(storage::Area::Local)
.expect("Unable to load state")
@ -152,18 +142,10 @@ impl MainState {
}
pub fn change_format(&mut self, id: Uuid, new_format: &PlateFormat) {
if let Some(index) = self
.source_plates
.iter()
.position(|spi| spi.get_uuid() == id)
{
if let Some(index) = self.source_plates.iter().position(|spi| spi.get_uuid() == id) {
self.source_plates[index].change_format(new_format);
}
if let Some(index) = self
.destination_plates
.iter()
.position(|dpi| dpi.get_uuid() == id)
{
if let Some(index) = self.destination_plates.iter().position(|dpi| dpi.get_uuid() == id) {
self.destination_plates[index].change_format(new_format);
}
}

View File

@ -205,8 +205,7 @@ fn PlateInfoModal(props: &PlateInfoModalProps) -> Html {
{
let dialog_ref = dialog_ref.clone();
use_effect_with(
dialog_ref,
use_effect_with_deps(
|dialog_ref| {
dialog_ref
.cast::<HtmlDialogElement>()
@ -214,6 +213,7 @@ fn PlateInfoModal(props: &PlateInfoModalProps) -> Html {
.show_modal()
.ok();
},
dialog_ref,
);
}