This commit is contained in:
sanjayk03-dev
2024-03-27 16:48:45 +05:30
parent 7008e1b715
commit 66799bd0be

View File

@@ -204,8 +204,9 @@ module.exports = {
return Math.min(1, p); return Math.min(1, p);
}, },
gcode_files: function () { gcode_files: function () {
const files = this.config.gcode_list let files = [];
.find(item => item.name == this.state.folder) files = this.config.gcode_list
.find(item => item.name == this.state.folder || "")
.files.map(item => item.file_name); .files.map(item => item.file_name);
// const filesWithNoMacros = this.state.files.filter( // const filesWithNoMacros = this.state.files.filter(
// item => !this.config.macros_list.some(compareItem => compareItem.file_name == item), // item => !this.config.macros_list.some(compareItem => compareItem.file_name == item),
@@ -213,7 +214,7 @@ module.exports = {
// const gcodeList = this.config.non_macros_list.map(item => item.file_name); // const gcodeList = this.config.non_macros_list.map(item => item.file_name);
// const unionSet = new Set([...filesWithNoMacros, ...gcodeList]); // const unionSet = new Set([...filesWithNoMacros, ...gcodeList]);
// const files = [...unionSet].sort(); // const files = [...unionSet].sort();
return files || []; return files;
}, },
gcode_folders: function () { gcode_folders: function () {
let folders = []; let folders = [];
@@ -444,6 +445,13 @@ module.exports = {
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 });
} }
SvelteComponents.showDialog("Upload", {
file,
onComplete: () => {
this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name);
},
});
const folder = this.config.gcode_list.find(item => item.type == "folder" && item.name == folderName); const folder = this.config.gcode_list.find(item => item.type == "folder" && item.name == folderName);
if (folder) { if (folder) {
folder.files.push({ file_name: file.name }); folder.files.push({ file_name: file.name });
@@ -458,15 +466,6 @@ module.exports = {
], ],
}); });
} }
setImmediate(() =>
SvelteComponents.showDialog("Upload", {
file,
onComplete: () => {
this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name);
},
}),
);
} }
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);