From 293e1f742074e9386b919651edc43086f2f9e638 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Mon, 22 Jan 2024 01:07:02 +0530 Subject: [PATCH] updating next tick, trying to filter --- src/js/macros.js | 26 +++++++++++++++++--------- src/pug/templates/macros.pug | 4 ++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/js/macros.js b/src/js/macros.js index ac1a144..ba139a6 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -55,17 +55,18 @@ module.exports = { }); const text = (await response.text()).split(" ").join("\n"); console.log(text); - if (text.length > 20e6) { - this.newGcode[this.tab - 1] = "File is large - gcode view disabled"; - } else { - this.newGcode[this.tab - 1] = text; - } + Vue.nextTick(() => { + if (text.length > 20e6) { + this.newGcode[this.tab - 1] = "File is large - gcode view disabled"; + } else { + this.newGcode[this.tab - 1] = text; + } + }); } else { - this.newGcode = ""; + Vue.nextTick(() => { + this.newGcode[this.tab - 1] = ""; + }); } - Vue.nextTick(() => { - console.log("updated"); - }); }, upload: function (e) { const files = e.target.files || e.dataTransfer.files; @@ -158,6 +159,13 @@ module.exports = { document.getElementById(`gcodeSelect-${this.tab - 1}`).value = "default"; this.newGcode[this.tab - 1] = ""; }, + macrosList: function () { + const macros = this.state.files.filter( + (name) => !this.config.macros.some((obj) => obj.name === name) + ); + console.log("Only Macros: ", macros); + return macros; + }, resetConfig: async function () { this.config.macros = [ { diff --git a/src/pug/templates/macros.pug b/src/pug/templates/macros.pug index 6c99659..2b3d0c4 100644 --- a/src/pug/templates/macros.pug +++ b/src/pug/templates/macros.pug @@ -64,7 +64,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 @@ -94,7 +94,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