From ddbbd56b156406798083c86f673387c056abe4a9 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Mon, 22 Jan 2024 10:20:48 +0530 Subject: [PATCH] fixing the list --- src/js/control-view.js | 3 +-- src/js/macros.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index 9df4f9c..cf1d981 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -42,8 +42,7 @@ module.exports = { tab: "auto", ask_home: true, 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) + gcode_files:this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name === item)) }; }, diff --git a/src/js/macros.js b/src/js/macros.js index 755539f..75db10f 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -85,14 +85,16 @@ module.exports = { return; } + SvelteComponents.showDialog("Upload", { file, onComplete: () => { this.last_file_time = undefined; // Force reload + }, }); }, - uploadGCode: function (filename, file) { + uploadGCode: async function (filename, file) { const xhr = new XMLHttpRequest(); xhr.onload = function () { @@ -116,6 +118,15 @@ module.exports = { xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true); xhr.send(file); + + // this.config.macrosList.push() + // try { + // await api.put("config/save", this.config); + // this.$dispatch("update"); + // } catch (error) { + // console.error("Restore Failed: ", error); + // alert("Restore failed"); + // } }, saveMacros: async function () { var macrosName = document.getElementById( @@ -130,7 +141,7 @@ module.exports = { if (this.state.selected == "default") { var file = this.newGcode[this.tab - 1]; - this.uploadGCode(macrosName, file); + this.uploadGCode(macrosName, file,); } this.config.macros[this.tab - 1].name = macrosName;