saving folderdata in config

This commit is contained in:
sanjayk03-dev
2024-03-27 12:26:34 +05:30
parent 649b1ea3f1
commit 4c584e792a
2 changed files with 57 additions and 14 deletions

View File

@@ -384,13 +384,16 @@ module.exports = {
const isAlreadyPresent = this.config.non_macros_list.find(element => element.file_name == file.name); const isAlreadyPresent = this.config.non_macros_list.find(element => element.file_name == file.name);
if (isAlreadyPresent == undefined) { if (isAlreadyPresent == undefined) {
this.config.non_macros_list.push({ file_name: file.name }); this.config.non_macros_list.push({ file_name: file.name });
try { }
await api.put("config/save", this.config); if (this.config.gcode_list.find(item => item.name == file.name && item.type == "file") == undefined) {
this.$dispatch("update"); this.config.gcode_list.push({ name: file.name, type: "file", files: [] });
} catch (error) { }
console.error("Restore Failed: ", error); try {
alert("Restore failed"); await api.put("config/save", this.config);
} this.$dispatch("update");
} catch (error) {
console.error("Restore Failed: ", error);
alert("Restore failed");
} }
SvelteComponents.showDialog("Upload", { SvelteComponents.showDialog("Upload", {
@@ -427,13 +430,27 @@ module.exports = {
const isAlreadyPresent = this.config.non_macros_list.find(element => element.file_name == file.name); const isAlreadyPresent = this.config.non_macros_list.find(element => element.file_name == file.name);
if (isAlreadyPresent == undefined) { if (isAlreadyPresent == undefined) {
this.config.non_macros_list.push({ file_name: file.name }); this.config.non_macros_list.push({ file_name: file.name });
try { }
await api.put("config/save", this.config); const folder = this.config.gcode_list.find(item => item.type == "folder" && item.name == folderName);
this.$dispatch("update"); if (folder) {
} catch (error) { folder.files.push({ file_name: file.name });
console.error("Restore Failed: ", error); } else {
alert("Restore failed"); this.config.gcode_list.push({
} name: folderName,
type: "folder",
files: [
{
file_name: file.name,
},
],
});
}
try {
await api.put("config/save", this.config);
this.$dispatch("update");
} catch (error) {
console.error("Restore Failed: ", error);
alert("Restore failed");
} }
SvelteComponents.showDialog("Upload", { SvelteComponents.showDialog("Upload", {

View File

@@ -627,6 +627,32 @@
} }
}, },
"gcode_list": {
"type": "list",
"default": [],
"template": {
"name": {
"type": "string",
"default": ""
},
"type": {
"type": "enum",
"values": ["file", "folder"],
"default": "folder"
},
"files": {
"type": "list",
"default": [],
"template": {
"file_name": {
"type": "string",
"default": ""
}
}
}
}
},
"admin": { "admin": {
"auto-check-upgrade": { "auto-check-upgrade": {
"type": "bool", "type": "bool",