bulk delete endpoint
This commit is contained in:
parent
f9f6b2da03
commit
6c7d8f8d44
@ -48,11 +48,8 @@ export class DialogService {
|
||||
|
||||
ref.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
const promises = fileIds
|
||||
.map((fileId) => this._appStateService.getFileById(projectId, fileId))
|
||||
.map((file) => this._fileManagementControllerService.deleteFile(file.projectId, file.fileId).toPromise());
|
||||
|
||||
Promise.all(promises)
|
||||
const deleteFilesPromise = this._fileManagementControllerService.deleteFiles(fileIds, projectId).toPromise();
|
||||
deleteFilesPromise
|
||||
.then(async () => {
|
||||
await this._appStateService.reloadActiveProjectFiles();
|
||||
if (cb) cb();
|
||||
|
||||
@ -103,6 +103,57 @@ export class FileManagementControllerService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a a list of files for a given projectId
|
||||
* None
|
||||
* @param body fileIds
|
||||
* @param projectId projectId
|
||||
* @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 deleteFiles(body: Array<string>, projectId: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
|
||||
public deleteFiles(body: Array<string>, projectId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
|
||||
public deleteFiles(body: Array<string>, projectId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
|
||||
public deleteFiles(body: Array<string>, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
|
||||
if (body === null || body === undefined) {
|
||||
throw new Error('Required parameter body was null or undefined when calling deleteFiles.');
|
||||
}
|
||||
|
||||
if (projectId === null || projectId === undefined) {
|
||||
throw new Error('Required parameter projectId was null or undefined when calling deleteFiles.');
|
||||
}
|
||||
|
||||
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;
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
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);
|
||||
if (httpContentTypeSelected !== undefined) {
|
||||
headers = headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.request<any>('post', `${this.basePath}/delete/${encodeURIComponent(String(projectId))}`, {
|
||||
body: body,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a downloadable byte stream of the annotated file with the specified fileId
|
||||
* Use the optional \"inline\" request parameter to select, if this downloadAnnotated will be opened in the browser.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user