trying adding files

This commit is contained in:
sanjayk03-dev
2024-01-12 00:55:13 +05:30
parent ff6b7fdc9e
commit bc0242b242
2 changed files with 33 additions and 28 deletions

View File

@@ -9,10 +9,9 @@ module.exports = {
data: function () {
return {
tab: 1,
tab: "1",
confirmReset: false,
confirmSave: false,
currentTab:1,
newGcode: ["", "", "", "", "", "", "", ""],
};
},
@@ -38,20 +37,17 @@ module.exports = {
},
methods: {
updateNewGcode(event) {
this.newGcode[this.tab] = event.target.value;
this.newGcode[this.tab-1] = event.target.value;
},
open: function () {
utils.clickFileInput("gcode-file-input");
},
load: function () {
const file_time = this.state.selected_time;
console.log(this.state.selected_time, "\n ",file_time);
const file = this.state.selected;
console.log(this.state.selected);
console.log(this.state.line);
this.$broadcast("gcode-load", file);
this.$broadcast("gcode-line", this.state.line);
this.newGcode[this.tab] = "";
this.newGcode[this.tab-1] = "";
},
upload: function (e) {
const files = e.target.files || e.dataTransfer.files;
@@ -81,25 +77,34 @@ module.exports = {
});
},
saveMacros: async function () {
console.log(this.state.selected);
if(this.state.selected =='default'){
const file = this.newGcode[this.tab-1];
SvelteComponents.showDialog("Upload", {
file,
onComplete: () => {
this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name);
},
});
}
var macrosName = document.getElementById(
`macros-name-${this.tab}`
`macros-name-${this.tab-1}`
).value;
var macrosColor = document.getElementById(
`macros-color-${this.tab}`
`macros-color-${this.tab-1}`
).value;
console.log(this.tab);
console.log(this.tab-1);
console.log(macrosColor, macrosName);
this.config.macros[this.tab].name = macrosName;
console.log(this.config.macros[this.tab-1]);
this.config.macros[this.tab].color = macrosColor;
this.config.macros[this.tab].gcode_file_name = this.state.selected;
this.config.macros[this.tab].gcode_file_time =
this.config.macros[this.tab-1].name = macrosName;
console.log(this.config.macros[this.tab-1].name);
this.config.macros[this.tab-1].color = macrosColor;
this.config.macros[this.tab-1].gcode_file_name = this.state.selected;
this.config.macros[this.tab-1].gcode_file_time =
this.state.selected_time;
console.log(this.config.macros);
this.cancelMacros(this.tab);
this.cancelMacros(this.tab-1);
this.confirmSave = false;
try {
await api.put("config/save", this.config);
@@ -111,9 +116,9 @@ module.exports = {
}
},
cancelMacros: function () {
document.getElementById(`macros-name-${this.tab}`).value = "";
document.getElementById(`macros-color-${this.tab}`).value = "#ffffff";
document.getElementById(`gcodeSelect-${this.tab}`).value = "default";
document.getElementById(`macros-name-${this.tab-1}`).value = "";
document.getElementById(`macros-color-${this.tab-1}`).value = "#ffffff";
document.getElementById(`gcodeSelect-${this.tab-1}`).value = "default";
this.$broadcast("gcode-clear");
},
resetConfig: async function () {