From ccf5ff651f4679499407f2a8851c69762b03a676 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Tue, 2 Jan 2024 16:23:19 +0530 Subject: [PATCH] modified save func, corrected form tag --- src/js/macros.js | 33 ++++++++++++------------------ src/pug/templates/control-view.pug | 12 +++++------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/js/macros.js b/src/js/macros.js index 4d94062..4d0098a 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -82,29 +82,22 @@ module.exports = { }); }, saveMacros: async function(id){ - console.log(typeof(id)," type"); var macrosName = document.getElementById(`macros-name-${id}`).value; var macrosColor = document.getElementById(`macros-color-${id}`).value; - console.log(macrosName); - console.log(macrosColor); - // if(this.config.macros == undefined) { - // console.log("macros is undefined"); - // this.config.macros=[]; - // }else{ - // this.config.macros[id].name=macrosName; - // this.config.macros[id].color=macrosColor; - // this.config.macros[id].gcode=this.state.selected; - // } - // console.log(this.config.macros); - // try { - // await api.put("config/save",this.config); - // console.log("Successfully saved"); - // this.$dispatch("update"); - // } catch (error) { - // console.error("Restore Failed: ",error); - // alert("Restore failed"); - // } + this.config.macros[id].name=macrosName; + this.config.macros[id].color=macrosColor; + this.config.macros[id].gcode=this.state.selected; + + console.log(this.config.macros); + try { + await api.put("config/save",this.config); + console.log("Successfully saved"); + this.$dispatch("update"); + } catch (error) { + console.error("Restore Failed: ",error); + alert("Restore failed"); + } }, printConfig: function(){ console.log(this.config); diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index 2a147bf..dd054ea 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -209,17 +209,17 @@ script#control-view-template(type="text/x-template") .macros-div(class="present") button.macros-buttons(title="Click to run Macros 1", @click="open", - :disabled="!isMacrosPresent(0)",style="height:60px;width:100px;font-weight:normal") Macros 1 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 1 button.macros-buttons(title="Click to run Macros 2", @click="open", - :disabled="!isMacrosPresent(1)",style="height:60px;width:100px;font-weight:normal") Macros 2 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 2 button.macros-buttons(title="Click to run Macros 3", @click="open", - :disabled="!isMacrosPresent(2)",style="height:60px;width:100px;font-weight:normal") Macros 3 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 3 button.macros-buttons(title="Click to run Macros 4", @click="open", - :disabled="!isMacrosPresent(3)",style="height:60px;width:100px;font-weight:normal") Macros 4 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 4 button.macros-buttons(title="Click to run Macros 5", @click="open", - :disabled="!isMacrosPresent(4)",style="height:60px;width:100px;font-weight:normal") Macros 5 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 5 button.macros-buttons(title="Click to run Macros 6", @click="open", - :disabled="!isMacrosPresent(5)",style="height:60px;width:100px;font-weight:normal") Macros 6 + :disabled="!true",style="height:60px;width:100px;font-weight:normal;border-radius:4px") Macros 6 .tabs