diff --git a/README.md b/README.md index 804989140..ba6bf8bcb 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ To re-generate http rune swagger YOu need swagger-codegen installed `brew install swagger-codegen` ``` -BASE=http://localhost:8080/ -URL="$BASE"v2/api-docs?group=redaction-gateway-v1 +BASE=https://adi-dev.iqser.cloud/ +URL="$BASE"redaction-gateway-v1/v2/api-docs?group=redaction-gateway-v1 mkdir -p /tmp/swagger swagger-codegen generate -i "$URL" -l typescript-angular -o /tmp/swagger cd /tmp/swagger diff --git a/apps/red-ui/src/app/models/file/annotation.permissions.ts b/apps/red-ui/src/app/models/file/annotation.permissions.ts index 149f3dfdc..eee7f8890 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -26,11 +26,11 @@ export class AnnotationPermissions { ); } - static forUser(isManagerAndOwner: boolean, user: UserWrapper, annotation: AnnotationWrapper) { + static forUser(isApprover: boolean, user: UserWrapper, annotation: AnnotationWrapper) { const permissions: AnnotationPermissions = new AnnotationPermissions(); permissions.canUndo = - annotation.isUndoableSuperType && (annotation.userId === user.id || (annotation.userId && isManagerAndOwner && !annotation.isSuggestion)); + annotation.isUndoableSuperType && (annotation.userId === user.id || (annotation.userId && isApprover && !annotation.isSuggestion)); permissions.canForceRedaction = annotation.isSkipped && !permissions.canUndo; @@ -43,10 +43,9 @@ export class AnnotationPermissions { permissions.canRemoveOrSuggestToRemoveFromDictionary = annotation.isRedacted && !annotation.isManualRedaction && annotation.isModifyDictionary && !annotation.force; - permissions.canAcceptSuggestion = isManagerAndOwner && (annotation.isSuggestion || annotation.isDeclinedSuggestion); + permissions.canAcceptSuggestion = isApprover && (annotation.isSuggestion || annotation.isDeclinedSuggestion); permissions.canRejectSuggestion = - isManagerAndOwner && - (annotation.isSuggestion || (annotation.isReadyForAnalysis && !permissions.canUndo && annotation.superType !== 'pending-analysis')); + isApprover && (annotation.isSuggestion || (annotation.isReadyForAnalysis && !permissions.canUndo && annotation.superType !== 'pending-analysis')); return permissions; } diff --git a/apps/red-ui/src/app/modules/projects/components/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/modules/projects/components/annotation-actions/annotation-actions.component.ts index a24e0ca00..840377eb7 100644 --- a/apps/red-ui/src/app/modules/projects/components/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/modules/projects/components/annotation-actions/annotation-actions.component.ts @@ -33,7 +33,7 @@ export class AnnotationActionsComponent implements OnInit { ngOnInit(): void { this.annotationPermissions = AnnotationPermissions.forUser( - this._permissionsService.isManagerAndOwner(), + this._permissionsService.isApprover(), this._permissionsService.currentUser, this.annotation ); diff --git a/apps/red-ui/src/app/modules/projects/components/annotation-remove-actions/annotation-remove-actions.component.ts b/apps/red-ui/src/app/modules/projects/components/annotation-remove-actions/annotation-remove-actions.component.ts index b25872e53..69b8cef19 100644 --- a/apps/red-ui/src/app/modules/projects/components/annotation-remove-actions/annotation-remove-actions.component.ts +++ b/apps/red-ui/src/app/modules/projects/components/annotation-remove-actions/annotation-remove-actions.component.ts @@ -85,7 +85,7 @@ export class AnnotationRemoveActionsComponent { private _annotationsPermissions(keys: string[], expectedValue: boolean): boolean { return this.annotations.reduce((prevValue, annotation) => { const annotationPermissions = AnnotationPermissions.forUser( - this._permissionsService.isManagerAndOwner(), + this._permissionsService.isApprover(), this._permissionsService.currentUser, annotation ); diff --git a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html index 7bcdfe0ea..4d10597f0 100644 --- a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html +++ b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html @@ -32,9 +32,9 @@ diff --git a/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.html b/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.html index d4b864b01..b9a770290 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.html +++ b/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.html @@ -59,7 +59,7 @@
-
+
diff --git a/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.scss b/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.scss index 5ef1a840a..264daedc3 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.scss +++ b/apps/red-ui/src/app/modules/projects/dialogs/assign-owner-dialog/assign-owner-dialog.component.scss @@ -56,7 +56,9 @@ redaction-team-members { } &.selected { - background-color: $green-2; + .actions { + display: flex; + } } &:hover { diff --git a/apps/red-ui/src/app/modules/projects/dialogs/force-redaction-dialog/force-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/projects/dialogs/force-redaction-dialog/force-redaction-dialog.component.ts index 70e9cd5e7..4c88ebead 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/force-redaction-dialog/force-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/projects/dialogs/force-redaction-dialog/force-redaction-dialog.component.ts @@ -50,7 +50,7 @@ export class ForceRedactionDialogComponent implements OnInit { this.legalOptions.sort((a, b) => a.label.localeCompare(b.label)); }); - this.isDocumentAdmin = this._permissionsService.isManagerAndOwner(); + this.isDocumentAdmin = this._permissionsService.isApprover(); this.redactionForm = this._formBuilder.group({ reason: [null, Validators.required], diff --git a/apps/red-ui/src/app/modules/projects/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/projects/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 903d6b503..8eb6522a7 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/projects/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -70,7 +70,7 @@ export class ManualAnnotationDialogComponent implements OnInit { this.legalOptions.sort((a, b) => a.label.localeCompare(b.label)); }); - this.isDocumentAdmin = this._permissionsService.isManagerAndOwner(); + this.isDocumentAdmin = this._permissionsService.isApprover(); this.isFalsePositiveRequest = this.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE'; this.isDictionaryRequest = this.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest; diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html index 1d6d1d2fc..322bd99b5 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html @@ -127,7 +127,7 @@
- +
diff --git a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.html b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.html index af4d7b065..d894bc06f 100644 --- a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.html +++ b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.html @@ -33,7 +33,7 @@
) { annotations.forEach((annotation) => { - const permissions = AnnotationPermissions.forUser(this._permissionsService.isManagerAndOwner(), this._permissionsService.currentUser, annotation); + const permissions = AnnotationPermissions.forUser(this._permissionsService.isApprover(), this._permissionsService.currentUser, annotation); const value = permissions.canMarkTextOnlyAsFalsePositive ? annotation.value : this._getFalsePositiveText(annotation); this._markAsFalsePositive($event, annotation, value, annotationsChanged); @@ -95,7 +95,7 @@ export class AnnotationActionsService { const annotationPermissions = annotations.map((a) => ({ annotation: a, - permissions: AnnotationPermissions.forUser(this._permissionsService.isManagerAndOwner(), this._permissionsService.currentUser, a) + permissions: AnnotationPermissions.forUser(this._permissionsService.isApprover(), this._permissionsService.currentUser, a) })); const canForceRedaction = annotationPermissions.reduce((acc, next) => acc && next.permissions.canForceRedaction, true); 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 a0396676b..df15668e7 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 @@ -33,7 +33,7 @@ export class FileActionService { } async assignProjectReviewerFromOverview(file?: FileStatusWrapper, callback?: Function) { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isOwner()) { this._openAssignReviewerDialog(file, callback); } else { await this.assignToMe(file, callback); diff --git a/apps/red-ui/src/app/modules/projects/services/manual-annotation.service.ts b/apps/red-ui/src/app/modules/projects/services/manual-annotation.service.ts index 30a847f5a..627fb4f52 100644 --- a/apps/red-ui/src/app/modules/projects/services/manual-annotation.service.ts +++ b/apps/red-ui/src/app/modules/projects/services/manual-annotation.service.ts @@ -56,7 +56,7 @@ export class ManualAnnotationService { // /manualRedaction/redaction/add // /manualRedaction/request/add addAnnotation(manualRedactionEntry: AddRedactionRequest) { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isApprover()) { return this._makeRedaction(manualRedactionEntry); } else { return this._makeRedactionRequest(manualRedactionEntry); @@ -67,7 +67,7 @@ export class ManualAnnotationService { // /manualRedaction/redaction/force // /manualRedaction/request/force forceRedaction(request: ForceRedactionRequest) { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isApprover()) { return this._makeForceRedaction(request); } else { return this._makeForceRedactionRequest(request); @@ -108,7 +108,7 @@ export class ManualAnnotationService { // /manualRedaction/decline/remove // /manualRedaction/undo declineOrRemoveRequest(annotationWrapper: AnnotationWrapper) { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isApprover()) { return this._manualRedactionControllerService .declineRequest(this._appStateService.activeProjectId, this._appStateService.activeFileId, annotationWrapper.id) .pipe( @@ -133,7 +133,7 @@ export class ManualAnnotationService { // /manualRedaction/redaction/remove/ // /manualRedaction/request/remove/ removeOrSuggestRemoveAnnotation(annotationWrapper: AnnotationWrapper, removeFromDictionary: boolean = false) { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isApprover()) { // if it was something manual simply decline the existing request if (annotationWrapper.dictionary === 'manual') { return this._manualRedactionControllerService @@ -183,7 +183,7 @@ export class ManualAnnotationService { } getTitle(type: 'DICTIONARY' | 'REDACTION' | 'FALSE_POSITIVE') { - if (this._permissionsService.isManagerAndOwner()) { + if (this._permissionsService.isApprover()) { switch (type) { case 'DICTIONARY': return 'manual-annotation.dialog.header.dictionary'; diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index 432ad4c6c..08cf15df7 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -23,8 +23,8 @@ export class PermissionsService { return this._userService.isManager(user); } - isReviewerOrOwner(fileStatus?: FileStatusWrapper) { - return this.isFileReviewer(fileStatus) || this.isManagerAndOwner(); + isReviewerOrApprover(fileStatus?: FileStatusWrapper) { + return this.isFileReviewer(fileStatus) || this.isApprover(); } projectReanalysisRequired(project?: ProjectWrapper) { @@ -60,7 +60,7 @@ export class PermissionsService { if (!project) { return false; } - return this.isManagerAndOwner(project) && project.files.filter((file) => this.fileRequiresReanalysis(file)).length > 0; + return this.isApprover(project) && project.files.filter((file) => this.fileRequiresReanalysis(file)).length > 0; } canReanalyseFile(fileStatus?: FileStatusWrapper) { @@ -71,7 +71,7 @@ export class PermissionsService { return false; } return ( - (this.fileRequiresReanalysis(fileStatus) && (this.isReviewerOrOwner(fileStatus) || fileStatus.isUnassigned)) || + (this.fileRequiresReanalysis(fileStatus) && (this.isReviewerOrApprover(fileStatus) || fileStatus.isUnassigned)) || (fileStatus.isError && fileStatus.isUnassigned) ); } @@ -87,7 +87,7 @@ export class PermissionsService { } canDeleteFile(fileStatus?: FileStatusWrapper, project?: ProjectWrapper) { - return this.isManagerAndOwner(project) || fileStatus.isUnassigned; + return this.isOwner(project) || fileStatus.isUnassigned; } isApprovedOrUnderApproval(fileStatus?: FileStatusWrapper) { @@ -117,7 +117,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return fileStatus.status === 'UNDER_APPROVAL' && this.isManagerAndOwner(); + return fileStatus.status === 'UNDER_APPROVAL' && this.isApprover(); } isReadyForApproval(fileStatus?: FileStatusWrapper) { @@ -147,10 +147,23 @@ export class PermissionsService { if (!fileStatus) { return false; } - return fileStatus.status === 'UNDER_REVIEW' && this.isReviewerOrOwner(fileStatus); + return fileStatus.status === 'UNDER_REVIEW' && this.isReviewerOrApprover(fileStatus); } - isManagerAndOwner(project?: ProjectWrapper, user?: UserWrapper) { + isOwner(project?: ProjectWrapper, user?: UserWrapper) { + if (!user) { + user = this._userService.user; + } + if (!project) { + project = this._appStateService.activeProject; + } + if (!project) { + return false; + } + return project.ownerId === user.id; + } + + isApprover(project?: ProjectWrapper, user?: UserWrapper) { if (!user) { user = this._userService.user; } @@ -209,7 +222,7 @@ export class PermissionsService { !fileStatus.isError && !fileStatus.isExcluded && !fileStatus.isApprovedOrUnderApproval && - (this.isManagerAndOwner() || !this.isFileReviewer(fileStatus)) + (this.isApprover() || !this.isFileReviewer(fileStatus)) ); } @@ -220,7 +233,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return fileStatus.status === 'APPROVED' && this.isManagerAndOwner(); + return fileStatus.status === 'APPROVED' && this.isApprover(); } canUndoUnderApproval(fileStatus: any) { @@ -240,9 +253,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return ( - (fileStatus.status === 'UNDER_REVIEW' && this.isFileReviewer(fileStatus)) || (fileStatus.status === 'UNDER_APPROVAL' && this.isManagerAndOwner()) - ); + return (fileStatus.status === 'UNDER_REVIEW' && this.isFileReviewer(fileStatus)) || (fileStatus.status === 'UNDER_APPROVAL' && this.isApprover()); } canDownloadRedactedFile(fileStatus: FileStatusWrapper) { @@ -256,7 +267,7 @@ export class PermissionsService { if (!project) { return false; } - return fileStatus.status === 'APPROVED' && this.isManagerAndOwner(project); + return fileStatus.status === 'APPROVED' && this.isApprover(project); } canDeleteProject(project?: ProjectWrapper) { @@ -320,6 +331,6 @@ export class PermissionsService { if (!fileStatus) { return false; } - return this.isFileReviewer(fileStatus) || this.isManagerAndOwner(); + return this.isFileReviewer(fileStatus) || this.isApprover(); } } diff --git a/libs/red-cache/src/lib/caches/cache-api.service.ts b/libs/red-cache/src/lib/caches/cache-api.service.ts index c46571a26..51f893359 100644 --- a/libs/red-cache/src/lib/caches/cache-api.service.ts +++ b/libs/red-cache/src/lib/caches/cache-api.service.ts @@ -18,9 +18,7 @@ export class CacheApiService { for (const dynCache of DYNAMIC_CACHES) { for (const cacheUrl of dynCache.urls) { if (url.indexOf(cacheUrl) >= 0) { - return caches.open(dynCache.name).then((cache) => { - return this._handleFetchResponse(httpResponse, dynCache, cache, url); - }); + return caches.open(dynCache.name).then((cache) => this._handleFetchResponse(httpResponse, dynCache, cache, url)); } } } @@ -73,9 +71,7 @@ export class CacheApiService { removeCache(cacheId: string): Promise { if (this.cachesAvailable) { - return caches.open(APP_LEVEL_CACHE).then((cache) => { - return cache.delete(cacheId); - }); + return caches.open(APP_LEVEL_CACHE).then((cache) => cache.delete(cacheId)); } else { return Promise.resolve(undefined); } @@ -91,9 +87,7 @@ export class CacheApiService { deleteDynamicCacheEntry(cacheName: string, cacheEntry: string): Promise { if (this.cachesAvailable && DYNAMIC_CACHES.some((cache) => cache.name === cacheName)) { - return caches.open(cacheName).then((cache) => { - return cache.delete(cacheEntry); - }); + return caches.open(cacheName).then((cache) => cache.delete(cacheEntry)); } else { return Promise.resolve(undefined); } @@ -101,8 +95,8 @@ export class CacheApiService { getCachedValue(name: string): Promise { if (this.cachesAvailable) { - return caches.open(APP_LEVEL_CACHE).then((cache) => { - return cache.match(name).then((result) => { + return caches.open(APP_LEVEL_CACHE).then((cache) => + cache.match(name).then((result) => { if (result) { const expires = result.headers.get('_expires'); try { @@ -112,8 +106,8 @@ export class CacheApiService { } catch (e) {} } return undefined; - }); - }); + }) + ); } else { return Promise.resolve(undefined); } @@ -187,16 +181,17 @@ export class CacheApiService { } // console.log('[CACHE-API] content type', contentType, response.url); return obs.pipe( - map((body) => { - // console.log('[CACHE-API] BODY', body); - return new HttpResponse({ - body, - status: response.status, - statusText: response.statusText, - url: response.url, - headers: this._toHttpHeaders(response.headers) - }); - }) + map( + (body) => + // console.log('[CACHE-API] BODY', body); + new HttpResponse({ + body, + status: response.status, + statusText: response.statusText, + url: response.url, + headers: this._toHttpHeaders(response.headers) + }) + ) ); } diff --git a/libs/red-cache/src/lib/caches/http-cache-interceptor.ts b/libs/red-cache/src/lib/caches/http-cache-interceptor.ts index 4a37ef023..07779ebf2 100644 --- a/libs/red-cache/src/lib/caches/http-cache-interceptor.ts +++ b/libs/red-cache/src/lib/caches/http-cache-interceptor.ts @@ -6,22 +6,22 @@ import { catchError, tap } from 'rxjs/operators'; @Injectable() export class HttpCacheInterceptor implements HttpInterceptor { - constructor(private cacheApiService: CacheApiService) {} + constructor(private _cacheApiService: CacheApiService) {} intercept(req: HttpRequest, next: HttpHandler): Observable> { // continue if not cachable. - if (!this.cacheApiService.isCachable(req)) { + if (!this._cacheApiService.isCachable(req)) { return next.handle(req); } - return this.cacheApiService.getCachedRequest(req).pipe( - tap((ok) => { + return this._cacheApiService.getCachedRequest(req).pipe( + tap(() => { // console.log('[CACHE-API] got from cache', ok); }), - catchError((cacheError) => { + catchError(() => // console.log("[CACHE-API] Cache fetch error", cacheError, req.url); - return this.sendRequest(req, next); - }) + this.sendRequest(req, next) + ) ); } @@ -35,7 +35,7 @@ export class HttpCacheInterceptor implements HttpInterceptor { tap((event) => { // There may be other events besides the response. if (event instanceof HttpResponse) { - this.cacheApiService.cacheRequest(request, event); + this._cacheApiService.cacheRequest(request, event); } }) ); diff --git a/libs/red-cache/src/lib/caches/id-to-object-cache.register.service.ts b/libs/red-cache/src/lib/caches/id-to-object-cache.register.service.ts index ae3cc19d7..772fcb66e 100644 --- a/libs/red-cache/src/lib/caches/id-to-object-cache.register.service.ts +++ b/libs/red-cache/src/lib/caches/id-to-object-cache.register.service.ts @@ -5,7 +5,7 @@ import { Injectable } from '@angular/core'; providedIn: 'root' }) export class IdToObjectCacheRegisterService { - constructor(private idToObjectListCacheStoreService: IdToObjectListCacheStoreService) {} + constructor(private _idToObjectListCacheStoreService: IdToObjectListCacheStoreService) {} registerCaches() {} } diff --git a/libs/red-cache/src/lib/caches/id-to-object-list-cache-store.service.ts b/libs/red-cache/src/lib/caches/id-to-object-list-cache-store.service.ts index 284c30b96..6f94a2726 100644 --- a/libs/red-cache/src/lib/caches/id-to-object-list-cache-store.service.ts +++ b/libs/red-cache/src/lib/caches/id-to-object-list-cache-store.service.ts @@ -18,30 +18,30 @@ export interface RegisteredCache { providedIn: 'root' }) export class IdToObjectListCacheStoreService { - private cachesList: { [key: string]: RegisteredCache } = {}; + private _cachesList: { [key: string]: RegisteredCache } = {}; - constructor(private cacheApiService: CacheApiService) {} + constructor(private _cacheApiService: CacheApiService) {} - public registerCache( + registerCache( name: string, cacheFunction: (ids: string[], ...params: any) => Observable<{ [key: string]: any }>, - keyConversionFunction: (id: string, ...params: any) => string = (id, params) => id + keyConversionFunction: (id: string, ...params: any) => string = (id) => id ) { - this.cachesList[name] = { + this._cachesList[name] = { name, keyConversionFunction, cacheFunction }; } - public invokeCache(name: string, ids: string[], ...params: any): Observable<{ [key: string]: any }> { + invokeCache(name: string, ids: string[], ...params: any): Observable<{ [key: string]: any }> { const promises = []; - const cache = this.cachesList[name]; + const cache = this._cachesList[name]; ids.map((id) => this._toUrl(name, cache.keyConversionFunction(id, params))).forEach((url) => { - promises.push(this.cacheApiService.getCachedValue(url)); + promises.push(this._cacheApiService.getCachedValue(url)); }); return from(Promise.all(promises)) - .pipe(catchError((error) => of([]))) + .pipe(catchError(() => of([]))) .pipe( mergeMap((resolvedValues: IdToObject[]) => { const partialResult = {}; @@ -52,9 +52,7 @@ export class IdToObjectListCacheStoreService { }); const existingIds = Object.keys(partialResult); - const requestIds = ids.filter((el) => { - return !existingIds.includes(el); - }); + const requestIds = ids.filter((el) => !existingIds.includes(el)); if (requestIds.length > 0) { return cache.cacheFunction(requestIds, params).pipe( @@ -66,7 +64,7 @@ export class IdToObjectListCacheStoreService { object: data[key] }; // cache each new result - this.cacheApiService.cacheValue(this._toUrl(name, cache.keyConversionFunction(key, params)), idToObject); + this._cacheApiService.cacheValue(this._toUrl(name, cache.keyConversionFunction(key, params)), idToObject); } // add existing results to final result for (const existingKey of Object.keys(partialResult)) { @@ -82,10 +80,10 @@ export class IdToObjectListCacheStoreService { ); } - public expireCache(name: string, id: string, ...params: any) { - const cache = this.cachesList[name]; + expireCache(name: string, id: string, ...params: any) { + const cache = this._cachesList[name]; const cacheUrl = this._toUrl(name, cache.keyConversionFunction(id, params)); - this.cacheApiService.removeCache(cacheUrl); + this._cacheApiService.removeCache(cacheUrl); } private _toUrl(cacheName: string, id: string) { diff --git a/libs/red-ui-http/src/lib/api/userPreferenceController.service.ts b/libs/red-ui-http/src/lib/api/userPreferenceController.service.ts index 8458c9778..ce8bad7f3 100644 --- a/libs/red-ui-http/src/lib/api/userPreferenceController.service.ts +++ b/libs/red-ui-http/src/lib/api/userPreferenceController.service.ts @@ -8,7 +8,7 @@ * 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. - */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/member-ordering */ + */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http'; @@ -20,9 +20,9 @@ import { Configuration } from '../configuration'; @Injectable() export class UserPreferenceControllerService { + protected basePath = ''; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); - protected basePath = ''; constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { if (basePath) { @@ -34,6 +34,20 @@ export class UserPreferenceControllerService { } } + /** + * @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; + } + /** * Delete User Preferences by key. * None @@ -42,11 +56,8 @@ export class UserPreferenceControllerService { * @param reportProgress flag to report request and response progress. */ public deletePreferences(key: string, observe?: 'body', reportProgress?: boolean): Observable; - public deletePreferences(key: string, observe?: 'response', reportProgress?: boolean): Observable>; - public deletePreferences(key: string, observe?: 'events', reportProgress?: boolean): Observable>; - public deletePreferences(key: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (key === null || key === undefined) { throw new Error('Required parameter key was null or undefined when calling deletePreferences.'); @@ -67,10 +78,7 @@ export class UserPreferenceControllerService { headers = headers.set('Accept', httpHeaderAcceptSelected); } - // to determine the Content-Type header - const consumes: string[] = []; - - return this.httpClient.request('delete', `${this.basePath}/preferences/${encodeURIComponent(String(key))}`, { + return this.httpClient.request('delete', `${this.basePath}/attributes/${encodeURIComponent(String(key))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, @@ -79,23 +87,15 @@ export class UserPreferenceControllerService { } /** - * Get User Preferences by key. + * Get User Attributes. * None - * @param key key * @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 getPreferences(key: string, observe?: 'body', reportProgress?: boolean): Observable; - - public getPreferences(key: string, observe?: 'response', reportProgress?: boolean): Observable>; - - public getPreferences(key: string, observe?: 'events', reportProgress?: boolean): Observable>; - - public getPreferences(key: string, observe: any = 'body', reportProgress: boolean = false): Observable { - if (key === null || key === undefined) { - throw new Error('Required parameter key was null or undefined when calling getPreferences.'); - } - + public getAllUserAttributes(observe?: 'body', reportProgress?: boolean): Observable<{ [key: string]: Array }>; + public getAllUserAttributes(observe?: 'response', reportProgress?: boolean): Observable }>>; + public getAllUserAttributes(observe?: 'events', reportProgress?: boolean): Observable }>>; + public getAllUserAttributes(observe: any = 'body', reportProgress: boolean = false): Observable { let headers = this.defaultHeaders; // authentication (RED-OAUTH) required @@ -111,10 +111,7 @@ export class UserPreferenceControllerService { headers = headers.set('Accept', httpHeaderAcceptSelected); } - // to determine the Content-Type header - const consumes: string[] = []; - - return this.httpClient.request('get', `${this.basePath}/preferences/${encodeURIComponent(String(key))}`, { + return this.httpClient.request<{ [key: string]: Array }>('get', `${this.basePath}/attributes`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, @@ -123,20 +120,17 @@ export class UserPreferenceControllerService { } /** - * Store User JSON Preferences. + * Store User Attribute by key. * None - * @param body jsonNode + * @param body values * @param key key * @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 savePreferences(body: any, key: string, observe?: 'body', reportProgress?: boolean): Observable; - - public savePreferences(body: any, key: string, observe?: 'response', reportProgress?: boolean): Observable>; - - public savePreferences(body: any, key: string, observe?: 'events', reportProgress?: boolean): Observable>; - - public savePreferences(body: any, key: string, observe: any = 'body', reportProgress: boolean = false): Observable { + public savePreferences(body: Array, key: string, observe?: 'body', reportProgress?: boolean): Observable; + public savePreferences(body: Array, key: string, observe?: 'response', reportProgress?: boolean): Observable>; + public savePreferences(body: Array, key: string, observe?: 'events', reportProgress?: boolean): Observable>; + public savePreferences(body: Array, key: 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 savePreferences.'); } @@ -167,7 +161,7 @@ export class UserPreferenceControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('put', `${this.basePath}/preferences/${encodeURIComponent(String(key))}`, { + return this.httpClient.request('put', `${this.basePath}/attributes/${encodeURIComponent(String(key))}`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, @@ -175,18 +169,4 @@ export class UserPreferenceControllerService { reportProgress: reportProgress }); } - - /** - * @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; - } }