From f202fc5755faf52a8ede620bbccb565ae80597c9 Mon Sep 17 00:00:00 2001 From: Patrick Sun Date: Sun, 11 Apr 2021 18:44:57 +1000 Subject: [PATCH] downlod attachment is done. --- src/app/service/upload.attach.service.ts | 6 ++++++ src/app/upload-cards/upload-cards.component.html | 3 ++- src/app/upload-cards/upload-cards.component.ts | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/service/upload.attach.service.ts b/src/app/service/upload.attach.service.ts index 691a014..de4a70c 100644 --- a/src/app/service/upload.attach.service.ts +++ b/src/app/service/upload.attach.service.ts @@ -32,6 +32,12 @@ export class UploadAttachService { const ts = Date.now(); return this.auth.getUrl('upload-as-pdf/' + id + '?date=' + ts); } + + public getUploadAsOriginalUrl(id: number): string { + const ts = Date.now(); + return this.auth.getUrl('upload-original/' + id + '?date=' + ts + '&download=force'); + } + public getUploadAsPdfUrlDefault(): string { const ts = Date.now(); return this.auth.getUrl('upload-as-pdf/default' + '?date=' + ts); diff --git a/src/app/upload-cards/upload-cards.component.html b/src/app/upload-cards/upload-cards.component.html index 622d45a..aa11ecb 100644 --- a/src/app/upload-cards/upload-cards.component.html +++ b/src/app/upload-cards/upload-cards.component.html @@ -11,8 +11,9 @@ - + + diff --git a/src/app/upload-cards/upload-cards.component.ts b/src/app/upload-cards/upload-cards.component.ts index 88f5de3..2817462 100644 --- a/src/app/upload-cards/upload-cards.component.ts +++ b/src/app/upload-cards/upload-cards.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; +import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import {Router} from '@angular/router'; import {ImagePopupDialogComponent} from '../image-popup-dialog/image-popup-dialog.component'; import {AuthService} from '../service/auth.service'; @@ -16,6 +16,7 @@ export class UploadCardsComponent implements OnInit { @Input() uploadId: number; @Input() icon = ''; @ViewChild('imgBox', {static: true}) imgBox: ImagePopupDialogComponent; + @ViewChild('downloadLink', {static: true}) downloadLink: ElementRef; public uploadMeta: UploadMetaModel = new UploadMetaModel({}); public thumbImage = 'https://svr2021.lawipac.com:8080/api/v1/upload-as-thumbnail/31'; @@ -36,11 +37,19 @@ export class UploadCardsComponent implements OnInit { } public onNavigateTo(id: number ): void{ - this.router.navigate(['/upload-details/' + id]); + this.router.navigate(['/upload-details/', id]); } + + public urlForDownload(id: number ): string{ + return this.uas.getUploadAsOriginalUrl(id); + } + public onDownload(id: number ): void{ - this.router.navigate(['/upload-details/' + id]); + const el = this.downloadLink.nativeElement; + el.href = this.urlForDownload(id); + el.click(); } + public onSearch(id: number ): void{ this.popupImage(this.fullImage); // this.popupImage(this.thumbImage);