integrated dictionary version

This commit is contained in:
Timo Bejan 2020-11-02 23:14:00 +02:00
parent 071d42fe0f
commit dc8d33a8a7
9 changed files with 111 additions and 72 deletions

View File

@ -17,6 +17,12 @@
"changeOrigin": true, "changeOrigin": true,
"logLevel": "debug" "logLevel": "debug"
}, },
"/version": {
"target": "https://timo-redaction-dev.iqser.cloud/",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
},
"/redactionLog": { "/redactionLog": {
"target": "https://timo-redaction-dev.iqser.cloud/", "target": "https://timo-redaction-dev.iqser.cloud/",
"secure": false, "secure": false,

View File

@ -169,7 +169,7 @@
{{ fileStatus.filename }} {{ fileStatus.filename }}
</div> </div>
<span <span
*ngIf="fileStatus.newRule" *ngIf="fileNotUpToDateWithDictionary(fileStatus)"
class="pill" class="pill"
translate="project-overview.new-rule.label" translate="project-overview.new-rule.label"
></span> ></span>

View File

@ -103,7 +103,11 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
private _displayNewRuleToast() { private _displayNewRuleToast() {
// @ts-ignore // @ts-ignore
if (!this.appStateService.activeProject.files.filter((file) => file.newRule).length) { if (
!this.appStateService.activeProject.files.filter((file) =>
this.fileNotUpToDateWithDictionary(file)
).length
) {
return; return;
} }
@ -337,4 +341,8 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
} }
return filterMatched; return filterMatched;
} }
fileNotUpToDateWithDictionary(fileStatus: FileStatus) {
return fileStatus.dictionaryVersion !== this.appStateService.dictionaryVersion;
}
} }

View File

@ -16,6 +16,7 @@ export class AppStateGuard implements CanActivate {
await this._userService.loadAllUsersIfNecessary(); await this._userService.loadAllUsersIfNecessary();
await this._appStateService.loadAllProjectsIfNecessary(); await this._appStateService.loadAllProjectsIfNecessary();
await this._appStateService.loadDictionaryDataIfNecessary(); await this._appStateService.loadDictionaryDataIfNecessary();
await this._appStateService.updateDictionaryVersion();
return true; return true;
} }

View File

