added new version endpoint

This commit is contained in:
Timo Bejan 2020-11-03 13:33:26 +02:00
parent c40348365c
commit 24bb32edfa
10 changed files with 163 additions and 55 deletions

View File

@ -101,14 +101,21 @@ export class DialogService {
public openAcceptSuggestionModal(
$event: MouseEvent,
annotation: AnnotationWrapper
annotation: AnnotationWrapper,
callback?: Function
): MatDialogRef<ConfirmationDialogComponent> {
$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);
}
});
}
});

View File

@ -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();
}
);
});
}

View File

@ -48,6 +48,7 @@ export class AnnotationWrapper {
comments: { [p: string]: Array<Comment> },
dictionaryData: { [p: string]: TypeValue }
) {
console.log(manualRedactionEntry);
const annotationWrapper = new AnnotationWrapper();
annotationWrapper.superType = AnnotationWrapper.getManualRedactionSuperType(
manualRedactionEntry,

View File

@ -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;
}
}

View File

@ -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 {

View File

@ -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
];

View File

@ -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<number>;
public getVersion(
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<number>>;
public getVersion(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<number>>;
public getVersion(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
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<number>('get', `${this.basePath}/version`, {
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Set system colors for redaction
*

View File

@ -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<VersionsResponse>;
public getVersions(
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<VersionsResponse>>;
public getVersions(
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<VersionsResponse>>;
public getVersions(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
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<VersionsResponse>('get', `${this.basePath}/version`, {
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
}

View File

@ -31,3 +31,4 @@ export * from './updateTypeValue';
export * from './user';
export * from './userRequest';
export * from './userResponse';
export * from './versionsResponse';

View File

@ -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;
}