mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
[bugy & CR]
This commit is contained in:
1 parent
4f7847bc1b
commit
88792943e6
20 files changed
+201
-107
No files matched your search
@@ -4,11 +4,11 @@
|
||||
<W-loadable :content="files" emptyMessage="Žiadne prílohy neboli nahraté">
|
||||
<div v-for="(file, index) in files" :key="file.id" class="d-flex align-center flex-wrap" :class="[index === 0 ? 'ml-0' : 'ml-2']">
|
||||
<v-chip class="mt-2">
|
||||
<p @click="handleDownload(index)" class="cursor-pointer">{{ file.name }}</p>
|
||||
<p @click="downloadFile(file)" class="cursor-pointer">{{ file.name }}</p>
|
||||
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
|
||||
<p>{{ (file.file_size / (1024 * 1024)).toFixed(2) }} MB</p>
|
||||
</v-chip>
|
||||
<div v-if="showDownload" class="d-flex align-center">
|
||||
<div v-if="file.isLoading" class="d-flex align-center">
|
||||
<img class="gif-loader" :src="require('@/plugins/app/_img/spinner.gif')" alt="Loading...">
|
||||
<p class="ml-2">Súbor sa sťahuje, počkajte prosím</p>
|
||||
</div>
|
||||
@@ -18,28 +18,36 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as FileSaver from "file-saver"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
files: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
|
||||
downloadFile: {
|
||||
type: Function,
|
||||
required: true
|
||||
},
|
||||
|
||||
showDownload: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleDownload(index) {
|
||||
this.downloadFile(index)
|
||||
data() {
|
||||
return {
|
||||
isLoading: false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async downloadFile(file) {
|
||||
file.isLoading = true // Show loader
|
||||
|
||||
try {
|
||||
const response = await fetch(file.path)
|
||||
const blob = await response.blob()
|
||||
FileSaver.saveAs(blob, file.name)
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
} finally {
|
||||
file.isLoading = false
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user