Commit a4d16295 by dongshufeng

refactor(all): add iesplan example

parent 584b119b
......@@ -11,7 +11,11 @@ serde = { version = "1.0", features = ["derive"] }
protobuf = { version = "3.5", features = ["with-bytes"] }
# this project
eig-expr = { path = "../eig-expr"}
eig-expr = { path = "../eig-expr" }
csv = "1.3"
calamine = "0.26"
encoding_rs = "0.8.34"
[build-dependencies]
# protobuf-codegen-pure = "2.28"
......
......@@ -11,6 +11,7 @@ use crate::prop::DataUnit;
pub mod prop;
pub mod proto;
pub mod web;
pub mod excel;
/**
* @api {Measurement} /Measurement Measurement
......
......@@ -6,6 +6,6 @@ edition = "2021"
[dependencies]
log = "0.4"
serde_json = "1.0"
csv = "1.3.0"
csv = "1.3"
eig-domain = { path = "../../../../eig-domain" }
mems = { path = "../../.." }
\ No newline at end of file
......@@ -28,7 +28,8 @@ getrandom = { version = "0.2", features = ["js"] }
chrono = { version = "0.4", features = ["wasmbind"] }
protobuf = { version = "3.7", features = ["with-bytes"] }
cron = "0.12"
yew-bulma = { git = "https://github.com/shufengdong/yew-bulma.git"}
yew-bulma = { git = "https://github.com/shufengdong/yew-bulma.git" }
eig-domain = { path = "../../../eig-domain" }
# web-sys and js-sys
js-sys = "0.3"
[dependencies.web-sys]
......
use wasm_bindgen::prelude::*;
use web_sys::Element;
use crate::startpage::Dashboard;
use crate::startpage::StartPage;
use yew_bulma::layout::tiles::Tiles;
use eig_domain::excel::get_first_sheet_merged_cells;
pub mod startpage;
#[wasm_bindgen]
pub fn create_view(e: Element) {
yew::Renderer::<Dashboard>::with_root(e).render();
yew::Renderer::<StartPage>::with_root(e).render();
}
pub fn new(xlsx_bytes: Vec<u8>) -> Option<Tiles> {
let (m, n, merge_map) = get_first_sheet_merged_cells(xlsx_bytes)?;
let mut class_vec = Vec::new();
let mut is_dealt = vec![false; (m * n) as usize];
for i in 0..m {
for j in 0..n {
let index = (i * n + j) as usize;
if is_dealt[index] {
continue;
}
let mut class_str = "cell".to_string();
let coordinate = (i, j);
if let Some((end_row, end_col)) = merge_map.get(&coordinate) {
let row_span = *end_row - i + 1;
let col_span = *end_col - j + 1;
if row_span > 1 {
class_str.push_str(&format!(" is-row-span-{row_span}"))
}
if col_span > 1 {
class_str.push_str(&format!(" is-col-span-{col_span}"))
}
class_vec.push(class_str);
for row in i..=*end_row {
for col in j..=*end_col {
let pos = (row * n + col) as usize;
is_dealt[pos] = true;
}
}
} else {
class_vec.push(class_str);
}
}
}
let tiles = Tiles { id: "".to_string(), class_str: class_vec, with_box: true };
Some(tiles)
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ pub enum Msg {
DateRangePicked(u64, u64),
}
pub struct Dashboard {
pub struct StartPage {
templates: HashMap<String, String>,
chart1: NodeRef,
chart2: NodeRef,
......@@ -19,7 +19,7 @@ pub struct Dashboard {
chart4: NodeRef,
}
impl Component for Dashboard {
impl Component for StartPage {
type Message = Msg;
type Properties = ();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论