From 381f8f2970428a85a5b79c0fd764a1d58413f46e Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 19 May 2021 12:30:53 +0300 Subject: [PATCH] added new exclusion flow, now using backend based file requires analysys flag --- .../app/models/file/file-status.wrapper.ts | 18 +- .../file-actions/file-actions.component.ts | 6 +- .../dossier-dictionary-dialog.component.ts | 2 +- .../projects/services/file-action.service.ts | 5 +- .../src/app/services/permissions.service.ts | 26 +- apps/red-ui/src/app/state/app-state.guard.ts | 1 - .../red-ui/src/app/state/app-state.service.ts | 76 +-- .../lib/api/reanalysisController.service.ts | 467 ++++++++++++------ libs/red-ui-http/src/lib/model/fileStatus.ts | 48 +- 9 files changed, 383 insertions(+), 266 deletions(-) diff --git a/apps/red-ui/src/app/models/file/file-status.wrapper.ts b/apps/red-ui/src/app/models/file/file-status.wrapper.ts index b023abfd0..61a746819 100644 --- a/apps/red-ui/src/app/models/file/file-status.wrapper.ts +++ b/apps/red-ui/src/app/models/file/file-status.wrapper.ts @@ -29,10 +29,6 @@ export class FileStatusWrapper { } } - get dossierDictionaryVersion() { - return this.fileStatus.dossierDictionaryVersion; - } - get analysisDuration() { return this.fileStatus.analysisDuration; } @@ -69,10 +65,6 @@ export class FileStatusWrapper { this.fileStatus.currentReviewer = value; } - get dictionaryVersion() { - return this.fileStatus.dictionaryVersion; - } - get fileId() { return this.fileStatus.fileId; } @@ -123,12 +115,8 @@ export class FileStatusWrapper { return this.fileStatus.projectId; } - get rulesVersion() { - return this.fileStatus.rulesVersion; - } - get isExcluded() { - return this.fileStatus.status === 'EXCLUDED'; + return this.fileStatus.excluded; } get status() { @@ -158,6 +146,10 @@ export class FileStatusWrapper { ].includes(this.status); } + get analysisRequired() { + return this.fileStatus.analysisRequired && !this.fileStatus.excluded; + } + get statusSort() { return StatusSorter[this.status]; } diff --git a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.ts index 6284a6d85..a74bc1ad7 100644 --- a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.ts @@ -132,8 +132,12 @@ export class FileActionsComponent implements OnInit { }); } - assignToMe($event: MouseEvent) { + async assignToMe($event: MouseEvent) { $event.stopPropagation(); + + await this._fileActionService.assignToMe(this.fileStatus, () => { + this.reloadProjects('reanalyse'); + }); } reanalyseFile($event: MouseEvent, priority = -1) { diff --git a/apps/red-ui/src/app/modules/projects/dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component.ts b/apps/red-ui/src/app/modules/projects/dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component.ts index 8e45be118..d07667e21 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/modules/projects/dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component.ts @@ -38,7 +38,7 @@ export class DossierDictionaryDialogComponent { this.project.projectId ) .subscribe(async () => { - await this._appStateService.updateProjectDictionaryVersion(this.project); + await this._appStateService.reloadActiveProjectFiles(); this._appStateService.updateProjectDictionary( this.project.ruleSetId, this.project.projectId diff --git a/apps/red-ui/src/app/modules/projects/services/file-action.service.ts b/apps/red-ui/src/app/modules/projects/services/file-action.service.ts index e04b81d34..b0a995631 100644 --- a/apps/red-ui/src/app/modules/projects/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/projects/services/file-action.service.ts @@ -38,9 +38,9 @@ export class FileActionService { fileStatusWrapper = this._appStateService.activeFile; } return this._reanalysisControllerService.toggleAnalysis( - fileStatusWrapper.projectId, fileStatusWrapper.fileId, - fileStatusWrapper.isExcluded + fileStatusWrapper.projectId, + !fileStatusWrapper.isExcluded ); } @@ -161,6 +161,7 @@ export class FileActionService { } private async _assignReviewerToCurrentUser(file?: FileStatus, callback?: Function) { + console.log('assign here'); await this._statusControllerService .setFileReviewer( this._appStateService.activeProjectId, diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index e8673ba68..148eedc49 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -46,14 +46,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return ( - ((fileStatus.status === 'UNASSIGNED' || - fileStatus.status === 'UNDER_REVIEW' || - fileStatus.status === 'UNDER_APPROVAL') && - (!this._appStateService.fileIsUpToDateWithLatestVersions(fileStatus) || - fileStatus.hasUnappliedSuggestions)) || - fileStatus.isError - ); + return fileStatus.analysisRequired; } displayReanalyseBtn(project?: ProjectWrapper) { @@ -119,10 +112,15 @@ export class PermissionsService { this.isProjectMember() && !fileStatus.isProcessing && !fileStatus.isError && - !fileStatus.isExcluded && !fileStatus.isApproved; + if (precondition) { - if ((fileStatus.isUnassigned || fileStatus.isUnderReview) && !this.isApprover()) { + if ( + (fileStatus.isUnassigned || fileStatus.isUnderReview) && + (!this.isApprover() || + !this._appStateService.activeProject.hasMoreThanOneReviewer) && + fileStatus.currentReviewer !== this._userService.userId + ) { return true; } } @@ -141,7 +139,6 @@ export class PermissionsService { this.isProjectMember() && !fileStatus.isProcessing && !fileStatus.isError && - !fileStatus.isExcluded && !fileStatus.isApproved && this.isApprover(); @@ -190,11 +187,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return ( - !fileStatus.hasRequests && - !fileStatus.hasUnappliedSuggestions && - this._appStateService.fileIsUpToDateWithLatestVersions(fileStatus) - ); + return !fileStatus.analysisRequired; } canSetUnderApproval(fileStatus?: FileStatusWrapper) { @@ -364,6 +357,7 @@ export class PermissionsService { return false; } return ( + !fileStatus.isExcluded && !fileStatus.ocrTime && (fileStatus.status === 'UNASSIGNED' || fileStatus.status === 'UNDER_REVIEW' || diff --git a/apps/red-ui/src/app/state/app-state.guard.ts b/apps/red-ui/src/app/state/app-state.guard.ts index e9912a4d0..8336b3ff9 100644 --- a/apps/red-ui/src/app/state/app-state.guard.ts +++ b/apps/red-ui/src/app/state/app-state.guard.ts @@ -22,7 +22,6 @@ export class AppStateGuard implements CanActivate { await this._userService.loadAllUsersIfNecessary(); await this._appStateService.loadRuleSetsIfNecessary(); await this._appStateService.loadDictionaryDataIfNecessary(); - await this._appStateService.updateDictionaryVersion(); } if (this._userService.isUser()) { diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index fab9e8322..3170b4b62 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -10,8 +10,7 @@ import { RuleSetControllerService, RuleSetModel, StatusControllerService, - TypeValue, - VersionsControllerService + TypeValue } from '@redaction/red-ui-http'; import { NotificationService, NotificationType } from '@services/notification.service'; import { TranslateService } from '@ngx-translate/core'; @@ -34,7 +33,6 @@ export interface AppState { totalAnalysedPages?: number; totalDocuments?: number; totalPeople?: number; - versions: { [key: string]: { dictionaryVersion?: number; rulesVersion?: number } }; } @Injectable({ @@ -55,7 +53,6 @@ export class AppStateService { private readonly _dictionaryControllerService: DictionaryControllerService, private readonly _ruleSetControllerService: RuleSetControllerService, private readonly _statusControllerService: StatusControllerService, - private readonly _versionsControllerService: VersionsControllerService, private readonly _fileAttributesService: FileAttributesControllerService ) { this._appState = { @@ -65,8 +62,7 @@ export class AppStateService { activeProjectId: null, activeFileId: null, activeRuleSetId: null, - activeDictionaryType: null, - versions: {} + activeDictionaryType: null }; this._router.events.subscribe((event: Event) => { @@ -190,27 +186,9 @@ export class AppStateService { async reloadActiveProjectFilesIfNecessary() { if (this.activeProject?.hasPendingOrProcessing) { await this.reloadActiveProjectFiles(); - await this.updateDictionaryVersion(); - await this.updateProjectDictionaryVersion(this.activeProject); } } - fileIsUpToDateWithLatestVersions(fileStatus?: FileStatusWrapper) { - if (!fileStatus) { - fileStatus = this.activeFile; - } - - const project = this.getProjectById(fileStatus.projectId); - const ruleSetId = project.ruleSetId; - - return ( - fileStatus.dictionaryVersion === this._dictionaryVersion(ruleSetId) && - fileStatus.rulesVersion === this._rulesVersion(ruleSetId) && - (!project.dictionaryVersion || - fileStatus.dossierDictionaryVersion === project.dictionaryVersion) - ); - } - getDictionaryColor(type?: string, ruleSetId?: string) { if (!ruleSetId && this.activeProject) { ruleSetId = this.activeProject.ruleSetId; @@ -225,19 +203,6 @@ export class AppStateService { return color ? color : this._dictionaryData[ruleSetId]['default'].hexColor; } - getDictionaryLabel(type: string, ruleSetId?: string) { - if (!ruleSetId && this.activeProject) { - ruleSetId = this.activeProject.ruleSetId; - } - if (!ruleSetId) { - ruleSetId = this.ruleSets.length > 0 ? this.ruleSets[0].ruleSetId : undefined; - } - if (!ruleSetId) { - return undefined; - } - return this._dictionaryData[ruleSetId][type]?.label; - } - getRuleSetById(id: string): RuleSetModel { return this.ruleSets.find((rs) => rs.ruleSetId === id); } @@ -284,8 +249,6 @@ export class AppStateService { this._appState.projects = mappedProjects; this._computeStats(); - - this.updateProjectDictionaryVersions(); } } @@ -308,7 +271,6 @@ export class AppStateService { file.fileId === activeFileWrapper.fileId ? activeFileWrapper : file ); - await this.updateDictionaryVersion(); this._computeStats(); if (activeFileWrapper.lastProcessed !== oldProcessedDate) { this.fileReanalysed.emit(activeFileWrapper); @@ -650,40 +612,6 @@ export class AppStateService { this._dictionaryData = obj; } - async updateDictionaryVersion() { - const ruleSetIds = this.ruleSets.map((rs) => rs.ruleSetId); - this._appState.versions = await this._versionsControllerService - .getVersions(ruleSetIds) - .toPromise(); - } - - updateProjectDictionaryVersions() { - for (const project of this.allProjects) { - // don't wait / block - this.updateProjectDictionaryVersion(project); - } - } - - async updateProjectDictionaryVersion(project: ProjectWrapper) { - project.dictionaryVersion = await this._versionsControllerService - .getDossierDictionaryVersion(project.projectId, project.ruleSetId) - .toPromise(); - } - - private _dictionaryVersion(ruleSetId?: string) { - if (!ruleSetId) { - ruleSetId = this.activeProject.ruleSetId; - } - return this._appState.versions[ruleSetId].dictionaryVersion; - } - - private _rulesVersion(ruleSetId?: string) { - if (!ruleSetId) { - ruleSetId = this.activeProject.ruleSetId; - } - return this._appState.versions[ruleSetId].rulesVersion; - } - private _getExistingFiles(projectId: string) { const found = this._appState.projects.find((p) => p.project.projectId === projectId); return found ? found.files : []; diff --git a/libs/red-ui-http/src/lib/api/reanalysisController.service.ts b/libs/red-ui-http/src/lib/api/reanalysisController.service.ts index d17789e15..2e79aa22a 100644 --- a/libs/red-ui-http/src/lib/api/reanalysisController.service.ts +++ b/libs/red-ui-http/src/lib/api/reanalysisController.service.ts @@ -25,7 +25,11 @@ export class ReanalysisControllerService { public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); - 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; } @@ -57,29 +61,57 @@ export class ReanalysisControllerService { * @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 ocrFile(projectId: string, fileId: string, observe?: 'body', reportProgress?: boolean): Observable; - public ocrFile(projectId: string, fileId: string, observe?: 'response', reportProgress?: boolean): Observable>; - public ocrFile(projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable>; - public ocrFile(projectId: string, fileId: string, observe: any = 'body', reportProgress: boolean = false): Observable { + public ocrFile( + projectId: string, + fileId: string, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public ocrFile( + projectId: string, + fileId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public ocrFile( + projectId: string, + fileId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public ocrFile( + 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 ocrFile.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling ocrFile.' + ); } if (fileId === null || fileId === undefined) { - throw new Error('Required parameter fileId was null or undefined when calling ocrFile.'); + throw new Error( + 'Required parameter fileId was null or undefined when calling ocrFile.' + ); } 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); } @@ -89,7 +121,9 @@ export class ReanalysisControllerService { return this.httpClient.request( 'post', - `${this.basePath}/ocr/reanalyze/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, + `${this.basePath}/ocr/reanalyze/${encodeURIComponent( + String(projectId) + )}/${encodeURIComponent(String(fileId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, @@ -107,47 +141,78 @@ export class ReanalysisControllerService { * @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 ocrFiles(body: Array, projectId: string, observe?: 'body', reportProgress?: boolean): Observable; - public ocrFiles(body: Array, projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; - public ocrFiles(body: Array, projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; - public ocrFiles(body: Array, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable { + public ocrFiles( + body: Array, + projectId: string, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public ocrFiles( + body: Array, + projectId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public ocrFiles( + body: Array, + projectId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public ocrFiles( + body: Array, + projectId: string, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling ocrFiles.'); } if (projectId === null || projectId === undefined) { - throw new Error('Required parameter projectId was null or undefined when calling ocrFiles.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling ocrFiles.' + ); } 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); } // 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); } - return this.httpClient.request('post', `${this.basePath}/ocr/reanalyze/${encodeURIComponent(String(projectId))}/bulk`, { - body: body, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); + return this.httpClient.request( + 'post', + `${this.basePath}/ocr/reanalyze/${encodeURIComponent(String(projectId))}/bulk`, + { + body: body, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); } /** @@ -157,25 +222,47 @@ export class ReanalysisControllerService { * @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 ocrProject(projectId: string, observe?: 'body', reportProgress?: boolean): Observable; - public ocrProject(projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; - public ocrProject(projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; - public ocrProject(projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable { + public ocrProject( + projectId: string, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public ocrProject( + projectId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public ocrProject( + projectId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public ocrProject( + projectId: 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 ocrProject.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling ocrProject.' + ); } 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); } @@ -183,12 +270,16 @@ export class ReanalysisControllerService { // to determine the Content-Type header const consumes: string[] = []; - return this.httpClient.request('post', `${this.basePath}/ocr/reanalyze/${encodeURIComponent(String(projectId))}`, { - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); + return this.httpClient.request( + 'post', + `${this.basePath}/ocr/reanalyze/${encodeURIComponent(String(projectId))}`, + { + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); } /** @@ -200,19 +291,47 @@ export class ReanalysisControllerService { * @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 reanalyzeFile(projectId: string, fileId: string, priority?: number, observe?: 'body', reportProgress?: boolean): Observable; + public reanalyzeFile( + projectId: string, + fileId: string, + priority?: number, + observe?: 'body', + reportProgress?: boolean + ): Observable; - public reanalyzeFile(projectId: string, fileId: string, priority?: number, observe?: 'response', reportProgress?: boolean): Observable>; + public reanalyzeFile( + projectId: string, + fileId: string, + priority?: number, + observe?: 'response', + reportProgress?: boolean + ): Observable>; - public reanalyzeFile(projectId: string, fileId: string, priority?: number, observe?: 'events', reportProgress?: boolean): Observable>; + public reanalyzeFile( + projectId: string, + fileId: string, + priority?: number, + observe?: 'events', + reportProgress?: boolean + ): Observable>; - public reanalyzeFile(projectId: string, fileId: string, priority?: number, observe: any = 'body', reportProgress: boolean = false): Observable { + public reanalyzeFile( + projectId: string, + fileId: string, + priority?: number, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { if (projectId === null || projectId === undefined) { - throw new Error('Required parameter projectId was null or undefined when calling reanalyzeFile.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling reanalyzeFile.' + ); } if (fileId === null || fileId === undefined) { - throw new Error('Required parameter fileId was null or undefined when calling reanalyzeFile.'); + throw new Error( + 'Required parameter fileId was null or undefined when calling reanalyzeFile.' + ); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -224,13 +343,17 @@ export class ReanalysisControllerService { // 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); } @@ -240,7 +363,9 @@ export class ReanalysisControllerService { return this.httpClient.request( 'post', - `${this.basePath}/reanalyze/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, + `${this.basePath}/reanalyze/${encodeURIComponent( + String(projectId) + )}/${encodeURIComponent(String(fileId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, @@ -260,7 +385,13 @@ export class ReanalysisControllerService { * @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 reanalyzeFilesForProject(body: Array, projectId: string, force?: boolean, observe?: 'body', reportProgress?: boolean): Observable; + public reanalyzeFilesForProject( + body: Array, + projectId: string, + force?: boolean, + observe?: 'body', + reportProgress?: boolean + ): Observable; public reanalyzeFilesForProject( body: Array, projectId: string, @@ -283,11 +414,15 @@ export class ReanalysisControllerService { reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { - throw new Error('Required parameter body was null or undefined when calling reanalyzeFilesForProject.'); + throw new Error( + 'Required parameter body was null or undefined when calling reanalyzeFilesForProject.' + ); } if (projectId === null || projectId === undefined) { - throw new Error('Required parameter projectId was null or undefined when calling reanalyzeFilesForProject.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling reanalyzeFilesForProject.' + ); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -299,32 +434,41 @@ export class ReanalysisControllerService { // 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); } // 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); } - return this.httpClient.request('post', `${this.basePath}/reanalyze/${encodeURIComponent(String(projectId))}/bulk`, { - body: body, - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); + return this.httpClient.request( + 'post', + `${this.basePath}/reanalyze/${encodeURIComponent(String(projectId))}/bulk`, + { + body: body, + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); } /** @@ -335,12 +479,34 @@ export class ReanalysisControllerService { * @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 reanalyzeProject(projectId: string, force?: boolean, observe?: 'body', reportProgress?: boolean): Observable; - public reanalyzeProject(projectId: string, force?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; - public reanalyzeProject(projectId: string, force?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; - public reanalyzeProject(projectId: string, force?: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { + public reanalyzeProject( + projectId: string, + force?: boolean, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public reanalyzeProject( + projectId: string, + force?: boolean, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public reanalyzeProject( + projectId: string, + force?: boolean, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public reanalyzeProject( + projectId: string, + force?: 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 reanalyzeProject.'); + throw new Error( + 'Required parameter projectId was null or undefined when calling reanalyzeProject.' + ); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); @@ -352,84 +518,17 @@ export class ReanalysisControllerService { // 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); - if (httpHeaderAcceptSelected !== undefined) { - headers = headers.set('Accept', httpHeaderAcceptSelected); - } - - // to determine the Content-Type header - const consumes: string[] = []; - - return this.httpClient.request('post', `${this.basePath}/reanalyze/${encodeURIComponent(String(projectId))}`, { - params: queryParameters, - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); - } - - /** - * Exclude or re-include a file to analysis - * None - * @param projectId projectId - * @param fileId fileId - * @param analysisStatus analysisStatus - * @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 toggleAnalysis(projectId: string, fileId: string, analysisStatus?: boolean, observe?: 'body', reportProgress?: boolean): Observable; - public toggleAnalysis( - projectId: string, - fileId: string, - analysisStatus?: boolean, - observe?: 'response', - reportProgress?: boolean - ): Observable>; - public toggleAnalysis( - projectId: string, - fileId: string, - analysisStatus?: boolean, - observe?: 'events', - reportProgress?: boolean - ): Observable>; - public toggleAnalysis( - projectId: string, - fileId: string, - analysisStatus?: 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 toggleAnalysis.'); - } - - if (fileId === null || fileId === undefined) { - throw new Error('Required parameter fileId was null or undefined when calling toggleAnalysis.'); - } - - let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); - if (analysisStatus !== undefined && analysisStatus !== null) { - queryParameters = queryParameters.set('analysisStatus', analysisStatus); - } - - 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); + const httpHeaderAcceptSelected: string | undefined = + this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -439,7 +538,95 @@ export class ReanalysisControllerService { return this.httpClient.request( 'post', - `${this.basePath}/toggle-analysis/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, + `${this.basePath}/reanalyze/${encodeURIComponent(String(projectId))}`, + { + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Exclude or re-include a file to analysis + * None + * @param fileId fileId + * @param projectId projectId + * @param excluded excluded + * @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 toggleAnalysis( + fileId: string, + projectId: string, + excluded?: boolean, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public toggleAnalysis( + fileId: string, + projectId: string, + excluded?: boolean, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public toggleAnalysis( + fileId: string, + projectId: string, + excluded?: boolean, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public toggleAnalysis( + fileId: string, + projectId: string, + excluded?: boolean, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { + if (fileId === null || fileId === undefined) { + throw new Error( + 'Required parameter fileId was null or undefined when calling toggleAnalysis.' + ); + } + + if (projectId === null || projectId === undefined) { + throw new Error( + 'Required parameter projectId was null or undefined when calling toggleAnalysis.' + ); + } + + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (excluded !== undefined && excluded !== null) { + queryParameters = queryParameters.set('excluded', excluded); + } + + 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); + } + + return this.httpClient.request( + 'post', + `${this.basePath}/toggle-analysis/${encodeURIComponent( + String(projectId) + )}/${encodeURIComponent(String(fileId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, diff --git a/libs/red-ui-http/src/lib/model/fileStatus.ts b/libs/red-ui-http/src/lib/model/fileStatus.ts index 65265ec22..11c4da42d 100644 --- a/libs/red-ui-http/src/lib/model/fileStatus.ts +++ b/libs/red-ui-http/src/lib/model/fileStatus.ts @@ -27,6 +27,10 @@ export interface FileStatus { * Shows how long the last analysis took */ analysisDuration?: number; + /** + * Shows if the file requires reanalysis. + */ + analysisRequired?: boolean; /** * Shows the date of approval, if approved. */ @@ -40,12 +44,13 @@ export interface FileStatus { */ dictionaryVersion?: number; /** - * dossier dictionary version + * Shows which dossier dictionary versions was used during the analysis. */ dossierDictionaryVersion?: number; /** - * File Attributes; + * Shows if the file was excluded from analysis. */ + excluded?: boolean; fileAttributes?: FileAttributes; /** * The ID of the file. @@ -99,6 +104,10 @@ export interface FileStatus { * Shows last date the document was uploaded. */ lastUploaded?: string; + /** + * Shows which legal basis versions was used during the analysis. + */ + legalBasisVersion?: number; /** * The number of times the file has been analyzed. */ @@ -111,6 +120,10 @@ export interface FileStatus { * The ID of the project the file belongs to. */ projectId?: string; + /** + * The ruleSetId for this file. + */ + ruleSetId?: string; /** * Shows which rules versions was used during the analysis. */ @@ -124,30 +137,29 @@ export interface FileStatus { */ uploader?: string; } + export namespace FileStatus { export type StatusEnum = - | 'UNPROCESSED' - | 'REPROCESS' - | 'PROCESSING' - | 'ERROR' - | 'UNASSIGNED' - | 'UNDER_REVIEW' - | 'UNDER_APPROVAL' | 'APPROVED' + | 'ERROR' | 'FULLREPROCESS' | 'OCR_PROCESSING' - | 'EXCLUDED'; + | 'PROCESSING' + | 'REPROCESS' + | 'UNASSIGNED' + | 'UNDER_APPROVAL' + | 'UNDER_REVIEW' + | 'UNPROCESSED'; export const StatusEnum = { - UNPROCESSED: 'UNPROCESSED' as StatusEnum, - REPROCESS: 'REPROCESS' as StatusEnum, - PROCESSING: 'PROCESSING' as StatusEnum, - ERROR: 'ERROR' as StatusEnum, - UNASSIGNED: 'UNASSIGNED' as StatusEnum, - UNDERREVIEW: 'UNDER_REVIEW' as StatusEnum, - UNDERAPPROVAL: 'UNDER_APPROVAL' as StatusEnum, APPROVED: 'APPROVED' as StatusEnum, + ERROR: 'ERROR' as StatusEnum, FULLREPROCESS: 'FULLREPROCESS' as StatusEnum, OCR_PROCESSING: 'OCR_PROCESSING' as StatusEnum, - EXCLUDED: 'EXCLUDED' as StatusEnum + PROCESSING: 'PROCESSING' as StatusEnum, + REPROCESS: 'REPROCESS' as StatusEnum, + UNASSIGNED: 'UNASSIGNED' as StatusEnum, + UNDERAPPROVAL: 'UNDER_APPROVAL' as StatusEnum, + UNDERREVIEW: 'UNDER_REVIEW' as StatusEnum, + UNPROCESSED: 'UNPROCESSED' as StatusEnum }; }