fix xfr rate and ETA and show ETA in (hh:)mm:ss

This commit is contained in:
joshuaboud 2021-07-20 15:55:05 -03:00
parent 48c422e043
commit 1300292544
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E
2 changed files with 3 additions and 5 deletions

View File

@ -41,7 +41,6 @@ export class FileUpload {
this.reader = new FileReader();
this.chunks = this.slice_file(file);
this.chunk_index = 0;
this.timestamp = Date.now();
this.modal_prompt = new ModalPrompt();
this.using_webkit = true;
this.make_html_element();
@ -127,6 +126,7 @@ export class FileUpload {
}
async upload() {
this.timestamp = Date.now();
this.dom_element.style.display = "flex";
this.proc = cockpit.spawn(["/usr/share/cockpit/navigator/scripts/write-chunks.py3", this.path], {err: "out", superuser: "try"});
this.proc.fail((e, data) => {
@ -164,7 +164,7 @@ export class FileUpload {
}
this.done();
}
this.update_rates_interval = setInterval(this.display_xfr_rate.bind(this), 2000);
this.update_rates_interval = setInterval(this.display_xfr_rate.bind(this), 1000);
}
/**

View File

@ -70,9 +70,7 @@ export function format_time_remaining(seconds_) {
if (hours) {
out = String(hours).padStart(2, '0') + ":";
}
if (minutes) {
out += String(minutes).padStart(2, '0') + ":";
}
out += String(minutes).padStart(2, '0') + ":";
out += String(seconds).padStart(2, '0');
return out;
}