chore: clippy & fmt
This commit is contained in:
parent
28c1716f17
commit
6aee3ded2c
|
@ -64,7 +64,7 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
|
||||||
.transfers
|
.transfers
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|t| t.dest_id == props.destination_plate.get_uuid());
|
.filter(|t| t.dest_id == props.destination_plate.get_uuid());
|
||||||
let mut tooltip_map: HashMap<(u8,u8), Vec<&Transfer>> = HashMap::new();
|
let mut tooltip_map: HashMap<(u8, u8), Vec<&Transfer>> = HashMap::new();
|
||||||
for t in ts {
|
for t in ts {
|
||||||
let dws = t.transfer_region.get_destination_wells();
|
let dws = t.transfer_region.get_destination_wells();
|
||||||
for dw in dws {
|
for dw in dws {
|
||||||
|
@ -120,10 +120,8 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
|
||||||
.map(|t| PALETTE.get_uuid(t.get_uuid()))
|
.map(|t| PALETTE.get_uuid(t.get_uuid()))
|
||||||
}
|
}
|
||||||
cell_height={props.cell_height}
|
cell_height={props.cell_height}
|
||||||
title={if let Some(transfers) = transfer_map.get(&(i,j)) {
|
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
|
||||||
Some(format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
|
.collect::<Vec<_>>().join(", ")))}
|
||||||
.collect::<Vec<_>>().join(", ")))
|
|
||||||
} else { None }}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
}).collect::<Html>();
|
}).collect::<Html>();
|
||||||
|
@ -179,10 +177,7 @@ fn DestPlateCell(props: &DestPlateCellProps) -> Html {
|
||||||
Some(true) => Some("in_transfer"),
|
Some(true) => Some("in_transfer"),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let color = match props.color {
|
let color = props.color.unwrap_or([255.0, 255.0, 255.0]);
|
||||||
Some(num) => num,
|
|
||||||
None => [255.0, 255.0, 255.0],
|
|
||||||
};
|
|
||||||
let mouse = Callback::clone(&props.mouse);
|
let mouse = Callback::clone(&props.mouse);
|
||||||
let mouse2 = Callback::clone(&props.mouse);
|
let mouse2 = Callback::clone(&props.mouse);
|
||||||
let (i, j) = (props.i, props.j);
|
let (i, j) = (props.i, props.j);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use wasm_bindgen::prelude::Closure;
|
use wasm_bindgen::prelude::Closure;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
use crate::data::plate_instances::PlateInstance;
|
use crate::data::plate_instances::PlateInstance;
|
||||||
|
@ -17,14 +17,22 @@ pub struct PlateContainerProps {
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
||||||
let cell_height = {
|
let cell_height = {
|
||||||
let height = web_sys::window().unwrap().inner_height().unwrap().as_f64().unwrap();
|
let height = web_sys::window()
|
||||||
let width = web_sys::window().unwrap().inner_width().unwrap().as_f64().unwrap();
|
.unwrap()
|
||||||
|
.inner_height()
|
||||||
|
.unwrap()
|
||||||
|
.as_f64()
|
||||||
|
.unwrap();
|
||||||
|
let width = web_sys::window()
|
||||||
|
.unwrap()
|
||||||
|
.inner_width()
|
||||||
|
.unwrap()
|
||||||
|
.as_f64()
|
||||||
|
.unwrap();
|
||||||
if let (Some(src_d), Some(dest_d)) = (&props.source_dims, &props.destination_dims) {
|
if let (Some(src_d), Some(dest_d)) = (&props.source_dims, &props.destination_dims) {
|
||||||
let h =
|
let h = (0.78 * height) / (src_d.plate.size().0 + dest_d.plate.size().0) as f64;
|
||||||
(0.78*height)/(src_d.plate.size().0 + dest_d.plate.size().0) as f64;
|
let w = (0.90 * width) / (src_d.plate.size().1 + dest_d.plate.size().1) as f64;
|
||||||
let w =
|
f64::min(w, h)
|
||||||
(0.90*width)/(src_d.plate.size().1 + dest_d.plate.size().1) as f64;
|
|
||||||
f64::min(w,h)
|
|
||||||
} else {
|
} else {
|
||||||
1f64
|
1f64
|
||||||
}
|
}
|
||||||
|
@ -34,7 +42,9 @@ pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
||||||
let onresize = Closure::<dyn FnMut(_)>::new(move |_: Event| {
|
let onresize = Closure::<dyn FnMut(_)>::new(move |_: Event| {
|
||||||
resize_trigger.force_update();
|
resize_trigger.force_update();
|
||||||
});
|
});
|
||||||
web_sys::window().unwrap().set_onresize(Some(onresize.as_ref().unchecked_ref()));
|
web_sys::window()
|
||||||
|
.unwrap()
|
||||||
|
.set_onresize(Some(onresize.as_ref().unchecked_ref()));
|
||||||
onresize.forget(); // Magic!
|
onresize.forget(); // Magic!
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
|
||||||
.transfers
|
.transfers
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|t| t.source_id == props.source_plate.get_uuid());
|
.filter(|t| t.source_id == props.source_plate.get_uuid());
|
||||||
let mut tooltip_map: HashMap<(u8,u8), Vec<&Transfer>> = HashMap::new();
|
let mut tooltip_map: HashMap<(u8, u8), Vec<&Transfer>> = HashMap::new();
|
||||||
for t in ts {
|
for t in ts {
|
||||||
let sws = t.transfer_region.get_source_wells();
|
let sws = t.transfer_region.get_source_wells();
|
||||||
for sw in sws {
|
for sw in sws {
|
||||||
|
@ -124,10 +124,8 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
|
||||||
.map(|t| PALETTE.get_uuid(t.get_uuid()))
|
.map(|t| PALETTE.get_uuid(t.get_uuid()))
|
||||||
}
|
}
|
||||||
cell_height={props.cell_height}
|
cell_height={props.cell_height}
|
||||||
title={if let Some(transfers) = transfer_map.get(&(i,j)) {
|
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
|
||||||
Some(format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
|
.collect::<Vec<_>>().join(", ")))}
|
||||||
.collect::<Vec<_>>().join(", ")))
|
|
||||||
} else { None }}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -184,10 +182,7 @@ fn SourcePlateCell(props: &SourcePlateCellProps) -> Html {
|
||||||
Some(true) => Some("in_transfer"),
|
Some(true) => Some("in_transfer"),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let color = match props.color {
|
let color = props.color.unwrap_or([255.0, 255.0, 255.0]);
|
||||||
Some(num) => num,
|
|
||||||
None => [255.0, 255.0, 255.0],
|
|
||||||
};
|
|
||||||
let mouse = Callback::clone(&props.mouse);
|
let mouse = Callback::clone(&props.mouse);
|
||||||
let mouse2 = Callback::clone(&props.mouse);
|
let mouse2 = Callback::clone(&props.mouse);
|
||||||
let (i, j) = (props.i, props.j);
|
let (i, j) = (props.i, props.j);
|
||||||
|
@ -279,7 +274,7 @@ mod tests {
|
||||||
let c2 = (10, 10);
|
let c2 = (10, 10);
|
||||||
let pt1 = (0, 0);
|
let pt1 = (0, 0);
|
||||||
let pt2 = (15, 15);
|
let pt2 = (15, 15);
|
||||||
assert_eq!(false, in_rect(Some(c1), Some(c2), pt1));
|
assert!(!in_rect(Some(c1), Some(c2), pt1));
|
||||||
assert_eq!(false, in_rect(Some(c1), Some(c2), pt2));
|
assert!(!in_rect(Some(c1), Some(c2), pt2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ impl ColorPalette {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_u8(&self, t: u8) -> [f64; 3] {
|
pub fn _get_u8(&self, t: u8) -> [f64; 3] {
|
||||||
assert!(t > 0, "t must be greater than zero!");
|
assert!(t > 0, "t must be greater than zero!");
|
||||||
self.get((2f64.powi(-1*t.ilog2() as i32)) as f64 * (t as f64 + 0.5f64)-1.0f64)
|
self.get((2f64.powi(-(t.ilog2() as i32))) * (t as f64 + 0.5f64) - 1.0f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_uuid(&self, t: uuid::Uuid) -> [f64; 3] {
|
pub fn get_uuid(&self, t: uuid::Uuid) -> [f64; 3] {
|
||||||
|
|
|
@ -454,7 +454,7 @@ mod tests {
|
||||||
Some("BJ".to_string())
|
Some("BJ".to_string())
|
||||||
);
|
);
|
||||||
for i in 1..=255 {
|
for i in 1..=255 {
|
||||||
assert_eq!(letters_to_num(&num_to_letters(i as u8).unwrap()), Some(i));
|
assert_eq!(letters_to_num(&num_to_letters(i).unwrap()), Some(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue