integrated dictionary version
This commit is contained in:
parent
071d42fe0f
commit
dc8d33a8a7
@ -17,6 +17,12 @@
|
||||
"changeOrigin": true,
|
||||
"logLevel": "debug"
|
||||
},
|
||||
"/version": {
|
||||
"target": "https://timo-redaction-dev.iqser.cloud/",
|
||||
"secure": false,
|
||||
"changeOrigin": true,
|
||||
"logLevel": "debug"
|
||||
},
|
||||
"/redactionLog": {
|
||||
"target": "https://timo-redaction-dev.iqser.cloud/",
|
||||
"secure": false,
|
||||
|
||||
@ -169,7 +169,7 @@
|
||||
{{ fileStatus.filename }}
|
||||
</div>
|
||||
<span
|
||||
*ngIf="fileStatus.newRule"
|
||||
*ngIf="fileNotUpToDateWithDictionary(fileStatus)"
|
||||
class="pill"
|
||||
translate="project-overview.new-rule.label"
|
||||
></span>
|
||||
|
||||
@ -103,7 +103,11 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
|
||||
|
||||
private _displayNewRuleToast() {
|
||||
// @ts-ignore
|
||||
if (!this.appStateService.activeProject.files.filter((file) => file.newRule).length) {
|
||||
if (
|
||||
!this.appStateService.activeProject.files.filter((file) =>
|
||||
this.fileNotUpToDateWithDictionary(file)
|
||||
).length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -337,4 +341,8 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
return filterMatched;
|
||||
}
|
||||
|
||||
fileNotUpToDateWithDictionary(fileStatus: FileStatus) {
|
||||
return fileStatus.dictionaryVersion !== this.appStateService.dictionaryVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ export class AppStateGuard implements CanActivate {
|
||||
await this._userService.loadAllUsersIfNecessary();
|
||||
await this._appStateService.loadAllProjectsIfNecessary();
|
||||
await this._appStateService.loadDictionaryDataIfNecessary();
|
||||
await this._appStateService.updateDictionaryVersion();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ export interface AppState {
|
||||
totalAnalysedPages?: number;
|
||||
totalDocuments?: number;
|
||||
totalPeople?: number;
|
||||
dictionaryVersion?: number;
|
||||
}
|
||||
|
||||
export class ProjectWrapper {
|
||||
@ -65,7 +66,6 @@ export class ProjectWrapper {
|
||||
export class AppStateService {
|
||||
private _appState: AppState;
|
||||
private _dictionaryData: { [key: string]: TypeValue } = null;
|
||||
|
||||
public fileStatusChanged = new EventEmitter<FileStatus>();
|
||||
|
||||
constructor(
|
||||
@ -93,6 +93,14 @@ export class AppStateService {
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
interval(5000)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.updateDictionaryVersion();
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
interval(30000)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
@ -102,6 +110,10 @@ export class AppStateService {
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
get dictionaryVersion() {
|
||||
return this._appState.dictionaryVersion;
|
||||
}
|
||||
|
||||
get isActiveProjectOwner() {
|
||||
return this._appState.activeProject?.project?.ownerId === this._userService.userId;
|
||||
}
|
||||
@ -452,4 +464,9 @@ export class AppStateService {
|
||||
return this._dictionaryData[annotation.dictionary];
|
||||
}
|
||||
}
|
||||
|
||||
async updateDictionaryVersion() {
|
||||
// this._appState.dictionaryVersion = await this._dictionaryControllerService.getVersion().toPromise();
|
||||
this._appState.dictionaryVersion = 42;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,8 +112,8 @@
|
||||
}
|
||||
|
||||
.REPROCESS {
|
||||
stroke: $green-1;
|
||||
background-color: $green-1;
|
||||
stroke: $grey-1;
|
||||
background-color: $grey-1;
|
||||
}
|
||||
|
||||
.ERROR {
|
||||
|
||||
@ -17,6 +17,9 @@ server {
|
||||
location /project {
|
||||
proxy_pass $API_URL;
|
||||
}
|
||||
location /version {
|
||||
proxy_pass $API_URL;
|
||||
}
|
||||
location /color {
|
||||
proxy_pass $API_URL;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -27,9 +27,9 @@ import { Configuration } from '../configuration';
|
||||
|
||||
@Injectable()
|
||||
export class DictionaryControllerService {
|
||||
protected basePath = '';
|
||||
public defaultHeaders = new HttpHeaders();
|
||||
public configuration = new Configuration();
|
||||
protected basePath = '';
|
||||
|
||||
constructor(
|
||||
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.
|
||||
* None
|
||||
@ -59,21 +73,18 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<any>;
|
||||
|
||||
public addEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public addEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public addEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
@ -100,7 +111,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -138,19 +149,16 @@ export class DictionaryControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public addType(body: TypeValue, observe?: 'body', reportProgress?: boolean): Observable<any>;
|
||||
|
||||
public addType(
|
||||
body: TypeValue,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public addType(
|
||||
body: TypeValue,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public addType(
|
||||
body: TypeValue,
|
||||
observe: any = 'body',
|
||||
@ -172,7 +180,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -212,21 +220,18 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<any>;
|
||||
|
||||
public deleteEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public deleteEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public deleteEntry(
|
||||
body: Array<string>,
|
||||
type: string,
|
||||
@ -257,7 +262,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -295,19 +300,16 @@ export class DictionaryControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public deleteType(type: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
|
||||
|
||||
public deleteType(
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public deleteType(
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public deleteType(
|
||||
type: string,
|
||||
observe: any = 'body',
|
||||
@ -331,7 +333,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -366,19 +368,16 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<any>;
|
||||
|
||||
public downloadDictionaryFile(
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public downloadDictionaryFile(
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public downloadDictionaryFile(
|
||||
type: string,
|
||||
observe: any = 'body',
|
||||
@ -402,7 +401,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = ['application/octet-stream'];
|
||||
let httpHeaderAccepts: string[] = ['*/*'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -432,17 +431,14 @@ export class DictionaryControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAllTypes(observe?: 'body', reportProgress?: boolean): Observable<TypeResponse>;
|
||||
|
||||
public getAllTypes(
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<TypeResponse>>;
|
||||
|
||||
public getAllTypes(
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<TypeResponse>>;
|
||||
|
||||
public getAllTypes(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
@ -456,7 +452,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = ['application/json'];
|
||||
let httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -482,14 +478,11 @@ export class DictionaryControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getColors(observe?: 'body', reportProgress?: boolean): Observable<Colors>;
|
||||
|
||||
public getColors(
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<Colors>>;
|
||||
|
||||
public getColors(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Colors>>;
|
||||
|
||||
public getColors(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
@ -503,7 +496,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = ['application/json'];
|
||||
let httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -534,19 +527,16 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<Dictionary>;
|
||||
|
||||
public getDictionaryForType(
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<Dictionary>>;
|
||||
|
||||
public getDictionaryForType(
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<Dictionary>>;
|
||||
|
||||
public getDictionaryForType(
|
||||
type: string,
|
||||
observe: any = 'body',
|
||||
@ -570,7 +560,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = ['application/json'];
|
||||
let httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
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
|
||||
*
|
||||
@ -601,19 +635,16 @@ export class DictionaryControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public setColors(body: Colors, observe?: 'body', reportProgress?: boolean): Observable<any>;
|
||||
|
||||
public setColors(
|
||||
body: Colors,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public setColors(
|
||||
body: Colors,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public setColors(
|
||||
body: Colors,
|
||||
observe: any = 'body',
|
||||
@ -637,7 +668,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -677,21 +708,18 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<any>;
|
||||
|
||||
public updateType(
|
||||
body: UpdateTypeValue,
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public updateType(
|
||||
body: UpdateTypeValue,
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public updateType(
|
||||
body: UpdateTypeValue,
|
||||
type: string,
|
||||
@ -722,7 +750,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -766,21 +794,18 @@ export class DictionaryControllerService {
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<any>;
|
||||
|
||||
public uploadDictionaryFileForm(
|
||||
file: Blob,
|
||||
type: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<any>>;
|
||||
|
||||
public uploadDictionaryFileForm(
|
||||
file: Blob,
|
||||
type: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<any>>;
|
||||
|
||||
public uploadDictionaryFileForm(
|
||||
file: Blob,
|
||||
type: string,
|
||||
@ -811,7 +836,7 @@ export class DictionaryControllerService {
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [];
|
||||
let httpHeaderAccepts: string[] = [];
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(
|
||||
httpHeaderAccepts
|
||||
);
|
||||
@ -826,7 +851,7 @@ export class DictionaryControllerService {
|
||||
|
||||
let formParams: { append(param: string, value: any): void };
|
||||
let useForm = false;
|
||||
const convertFormParamsToString = false;
|
||||
let convertFormParamsToString = false;
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user