Skip to content

Commit

Permalink
fix status display in web
Browse files Browse the repository at this point in the history
  • Loading branch information
o-tho committed Dec 6, 2024
1 parent b8b166c commit a112b2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ image = {version = "0.25", default-features = false, features = [
"tiff",
]}
nalgebra = "0.33.2"
serde = {version = "1.0.214", features= ["derive"]}
serde = {version = "1.0.214", features=["derive"]}
serde_json = "1.0.132"
pdf = {version="0.9.0", default-features=false, features = ["cache"]}
pdf = {version="0.9.0", default-features=false, features=["cache"]}
fax = "0.2.4"
tiff = "0.9.1"
clap = {version = "4.5.20", features = ["derive"]}
Expand Down
11 changes: 6 additions & 5 deletions src/webapp/generate_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ impl GenerateReport {
self.preview_image = Rc::new(RefCell::new(None));
self.zipped_results = Rc::new(RefCell::new(None));
let mut cloned_self = self.clone();
let ctx = ctx.clone();
spawn_local(async move {
cloned_self.generate_reports().await;
cloned_self.generate_reports(&ctx).await;
});
ctx.request_repaint();
}
}
});
Expand All @@ -237,7 +237,7 @@ impl GenerateReport {
});
}

pub async fn generate_reports(&mut self) {
pub async fn generate_reports(&mut self, ctx: &Context) {
let template = self.template.clone().unwrap();
let key = self.key.clone().unwrap();

Expand All @@ -263,7 +263,7 @@ impl GenerateReport {
);
*self.status.borrow_mut() =
Some(format!("Working on the first {} scans", chunksize));
gloo_timers::future::TimeoutFuture::new(50).await;
gloo_timers::future::TimeoutFuture::new(1).await;
for chunk in &iterator.chunks(chunksize) {
let images: Vec<image::GrayImage> = chunk.collect();
let results: Vec<ImageReport> = images
Expand Down Expand Up @@ -295,7 +295,8 @@ impl GenerateReport {
turn += 1;
*self.status.borrow_mut() =
Some(format!("processed {} scans", turn * chunksize));
gloo_timers::future::TimeoutFuture::new(100).await;
ctx.request_repaint();
gloo_timers::future::TimeoutFuture::new(1).await;
}

let csv_data = csv_writer.into_inner().unwrap().into_inner();
Expand Down

0 comments on commit a112b2d

Please sign in to comment.