fixed file name bug

This commit is contained in:
sanjayk03-dev
2024-02-22 03:02:36 +05:30
parent 217de6dcf3
commit 8fd0f763be
2 changed files with 11 additions and 4 deletions

View File

@@ -201,18 +201,25 @@ module.exports = {
const macrosList = macros.map(item => item.name); const macrosList = 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;
if (macrosList.includes(macrosName)) { const formattedFilename = macrosName
.replace(/\\/g, "_")
.replace(/\//g, "_")
.replace(/#/g, "-")
.replace(/\?/g, "-");
if (macrosList.includes(formattedFilename)) {
this.sameName = true; this.sameName = true;
this.confirmSave = false; this.confirmSave = false;
return; return;
} }
var file_name = this.fileName == "default" ? macrosName + ".ngc" : this.fileName;
var file_name = this.fileName == "default" ? formattedFilename + ".ngc" : this.fileName;
var file = this.newGcode; var file = this.newGcode;
this.uploadGCode(file_name, file); this.uploadGCode(file_name, file);
this.config.macros[this.tab - 1].name = macrosName; this.config.macros[this.tab - 1].name = formattedFilename;
this.config.macros[this.tab - 1].color = macrosColor; this.config.macros[this.tab - 1].color = macrosColor;
this.config.macros[this.tab - 1].file_name = file_name; this.config.macros[this.tab - 1].file_name = file_name;
this.confirmSave = false; this.confirmSave = false;

View File

@@ -81,7 +81,7 @@ script#macros-template(type="text/x-template")
p.title Macros Name p.title Macros Name
.input-container .input-container
input.input-color(type="color",id="macros-color",value="#ffffff",@change="editedColor") input.input-color(type="color",id="macros-color",value="#ffffff",@change="editedColor")
input.input-name(type="text",minlength='1',maxlength='20',id="macros-name" ,v-model="macrosName",@keypress="editedName") input.input-name(type="text",minlength='1',maxlength='15',id="macros-name" ,v-model="macrosName",@keypress="editedName")
p.title Macros G-Code p.title Macros G-Code
.flex-row-container .flex-row-container
select(id="gcode-select",title="Select previously uploaded GCode programs.",selected select(id="gcode-select",title="Select previously uploaded GCode programs.",selected