naming conventions

This commit is contained in:
sanjayk03-dev
2024-03-27 01:55:11 +05:30
parent 48e1fdf0df
commit e7f0c259a2
5 changed files with 40 additions and 42 deletions

View File

@@ -115,8 +115,8 @@ module.exports = new Vue({
ip: "<>", ip: "<>",
wifiName: "not connected", wifiName: "not connected",
macros:[{},{},{},{},{},{},{},{}], macros:[{},{},{},{},{},{},{},{}],
macrosList:[], macros_list:[],
gcodeList:[] non_macros_list:[]
}, },
state: { state: {
messages: [], messages: [],

View File

@@ -204,12 +204,10 @@ module.exports = {
}, },
gcodeFiles: function () { gcodeFiles: function () {
const filesWithNoMacros = this.state.files.filter( const filesWithNoMacros = this.state.files.filter(
item => !this.config.macrosList.some(compareItem => compareItem.file_name == item), item => !this.config.macros_list.some(compareItem => compareItem.file_name == item),
); );
const gcodelist = this.config.gcodeList.map(item => item.file_name); const gcodeList = this.config.non_macros_list.map(item => item.file_name);
console.log(filesWithNoMacros); const unionSet = new Set([...filesWithNoMacros, ...gcodeList]);
console.log(gcodelist);
const unionSet = new Set([...filesWithNoMacros, ...gcodelist]);
const files = [...unionSet].sort(); const files = [...unionSet].sort();
return files; return files;
}, },
@@ -379,9 +377,9 @@ module.exports = {
return; return;
} }
const isAlreadyPresent = this.config.gcodeList.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.gcodeList.push({ file_name: file.name }); this.config.non_macros_list.push({ file_name: file.name });
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
this.$dispatch("update"); this.$dispatch("update");
@@ -422,17 +420,17 @@ module.exports = {
return; return;
} }
// const isAlreadyPresent = this.config.gcodeList.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.gcodeList.push({ file_name: file.name }); this.config.non_macros_list.push({ file_name: file.name });
// try { try {
// await api.put("config/save", this.config); await api.put("config/save", this.config);
// this.$dispatch("update"); this.$dispatch("update");
// } catch (error) { } catch (error) {
// console.error("Restore Failed: ", error); console.error("Restore Failed: ", error);
// alert("Restore failed"); alert("Restore failed");
// } }
// } }
SvelteComponents.showDialog("Upload", { SvelteComponents.showDialog("Upload", {
file, file,
@@ -445,13 +443,13 @@ module.exports = {
}, },
delete_current: function () { delete_current: function () {
if (this.config.macrosList.find(item => item.file_name == this.state.selected) == undefined) { if (this.config.macros_list.find(item => item.file_name == this.state.selected) == undefined) {
if (this.state.selected) { if (this.state.selected) {
this.config.gcodeList = this.config.gcodeList.filter(item => item.file_name != this.state.selected); this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
api.delete(`file/${this.state.selected}`); api.delete(`file/${this.state.selected}`);
} }
} else { } else {
this.config.gcodeList = this.config.gcodeList.filter(item => item.file_name != this.state.selected); this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
} }
this.deleteGCode = false; this.deleteGCode = false;
@@ -463,9 +461,9 @@ module.exports = {
}, },
delete_all_except_macros: async function () { delete_all_except_macros: async function () {
const macrosList = this.config.macrosList.map(item => item.file_name).toString(); const macrosList = this.config.macros_list.map(item => item.file_name).toString();
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`); api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
this.config.gcodeList = []; this.config.non_macros_list = [];
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
this.$dispatch("update"); this.$dispatch("update");

View File

@@ -46,10 +46,10 @@ module.exports = {
macrosLength: function () { macrosLength: function () {
return this.tab > 8; return this.tab > 8;
}, },
macrosGCodeList: function () { macros_gcode_list: function () {
return this.config.macrosList.map(el => el.file_name).sort(); return this.config.macros_list.map(el => el.file_name).sort();
}, },
macrosList: function () { macros_list: function () {
return this.config.macros.map(item => item.name); return this.config.macros.map(item => item.name);
}, },
initial_tab: function () { initial_tab: function () {
@@ -138,9 +138,9 @@ module.exports = {
const gcodeData = { const gcodeData = {
file_name: file.name, file_name: file.name,
}; };
if (!this.config.macrosList.some(item => item.file_name == file.name)) { if (!this.config.macros_list.some(item => item.file_name == file.name)) {
this.fileName = file.name; this.fileName = file.name;
this.config.macrosList.push(gcodeData); this.config.macros_list.push(gcodeData);
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
this.$dispatch("update"); this.$dispatch("update");
@@ -187,8 +187,8 @@ module.exports = {
const gcodeData = { const gcodeData = {
file_name: filename, file_name: filename,
}; };
if (!this.config.macrosList.some(item => item.file_name == filename)) { if (!this.config.macros_list.some(item => item.file_name == filename)) {
this.config.macrosList.push(gcodeData); this.config.macros_list.push(gcodeData);
} }
}, },
saveMacros: async function () { saveMacros: async function () {
@@ -198,7 +198,7 @@ module.exports = {
} }
const macros = [...this.config.macros]; const macros = [...this.config.macros];
macros.splice(this.tab - 1, 1); macros.splice(this.tab - 1, 1);
const macrosList = macros.map(item => item.name); const macros_list = macros.map(item => item.name);
var macrosName = document.getElementById("macros-name").value; var macrosName = document.getElementById("macros-name").value;
var macrosColor = document.getElementById("macros-color").value; var macrosColor = document.getElementById("macros-color").value;
var macrosAlert = this.isChecked; var macrosAlert = this.isChecked;
@@ -208,7 +208,7 @@ module.exports = {
.replace(/#/g, "-") .replace(/#/g, "-")
.replace(/\?/g, "-"); .replace(/\?/g, "-");
if (macrosList.includes(formattedFilename)) { if (macros_list.includes(formattedFilename)) {
this.sameName = true; this.sameName = true;
this.confirmSave = false; this.confirmSave = false;
return; return;
@@ -244,7 +244,7 @@ module.exports = {
api.delete(`file/${filename}`); api.delete(`file/${filename}`);
this.newGcode = ""; this.newGcode = "";
this.config.macros[this.tab - 1].file_name = "default"; this.config.macros[this.tab - 1].file_name = "default";
this.config.macrosList = this.config.macrosList.filter(item => item.file_name !== filename); this.config.macros_list = this.config.macros_list.filter(item => item.file_name !== filename);
} }
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
@@ -257,9 +257,9 @@ module.exports = {
this.deleteGCode = false; this.deleteGCode = false;
}, },
delete_all_macros: async function () { delete_all_macros: async function () {
const macrosList = this.config.macrosList.map(item => item.file_name).toString(); const macros_list = this.config.macros_list.map(item => item.file_name).toString();
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macrosList}`); api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macros_list}`);
this.config.macrosList = []; this.config.macros_list = [];
}, },
clearMacros: async function () { clearMacros: async function () {
if (this.tab == 0 || this.tab > this.config.macros.length) { if (this.tab == 0 || this.tab > this.config.macros.length) {

View File

@@ -76,7 +76,7 @@ script#macros-template(type="text/x-template")
v-model="tab",@change="clearMacros", v-model="tab",@change="clearMacros",
style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px") style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px")
option( selected='' value='0') Select a Macros option( selected='' value='0') Select a Macros
option(v-for="(index,file) in macrosList", :value="index+1") {{file}} option(v-for="(index,file) in macros_list", :value="index+1") {{file}}
.macros-form .macros-form
p.title Macros Name p.title Macros Name
.input-container .input-container
@@ -91,7 +91,7 @@ script#macros-template(type="text/x-template")
v-model="fileName",@change="loadMacrosGcode", :disabled="!is_ready", v-model="fileName",@change="loadMacrosGcode", :disabled="!is_ready",
style="max-width:100%;height:40px;border-radius:5px") style="max-width:100%;height:40px;border-radius:5px")
option( selected='' value='default') Create G-Code option( selected='' value='default') Create G-Code
option(v-for="file in macrosGCodeList", :value="file") {{file}} option(v-for="file in macros_gcode_list", :value="file") {{file}}
button.config-button.button-blue(title="Upload a new GCode program.", @click="open", button.config-button.button-blue(title="Upload a new GCode program.", @click="open",
:disabled="!is_ready") Upload :disabled="!is_ready") Upload

View File

@@ -605,7 +605,7 @@
} }
}, },
"macrosList": { "macros_list": {
"type": "list", "type": "list",
"default": [], "default": [],
"template": { "template": {
@@ -616,7 +616,7 @@
} }
}, },
"gcodeList": { "non_macros_list": {
"type": "list", "type": "list",
"default": [], "default": [],
"template": { "template": {