preventing to upload file with same name

This commit is contained in:
sanjayk03-dev
2024-03-29 03:05:37 +05:30
parent 074533b17b
commit 72fc59ee04
3 changed files with 17 additions and 3 deletions

View File

@@ -48,6 +48,7 @@ module.exports = {
showGcodeMessage: false,
showNoGcodeMessage: false,
macrosLoading: false,
showFileDuplicate: false,
show_gcodes: false,
};
},
@@ -404,6 +405,10 @@ module.exports = {
}
const file = files[0];
if (this.state.files.includes(file.name)) {
this.showFileDuplicate = true;
return;
}
const extension = file.name.split(".").pop();
switch (extension.toLowerCase()) {
case "nc":
@@ -506,6 +511,10 @@ module.exports = {
for (let file of files) {
console.log(file.name);
if (this.state.files.includes(file.name)) {
this.showFileDuplicate = true;
return;
}
const gcode = await file.text();
const extension = file.name.split(".").pop();
switch (extension.toLowerCase()) {

View File

@@ -72,9 +72,6 @@ module.exports = {
}
const response = await fetch(`/api/file/${file}`, { cache: "no-cache" });
if (response.status == 400) {
return;
}
const text = await response.text();
if (text.length > 20e6) {

View File

@@ -270,6 +270,14 @@ script#control-view-template(type="text/x-template")
:disabled="(!is_ready && !is_holding) || !state.selected",
v-if="false", style="height:100px;width:100px;font-weight:normal")
.fa.fa-step-forward
message(:show.sync="showFileDuplicate")
h3(slot="header") G-Code file with the same name already exists
div(slot="body")
p Please rename the file and try again.
div(slot="footer")
button.pure-button(@click="showFileDuplicate=false") OK
button.pure-button(title="Upload a new GCode folder.", @click="open_folder",
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")