[subtask, mastertask] download fileov

This commit is contained in:
romankko2 committed 2023-06-30 17:47:33 +02:00
1 parent 25321a56b0
commit 412530fb93
7 files changed
+90 -25

No files matched your search

@@ -7,10 +7,12 @@
<Z-remaining-time :hours="mastertask.duration - mastertask.time_worked" />
<Z-spent-time :hours="mastertask.time_worked" :is-exceeded="mastertask.time_worked > mastertask.duration" />
<Z-description :description="mastertask.description" />
<Z-files :files="mastertask.files" />
<Z-files :files="mastertask.files" :download-file="downloadFile" :showDownload="showDownload" />
</template>
<script>
import * as FileSaver from "file-saver"
import ZCreatedBy from '../../_components/read-only/z-created-by.vue'
import ZDeadline from '../../_components/read-only/z-deadline.vue'
import ZDescription from '../../_components/read-only/z-description.vue'
@@ -39,6 +41,25 @@ export default {
type: Object,
required: true
}
},
data() {
return {
showDownload: false
}
},
methods: {
async downloadFile(id) {
this.showDownload = true
try {
const file = await this.$axios.get_auth_data(`v1/mastertasks/${this.mastertask.id}`, { responseType: "arraybuffer" })
FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch (error) {
this.$toast.error(error)
}
this.showDownload = false
},
}
}
</script>