double-dropdown

This commit is contained in:
sanjayk03-dev
2024-03-27 16:10:29 +05:30
parent 894e7b64cb
commit 7008e1b715
2 changed files with 48 additions and 32 deletions

View File

@@ -203,14 +203,26 @@ 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);
}, },
gcodeFiles: function () { gcode_files: function () {
const filesWithNoMacros = this.state.files.filter( const files = this.config.gcode_list
item => !this.config.macros_list.some(compareItem => compareItem.file_name == item), .find(item => item.name == this.state.folder)
); .files.map(item => item.file_name);
const gcodeList = this.config.non_macros_list.map(item => item.file_name); // const filesWithNoMacros = this.state.files.filter(
const unionSet = new Set([...filesWithNoMacros, ...gcodeList]); // item => !this.config.macros_list.some(compareItem => compareItem.file_name == item),
const files = [...unionSet].sort(); // );
return files; // const gcodeList = this.config.non_macros_list.map(item => item.file_name);
// const unionSet = new Set([...filesWithNoMacros, ...gcodeList]);
// const files = [...unionSet].sort();
return files || [];
},
gcode_folders: function () {
let folders = [];
for (let item of this.config.gcode_list) {
if (item.type == "folder") {
folders.push(item.name);
}
}
return folders;
}, },
}, },
@@ -446,14 +458,6 @@ module.exports = {
], ],
}); });
} }
try {
await api.put("config/save", this.config);
this.$dispatch("update");
} catch (error) {
console.error("Restore Failed: ", error);
alert("Restore failed");
}
setImmediate(() => setImmediate(() =>
SvelteComponents.showDialog("Upload", { SvelteComponents.showDialog("Upload", {
file, file,
@@ -464,6 +468,13 @@ module.exports = {
}), }),
); );
} }
try {
await api.put("config/save", this.config);
this.$dispatch("update");
} catch (error) {
console.error("Restore Failed: ", error);
alert("Restore failed");
}
}, },
delete_current: async function () { delete_current: async function () {

View File

@@ -271,23 +271,23 @@ script#control-view-template(type="text/x-template")
v-if="false", style="height:100px;width:100px;font-weight:normal") v-if="false", style="height:100px;width:100px;font-weight:normal")
.fa.fa-step-forward .fa.fa-step-forward
message(:show.sync="show_gcodes") //- message(:show.sync="show_gcodes")
h3(slot="header") Select G-Code //- h3(slot="header") Select G-Code
div(slot="body") //- div(slot="body")
details //- details
summary //- summary
| folder name //- | folder name
ul.folder-list //- ul.folder-list
li one //- li one
li two //- li two
div(slot="footer") //- div(slot="footer")
button.pure-button(@click="show_gcodes=false") Cancel //- button.pure-button(@click="show_gcodes=false") Cancel
button.pure-button.pure-button-primary(@click="show_gcodes=false") Select //- button.pure-button.pure-button-primary(@click="show_gcodes=false") Select
button.pure-button(title="Open Title", @click="show_gcodes=true", //- button.pure-button(title="Open Title", @click="show_gcodes=true",
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal") //- :disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
.fa.fa-folder //- .fa.fa-folder
button.pure-button(title="Upload a new GCode program.", @click="open_file", button.pure-button(title="Upload a new GCode program.", @click="open_file",
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal") :disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
@@ -328,10 +328,15 @@ script#control-view-template(type="text/x-template")
.fa.fa-trash .fa.fa-trash
|  Selected |  Selected
select(title="Select previously uploaded GCode programs.",
v-model="state.folder", :disabled="!is_ready",
style="max-width:100%")
option(v-for="file in gcode_folders", :value="file") {{file}}
select(title="Select previously uploaded GCode programs.", select(title="Select previously uploaded GCode programs.",
v-model="state.selected", @change="load", :disabled="!is_ready", v-model="state.selected", @change="load", :disabled="!is_ready",
style="max-width:100%") style="max-width:100%")
option(v-for="file in gcodeFiles", :value="file") {{file}} option(v-for="file in gcode_files", :value="file") {{file}}
.progress(v-if="toolpath_progress && toolpath_progress < 1", .progress(v-if="toolpath_progress && toolpath_progress < 1",
title="Simulating GCode to check for errors, calculate ETA and " + title="Simulating GCode to check for errors, calculate ETA and " +