Added config file, edited config.py , added save funcs
This commit is contained in:
@@ -114,7 +114,7 @@ module.exports = new Vue({
|
||||
full_version: "<loading>",
|
||||
ip: "<>",
|
||||
wifiName: "not connected",
|
||||
macros:[]
|
||||
macros:[{},{},{}]
|
||||
},
|
||||
state: {
|
||||
messages: [],
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
11
src/resources/macros_config.json
Normal file
11
src/resources/macros_config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user