fix: add file extension filter to drag&drop fileupload in gcode files

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej committed 2021-12-08 19:35:35 +01:00
1 parent 4037715c8d
commit 9d9e914533
2 files changed
+15 -2

No files matched your search

+14 -2
View File
@@ -727,11 +727,23 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
this.dropzone.opacity = 0
if (e.dataTransfer.files.length) {
const files = [...e.dataTransfer.files].filter((file: File) => {
const format = file.name.slice(file.name.lastIndexOf('.'))
if (!validGcodeExtensions.includes(format)) {
this.$toast.error(this.$t('Files.WrongFileUploaded', { filename: file.name }).toString())
return false
}
return true
})
this.$store.dispatch('socket/addLoading', { name: 'gcodeUpload' })
let successFiles = []
this.uploadSnackbar.number = 0
this.uploadSnackbar.max = e.dataTransfer.files.length
for (const file of e.dataTransfer.files) {
this.uploadSnackbar.max = files.length
for (const file of files) {
this.uploadSnackbar.number++
const result = await this.doUploadFile(file)
successFiles.push(result)
+1
View File
@@ -161,6 +161,7 @@
"PrintTime": "Print Time",
"Slicer": "Slicer",
"Downloading": "Downloading",
"WrongFileUploaded": "Upload was denied for {filename}. Wrong file format!",
"SuccessfullyUploaded": "Upload of {filename} successful!",
"SuccessfullyRenamed": "Successfully renamed {filename}.",
"SuccessfullyMoved": "Successfully moved {filename}.",