adding to macrosList, testing gcodelist
This commit is contained in:
@@ -201,6 +201,11 @@ module.exports = {
|
|||||||
|
|
||||||
const p = this.plan_time / this.toolpath.time;
|
const p = this.plan_time / this.toolpath.time;
|
||||||
return Math.min(1, p);
|
return Math.min(1, p);
|
||||||
|
},
|
||||||
|
gcode_files: async function (){
|
||||||
|
const files=this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name == item));
|
||||||
|
console.log(files);
|
||||||
|
return files;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -513,9 +518,9 @@ module.exports = {
|
|||||||
console.warn("Error running program: ",error);
|
console.warn("Error running program: ",error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gcode_files: async function (){
|
// gcode_files: async function (){
|
||||||
const files=this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name == item));
|
// const files=this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name == item));
|
||||||
console.log(files);
|
// console.log(files);
|
||||||
// this.config.gcodeList=files;
|
// this.config.gcodeList=files;
|
||||||
// try {
|
// try {
|
||||||
// await api.put("config/save", this.config);
|
// await api.put("config/save", this.config);
|
||||||
@@ -525,8 +530,8 @@ module.exports = {
|
|||||||
// console.error("Restore Failed: ", error);
|
// console.error("Restore Failed: ", error);
|
||||||
// alert("Restore failed");
|
// alert("Restore failed");
|
||||||
// }
|
// }
|
||||||
return files;
|
// return files;
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [ require("./axis-vars") ]
|
mixins: [ require("./axis-vars") ]
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
macrosList: function () {
|
macrosList: function () {
|
||||||
return this.config.macrosList.map((el) => el.gcode_file_name);
|
return this.config.macrosList.map((el) => el.gcode_file_name);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open: function () {
|
open: function () {
|
||||||
@@ -70,7 +70,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
console.log(this.newGcode[this.tab - 1]);
|
console.log(this.newGcode[this.tab - 1]);
|
||||||
},
|
},
|
||||||
upload: function (e) {
|
upload:async function (e) {
|
||||||
const files = e.target.files || e.dataTransfer.files;
|
const files = e.target.files || e.dataTransfer.files;
|
||||||
if (!files.length) {
|
if (!files.length) {
|
||||||
return;
|
return;
|
||||||
@@ -90,12 +90,28 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gcodeData = {
|
||||||
|
gcode_file_name: file.name,
|
||||||
|
gcode_file_time: this.state.selected_time,
|
||||||
|
};
|
||||||
|
if(!this.config.macrosList.some(item=> item['gcode_file_name'] == file.name)){
|
||||||
|
console.log('new gcode file');
|
||||||
|
this.config.macrosList.push(gcodeData);
|
||||||
|
try {
|
||||||
|
await api.put("config/save", this.config);
|
||||||
|
this.$dispatch("update");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Restore Failed: ", error);
|
||||||
|
alert("Restore failed");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
console.log('Already exists');
|
||||||
|
}
|
||||||
|
|
||||||
SvelteComponents.showDialog("Upload", {
|
SvelteComponents.showDialog("Upload", {
|
||||||
file,
|
file,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.last_file_time = undefined; // Force reload
|
this.last_file_time = undefined; // Force reload
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -124,14 +140,19 @@ module.exports = {
|
|||||||
xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true);
|
xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true);
|
||||||
xhr.send(file);
|
xhr.send(file);
|
||||||
|
|
||||||
// this.config.macrosList.push()
|
const gcodeData = {
|
||||||
// try {
|
gcode_file_name: filename,
|
||||||
// await api.put("config/save", this.config);
|
gcode_file_time: this.state.selected_time,
|
||||||
// this.$dispatch("update");
|
};
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Restore Failed: ", error);
|
this.config.macrosList.push(gcodeData);
|
||||||
// alert("Restore failed");
|
try {
|
||||||
// }
|
await api.put("config/save", this.config);
|
||||||
|
this.$dispatch("update");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Restore Failed: ", error);
|
||||||
|
alert("Restore failed");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
saveMacros: async function () {
|
saveMacros: async function () {
|
||||||
var macrosName = document.getElementById(
|
var macrosName = document.getElementById(
|
||||||
@@ -146,16 +167,16 @@ module.exports = {
|
|||||||
|
|
||||||
if (this.state.selected == "default") {
|
if (this.state.selected == "default") {
|
||||||
var file = this.newGcode[this.tab - 1];
|
var file = this.newGcode[this.tab - 1];
|
||||||
this.uploadGCode(macrosName, file,);
|
this.uploadGCode(macrosName, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.macros[this.tab - 1].name = macrosName;
|
this.config.macros[this.tab - 1].name = macrosName;
|
||||||
this.config.macros[this.tab - 1].color = macrosColor;
|
this.config.macros[this.tab - 1].color = macrosColor;
|
||||||
this.config.macros[this.tab - 1].gcode_file_name =
|
this.config.macros[this.tab - 1].gcode_file_name =
|
||||||
this.state.selected == "default" ? macrosName : this.state.selected;
|
this.state.selected == "default" ? macrosName+'.ngc' : this.state.selected;
|
||||||
this.config.macros[this.tab - 1].gcode_file_time =
|
this.config.macros[this.tab - 1].gcode_file_time =
|
||||||
this.state.selected_time;
|
this.state.selected_time;
|
||||||
this.cancelMacros(this.tab - 1);
|
console.log(this.config.macros[this.tab - 1].gcode_file_name);
|
||||||
this.confirmSave = false;
|
this.confirmSave = false;
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
|
|||||||
Reference in New Issue
Block a user