diff --git a/src/js/control-view.js b/src/js/control-view.js index d45d72f..26e4c07 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -203,14 +203,26 @@ module.exports = { const p = this.plan_time / this.toolpath.time; return Math.min(1, p); }, - gcodeFiles: function () { - const filesWithNoMacros = this.state.files.filter( - item => !this.config.macros_list.some(compareItem => compareItem.file_name == item), - ); - const gcodeList = this.config.non_macros_list.map(item => item.file_name); - const unionSet = new Set([...filesWithNoMacros, ...gcodeList]); - const files = [...unionSet].sort(); - return files; + gcode_files: function () { + const files = this.config.gcode_list + .find(item => item.name == this.state.folder) + .files.map(item => item.file_name); + // const filesWithNoMacros = this.state.files.filter( + // item => !this.config.macros_list.some(compareItem => compareItem.file_name == item), + // ); + // const gcodeList = this.config.non_macros_list.map(item => item.file_name); + // const unionSet = new Set([...filesWithNoMacros, ...gcodeList]); + // const files = [...unionSet].sort(); + return files || []; + }, + gcode_folders: function () { + let folders = []; + for (let item of this.config.gcode_list) { + if (item.type == "folder") { + folders.push(item.name); + } + } + return folders; }, }, @@ -446,14 +458,6 @@ module.exports = { ], }); } - try { - await api.put("config/save", this.config); - this.$dispatch("update"); - } catch (error) { - console.error("Restore Failed: ", error); - alert("Restore failed"); - } - setImmediate(() => SvelteComponents.showDialog("Upload", { file, @@ -464,6 +468,13 @@ module.exports = { }), ); } + try { + await api.put("config/save", this.config); + this.$dispatch("update"); + } catch (error) { + console.error("Restore Failed: ", error); + alert("Restore failed"); + } }, delete_current: async function () { diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index a7a1075..5dab058 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -271,23 +271,23 @@ script#control-view-template(type="text/x-template") v-if="false", style="height:100px;width:100px;font-weight:normal") .fa.fa-step-forward - message(:show.sync="show_gcodes") - h3(slot="header") Select G-Code - div(slot="body") - details - summary - | folder name - ul.folder-list - li one - li two + //- message(:show.sync="show_gcodes") + //- h3(slot="header") Select G-Code + //- div(slot="body") + //- details + //- summary + //- | folder name + //- ul.folder-list + //- li one + //- li two - div(slot="footer") - button.pure-button(@click="show_gcodes=false") Cancel - button.pure-button.pure-button-primary(@click="show_gcodes=false") Select + //- div(slot="footer") + //- button.pure-button(@click="show_gcodes=false") Cancel + //- button.pure-button.pure-button-primary(@click="show_gcodes=false") Select - button.pure-button(title="Open Title", @click="show_gcodes=true", - :disabled="!is_ready",style="height:100px;width:100px;font-weight:normal") - .fa.fa-folder + //- button.pure-button(title="Open Title", @click="show_gcodes=true", + //- :disabled="!is_ready",style="height:100px;width:100px;font-weight:normal") + //- .fa.fa-folder button.pure-button(title="Upload a new GCode program.", @click="open_file", :disabled="!is_ready",style="height:100px;width:100px;font-weight:normal") @@ -328,10 +328,15 @@ script#control-view-template(type="text/x-template") .fa.fa-trash |  Selected + select(title="Select previously uploaded GCode programs.", + v-model="state.folder", :disabled="!is_ready", + style="max-width:100%") + option(v-for="file in gcode_folders", :value="file") {{file}} + select(title="Select previously uploaded GCode programs.", v-model="state.selected", @change="load", :disabled="!is_ready", style="max-width:100%") - option(v-for="file in gcodeFiles", :value="file") {{file}} + option(v-for="file in gcode_files", :value="file") {{file}} .progress(v-if="toolpath_progress && toolpath_progress < 1", title="Simulating GCode to check for errors, calculate ETA and " +