diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 6114a8ece..21fe9ce1a 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -101,14 +101,21 @@ export class DialogService { public openAcceptSuggestionModal( $event: MouseEvent, - annotation: AnnotationWrapper + annotation: AnnotationWrapper, + callback?: Function ): MatDialogRef { $event.stopPropagation(); const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); ref.afterClosed().subscribe((result) => { if (result) { - this._manualAnnotationService.acceptSuggestion(annotation).subscribe(() => {}); + this._manualAnnotationService + .acceptSuggestion(annotation) + .subscribe((acceptResult) => { + if (callback) { + callback(acceptResult); + } + }); } }); 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 2cc410668..9f325bddc 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 @@ -256,7 +256,13 @@ export class FilePreviewScreenComponent implements OnInit { public acceptSuggestion($event: MouseEvent, annotation: AnnotationWrapper) { this.ngZone.run(() => { - this._dialogRef = this._dialogService.openAcceptSuggestionModal($event, annotation); + this._dialogRef = this._dialogService.openAcceptSuggestionModal( + $event, + annotation, + () => { + this._cleanupAndRedrawManualAnnotations(); + } + ); }); } diff --git a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts index 4a923f7d7..0f8225381 100644 --- a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts +++ b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts @@ -48,6 +48,7 @@ export class AnnotationWrapper { comments: { [p: string]: Array }, dictionaryData: { [p: string]: TypeValue } ) { + console.log(manualRedactionEntry); const annotationWrapper = new AnnotationWrapper(); annotationWrapper.superType = AnnotationWrapper.getManualRedactionSuperType( manualRedactionEntry, 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 d8b17e6d3..e3762d1b4 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -7,7 +7,8 @@ import { ProjectControllerService, ReanalysisControllerService, StatusControllerService, - TypeValue + TypeValue, + VersionsControllerService } from '@redaction/red-ui-http'; import { NotificationService, NotificationType } from '../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; @@ -28,6 +29,7 @@ export interface AppState { totalDocuments?: number; totalPeople?: number; dictionaryVersion?: number; + ruleVersion?: number; } export class ProjectWrapper { @@ -77,7 +79,8 @@ export class AppStateService { private readonly _reanalysisControllerService: ReanalysisControllerService, private readonly _translateService: TranslateService, private readonly _dictionaryControllerService: DictionaryControllerService, - private readonly _statusControllerService: StatusControllerService + private readonly _statusControllerService: StatusControllerService, + private readonly _versionsControllerService: VersionsControllerService ) { this._appState = { projects: [], @@ -466,9 +469,8 @@ export class AppStateService { } async updateDictionaryVersion() { - this._appState.dictionaryVersion = await this._dictionaryControllerService - .getVersion() - .toPromise(); - // this._appState.dictionaryVersion = 42; + const result = await this._versionsControllerService.getVersions().toPromise(); + this._appState.dictionaryVersion = result.dictionaryVersion; + this._appState.ruleVersion = result.rulesVersion; } } diff --git a/libs/red-ui-http/src/lib/api.module.ts b/libs/red-ui-http/src/lib/api.module.ts index 915cdeaf3..f228c4950 100644 --- a/libs/red-ui-http/src/lib/api.module.ts +++ b/libs/red-ui-http/src/lib/api.module.ts @@ -14,6 +14,7 @@ import { RedactionLogControllerService } from './api/redactionLogController.serv import { RulesControllerService } from './api/rulesController.service'; import { StatusControllerService } from './api/statusController.service'; import { UserControllerService } from './api/userController.service'; +import { VersionsControllerService } from './api/versionsController.service'; @NgModule({ imports: [], @@ -31,7 +32,8 @@ import { UserControllerService } from './api/userController.service'; RedactionLogControllerService, RulesControllerService, UserControllerService, - StatusControllerService + StatusControllerService, + VersionsControllerService ] }) export class ApiModule { diff --git a/libs/red-ui-http/src/lib/api/api.ts b/libs/red-ui-http/src/lib/api/api.ts index f5658b654..e71946884 100644 --- a/libs/red-ui-http/src/lib/api/api.ts +++ b/libs/red-ui-http/src/lib/api/api.ts @@ -1,3 +1,5 @@ +import { VersionsControllerService } from './versionsController.service'; + export * from './debugController.service'; import { DebugControllerService } from './debugController.service'; import { DictionaryControllerService } from './dictionaryController.service'; @@ -34,6 +36,8 @@ export * from './statusController.service'; export * from './userController.service'; +export * from './versionsController.service'; + export const APIS = [ DebugControllerService, DictionaryControllerService, @@ -46,5 +50,6 @@ export const APIS = [ RedactionLogControllerService, RulesControllerService, StatusControllerService, - UserControllerService + UserControllerService, + VersionsControllerService ]; diff --git a/libs/red-ui-http/src/lib/api/dictionaryController.service.ts b/libs/red-ui-http/src/lib/api/dictionaryController.service.ts index 6d28aea25..c13a1c67e 100644 --- a/libs/red-ui-http/src/lib/api/dictionaryController.service.ts +++ b/libs/red-ui-http/src/lib/api/dictionaryController.service.ts @@ -583,50 +583,6 @@ export class DictionaryControllerService { ); } - /** - * Retrieves current dictionary version. - * None - * @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 getVersion(observe?: 'body', reportProgress?: boolean): Observable; - public getVersion( - observe?: 'response', - reportProgress?: boolean - ): Observable>; - public getVersion(observe?: 'events', reportProgress?: boolean): Observable>; - public getVersion(observe: any = 'body', reportProgress: boolean = false): Observable { - 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[] = []; - - return this.httpClient.request('get', `${this.basePath}/version`, { - withCredentials: this.configuration.withCredentials, - headers: headers, - observe: observe, - reportProgress: reportProgress - }); - } - /** * Set system colors for redaction * diff --git a/libs/red-ui-http/src/lib/api/versionsController.service.ts b/libs/red-ui-http/src/lib/api/versionsController.service.ts new file mode 100644 index 000000000..31f9f00a6 --- /dev/null +++ b/libs/red-ui-http/src/lib/api/versionsController.service.ts @@ -0,0 +1,103 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ /* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { VersionsResponse } from '../model/versionsResponse'; + +import { BASE_PATH } from '../variables'; +import { Configuration } from '../configuration'; + +@Injectable() +export class VersionsControllerService { + protected basePath = ''; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + + constructor( + protected httpClient: HttpClient, + @Optional() @Inject(BASE_PATH) basePath: string, + @Optional() configuration: Configuration + ) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + this.basePath = basePath || configuration.basePath || this.basePath; + } + } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (const consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } + + /** + * Retrieves current versions. + * None + * @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 getVersions(observe?: 'body', reportProgress?: boolean): Observable; + public getVersions( + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public getVersions( + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public getVersions(observe: any = 'body', reportProgress: boolean = false): Observable { + 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[] = []; + + return this.httpClient.request('get', `${this.basePath}/version`, { + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } +} diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index 50a168016..d0710cd09 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -31,3 +31,4 @@ export * from './updateTypeValue'; export * from './user'; export * from './userRequest'; export * from './userResponse'; +export * from './versionsResponse'; diff --git a/libs/red-ui-http/src/lib/model/versionsResponse.ts b/libs/red-ui-http/src/lib/model/versionsResponse.ts new file mode 100644 index 000000000..2509569aa --- /dev/null +++ b/libs/red-ui-http/src/lib/model/versionsResponse.ts @@ -0,0 +1,25 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * Object containing a list of values of user. + */ +export interface VersionsResponse { + /** + * The current dictionary version. + */ + dictionaryVersion?: number; + /** + * The current rules version. + */ + rulesVersion?: number; +}