preventing to upload file with same name
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user