From d752fd2b766cf2df49b2a7540c6cac755e05cdcf Mon Sep 17 00:00:00 2001 From: David Carley Date: Tue, 2 Mar 2021 18:42:34 -0800 Subject: [PATCH 1/2] Fixed the issue where the UI becomes unresponsive on the first file upload --- src/js/control-view.js | 20 ++++-- src/pug/templates/control-view.pug | 100 ++++++++++++++--------------- 2 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index b0ca095..67412d9 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -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)); + } }, diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index bad4a5f..528f4d6 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -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 @@ -87,7 +135,7 @@ script#control-view-template(type="text/x-template") button.pure-button(title="Home all axes.", @click="home()", :disabled="!is_idle",style="height:60px;width:60px") .fa.fa-home - + each axis in 'xyzabc' tr.axis(:class=`${axis}.klass`, v-if=`${axis}.enabled`, :title=`${axis}.title`) @@ -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.`, From e9330f06848478be446cbcfc0047306ba851a515 Mon Sep 17 00:00:00 2001 From: David Carley Date: Tue, 2 Mar 2021 18:44:13 -0800 Subject: [PATCH 2/2] Removed debugging code --- src/js/control-view.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index 67412d9..4984f4c 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -519,14 +519,11 @@ module.exports = { this.showGcodeMessage = true; - let done; + let done = false; 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; @@ -540,7 +537,6 @@ module.exports = { Vue.set(state, 'path_max_' + axis, bounds.max[axis]); } } else { - console.log("Still loading toolpath"); this.toolpath_progress = toolpath.progress; } }