Fixed the issue where the UI becomes unresponsive on the first file upload

This commit is contained in:
David Carley
2021-03-02 18:42:34 -08:00
parent a0ae0a4e30
commit d752fd2b76
2 changed files with 62 additions and 58 deletions

View File

@@ -511,15 +511,23 @@ module.exports = {
},
load_toolpath: function (file, file_time) {
load_toolpath: async function (file, file_time) {
this.toolpath = {};
if (!file) return;
api.get('path/' + file).done(function (toolpath) {
if (this.last_file_time != file_time) return;
this.showGcodeMessage = true;
let done;
while (!done) {
const toolpath = await api.get(`path/${file}`);
console.log("toolpath progress: ", toolpath.progress);
if (typeof toolpath.progress == 'undefined') {
console.log("done loading toolpath");
done = true;
toolpath.filename = file;
this.toolpath_progress = 1;
this.showGcodeMessage = false;
@@ -531,13 +539,11 @@ module.exports = {
Vue.set(state, 'path_min_' + axis, bounds.min[axis]);
Vue.set(state, 'path_max_' + axis, bounds.max[axis]);
}
} else {
this.showGcodeMessage = true;
console.log("Still loading toolpath");
this.toolpath_progress = toolpath.progress;
this.load_toolpath(file, file_time); // Try again
}
}.bind(this));
}
},

View File

@@ -27,6 +27,54 @@
script#control-view-template(type="text/x-template")
#control
message(:show.sync="showGcodeMessage")
h3(slot="header") Processing New File
div(slot="body")
h3 Please wait..
p Simulating GCode to check for errors, calculate ETA and generate 3D view.
div(slot="footer")
label Simulating {{(toolpath_progress || 0) | percent}}
message(:show.sync=`ask_home_msg`)
h3(slot="header") Home Machine
div(slot="body")
p Home the machine?
div(slot="footer")
button.pure-button(@click="home()")
| OK
button.pure-button(@click='ask_home_msg = false; ask_home = false')
| Cancel
message(:show.sync=`ask_zero_xy_msg`)
h3(slot="header") XY Origin
div(slot="body")
p Move to XY origin?
div(slot="footer")
button.pure-button(@click="goto_zero(1,1,0,0)")
| Confirm
button.pure-button(@click='ask_zero_xy_msg = false')
| Cancel
message(:show.sync=`ask_zero_z_msg`)
h3(slot="header") Z Origin
div(slot="body")
p Move to Z origin?
div(slot="footer")
button.pure-button(@click="goto_zero(0,0,1,0)")
| Confirm
button.pure-button(@click='ask_zero_z_msg = false')
| Cancel
table(width="99%")
tr
@@ -114,56 +162,6 @@ script#control-view-template(type="text/x-template")
button.pure-button(@click=`toolpath_msg['${axis}'] = false`)
| OK
message(:show.sync="showGcodeMessage")
h3(slot="header") Processing New File
div(slot="body")
h3 Please wait..
p Simulating GCode to check for errors, calculate ETA and generate 3D view.
div(slot="footer")
label Simulating {{(toolpath_progress || 0) | percent}}
message(:show.sync=`ask_home_msg`)
h3(slot="header") Home Machine
div(slot="body")
p Home the machine?
div(slot="footer")
button.pure-button(@click="home()")
| OK
button.pure-button(@click='ask_home_msg = false; ask_home = false')
| Cancel
message(:show.sync=`ask_zero_xy_msg`)
h3(slot="header") XY Origin
div(slot="body")
p Move to XY origin?
div(slot="footer")
button.pure-button(@click="goto_zero(1,1,0,0)")
| Confirm
button.pure-button(@click='ask_zero_xy_msg = false')
| Cancel
message(:show.sync=`ask_zero_z_msg`)
h3(slot="header") Z Origin
div(slot="body")
p Move to Z origin?
div(slot="footer")
button.pure-button(@click="goto_zero(0,0,1,0)")
| Confirm
button.pure-button(@click='ask_zero_z_msg = false')
| Cancel
th.actions
button.pure-button(:disabled="!can_set_axis",
title=`Set {{'${axis}' | upper}} axis position.`,