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;