From 0434feb5fc338493e7aa52ed6cf68f75fa284a88 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 28 Jan 2021 10:42:55 +0200 Subject: [PATCH] fixed varioues parts of the APP after s3 storage migration --- apps/red-ui/src/app/app.module.ts | 4 +-- .../file-download-btn.component.ts | 2 +- .../file-preview-screen.component.ts | 4 +-- .../html-debug-screen.component.ts | 19 ++++++++++-- .../pdf-viewer-screen.component.ts | 11 ++++++- apps/red-ui/src/index.html | 1 - .../src/lib/api/debugController.service.ts | 3 +- .../api/fileManagementController.service.ts | 30 ++++++++++++------- 8 files changed, 53 insertions(+), 21 deletions(-) diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index 682162e1d..10e3ab56e 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -126,7 +126,7 @@ const routes = [ canActivate: [AuthGuard] }, { - path: 'pdf-preview/:fileId', + path: 'pdf-preview/:projectId/:fileId', component: PdfViewerScreenComponent, canActivate: [CompositeRouteGuard], data: { @@ -134,7 +134,7 @@ const routes = [ } }, { - path: 'html-debug/:fileId', + path: 'html-debug/:projectId/:fileId', component: HtmlDebugScreenComponent, canActivate: [CompositeRouteGuard], data: { diff --git a/apps/red-ui/src/app/components/buttons/file-download-btn/file-download-btn.component.ts b/apps/red-ui/src/app/components/buttons/file-download-btn/file-download-btn.component.ts index 3615924b8..13c68145c 100644 --- a/apps/red-ui/src/app/components/buttons/file-download-btn/file-download-btn.component.ts +++ b/apps/red-ui/src/app/components/buttons/file-download-btn/file-download-btn.component.ts @@ -65,7 +65,7 @@ export class FileDownloadBtnComponent { this._changeDetectorRef.detectChanges(); } else { this._fileManagementControllerService - .downloadPreviewFile(this.file.fileId, this.file.projectId, true, this.file.lastProcessed, 'body') + .downloadPreviewFile(this.file.projectId, this.file.fileId, true, this.file.lastProcessed, 'body') .subscribe((data) => saveAs(data, (this.file).filename)); } } diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index 54087f34e..3bdd16884 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -572,11 +572,11 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy { // async openSSRFilePreview() { - window.open(`/pdf-preview/${this.fileId}`, '_blank'); + window.open(`/pdf-preview/${this.projectId}/${this.fileId}`, '_blank'); } async openHTMLDebug() { - window.open(`/html-debug/${this.fileId}`, '_blank'); + window.open(`/html-debug/${this.projectId}/${this.fileId}`, '_blank'); } // diff --git a/apps/red-ui/src/app/screens/html-debug-screen/html-debug-screen.component.ts b/apps/red-ui/src/app/screens/html-debug-screen/html-debug-screen.component.ts index d0235b3b3..418771438 100644 --- a/apps/red-ui/src/app/screens/html-debug-screen/html-debug-screen.component.ts +++ b/apps/red-ui/src/app/screens/html-debug-screen/html-debug-screen.component.ts @@ -13,6 +13,7 @@ import { SingleFileDownloadService } from '../file/service/single-file-download. }) export class HtmlDebugScreenComponent { private _fileId: string; + private _projectId: string; htmlData: any; loading: boolean; @@ -25,13 +26,21 @@ export class HtmlDebugScreenComponent { ) { this._activatedRoute.params.subscribe((params) => { this._fileId = params.fileId; + this._projectId = params.projectId; this._loadDebugHTML(); }); } private _loadDebugHTML() { this.loading = true; - const fileStatus = new FileStatusWrapper({ fileId: this._fileId, lastProcessed: new Date().toISOString() }, null); + const fileStatus = new FileStatusWrapper( + { + projectId: this._projectId, + fileId: this._fileId, + lastProcessed: new Date().toISOString() + }, + null + ); this._fileDownloadService .loadFile(FileType.ANNOTATED, fileStatus) @@ -41,8 +50,12 @@ export class HtmlDebugScreenComponent { }) ) .subscribe((data) => { - this.htmlData = data; - this.loading = false; + const reader = new FileReader(); + reader.onload = () => { + this.htmlData = reader.result; + this.loading = false; + }; + reader.readAsText(data); }); } } diff --git a/apps/red-ui/src/app/screens/pdf-viewer-screen/pdf-viewer-screen.component.ts b/apps/red-ui/src/app/screens/pdf-viewer-screen/pdf-viewer-screen.component.ts index 2c4ac4f55..8f1b88441 100644 --- a/apps/red-ui/src/app/screens/pdf-viewer-screen/pdf-viewer-screen.component.ts +++ b/apps/red-ui/src/app/screens/pdf-viewer-screen/pdf-viewer-screen.component.ts @@ -17,6 +17,7 @@ export class PdfViewerScreenComponent implements OnInit { private _viewer: ElementRef; private _fileId: string; + private _projectId: string; private _fileData: any; constructor( @@ -26,6 +27,7 @@ export class PdfViewerScreenComponent implements OnInit { ) { this._activatedRoute.params.subscribe((params) => { this._fileId = params.fileId; + this._projectId = params.projectId; this._loadFile(); }); } @@ -57,7 +59,14 @@ export class PdfViewerScreenComponent implements OnInit { } private _loadFile() { - const fileStatus = new FileStatusWrapper({ fileId: this._fileId, lastProcessed: new Date().toISOString() }, null); + const fileStatus = new FileStatusWrapper( + { + projectId: this._projectId, + fileId: this._fileId, + lastProcessed: new Date().toISOString() + }, + null + ); this._fileDownloadService.loadFile(FileType.ANNOTATED, fileStatus).subscribe((data) => { this._fileData = data; this._loadDocumentIntoViewer(); diff --git a/apps/red-ui/src/index.html b/apps/red-ui/src/index.html index 2d6f80065..765700dd8 100644 --- a/apps/red-ui/src/index.html +++ b/apps/red-ui/src/index.html @@ -2,7 +2,6 @@ - ... diff --git a/libs/red-ui-http/src/lib/api/debugController.service.ts b/libs/red-ui-http/src/lib/api/debugController.service.ts index becb2fc38..15e0273b0 100644 --- a/libs/red-ui-http/src/lib/api/debugController.service.ts +++ b/libs/red-ui-http/src/lib/api/debugController.service.ts @@ -165,7 +165,8 @@ export class DebugControllerService { formParams = (formParams.append('file', file) as any) || formParams; } - return this.httpClient.request('post', `${this.basePath}/debug/htmlTables`, { + return this.httpClient.request('post', `${this.basePath}/debug/htmlTables`, { + responseType: 'blob', body: convertFormParamsToString ? formParams.toString() : formParams, params: queryParameters, withCredentials: this.configuration.withCredentials, diff --git a/libs/red-ui-http/src/lib/api/fileManagementController.service.ts b/libs/red-ui-http/src/lib/api/fileManagementController.service.ts index 4b1ece554..f32d70a5e 100644 --- a/libs/red-ui-http/src/lib/api/fileManagementController.service.ts +++ b/libs/red-ui-http/src/lib/api/fileManagementController.service.ts @@ -224,10 +224,11 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( + return this.httpClient.request( 'get', `${this.basePath}/download/annotated/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -315,10 +316,11 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( + return this.httpClient.request( 'get', `${this.basePath}/download/flatted/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -406,10 +408,11 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( + return this.httpClient.request( 'get', `${this.basePath}/download/original/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -497,10 +500,11 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( + return this.httpClient.request( 'get', `${this.basePath}/download/preview/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -567,7 +571,8 @@ export class FileManagementControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/download/bulk/preview/${encodeURIComponent(String(projectId))}`, { + return this.httpClient.request('post', `${this.basePath}/download/bulk/preview/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', body: body, params: queryParameters, withCredentials: this.configuration.withCredentials, @@ -655,10 +660,11 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( + return this.httpClient.request( 'get', `${this.basePath}/download/redacted/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -725,7 +731,8 @@ export class FileManagementControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/download/bulk/redacted/${encodeURIComponent(String(projectId))}`, { + return this.httpClient.request('post', `${this.basePath}/download/bulk/redacted/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', body: body, params: queryParameters, withCredentials: this.configuration.withCredentials, @@ -818,7 +825,8 @@ export class FileManagementControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, { + return this.httpClient.request('post', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', body: body, params: queryParameters, withCredentials: this.configuration.withCredentials, @@ -898,7 +906,8 @@ export class FileManagementControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request('get', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, { + return this.httpClient.request('get', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, @@ -982,7 +991,8 @@ export class FileManagementControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/download/bulk/submission/${encodeURIComponent(String(projectId))}`, { + return this.httpClient.request('post', `${this.basePath}/download/bulk/submission/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', body: body, params: queryParameters, withCredentials: this.configuration.withCredentials,