updated API to match gateway
This commit is contained in:
parent
5db6dd9534
commit
d51813d6a8
@ -65,7 +65,7 @@ export class FileDownloadBtnComponent {
|
||||
this._changeDetectorRef.detectChanges();
|
||||
} else {
|
||||
this._fileManagementControllerService
|
||||
.downloadPreviewFile(this.file.fileId, true, this.file.lastProcessed, 'body')
|
||||
.downloadPreviewFile(this.file.fileId, this.file.projectId, true, this.file.lastProcessed, 'body')
|
||||
.subscribe((data) => saveAs(data, (<FileStatusWrapper>this.file).filename));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import {
|
||||
FileManagementControllerService,
|
||||
FileStatus,
|
||||
ManualRedactionControllerService,
|
||||
RedactionLogControllerService,
|
||||
ViewedPagesControllerService
|
||||
@ -12,6 +11,7 @@ import { FileType } from '../model/file-type';
|
||||
import { FileDataModel } from '../model/file-data.model';
|
||||
import { AppStateService } from '../../../state/app-state.service';
|
||||
import { PermissionsService } from '../../../common/service/permissions.service';
|
||||
import { FileStatusWrapper } from '../model/file-status.wrapper';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -57,45 +57,58 @@ export class SingleFileDownloadService {
|
||||
return of({ pages: [] });
|
||||
}
|
||||
|
||||
loadFile(fileType: FileType | string, fileStatus: FileStatus, saveTo: (fileData) => void = () => null, fetch: () => any = () => null): Observable<any> {
|
||||
loadFile(
|
||||
fileType: FileType | string,
|
||||
fileStatus: FileStatusWrapper,
|
||||
saveTo: (fileData) => void = () => null,
|
||||
fetch: () => any = () => null
|
||||
): Observable<any> {
|
||||
let fileObs$: Observable<any>;
|
||||
switch (fileType) {
|
||||
case FileType.ANNOTATED:
|
||||
fileObs$ = fetch()
|
||||
? of(fetch())
|
||||
: this._fileManagementControllerService.downloadAnnotatedFile(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
: this._fileManagementControllerService
|
||||
.downloadAnnotatedFile(fileStatus.projectId, fileStatus.fileId, true, fileStatus.lastProcessed, 'body')
|
||||
.pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
break;
|
||||
case FileType.REDACTED:
|
||||
fileObs$ = fetch()
|
||||
? of(fetch())
|
||||
: this._fileManagementControllerService.downloadRedactedFile(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
: this._fileManagementControllerService
|
||||
.downloadRedactedFile(fileStatus.projectId, fileStatus.fileId, true, fileStatus.lastProcessed, 'body')
|
||||
.pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
break;
|
||||
case FileType.FLAT_REDACTED:
|
||||
fileObs$ = fetch()
|
||||
? of(fetch())
|
||||
: this._fileManagementControllerService.downloadFlatRedacted(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
: this._fileManagementControllerService
|
||||
.downloadFlatRedacted(fileStatus.projectId, fileStatus.fileId, true, fileStatus.lastProcessed, 'body')
|
||||
.pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
break;
|
||||
case FileType.ORIGINAL:
|
||||
default:
|
||||
fileObs$ = fetch()
|
||||
? of(fetch())
|
||||
: this._fileManagementControllerService.downloadOriginalFile(fileStatus.fileId, true, fileStatus.lastUploaded, 'body').pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
: this._fileManagementControllerService
|
||||
.downloadOriginalFile(fileStatus.projectId, fileStatus.fileId, true, fileStatus.lastUploaded, 'body')
|
||||
.pipe(
|
||||
tap((data) => {
|
||||
saveTo(data);
|
||||
})
|
||||
);
|
||||
break;
|
||||
}
|
||||
return fileObs$;
|
||||
|
||||
@ -450,7 +450,7 @@ export class AppStateService {
|
||||
if (!file) {
|
||||
file = this.activeFile;
|
||||
}
|
||||
this._fileManagementControllerService.downloadRedactionReport({ fileIds: [file.fileId] }, true, template, 'body').subscribe((data) => {
|
||||
this._fileManagementControllerService.downloadRedactionReport({ fileIds: [file.fileId] }, file.projectId, true, template, 'body').subscribe((data) => {
|
||||
saveAs(data, 'redaction-report-' + file.filename + '.docx');
|
||||
});
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -124,7 +124,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -215,7 +215,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -306,7 +306,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -397,7 +397,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -488,7 +488,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -554,7 +554,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -646,7 +646,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -712,7 +712,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -805,7 +805,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -889,7 +889,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -969,7 +969,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -1024,7 +1024,7 @@ export class FileManagementControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
@ -1037,7 +1037,7 @@ export class FileManagementControllerService {
|
||||
|
||||
let formParams: { append(param: string, value: any): void };
|
||||
let useForm = false;
|
||||
let convertFormParamsToString = false;
|
||||
const convertFormParamsToString = false;
|
||||
// use FormData to transmit files using content-type "multipart/form-data"
|
||||
// see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
|
||||
useForm = canConsumeForm;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user