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:
2 files changed
+15
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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}.",
|
||||
|
||||
Reference in new issue
Block a user