From eb92e72e6c3404e42e4815f0bdc6b5026726c917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 20 Oct 2020 12:28:10 +0200 Subject: [PATCH] Updates can send progress update status --- public/updates-script.js | 8 +++++++- src/subcommand/serve.rs | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/public/updates-script.js b/public/updates-script.js index 57a28835e..09e9c25e1 100644 --- a/public/updates-script.js +++ b/public/updates-script.js @@ -52,7 +52,13 @@ $(window).on('load', function () { if (status.type == "Processing") { const id = 'update-' + status.update_id; const content = $(`#${id} .updateStatus.content`); - content.html('processing'); + content.html('processing...'); + } + + if (status.type == "Progressing") { + const id = 'update-' + status.update_id; + const content = $(`#${id} .updateStatus.content`); + content.html('progressing...'); } if (status.type == "Processed") { diff --git a/src/subcommand/serve.rs b/src/subcommand/serve.rs index 64c9edf20..4f795107c 100644 --- a/src/subcommand/serve.rs +++ b/src/subcommand/serve.rs @@ -96,6 +96,7 @@ struct UpdatesTemplate { enum UpdateStatus { Pending { update_id: u64, meta: M }, Processing { update_id: u64, meta: M }, + Progressing { update_id: u64, meta: M }, Processed { update_id: u64, meta: M }, } @@ -132,6 +133,16 @@ pub fn run(opt: Opt) -> anyhow::Result<()> { std::thread::sleep(Duration::from_secs(3)); + let progress = UpdateStatus::Progressing { update_id, meta: meta.clone() }; + let _ = update_status_sender_cloned.send(progress); + + std::thread::sleep(Duration::from_secs(3)); + + let progress = UpdateStatus::Progressing { update_id, meta: meta.clone() }; + let _ = update_status_sender_cloned.send(progress); + + std::thread::sleep(Duration::from_secs(3)); + let processed = UpdateStatus::Processed { update_id, meta: meta.clone() }; let _ = update_status_sender_cloned.send(processed); Ok(meta)