Added config file, edited config.py , added save funcs

This commit is contained in:
sanjayk03-dev
2024-01-02 13:52:53 +05:30
parent c9204ad2d1
commit f277cd9690
6 changed files with 47 additions and 30 deletions

View File

@@ -114,7 +114,7 @@ module.exports = new Vue({
full_version: "<loading>",
ip: "<>",
wifiName: "not connected",
macros:[]
macros:[{},{},{}]
},
state: {
messages: [],

View File

@@ -496,24 +496,6 @@ module.exports = {
showProbeDialog: function(probeType) {
SvelteComponents.showDialog("Probe", { probeType });
},
runMacros: function(id){
if(id==null || id == undefined ){
console.log("id null/undefined");
return;
}
if(this.config.macros!=undefined && this.config.macros.length!=0){
this.config.macros.find(el=>{
if(el.id==id){
console.log(el);
}else{
console.log("error in finding macros");
}
})
}else{
console.log("No macros found");
}
}
},

View File

@@ -1,5 +1,6 @@
"use strict";
const api = require("./api");
const utils = require("./utils");
module.exports = {
@@ -80,22 +81,29 @@ module.exports = {
}
});
},
saveMacros: function(){
saveMacros: async function(){
var macrosName = document.getElementById("macros-name").value;
var macrosColor = document.getElementById("macros-color").value;
if(this.config.macros == undefined) {
console.log("macros is undefined");
this.config.macros=[];
return;
}
}else{
this.config.macros.push({
id:Math.round(Math.random()*100000),
name:macrosName,
color:macrosColor,
gcode:this.state.selected,
})
console.log("Successfully saved");
}
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);

View File

@@ -208,9 +208,9 @@ script#control-view-template(type="text/x-template")
.bar(:style="'width:' + (progress || 0) * 100 + '%'")
.macros-div
.macros-buttons(class="present",v-if=" typeof config.macros != 'undefined'")
.macros-buttons(class="present",v-if="isMacrosPresent")
p there is a active macro
.macros-buttons(class ="absent",v-if="typeof config.macros == 'undefined'")
.macros-buttons(class ="absent",v-if="!isMacrosPresent")
p there is No macro

View File

@@ -584,6 +584,22 @@
}
},
"macros": {
"type":"list",
"index":"123",
"default":[
{ "name" : "Macros 1"},
{ "name" : "Macros 2"},
{ "name" : "Macros 3"}
],
"template": {
"name": {
"type": "text",
"default": "New Macro"
}
}
},
"admin": {
"auto-check-upgrade": {
"type": "bool",

View File

@@ -0,0 +1,11 @@
[
{
},
{
},
{
}
]