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>",
|
full_version: "<loading>",
|
||||||
ip: "<>",
|
ip: "<>",
|
||||||
wifiName: "not connected",
|
wifiName: "not connected",
|
||||||
macros:[]
|
macros:[{},{},{}]
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
messages: [],
|
messages: [],
|
||||||
|
|||||||
@@ -496,24 +496,6 @@ module.exports = {
|
|||||||
|
|
||||||
showProbeDialog: function(probeType) {
|
showProbeDialog: function(probeType) {
|
||||||
SvelteComponents.showDialog("Probe", { 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";
|
"use strict";
|
||||||
|
|
||||||
|
const api = require("./api");
|
||||||
const utils = require("./utils");
|
const utils = require("./utils");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -80,22 +81,29 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveMacros: function(){
|
saveMacros: async function(){
|
||||||
var macrosName = document.getElementById("macros-name").value;
|
var macrosName = document.getElementById("macros-name").value;
|
||||||
var macrosColor = document.getElementById("macros-color").value;
|
var macrosColor = document.getElementById("macros-color").value;
|
||||||
if(this.config.macros == undefined) {
|
if(this.config.macros == undefined) {
|
||||||
console.log("macros is undefined");
|
console.log("macros is undefined");
|
||||||
this.config.macros=[];
|
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);
|
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(){
|
printConfig: function(){
|
||||||
console.log(this.config);
|
console.log(this.config);
|
||||||
|
|||||||
@@ -208,9 +208,9 @@ script#control-view-template(type="text/x-template")
|
|||||||
.bar(:style="'width:' + (progress || 0) * 100 + '%'")
|
.bar(:style="'width:' + (progress || 0) * 100 + '%'")
|
||||||
|
|
||||||
.macros-div
|
.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
|
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
|
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": {
|
"admin": {
|
||||||
"auto-check-upgrade": {
|
"auto-check-upgrade": {
|
||||||
"type": "bool",
|
"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