[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

@@ -8,10 +8,12 @@
<A-task-remaining-time :hours="subtask.duration - subtask.spent_time" />
<A-task-spent-time :hours="subtask.spent_time" :subtask="subtask" />
<A-task-description :description="subtask.description" :mastertask-description="subtask.master_task_description" />
<Z-files :files="subtask.files" />
<Z-files :files="subtask.files" :download-file="downloadFile" :showDownload="showDownload" />
</template>
<script>
import * as FileSaver from "file-saver"
import AMastertaskName from './_components/a-mastertask-name.vue'
import AMastertaskStatus from './_components/a-mastertask-status.vue'
import ATaskTimeblocks from './_components/a-task-timeblocks.vue'
@@ -44,6 +46,26 @@ 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/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
},
}
}
</script>
@@ -262,15 +262,6 @@ export default {
}
},
async downloadFile(id) {
try {
const file = await this.$axios.get_auth_data(`v1/subtasks/${this.subtask.id}`, { responseType: "arraybuffer" })
FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch (error) {
this.$toast.error(error)
}
},
openDeleteTaskModal(subtask) {
this.$events.emit("show-delete-task-modal", { subtask })
},