From abfed3f596219ae40d94ab6f52cb557af0464490 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Tue, 23 Jan 2024 14:33:51 +0530 Subject: [PATCH] reset mAcros list --- src/js/macros.js | 45 +++++++++++++++++++++++++++++++++++- src/pug/templates/macros.pug | 2 ++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/js/macros.js b/src/js/macros.js index 2744913..de20b1d 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -125,7 +125,7 @@ module.exports = { gcode_file_name: file.name, gcode_file_time: this.state.selected_time, }; - if (!this.config.macrosList.some(item => item["gcode_file_name"] == file.name)) { + if (!this.config.macrosList.some(item => item.gcode_file_name == file.name)) { console.log("new gcode file"); this.config.macrosList.push(gcodeData); try { @@ -330,5 +330,48 @@ module.exports = { printConfig: function () { console.log(this.config); }, + resetMacrosList: async function (){ + this.config.macrosList=[ + { + "gcode_file_name": "FireLaser.ngc", + "gcode_file_time": 1705008250.2333415 + }, + { + "gcode_file_name": "GoHomeXYZ.ngc", + "gcode_file_time": 1705008321.710827 + }, + { + "gcode_file_name": "ParkRearRightWW.ngc", + "gcode_file_time": 1705008360.977644 + }, + { + "gcode_file_name": "SpindleWarmUp1Minute.ngc", + "gcode_file_time": 1705008372.967075 + }, + { + "gcode_file_name": "TurnOnSpindle.ngc", + "gcode_file_time": 1705008405.5059154 + }, + { + "gcode_file_name": "TurnOffSpindleAndLaser.ngc", + "gcode_file_time": 1705008384.6566093 + }, + { + "gcode_file_name": "VacOn.ngc", + "gcode_file_time": 1705008413.7756715 + }, + { + "gcode_file_name": "TurnOffVac.ngc", + "gcode_file_time": 1705008395.476232 + } + ] + try { + await api.put("config/save", this.config); + this.$dispatch("update"); + } catch (error) { + console.error("Restore Failed: ", error); + alert("Restore failed"); + } + }, }, }; diff --git a/src/pug/templates/macros.pug b/src/pug/templates/macros.pug index e59f158..29126f8 100644 --- a/src/pug/templates/macros.pug +++ b/src/pug/templates/macros.pug @@ -332,3 +332,5 @@ script#macros-template(type="text/x-template") style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Print State button.submit-macros(title="Cancel Macros",@click="printConfig", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Print Config + button.submit-macros(title="Cancel Macros",@click="resetMacrosList", + style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Reset Macros List