From 96657f3cb1ccbc0750d5239565a0418e76c117c1 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Mon, 22 Jan 2024 09:56:48 +0530 Subject: [PATCH] filtering Gcodes --- src/js/control-view.js | 6 +++++- src/js/macros.js | 4 ++-- src/pug/templates/control-view.pug | 2 +- src/pug/templates/macros.pug | 12 ++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index ab701f6..9df4f9c 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -41,7 +41,9 @@ module.exports = { deleteGCode: false, tab: "auto", ask_home: true, - showGcodeMessage: false + showGcodeMessage: false, + gcode_files:this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name === item.gcode_file_name)) + .map(item => item.gcode_file_name) }; }, @@ -285,6 +287,8 @@ module.exports = { return; } + console.log(file,file_time); + this.last_file = file; this.last_file_time = file_time; diff --git a/src/js/macros.js b/src/js/macros.js index 24e604c..755539f 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -23,7 +23,7 @@ module.exports = { "default", ], newGcode: ["", "", "", "", "", "", "", ""], - macrosList: this.config.macros.map((item) => item.gcode_file_name), + macrosList: this.config.macrosList.map((el) => el.gcode_file_name), }; }, computed: { @@ -63,7 +63,7 @@ module.exports = { } else { this.newGcode[this.tab - 1] = ""; } - console.log(this.newGcode[this.tab-1]); + console.log(this.newGcode[this.tab - 1]); }, upload: function (e) { const files = e.target.files || e.dataTransfer.files; diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index f37867d..d55185a 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -297,7 +297,7 @@ script#control-view-template(type="text/x-template") 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 state.files", :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 " + diff --git a/src/pug/templates/macros.pug b/src/pug/templates/macros.pug index 9da5083..83636c2 100644 --- a/src/pug/templates/macros.pug +++ b/src/pug/templates/macros.pug @@ -125,7 +125,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload @@ -155,7 +155,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload @@ -185,7 +185,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload @@ -215,7 +215,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload @@ -245,7 +245,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]",@change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload @@ -275,7 +275,7 @@ script#macros-template(type="text/x-template") v-model="selectedValues[tab - 1]",@change="load", :disabled="!is_ready", style="max-width:100%;height:40px;border-radius:5px") option(selected='' value='default') Create G-Code - option(v-for="file in state.files", :value="file") {{file}} + option(v-for="file in macrosList", :value="file") {{file}} button.pure-button(title="Upload a new GCode program.", @click="open", :disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around") Upload