From f8656396e77b9309dbedef357718e0d823c3075e Mon Sep 17 00:00:00 2001 From: romankko2 Date: Tue, 4 Jul 2023 17:17:03 +0200 Subject: [PATCH] [subtask, mastertask] dowmload files gif loader fix --- .../_components/read-only/z-files.vue | 17 +++++--------- .../_components/a-mastertask-description.vue | 22 ++++++++++++------- .../_components/a-task-spent-time.vue | 4 ++++ .../task/_components/z-task-readonly-info.vue | 22 +++++++++++-------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/app/src/plugins/tm@modal/_components/read-only/z-files.vue b/app/src/plugins/tm@modal/_components/read-only/z-files.vue index e75f090..e9c9f4c 100644 --- a/app/src/plugins/tm@modal/_components/read-only/z-files.vue +++ b/app/src/plugins/tm@modal/_components/read-only/z-files.vue @@ -4,12 +4,14 @@
-

- {{ file.name }} -

+

{{ file.name }}

+

{{ (file.file_size / (1024 * 1024)).toFixed(2) }} MB

- Loading... +
+ Loading... +

Súbor sa sťahuje, počkajte prosím

+
@@ -34,15 +36,8 @@ export default { } }, - data() { - return { - // downloadingIndex: null - } - }, - methods: { handleDownload(index) { - // this.downloadingIndex = index this.downloadFile(index) } } diff --git a/app/src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue b/app/src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue index 2df18d9..777ab30 100644 --- a/app/src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue +++ b/app/src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue @@ -51,14 +51,20 @@ export default { 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 + this.showDownload = true // Show loader + + const file = this.mastertask.files[id] + + // Iterate over each file in the task + 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)) }, } } diff --git a/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue b/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue index 04a965c..b14830f 100644 --- a/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue +++ b/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue @@ -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) }, diff --git a/app/src/plugins/tm@modal/task/_components/z-task-readonly-info.vue b/app/src/plugins/tm@modal/task/_components/z-task-readonly-info.vue index 317d8bc..3ef482f 100644 --- a/app/src/plugins/tm@modal/task/_components/z-task-readonly-info.vue +++ b/app/src/plugins/tm@modal/task/_components/z-task-readonly-info.vue @@ -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)) }, } }