[subtask, mastertask] dowmload files gif loader fix

This commit is contained in:
romankko2 committed 2023-07-04 17:17:03 +02:00
1 parent 412530fb93
commit f8656396e7
4 files changed
+37 -28

No files matched your search

@@ -54,6 +54,7 @@ import moment from 'moment'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import useVuelidate from '@vuelidate/core'
import { required, numeric, minValue } from '@vuelidate/validators'
import tmUtils from '@/plugins/tm@_utils/tm.utils'
export default {
props: {
@@ -101,12 +102,15 @@ export default {
time: typeof this.form.hours == 'string' ? parseFloat(this.form.hours) : this.form.hours
})
if(subtask.deadline) subtask.deadline = tmUtils.formatDateTimeForBackend(subtask.deadline)
this._update(subtask)
},
async deleteTimesheet({ id }) {
const subtask = JSON.parse(JSON.stringify(this.subtask))
subtask.timesheets = subtask.timesheets.filter(timesheet => timesheet.id != id)
if(subtask.deadline) subtask.deadline = tmUtils.formatDateTimeForBackend(subtask.deadline)
this._update(subtask)
},
@@ -56,15 +56,19 @@ export default {
methods: {
async downloadFile(id) {
this.showDownload = true
try {
const file = await this.$axios.get_auth_data(`v1/subtasks/${this.subtask.id}`, { responseType: "arraybuffer" })
console.log(file)
FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch (error) {
this.$toast.error(error)
}
this.showDownload = false
this.showDownload = true // Show loader
// Iterate over each file in the task
const file = this.subtask.files[id]
const fileName = file.name
fetch(file.path)
.then(response => response.blob())
.then(blob => {
FileSaver.saveAs(blob, fileName)
this.showDownload = false
})
.catch(error => this.$toast.error(error))
},
}
}