From a880121dac9176294f3389f0ee58d4877bbf75c5 Mon Sep 17 00:00:00 2001 From: Vijeinath Tissaveerasingham Date: Thu, 4 Aug 2022 10:16:39 +0200 Subject: [PATCH 1/6] move tool bar to the bottom --- .../resource/representation/document/document.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html index 896ab7ceff..6234de2973 100644 --- a/src/app/workspace/resource/representation/document/document.component.html +++ b/src/app/workspace/resource/representation/document/document.component.html @@ -1,5 +1,5 @@
-
+
Date: Thu, 4 Aug 2022 17:55:00 +0200 Subject: [PATCH 2/6] mat-menu, downloading document with org name --- .../document/document.component.html | 19 +++++--- .../document/document.component.ts | 46 +++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html index 6234de2973..cc62cd5db0 100644 --- a/src/app/workspace/resource/representation/document/document.component.html +++ b/src/app/workspace/resource/representation/document/document.component.html @@ -1,6 +1,19 @@
+ + + + + Download file + + + + add_circle_outline - - - launch -
diff --git a/src/app/workspace/resource/representation/document/document.component.ts b/src/app/workspace/resource/representation/document/document.component.ts index c12782cf29..912e89a76c 100644 --- a/src/app/workspace/resource/representation/document/document.component.ts +++ b/src/app/workspace/resource/representation/document/document.component.ts @@ -19,6 +19,7 @@ import { ErrorHandlerService } from 'src/app/main/services/error-handler.service import { EmitEvent, Events, UpdatedFileEventValue, ValueOperationEventService } from '../../services/value-operation-event.service'; import { FileRepresentation } from '../file-representation'; import { RepresentationService } from '../representation.service'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; @Component({ selector: 'app-document', @@ -35,6 +36,8 @@ export class DocumentComponent implements OnInit, AfterViewInit { @ViewChild(PdfViewerComponent) private _pdfComponent: PdfViewerComponent; + originalFilename: string; + zoomFactor = 1.0; pdfQuery = ''; @@ -43,6 +46,7 @@ export class DocumentComponent implements OnInit, AfterViewInit { constructor( @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, + private readonly _http: HttpClient, private _dialog: MatDialog, private _errorHandler: ErrorHandlerService, private _rs: RepresentationService, @@ -50,6 +54,7 @@ export class DocumentComponent implements OnInit, AfterViewInit { ) { } ngOnInit(): void { + this._getOriginalFilename(); this.failedToLoad = !this._rs.doesFileExist(this.src.fileValue.fileUrl); } @@ -72,6 +77,32 @@ export class DocumentComponent implements OnInit, AfterViewInit { } } + async downloadDocument(url: string) { + try { + const res = await this._http.get(url, { responseType: 'blob' }).toPromise(); + this.downloadFile(res); + } catch (e) { + this._errorHandler.showMessage(e); + } + } + + downloadFile(data) { + const url = window.URL.createObjectURL(data); + const e = document.createElement('a'); + e.href = url; + + // set filename + if (this.originalFilename === undefined) { + e.download = url.substr(url.lastIndexOf('/') + 1); + } else { + e.download = this.originalFilename; + } + + document.body.appendChild(e); + e.click(); + document.body.removeChild(e); + } + openReplaceFileDialog(){ const propId = this.parentResource.properties[Constants.HasDocumentFileValue][0].id; @@ -96,6 +127,21 @@ export class DocumentComponent implements OnInit, AfterViewInit { }); } + private _getOriginalFilename() { + const requestOptions = { + headers: new HttpHeaders({ 'Content-Type': 'application/json' }), + withCredentials: true + }; + + const pathToJson = this.src.fileValue.fileUrl.substring(0, this.src.fileValue.fileUrl.lastIndexOf('/')) + '/knora.json'; + + this._http.get(pathToJson, requestOptions).subscribe( + res => { + this.originalFilename = res['originalFilename']; + } + ); + } + private _replaceFile(file: UpdateFileValue) { const updateRes = new UpdateResource(); updateRes.id = this.parentResource.id; From b28a71deaf67bd2b028430c3c9bfc717a22d6f51 Mon Sep 17 00:00:00 2001 From: Vijeinath Tissaveerasingham Date: Thu, 4 Aug 2022 18:51:22 +0200 Subject: [PATCH 3/6] fullscreen function --- .../document/document.component.html | 5 ++++- .../document/document.component.ts | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html index cc62cd5db0..1df8e3dfa3 100644 --- a/src/app/workspace/resource/representation/document/document.component.html +++ b/src/app/workspace/resource/representation/document/document.component.html @@ -41,12 +41,15 @@ +
-
diff --git a/src/app/workspace/resource/representation/document/document.component.ts b/src/app/workspace/resource/representation/document/document.component.ts index 912e89a76c..1719b343af 100644 --- a/src/app/workspace/resource/representation/document/document.component.ts +++ b/src/app/workspace/resource/representation/document/document.component.ts @@ -20,6 +20,7 @@ import { EmitEvent, Events, UpdatedFileEventValue, ValueOperationEventService } import { FileRepresentation } from '../file-representation'; import { RepresentationService } from '../representation.service'; import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-document', @@ -44,7 +45,10 @@ export class DocumentComponent implements OnInit, AfterViewInit { failedToLoad = false; + elem: any; + constructor( + @Inject(DOCUMENT) private document: any, @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, private readonly _http: HttpClient, private _dialog: MatDialog, @@ -54,6 +58,7 @@ export class DocumentComponent implements OnInit, AfterViewInit { ) { } ngOnInit(): void { + this.elem = document.getElementsByClassName('pdf-viewer')[0]; this._getOriginalFilename(); this.failedToLoad = !this._rs.doesFileExist(this.src.fileValue.fileUrl); } @@ -127,6 +132,21 @@ export class DocumentComponent implements OnInit, AfterViewInit { }); } + openFullscreen() { + if (this.elem.requestFullscreen) { + this.elem.requestFullscreen(); + } else if (this.elem.mozRequestFullScreen) { + // firefox + this.elem.mozRequestFullScreen(); + } else if (this.elem.webkitRequestFullscreen) { + // chrome, safari and opera + this.elem.webkitRequestFullscreen(); + } else if (this.elem.msRequestFullscreen) { + // edge, ie + this.elem.msRequestFullscreen(); + } + } + private _getOriginalFilename() { const requestOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }), From d2fb2cfc07d29c535db9f0ac05e581783c5b786e Mon Sep 17 00:00:00 2001 From: Vijeinath Tissaveerasingham Date: Fri, 5 Aug 2022 10:07:09 +0200 Subject: [PATCH 4/6] style --- .../resource/representation/document/document.component.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html index 1df8e3dfa3..dba3c0243d 100644 --- a/src/app/workspace/resource/representation/document/document.component.html +++ b/src/app/workspace/resource/representation/document/document.component.html @@ -28,7 +28,6 @@ (keyup.enter)="searchQueryChanged(queryInp.value)" /> - @@ -41,6 +40,9 @@ + + + From 6ecce6ee716a0f49a797d4713a4450be818d0e8e Mon Sep 17 00:00:00 2001 From: Vijeinath Tissaveerasingham Date: Fri, 5 Aug 2022 10:54:16 +0200 Subject: [PATCH 5/6] expanding input field --- .../document/document.component.html | 36 +++++++++++-------- .../document/document.component.scss | 3 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html index dba3c0243d..96226bb3ae 100644 --- a/src/app/workspace/resource/representation/document/document.component.html +++ b/src/app/workspace/resource/representation/document/document.component.html @@ -14,20 +14,21 @@ - - - + + + + @@ -41,7 +42,14 @@ add_circle_outline + + + + + + +