From 6a15e5e041129ffd365088b0c9a9dc0882d97689 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Thu, 12 Nov 2020 22:05:28 +0200 Subject: [PATCH] caches --- .../api-path-interceptor.service.ts | 8 - .../file-preview-screen.component.ts | 3 + .../file/pdf-viewer/pdf-viewer.component.ts | 2 +- .../file/service/file-download.service.ts | 20 +- libs/red-cache/src/lib/caches/cache-utils.ts | 2 +- .../lib/api/fileUploadController.service.ts | 377 +++++------------- 6 files changed, 114 insertions(+), 298 deletions(-) diff --git a/apps/red-ui/src/app/interceptor/api-path-interceptor.service.ts b/apps/red-ui/src/app/interceptor/api-path-interceptor.service.ts index 0530add81..16f2371e2 100644 --- a/apps/red-ui/src/app/interceptor/api-path-interceptor.service.ts +++ b/apps/red-ui/src/app/interceptor/api-path-interceptor.service.ts @@ -9,20 +9,12 @@ export class ApiPathInterceptorService implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { if (!req.url.startsWith('/assets')) { - console.log(this._appConfigService); const updatedRequest = req.clone({ url: this._appConfigService.getConfig(AppConfigKey.API_URL) + req.url }); return next.handle(updatedRequest); } else { - // if (!req.url.startsWith('/assets')) { - // const updatedRequest = req.clone({ - // url: this._appConfigService.getConfig(AppConfigKey.API_URL) + req.url - // }) - // return next.handle(updatedRequest); - // } else { return next.handle(req); } - // } } } 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 040e5f798..8fdbb938d 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 @@ -371,6 +371,9 @@ export class FilePreviewScreenComponent implements OnInit { } private _cleanupAndRedrawManualAnnotations(annotationIdToDraw?: string) { + if (!annotationIdToDraw) { + this._fileDownloadService.loadRedactedView(this.fileData); + } this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => { this.fileData.manualRedactions = manualRedactions; this._rebuildFilters(); diff --git a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts index 1c9038e85..2ccf13878 100644 --- a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts @@ -268,7 +268,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { } private _restoreViewerState() { - console.log('emit'); + console.log('emit viewer ready'); this.viewerReady.emit(this.instance); this._restoreState(this._viewerState, this.instance); } diff --git a/apps/red-ui/src/app/screens/file/service/file-download.service.ts b/apps/red-ui/src/app/screens/file/service/file-download.service.ts index a337213d2..5041a0709 100644 --- a/apps/red-ui/src/app/screens/file/service/file-download.service.ts +++ b/apps/red-ui/src/app/screens/file/service/file-download.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { forkJoin, Observable, of } from 'rxjs'; import { map, tap } from 'rxjs/operators'; import { + FileStatus, FileUploadControllerService, ManualRedactionControllerService, RedactionLogControllerService, @@ -30,7 +31,7 @@ export class FileDownloadService { } public loadActiveFileData(): Observable { - const annotatedObs = this.loadFile('ORIGINAL', this._appStateService.activeFileId); + const annotatedObs = this.loadFile('ORIGINAL', this._appStateService.activeFile); const reactionLogObs = this._redactionLogControllerService.getRedactionLog(this._appStateService.activeFileId); const manualRedactionsObs = this._manualRedactionControllerService.getManualRedaction( this._appStateService.activeProjectId, @@ -40,14 +41,15 @@ export class FileDownloadService { return forkJoin([annotatedObs, reactionLogObs, manualRedactionsObs, viewedPagesObs]).pipe( map((data) => { - const fileData = new FileDataModel(this._appStateService.activeFile, ...data); - // lazy load redacted data - this.loadFile('REDACTED', this._appStateService.activeFileId).subscribe((redactedFileData) => (fileData.redactedFileData = redactedFileData)); - return fileData; + return new FileDataModel(this._appStateService.activeFile, ...data); }) ); } + public loadRedactedView(fileData: FileDataModel) { + this.loadFile('REDACTED', fileData.fileStatus).subscribe((redactedFileData) => (fileData.redactedFileData = redactedFileData)); + } + getViewedPagesForActiveFile() { if (this._permissionsService.canMarkPagesAsViewed()) { return this._viewedPagesControllerService.getViewedPages(this._appStateService.activeProjectId, this._appStateService.activeFileId); @@ -55,13 +57,13 @@ export class FileDownloadService { return of({ pages: [] }); } - loadFile(fileType: FileType | string, fileId: string, saveTo: (fileData) => void = () => null, fetch: () => any = () => null): Observable { + loadFile(fileType: FileType | string, fileStatus: FileStatus, saveTo: (fileData) => void = () => null, fetch: () => any = () => null): Observable { let fileObs$: Observable; switch (fileType) { case FileType.ANNOTATED: fileObs$ = fetch() ? of(fetch()) - : this._fileUploadControllerService.downloadAnnotatedFile(fileId, true, 'body').pipe( + : this._fileUploadControllerService.downloadAnnotatedFile(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe( tap((data) => { saveTo(data); }) @@ -70,7 +72,7 @@ export class FileDownloadService { case FileType.REDACTED: fileObs$ = fetch() ? of(fetch()) - : this._fileUploadControllerService.downloadRedactedFile(fileId, true, 'body').pipe( + : this._fileUploadControllerService.downloadRedactedFile(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe( tap((data) => { saveTo(data); }) @@ -80,7 +82,7 @@ export class FileDownloadService { default: fileObs$ = fetch() ? of(fetch()) - : this._fileUploadControllerService.downloadOriginalFile(fileId, true, 'body').pipe( + : this._fileUploadControllerService.downloadOriginalFile(fileStatus.fileId, true, fileStatus.added, 'body').pipe( tap((data) => { saveTo(data); }) diff --git a/libs/red-cache/src/lib/caches/cache-utils.ts b/libs/red-cache/src/lib/caches/cache-utils.ts index b07212af3..eee34867d 100644 --- a/libs/red-cache/src/lib/caches/cache-utils.ts +++ b/libs/red-cache/src/lib/caches/cache-utils.ts @@ -10,7 +10,7 @@ export const DYNAMIC_CACHES = [ }, { - urls: ['/download/original'], + urls: ['/download'], name: 'files', maxAge: 3600 * 24 * 7, maxSize: 1000, diff --git a/libs/red-ui-http/src/lib/api/fileUploadController.service.ts b/libs/red-ui-http/src/lib/api/fileUploadController.service.ts index fe90c8ed1..b3e992d12 100644 --- a/libs/red-ui-http/src/lib/api/fileUploadController.service.ts +++ b/libs/red-ui-http/src/lib/api/fileUploadController.service.ts @@ -28,11 +28,7 @@ export class FileUploadControllerService { public configuration = new Configuration(); protected basePath = ''; - constructor( - protected httpClient: HttpClient, - @Optional() @Inject(BASE_PATH) basePath: string, - @Optional() configuration: Configuration - ) { + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { if (basePath) { this.basePath = basePath; } @@ -50,61 +46,32 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public deleteFile( - projectId: string, - fileId: string, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public deleteFile(projectId: string, fileId: string, observe?: 'body', reportProgress?: boolean): Observable; - public deleteFile( - projectId: string, - fileId: string, - observe?: 'response', - reportProgress?: boolean - ): Observable>; + public deleteFile(projectId: string, fileId: string, observe?: 'response', reportProgress?: boolean): Observable>; - public deleteFile( - projectId: string, - fileId: string, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public deleteFile(projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable>; - public deleteFile( - projectId: string, - fileId: string, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public deleteFile(projectId: string, fileId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling deleteFile.' - ); + throw new Error('Required parameter projectId was null or undefined when calling deleteFile.'); } if (fileId === null || fileId === undefined) { - throw new Error( - 'Required parameter fileId was null or undefined when calling deleteFile.' - ); + throw new Error('Required parameter fileId was null or undefined when calling deleteFile.'); } let headers = this.defaultHeaders; // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = []; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -114,9 +81,7 @@ export class FileUploadControllerService { return this.httpClient.request( 'delete', - `${this.basePath}/delete/${encodeURIComponent(String(projectId))}/${encodeURIComponent( - String(fileId) - )}`, + `${this.basePath}/delete/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, @@ -134,16 +99,12 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public downloadAnnotatedFile( - fileId: string, - inline?: boolean, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public downloadAnnotatedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable; public downloadAnnotatedFile( fileId: string, inline?: boolean, + indicator?: string, observe?: 'response', reportProgress?: boolean ): Observable>; @@ -151,6 +112,7 @@ export class FileUploadControllerService { public downloadAnnotatedFile( fileId: string, inline?: boolean, + indicator?: string, observe?: 'events', reportProgress?: boolean ): Observable>; @@ -158,13 +120,12 @@ export class FileUploadControllerService { public downloadAnnotatedFile( fileId: string, inline?: boolean, + indicator?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { if (fileId === null || fileId === undefined) { - throw new Error( - 'Required parameter fileId was null or undefined when calling downloadAnnotatedFile.' - ); + throw new Error('Required parameter fileId was null or undefined when calling downloadAnnotatedFile.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -176,18 +137,13 @@ export class FileUploadControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -195,18 +151,14 @@ export class FileUploadControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( - 'get', - `${this.basePath}/download/annotated/${encodeURIComponent(String(fileId))}`, - { - responseType: 'blob', - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - } - ); + return this.httpClient.request('get', `${this.basePath}/download/annotated/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); } /** @@ -217,60 +169,41 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public downloadOriginalFile( - fileId: string, - inline?: boolean, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable; public downloadOriginalFile( fileId: string, inline?: boolean, + indicator?: string, observe?: 'response', reportProgress?: boolean ): Observable>; - public downloadOriginalFile( - fileId: string, - inline?: boolean, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'events', reportProgress?: boolean): Observable>; - public downloadOriginalFile( - fileId: string, - inline?: boolean, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (fileId === null || fileId === undefined) { - throw new Error( - 'Required parameter fileId was null or undefined when calling downloadOriginalFile.' - ); + throw new Error('Required parameter fileId was null or undefined when calling downloadOriginalFile.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } - + if (indicator !== undefined && indicator !== null) { + queryParameters = queryParameters.set('indicator', indicator); + } let headers = this.defaultHeaders; // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -278,18 +211,14 @@ export class FileUploadControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( - 'get', - `${this.basePath}/download/original/${encodeURIComponent(String(fileId))}`, - { - responseType: 'blob', - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - } - ); + return this.httpClient.request('get', `${this.basePath}/download/original/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); } /** @@ -300,60 +229,42 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public downloadRedactedFile( - fileId: string, - inline?: boolean, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable; public downloadRedactedFile( fileId: string, inline?: boolean, + indicator?: string, observe?: 'response', reportProgress?: boolean ): Observable>; - public downloadRedactedFile( - fileId: string, - inline?: boolean, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'events', reportProgress?: boolean): Observable>; - public downloadRedactedFile( - fileId: string, - inline?: boolean, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (fileId === null || fileId === undefined) { - throw new Error( - 'Required parameter fileId was null or undefined when calling downloadRedactedFile.' - ); + throw new Error('Required parameter fileId was null or undefined when calling downloadRedactedFile.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } + if (indicator !== undefined && indicator !== null) { + queryParameters = queryParameters.set('indicator', indicator); + } let headers = this.defaultHeaders; // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -361,18 +272,14 @@ export class FileUploadControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( - 'get', - `${this.basePath}/download/redacted/${encodeURIComponent(String(fileId))}`, - { - responseType: 'blob', - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - } - ); + return this.httpClient.request('get', `${this.basePath}/download/redacted/${encodeURIComponent(String(fileId))}`, { + responseType: 'blob', + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); } /** @@ -383,37 +290,15 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public downloadRedactionReport( - body: FileIds, - inline?: boolean, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; - public downloadRedactionReport( - body: FileIds, - inline?: boolean, - observe?: 'response', - reportProgress?: boolean - ): Observable>; + public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; - public downloadRedactionReport( - body: FileIds, - inline?: boolean, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; - public downloadRedactionReport( - body: FileIds, - inline?: boolean, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public downloadRedactionReport(body: FileIds, inline?: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling downloadRedactionReport.' - ); + throw new Error('Required parameter body was null or undefined when calling downloadRedactionReport.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -425,27 +310,20 @@ export class FileUploadControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = ['application/json']; - const httpContentTypeSelected: - | string - | undefined = this.configuration.selectHeaderContentType(consumes); + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } @@ -469,12 +347,7 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public downloadRedactionReportForProject( - projectId: string, - inline?: boolean, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadRedactionReportForProject( projectId: string, @@ -483,23 +356,11 @@ export class FileUploadControllerService { reportProgress?: boolean ): Observable>; - public downloadRedactionReportForProject( - projectId: string, - inline?: boolean, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; - public downloadRedactionReportForProject( - projectId: string, - inline?: boolean, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling downloadRedactionReportForProject.' - ); + throw new Error('Required parameter projectId was null or undefined when calling downloadRedactionReportForProject.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -511,18 +372,13 @@ export class FileUploadControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -530,18 +386,14 @@ export class FileUploadControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request( - 'get', - `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, - { - responseType: 'blob', - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - } - ); + return this.httpClient.request('get', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, { + responseType: 'blob', + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); } /** @@ -552,61 +404,32 @@ export class FileUploadControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public uploadFileForm( - file: Blob, - projectId: string, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public uploadFileForm(file: Blob, projectId: string, observe?: 'body', reportProgress?: boolean): Observable; - public uploadFileForm( - file: Blob, - projectId: string, - observe?: 'response', - reportProgress?: boolean - ): Observable>; + public uploadFileForm(file: Blob, projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; - public uploadFileForm( - file: Blob, - projectId: string, - observe?: 'events', - reportProgress?: boolean - ): Observable>; + public uploadFileForm(file: Blob, projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; - public uploadFileForm( - file: Blob, - projectId: string, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + public uploadFileForm(file: Blob, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (file === null || file === undefined) { - throw new Error( - 'Required parameter file was null or undefined when calling uploadFile.' - ); + throw new Error('Required parameter file was null or undefined when calling uploadFile.'); } if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling uploadFile.' - ); + throw new Error('Required parameter projectId was null or undefined when calling uploadFile.'); } let headers = this.defaultHeaders; // authentication (RED-OAUTH) required if (this.configuration.accessToken) { - const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( - httpHeaderAccepts - ); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -632,17 +455,13 @@ export class FileUploadControllerService { formParams = (formParams.append('file', file) as any) || formParams; } - return this.httpClient.request( - 'post', - `${this.basePath}/upload/${encodeURIComponent(String(projectId))}`, - { - body: convertFormParamsToString ? formParams.toString() : formParams, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - } - ); + return this.httpClient.request('post', `${this.basePath}/upload/${encodeURIComponent(String(projectId))}`, { + body: convertFormParamsToString ? formParams.toString() : formParams, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); } /**