Browse Source

Add download method

pull/1242/head
Hironsan 4 years ago
parent
commit
7cd927b465
1 changed files with 12 additions and 0 deletions
  1. 12
      frontend/services/application/document.service.ts

12
frontend/services/application/document.service.ts

@ -70,6 +70,18 @@ export class DocumentApplicationService {
return this.repository.bulkDelete(projectId, ids)
}
public async download(
projectId: string, filename: string, format: any, onlyApproved: boolean
): Promise<void> {
const response = await this.repository.exportFile(projectId, format.type, onlyApproved)
const url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', `${filename}.${format.extension}`)
document.body.appendChild(link)
link.click()
}
private toModel(item: DocumentDTO): DocumentItem {
return new DocumentItem(
item.id,

Loading…
Cancel
Save