preventing to upload file with same name
This commit is contained in:
@@ -48,6 +48,7 @@ module.exports = {
|
|||||||
showGcodeMessage: false,
|
showGcodeMessage: false,
|
||||||
showNoGcodeMessage: false,
|
showNoGcodeMessage: false,
|
||||||
macrosLoading: false,
|
macrosLoading: false,
|
||||||
|
showFileDuplicate: false,
|
||||||
show_gcodes: false,
|
show_gcodes: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -404,6 +405,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
|
if (this.state.files.includes(file.name)) {
|
||||||
|
this.showFileDuplicate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const extension = file.name.split(".").pop();
|
const extension = file.name.split(".").pop();
|
||||||
switch (extension.toLowerCase()) {
|
switch (extension.toLowerCase()) {
|
||||||
case "nc":
|
case "nc":
|
||||||
@@ -506,6 +511,10 @@ module.exports = {
|
|||||||
|
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
console.log(file.name);
|
console.log(file.name);
|
||||||
|
if (this.state.files.includes(file.name)) {
|
||||||
|
this.showFileDuplicate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const gcode = await file.text();
|
const gcode = await file.text();
|
||||||
const extension = file.name.split(".").pop();
|
const extension = file.name.split(".").pop();
|
||||||
switch (extension.toLowerCase()) {
|
switch (extension.toLowerCase()) {
|
||||||
|
|||||||
@@ -72,9 +72,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`/api/file/${file}`, { cache: "no-cache" });
|
const response = await fetch(`/api/file/${file}`, { cache: "no-cache" });
|
||||||
if (response.status == 400) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
||||||
if (text.length > 20e6) {
|
if (text.length > 20e6) {
|
||||||
|
|||||||
@@ -271,6 +271,14 @@ script#control-view-template(type="text/x-template")
|
|||||||
v-if="false", style="height:100px;width:100px;font-weight:normal")
|
v-if="false", style="height:100px;width:100px;font-weight:normal")
|
||||||
.fa.fa-step-forward
|
.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",
|
button.pure-button(title="Upload a new GCode folder.", @click="open_folder",
|
||||||
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
|
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
|
||||||
.fa.fa-folder
|
.fa.fa-folder
|
||||||
|
|||||||
Reference in New Issue
Block a user