naming conventions

This commit is contained in:
sanjayk03-dev
2024-03-27 15:12:00 +05:30
parent 4c584e792a
commit 60718891f6
3 changed files with 37 additions and 22 deletions

View File

@@ -463,17 +463,25 @@ module.exports = {
}
},
delete_current: function () {
delete_current: async function () {
if (this.config.macros_list.find(item => item.file_name == this.state.selected) == undefined) {
if (this.state.selected) {
this.config.non_macros_list = this.config.non_macros_list.filter(
item => item.file_name != this.state.selected,
);
//TODO: remove file from the gcode_list
api.delete(`file/${this.state.selected}`);
}
} else {
this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
}
try {
await api.put("config/save", this.config);
this.$dispatch("update");
} catch (error) {
console.error("Restore Failed: ", error);
alert("Restore failed");
}
this.deleteGCode = false;
},
@@ -487,6 +495,7 @@ module.exports = {
const macrosList = this.config.macros_list.map(item => item.file_name).toString();
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
this.config.non_macros_list = [];
this.config.gcode_list = [];
try {
await api.put("config/save", this.config);
this.$dispatch("update");

View File

@@ -191,9 +191,9 @@ module.exports = {
this.config.macros_list.push(gcodeData);
}
},
saveMacros: async function () {
save_macro: async function () {
if (this.tab == 0) {
this.clearMacros();
this.clear_macro();
return;
}
const macros = [...this.config.macros];
@@ -256,12 +256,7 @@ module.exports = {
this.fileName = "default";
this.deleteGCode = false;
},
delete_all_macros: async function () {
const macros_list = this.config.macros_list.map(item => item.file_name).toString();
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macros_list}`);
this.config.macros_list = [];
},
clearMacros: async function () {
clear_macro: async function () {
if (this.tab == 0 || this.tab > this.config.macros.length) {
document.getElementById("macros-name").value = "";
document.getElementById("macros-color").value = "#ffffff";
@@ -279,7 +274,7 @@ module.exports = {
}
this.edited = false;
},
deleteAllMacros: async function () {
delete_all_macros: async function () {
this.config.macros = [
{
name: "Macros 1",
@@ -330,8 +325,10 @@ module.exports = {
alert: true,
},
];
this.delete_all_macros();
this.clearMacros();
const macros_list = this.config.macros_list.map(item => item.file_name).toString();
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macros_list}`);
this.config.macros_list = [];
this.clear_macro();
this.edited = false;
this.confirmReset = false;
try {
@@ -342,7 +339,7 @@ module.exports = {
alert("Restore failed");
}
},
addNewMacros: async function () {
add_new_macro: async function () {
const length = this.config.macros.length;
if (length >= 20) {
this.maxLimitReached = true;
@@ -364,13 +361,13 @@ module.exports = {
alert("Restore failed");
}
},
deleteSelectedMacros: async function () {
delete_selected_macro: async function () {
if (this.tab == 0) {
this.clearMacros();
this.clear_macro();
return;
}
this.config.macros.splice(this.tab - 1, 1);
this.clearMacros();
this.clear_macro();
try {
await api.put("config/save", this.config);
this.$dispatch("update");
@@ -381,4 +378,10 @@ module.exports = {
this.deleteSelected = false;
},
},
print_config: function () {
console.log(this.config);
},
print_state: function () {
console.log(this.state);
},
};