diff --git a/public/app/percona/pmm-dump/PMMDump.service.ts b/public/app/percona/pmm-dump/PMMDump.service.ts index 6e5b681f0ed4..df337fdbc606 100644 --- a/public/app/percona/pmm-dump/PMMDump.service.ts +++ b/public/app/percona/pmm-dump/PMMDump.service.ts @@ -1,4 +1,4 @@ -import { CancelToken, AxiosResponse } from 'axios'; +import { CancelToken } from 'axios'; import { PmmDump, ExportDatasetProps } from 'app/percona/shared/core/reducers/pmmDump/pmmDump.types'; import { api } from 'app/percona/shared/helpers/api'; @@ -38,22 +38,20 @@ export const PMMDumpService = { async delete(dumpIds: string[]) { await api.post(`${BASE_URL}/Delete`, { dump_ids: dumpIds }); }, - async dowload(dumpIds: string[]) { - for (const dumpId of dumpIds) { - api.get, DeleteDump>(`/dump/${dumpId}.tar.gz`).then((response: AxiosResponse) => { - const blob = new Blob([response.data], { type: 'application/gzip' }); - const url = window.URL.createObjectURL(blob); + dowload(dumpIds: string[], index = 0) { + if (index < dumpIds.length) { + const dumpId = dumpIds[index]; + const link = document.createElement('a'); + link.setAttribute('href', `${window.location.origin}/dump/${dumpId}.tar.gz`); + link.setAttribute('download', `${dumpId}.tar.gz`); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); - const a = document.createElement('a'); - a.style.display = 'none'; - a.href = url; - a.download = `${dumpId}.tar.gz`; - - document.body.appendChild(a); - a.click(); - window.URL.revokeObjectURL(url); - document.body.removeChild(a); - }); + // Add a delay (1000ms) before the next download + setTimeout(() => { + PMMDumpService.dowload(dumpIds, index + 1); + }, 1000); } }, async sendToSupport(body: SendToSupportRequestBody) {