Skip to content

Commit

Permalink
an est. time to completion in the progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jvo203 committed Apr 24, 2019
1 parent e1fd225 commit 21cd8ef
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fits_web_ql"
version = "4.1.15"
version = "4.1.16"
authors = ["jvo203 <[email protected]>"]
edition = "2018"

Expand Down
22 changes: 14 additions & 8 deletions htdocs/fitswebql/fitswebql.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function get_js_version() {
return "JS2019-04-18.1";
return "JS2019-04-24.0";
}

const wasm_supported = (() => {
Expand Down Expand Up @@ -1369,8 +1369,9 @@ function process_progress_event(data, index) {
var message = data.message;
var running = data.running;
var total = data.total;
var elapsed = data.elapsed;

//console.log(data, index) ;
//console.log(data, index);

if (total > 0) {
notifications_received[index - 1] = Math.max(running, notifications_received[index - 1]);
Expand All @@ -1380,18 +1381,23 @@ function process_progress_event(data, index) {
else*/
var PROGRESS_VARIABLE = notifications_received[index - 1] / total;

var progress = Math.round(100 * PROGRESS_VARIABLE);
if (PROGRESS_VARIABLE != previous_progress[index - 1]) {
previous_progress[index - 1] = PROGRESS_VARIABLE;

if (progress != previous_progress[index - 1]) {
previous_progress[index - 1] = progress;
PROGRESS_INFO = "&nbsp;" + numeral(PROGRESS_VARIABLE).format('0.0%');

PROGRESS_INFO = "&nbsp;" + message + " " + progress + "%";
var speed = notifications_received[index - 1] / elapsed;
var remaining_time = (total - notifications_received[index - 1]) / speed;//[s]

//console.log("speed:", speed, "remaining:", remaining_time);
if (remaining_time > 1)
PROGRESS_INFO += ", " + numeral(remaining_time).format('00:00:00');

//console.log(PROGRESS_INFO) ;

d3.select("#progress-bar" + index)
.attr("aria-valuenow", progress)
.style("width", progress + "%")
.attr("aria-valuenow", (100.0 * PROGRESS_VARIABLE))
.style("width", (100.0 * PROGRESS_VARIABLE) + "%")
.html(PROGRESS_INFO);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/fits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ pub enum Intensity {

#[derive(Debug)]
pub struct FITS {
created: std::time::Instant,
pub dataset_id: String,
data_id: String,
filesize: u64,
Expand Down Expand Up @@ -379,6 +380,7 @@ impl FITS {
};

let fits = FITS {
created: std::time::Instant::now(),
dataset_id: id.clone(),
data_id: format!("{}_00_00_00", id),
filesize: 0,
Expand Down Expand Up @@ -1894,6 +1896,7 @@ println!("CRITICAL ERROR cannot read from file: {:?}", err);
notification: String::from(notification),
total: total,
running: running,
elapsed: std::time::Instant::now().duration_since(self.created),
dataset_id: self.dataset_id.clone(),
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2253,8 +2253,8 @@ lazy_static! {
#[cfg(feature = "jvo")]
static LOG_DIRECTORY: &'static str = "LOGS";

static SERVER_STRING: &'static str = "FITSWebQL v4.1.15";
static VERSION_STRING: &'static str = "SV2019-04-19.0";
static SERVER_STRING: &'static str = "FITSWebQL v4.1.16";
static VERSION_STRING: &'static str = "SV2019-04-24.0";
static WASM_STRING: &'static str = "WASM2019-02-08.1";

#[cfg(not(feature = "jvo"))]
Expand Down
4 changes: 3 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct WsMessage {
pub notification: String,
pub total: i32,
pub running: i32,
pub elapsed: std::time::Duration,
/// dataset
pub dataset_id: String,
}
Expand Down Expand Up @@ -323,7 +324,8 @@ impl Handler<WsMessage> for SessionServer {
"type" : "progress",
"message" : msg.notification,
"total" : msg.total,
"running" : msg.running
"running" : msg.running,
"elapsed" : (msg.elapsed.as_millis() as f64) / 1000.0
})
.to_string();

Expand Down

0 comments on commit 21cd8ef

Please sign in to comment.