@ -27,6 +27,7 @@ export interface AppState {
totalAnalysedPages?: number; totalAnalysedPages?: number;
totalDocuments?: number; totalDocuments?: number;
totalPeople?: number; totalPeople?: number;
dictionaryVersion?: number;
} }
export class ProjectWrapper { export class ProjectWrapper {
@ -65,7 +66,6 @@ export class ProjectWrapper {
export class AppStateService { export class AppStateService {
private _appState: AppState; private _appState: AppState;
private _dictionaryData: { [key: string]: TypeValue } = null; private _dictionaryData: { [key: string]: TypeValue } = null;
public fileStatusChanged = new EventEmitter<FileStatus>(); public fileStatusChanged = new EventEmitter<FileStatus>();
constructor( constructor(
@ -93,6 +93,14 @@ export class AppStateService {
) )
.subscribe(); .subscribe();
interval(5000)
.pipe(
tap(() => {
this.updateDictionaryVersion();
})
)
.subscribe();
interval(30000) interval(30000)
.pipe( .pipe(
tap(() => { tap(() => {
@ -102,6 +110,10 @@ export class AppStateService {
.subscribe(); .subscribe();
} }
get dictionaryVersion() {
return this._appState.dictionaryVersion;
}
get isActiveProjectOwner() { get isActiveProjectOwner() {
return this._appState.activeProject?.project?.ownerId === this._userService.userId; return this._appState.activeProject?.project?.ownerId === this._userService.userId;
} }
@ -452,4 +464,9 @@ export class AppStateService {
return this._dictionaryData[annotation.dictionary]; return this._dictionaryData[annotation.dictionary];
} }
} }
async updateDictionaryVersion() {
// this._appState.dictionaryVersion = await this._dictionaryControllerService.getVersion().toPromise();
this._appState.dictionaryVersion = 42;
}
} }

View File

@ -112,8 +112,8 @@
} }
.REPROCESS { .REPROCESS {
stroke: $green-1; stroke: $grey-1;
background-color: $green-1; background-color: $grey-1;
} }
.ERROR { .ERROR {

View File

@ -17,6 +17,9 @@ server {
location /project { location /project {
proxy_pass $API_URL; proxy_pass $API_URL;
} }
location /version {
proxy_pass $API_URL;
}
location /color { location /color {
proxy_pass $API_URL; proxy_pass $API_URL;
} }

View File

@ -1,7 +0,0 @@
# red-ui-http
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test red-ui-http` to execute the unit tests.

View File

@ -27,9 +27,9 @@ import { Configuration } from '../configuration';
@Injectable() @Injectable()
export class DictionaryControllerService { export class DictionaryControllerService {
protected basePath = '';
public defaultHeaders = new HttpHeaders(); public defaultHeaders = new HttpHeaders();
public configuration = new Configuration(); public configuration = new Configuration();
protected basePath = '';
constructor( constructor(
protected httpClient: HttpClient, protected httpClient: HttpClient,
@ -45,6 +45,20 @@ export class DictionaryControllerService {
} }
} }
/**
* @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;
}
/** /**
* Add dictionary entries with entry type. * Add dictionary entries with entry type.
* None * None
@ -59,21 +73,18 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<any>; ): Observable<any>;
public addEntry( public addEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public addEntry( public addEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public addEntry( public addEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
@ -100,7 +111,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -138,19 +149,16 @@ export class DictionaryControllerService {
* @param reportProgress flag to report request and response progress. * @param reportProgress flag to report request and response progress.
*/ */
public addType(body: TypeValue, observe?: 'body', reportProgress?: boolean): Observable<any>; public addType(body: TypeValue, observe?: 'body', reportProgress?: boolean): Observable<any>;
public addType( public addType(
body: TypeValue, body: TypeValue,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public addType( public addType(
body: TypeValue, body: TypeValue,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public addType( public addType(
body: TypeValue, body: TypeValue,
observe: any = 'body', observe: any = 'body',
@ -172,7 +180,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -212,21 +220,18 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<any>; ): Observable<any>;
public deleteEntry( public deleteEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public deleteEntry( public deleteEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public deleteEntry( public deleteEntry(
body: Array<string>, body: Array<string>,
type: string, type: string,
@ -257,7 +262,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -295,19 +300,16 @@ export class DictionaryControllerService {
* @param reportProgress flag to report request and response progress. * @param reportProgress flag to report request and response progress.
*/ */
public deleteType(type: string, observe?: 'body', reportProgress?: boolean): Observable<any>; public deleteType(type: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public deleteType( public deleteType(
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public deleteType( public deleteType(
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public deleteType( public deleteType(
type: string, type: string,
observe: any = 'body', observe: any = 'body',
@ -331,7 +333,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -366,19 +368,16 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<any>; ): Observable<any>;
public downloadDictionaryFile( public downloadDictionaryFile(
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public downloadDictionaryFile( public downloadDictionaryFile(
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public downloadDictionaryFile( public downloadDictionaryFile(
type: string, type: string,
observe: any = 'body', observe: any = 'body',
@ -402,7 +401,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = ['application/octet-stream']; let httpHeaderAccepts: string[] = ['*/*'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -432,17 +431,14 @@ export class DictionaryControllerService {
* @param reportProgress flag to report request and response progress. * @param reportProgress flag to report request and response progress.
*/ */
public getAllTypes(observe?: 'body', reportProgress?: boolean): Observable<TypeResponse>; public getAllTypes(observe?: 'body', reportProgress?: boolean): Observable<TypeResponse>;
public getAllTypes( public getAllTypes(
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<TypeResponse>>; ): Observable<HttpResponse<TypeResponse>>;
public getAllTypes( public getAllTypes(
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<TypeResponse>>; ): Observable<HttpEvent<TypeResponse>>;
public getAllTypes(observe: any = 'body', reportProgress: boolean = false): Observable<any> { public getAllTypes(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
@ -456,7 +452,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json']; let httpHeaderAccepts: string[] = ['application/json'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -482,14 +478,11 @@ export class DictionaryControllerService {
* @param reportProgress flag to report request and response progress. * @param reportProgress flag to report request and response progress.
*/ */
public getColors(observe?: 'body', reportProgress?: boolean): Observable<Colors>; public getColors(observe?: 'body', reportProgress?: boolean): Observable<Colors>;
public getColors( public getColors(
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<Colors>>; ): Observable<HttpResponse<Colors>>;
public getColors(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Colors>>; public getColors(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Colors>>;
public getColors(observe: any = 'body', reportProgress: boolean = false): Observable<any> { public getColors(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
@ -503,7 +496,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json']; let httpHeaderAccepts: string[] = ['application/json'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -534,19 +527,16 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<Dictionary>; ): Observable<Dictionary>;
public getDictionaryForType( public getDictionaryForType(
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<Dictionary>>; ): Observable<HttpResponse<Dictionary>>;
public getDictionaryForType( public getDictionaryForType(
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<Dictionary>>; ): Observable<HttpEvent<Dictionary>>;
public getDictionaryForType( public getDictionaryForType(
type: string, type: string,
observe: any = 'body', observe: any = 'body',
@ -570,7 +560,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json']; let httpHeaderAccepts: string[] = ['application/json'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -593,6 +583,50 @@ 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
let 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 * Set system colors for redaction
* *
@ -601,19 +635,16 @@ export class DictionaryControllerService {
* @param reportProgress flag to report request and response progress. * @param reportProgress flag to report request and response progress.
*/ */
public setColors(body: Colors, observe?: 'body', reportProgress?: boolean): Observable<any>; public setColors(body: Colors, observe?: 'body', reportProgress?: boolean): Observable<any>;
public setColors( public setColors(
body: Colors, body: Colors,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public setColors( public setColors(
body: Colors, body: Colors,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public setColors( public setColors(
body: Colors, body: Colors,
observe: any = 'body', observe: any = 'body',
@ -637,7 +668,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -677,21 +708,18 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<any>; ): Observable<any>;
public updateType( public updateType(
body: UpdateTypeValue, body: UpdateTypeValue,
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public updateType( public updateType(
body: UpdateTypeValue, body: UpdateTypeValue,
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public updateType( public updateType(
body: UpdateTypeValue, body: UpdateTypeValue,
type: string, type: string,
@ -722,7 +750,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -766,21 +794,18 @@ export class DictionaryControllerService {
observe?: 'body', observe?: 'body',
reportProgress?: boolean reportProgress?: boolean
): Observable<any>; ): Observable<any>;
public uploadDictionaryFileForm( public uploadDictionaryFileForm(
file: Blob, file: Blob,
type: string, type: string,
observe?: 'response', observe?: 'response',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpResponse<any>>; ): Observable<HttpResponse<any>>;
public uploadDictionaryFileForm( public uploadDictionaryFileForm(
file: Blob, file: Blob,
type: string, type: string,
observe?: 'events', observe?: 'events',
reportProgress?: boolean reportProgress?: boolean
): Observable<HttpEvent<any>>; ): Observable<HttpEvent<any>>;
public uploadDictionaryFileForm( public uploadDictionaryFileForm(
file: Blob, file: Blob,
type: string, type: string,
@ -811,7 +836,7 @@ export class DictionaryControllerService {
} }
// to determine the Accept header // to determine the Accept header
const httpHeaderAccepts: string[] = []; let httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept( const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
httpHeaderAccepts httpHeaderAccepts
); );
@ -826,7 +851,7 @@ export class DictionaryControllerService {
let formParams: { append(param: string, value: any): void }; let formParams: { append(param: string, value: any): void };
let useForm = false; let useForm = false;
const convertFormParamsToString = false; let convertFormParamsToString = false;
// use FormData to transmit files using content-type "multipart/form-data" // 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 // see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
useForm = canConsumeForm; useForm = canConsumeForm;
@ -852,18 +877,4 @@ export class DictionaryControllerService {
} }
); );
} }
/**
* @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;
}
} }