diff --git a/src/app/permission/app-detail/app-detail.component.html b/src/app/permission/app-detail/app-detail.component.html index e5d7133..3a64508 100644 --- a/src/app/permission/app-detail/app-detail.component.html +++ b/src/app/permission/app-detail/app-detail.component.html @@ -376,13 +376,16 @@ *ngIf="myPermissions.includes('PERMISSION#EDIT')" [id]="'app_detail_permission_table_row_' + row + '_edit_action'" (click)="onDetailPermission($event, rowData)" - [title]="'ACTIONS.EDIT.PERMISSION' | translate" + [title]=" + (rowData.mandatory || rowData.operator ? 'ACTIONS.VIEW' : 'ACTIONS.EDIT') + '.PERMISSION' + | translate + " class="mr-1 my-0 p-1 p-button-rounded font-medium p-button-text p-button p-component p-button-icon-only" > @@ -403,7 +406,7 @@ *ngIf="myPermissions.includes('PERMISSION#DELETE')" [id]="'app_detail_permission_table_row_' + row + '_delete_action'" (click)="onDeletePermission($event, rowData)" - [disabled]="rowData.mandatory" + [disabled]="rowData.mandatory || rowData.operator" [title]="'ACTIONS.DELETE.PERMISSION' | translate" class="my-0 p-1 p-button-rounded font-medium p-button-text p-button p-component p-button-icon-only" > diff --git a/src/app/permission/app-detail/app-detail.component.ts b/src/app/permission/app-detail/app-detail.component.ts index e21ccef..707353c 100644 --- a/src/app/permission/app-detail/app-detail.component.ts +++ b/src/app/permission/app-detail/app-detail.component.ts @@ -16,21 +16,23 @@ import { PermissionPageResult, Permission, Assignment, - RevokeAssignmentRequest, CreateAssignmentRequestParams, GrantRoleAssignmentsRequestParams, - CreateRoleProductAssignmentRequest, - GrantRoleProductAssignmentsRequestParams, - CreateRoleProductsAssignmentRequest, + GrantRoleApplicationAssignmentsRequestParams, GrantRoleProductsAssignmentsRequestParams, + RevokeRoleAssignmentsRequestParams, + RevokeRoleProductsAssignmentsRequestParams, + RevokeRoleApplicationAssignmentsRequestParams, DeleteAssignmentRequestParams, + MfeMsAbstract, Application, ApplicationAPIService, AssignmentAPIService, PermissionAPIService, RoleAPIService, WorkspaceAPIService, - WorkspaceDetails + WorkspaceDetails, + ProductDetails } from 'src/app/shared/generated' import { dropDownSortItemsByLabel, limitText } from 'src/app/shared/utils' @@ -258,18 +260,8 @@ export class AppDetailComponent implements OnInit, OnDestroy { console.error('getDetailsByWorkspaceName() result:', result) } else if (result instanceof Object) { this.currentApp.workspaceDetails = { ...result } - if (this.currentApp.workspaceDetails?.products && this.currentApp.workspaceDetails?.products.length > 0) { - this.currentApp.workspaceDetails?.products.map((product) => { - if (product.mfe) - product.mfe.map((a) => { - this.productApps.push({ appId: a.appId, name: a.appName, productName: product.productName } as App) - }) - if (product.ms) - product.ms.map((a) => { - this.productApps.push({ appId: a.appId, name: a.appName, productName: product.productName } as App) - }) - }) - } + this.currentApp.workspaceDetails?.products?.map((product) => this.fillProductApps(product)) + console.log(this.productApps) this.prepareActionButtons() this.loadRolesAndPermissions() } else { @@ -278,6 +270,14 @@ export class AppDetailComponent implements OnInit, OnDestroy { } }) } + private fillProductApps(product: ProductDetails) { + if (product.mfe) product.mfe.map((app) => this.pushProductApps(product.productName!, app)) + if (product.ms) product.ms.map((app) => this.pushProductApps(product.productName!, app)) + } + private pushProductApps(productName: string, app: MfeMsAbstract) { + if (this.productApps.filter((aa) => aa.appId === app.appId).length === 0) + this.productApps.push({ appId: app.appId, name: app.appName, productName: productName } as App) + } /** * COLUMNS => Roles, ROWS => Permissions @@ -560,18 +560,13 @@ export class AppDetailComponent implements OnInit, OnDestroy { ev.stopPropagation() this.permissionTable?.clear() switch (icon.className) { - case 'pi pi-fw pi-sort-alt': // init - icon.className = 'pi pi-fw pi-sort-amount-down' - this.permissionTable?._value.sort( - field === 'appId' ? this.sortPermissionRowByAppIdDesc : this.sortPermissionRowByProductDesc - ) - break case 'pi pi-fw pi-sort-amount-down': icon.className = 'pi pi-fw pi-sort-amount-up-alt' this.permissionTable?._value.sort( field === 'appId' ? this.sortPermissionRowByAppIdAsc : this.sortPermissionRowByProductAsc ) break + case 'pi pi-fw pi-sort-alt': // init case 'pi pi-fw pi-sort-amount-up-alt': icon.className = 'pi pi-fw pi-sort-amount-down' this.permissionTable?._value.sort( @@ -642,7 +637,6 @@ export class AppDetailComponent implements OnInit, OnDestroy { this.showPermissionDetailDialog = true } public onDetailPermission(ev: MouseEvent, perm: PermissionViewRow): void { - console.log('onDetailPermission') ev.stopPropagation() this.permission = perm this.changeMode = this.permission.mandatory || this.permission.operator ? 'VIEW' : 'EDIT' @@ -708,21 +702,19 @@ export class AppDetailComponent implements OnInit, OnDestroy { } if (this.filterAppValue) { this.assApi - .grantRoleProductAssignments({ + .grantRoleApplicationAssignments({ roleId: role.id, - createRoleProductAssignmentRequest: { + createRoleApplicationAssignmentRequest: { appId: this.filterAppValue, productName: this.getProductNameForApp(this.filterAppValue) - } as CreateRoleProductAssignmentRequest - } as GrantRoleProductAssignmentsRequestParams) + } + } as GrantRoleApplicationAssignmentsRequestParams) .subscribe(response) } else if (this.filterProductValue) { this.assApi .grantRoleProductsAssignments({ roleId: role.id, - createRoleProductsAssignmentRequest: { - productNames: this.prepareProductList() - } as CreateRoleProductsAssignmentRequest + createRoleProductsAssignmentRequest: { productNames: this.prepareProductList() } } as GrantRoleProductsAssignmentsRequestParams) .subscribe(response) } else { @@ -730,23 +722,41 @@ export class AppDetailComponent implements OnInit, OnDestroy { } } + // REVOKE ALL depends on what ALL means: + // 1. Value in App filter => remove all assignments of this app to the role + // 2. Value in Product filter => remove all assignments of all Apps of this product to the role + // 3. No filter => remove all assignments of the role public onRevokeAllPermissions(ev: MouseEvent, role: Role): void { - const pList = this.prepareProductList() - if (pList.length === 0) return // products are required - this.assApi - .revokeAssignments({ - revokeAssignmentRequest: { roleId: role.id, productNames: pList } as RevokeAssignmentRequest - }) - .subscribe({ - next: () => { - this.msgService.success({ summaryKey: 'PERMISSION.ASSIGNMENTS.REVOKE_ALL_SUCCESS' }) - this.loadRoleAssignments(false, role.id) - }, - error: (err) => { - this.msgService.error({ summaryKey: 'PERMISSION.ASSIGNMENTS.REVOKE_ERROR' }) - console.error(err) - } - }) + const response: any = { + next: () => { + this.msgService.success({ summaryKey: 'PERMISSION.ASSIGNMENTS.REVOKE_ALL_SUCCESS' }) + this.loadRoleAssignments(false, role.id) + }, + error: (err: any) => { + this.msgService.error({ summaryKey: 'PERMISSION.ASSIGNMENTS.REVOKE_ERROR' }) + console.error(err) + } + } + if (this.filterAppValue) { + this.assApi + .revokeRoleApplicationAssignments({ + roleId: role.id, + revokeRoleApplicationAssignmentRequest: { + appId: this.filterAppValue, + productName: this.getProductNameForApp(this.filterAppValue) + } + } as RevokeRoleApplicationAssignmentsRequestParams) + .subscribe(response) + } else if (this.filterProductValue) { + this.assApi + .revokeRoleProductsAssignments({ + roleId: role.id, + revokeRoleProductsAssignmentRequest: { productNames: this.prepareProductList() } + } as RevokeRoleProductsAssignmentsRequestParams) + .subscribe(response) + } else { + this.assApi.revokeRoleAssignments({ roleId: role.id } as RevokeRoleAssignmentsRequestParams).subscribe(response) + } } // Not perfect: apps are uinique only within the product @@ -757,6 +767,7 @@ export class AppDetailComponent implements OnInit, OnDestroy { } return pList.length === 1 ? pList[0].productName : undefined } + private prepareProductList(): string[] { const pList: string[] = [] // => case 1: Product @@ -767,7 +778,7 @@ export class AppDetailComponent implements OnInit, OnDestroy { // b) all products else if (this.filterProductItems.length > 1) this.filterProductItems.map((p) => { - if (p.value) pList.push(p.value!) // ignore empty entry + if (p.value) pList.push(p.value) // ignore empty entry }) return pList } @@ -789,19 +800,19 @@ export class AppDetailComponent implements OnInit, OnDestroy { } private sortPermissionRowByProductAsc(a: PermissionViewRow, b: PermissionViewRow): number { return ( - (a.productName ? a.productName.toUpperCase() : '').localeCompare( + ((a.productName ? a.productName.toUpperCase() : '').localeCompare( b.productName ? b.productName.toUpperCase() : '' ) || - a.appId?.localeCompare(b!.appId!) || + a.appId?.localeCompare(b.appId!)) ?? a.key.localeCompare(b.key) ) } private sortPermissionRowByProductDesc(bP: PermissionViewRow, aP: PermissionViewRow): number { return ( - (aP.productName ? aP.productName.toUpperCase() : '').localeCompare( + ((aP.productName ? aP.productName.toUpperCase() : '').localeCompare( bP.productName ? bP.productName.toUpperCase() : '' ) || - aP.appId?.localeCompare(bP!.appId!) || + aP.appId?.localeCompare(bP.appId!)) ?? aP.key.localeCompare(bP.key) ) } diff --git a/src/app/permission/app-search/app-search.component.ts b/src/app/permission/app-search/app-search.component.ts index 0543cf0..a259eea 100644 --- a/src/app/permission/app-search/app-search.component.ts +++ b/src/app/permission/app-search/app-search.component.ts @@ -12,6 +12,7 @@ import { limitText } from 'src/app/shared/utils' import { Application, ApplicationAPIService, + WorkspaceAbstract, WorkspaceAPIService, WorkspacePageResult, ApplicationPageResult @@ -116,10 +117,10 @@ export class AppSearchComponent implements OnInit, OnDestroy { finalize(() => (this.searchInProgress = false)) ) return this.workspaces$.pipe( - map((result) => { + map((result: any) => { return result.stream ? result.stream - ?.map((w) => { + ?.map((w: WorkspaceAbstract) => { return { appId: w.name, appType: 'WORKSPACE', description: w.description } as App }) .sort(this.sortAppsByAppId) @@ -147,28 +148,26 @@ export class AppSearchComponent implements OnInit, OnDestroy { finalize(() => (this.searchInProgress = false)) ) return this.papps$.pipe( - map((result) => { + map((result: any) => { if (!result.stream) return [] const productNames: string[] = [] const apps: App[] = [] - result.stream?.map((app) => { + result.stream?.map((app: Application) => { if (!productNames.includes(app.productName ?? '')) { productNames.push(app.productName ?? '') apps.push({ ...app, appType: 'PRODUCT' } as App) } - //} }) return apps.sort(this.sortAppsByAppId) }) ) } public searchApps(): void { - console.log('searchApps: ' + this.appSearchCriteriaGroup.controls['appType'].value) this.searchInProgress = true switch (this.appSearchCriteriaGroup.controls['appType'].value) { case 'ALL': this.apps$ = combineLatest([this.searchWorkspaces(), this.searchProducts('PRODUCT')]).pipe( - map(([w, a]) => w.concat(a).sort(this.sortAppsByAppId)) + map(([w, a]: [App[], App[]]) => w.concat(a).sort(this.sortAppsByAppId)) ) break case 'WORKSPACE': @@ -199,7 +198,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { 'ACTIONS.SEARCH.SORT_DIRECTION_DESC' ]) .pipe( - map((data) => { + map((data: any) => { this.dataViewControlsTranslations = { sortDropdownPlaceholder: data['ACTIONS.SEARCH.SORT_BY'], filterInputPlaceholder: data['ACTIONS.SEARCH.FILTER.LABEL'], @@ -218,6 +217,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { * UI Events */ public onAppClick(ev: any, app: App): void { + ev.stopPropagation() this.router.navigate(['./', app.appType.toLowerCase(), app.appType === 'PRODUCT' ? app.productName : app.appId], { relativeTo: this.route }) diff --git a/src/app/permission/permission-detail/permission-detail.component.html b/src/app/permission/permission-detail/permission-detail.component.html index 4ea7fd4..7616f41 100644 --- a/src/app/permission/permission-detail/permission-detail.component.html +++ b/src/app/permission/permission-detail/permission-detail.component.html @@ -32,7 +32,7 @@ -
+
; - public grantAssignments(requestParameters: GrantAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantAssignments(requestParameters: GrantAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantAssignments(requestParameters: GrantAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - const createProductAssignmentsRequest = requestParameters.createProductAssignmentsRequest; - if (createProductAssignmentsRequest === null || createProductAssignmentsRequest === undefined) { - throw new Error('Required parameter createProductAssignmentsRequest was null or undefined when calling grantAssignments.'); + public grantRoleApplicationAssignments(requestParameters: GrantRoleApplicationAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public grantRoleApplicationAssignments(requestParameters: GrantRoleApplicationAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public grantRoleApplicationAssignments(requestParameters: GrantRoleApplicationAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public grantRoleApplicationAssignments(requestParameters: GrantRoleApplicationAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + const roleId = requestParameters.roleId; + if (roleId === null || roleId === undefined) { + throw new Error('Required parameter roleId was null or undefined when calling grantRoleApplicationAssignments.'); + } + const createRoleApplicationAssignmentRequest = requestParameters.createRoleApplicationAssignmentRequest; + if (createRoleApplicationAssignmentRequest === null || createRoleApplicationAssignmentRequest === undefined) { + throw new Error('Required parameter createRoleApplicationAssignmentRequest was null or undefined when calling grantRoleApplicationAssignments.'); } let localVarHeaders = this.defaultHeaders; @@ -386,11 +396,11 @@ export class AssignmentAPIService { } } - let localVarPath = `/assignments/grant`; + let localVarPath = `/assignments/grant/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/application`; return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: createProductAssignmentsRequest, + body: createRoleApplicationAssignmentRequest, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -459,22 +469,22 @@ export class AssignmentAPIService { } /** - * Create new assignments for role and product + * Create new assignments for role and products * @param requestParameters * @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 grantRoleProductAssignments(requestParameters: GrantRoleProductAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public grantRoleProductAssignments(requestParameters: GrantRoleProductAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantRoleProductAssignments(requestParameters: GrantRoleProductAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantRoleProductAssignments(requestParameters: GrantRoleProductAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { const roleId = requestParameters.roleId; if (roleId === null || roleId === undefined) { - throw new Error('Required parameter roleId was null or undefined when calling grantRoleProductAssignments.'); + throw new Error('Required parameter roleId was null or undefined when calling grantRoleProductsAssignments.'); } - const createRoleProductAssignmentRequest = requestParameters.createRoleProductAssignmentRequest; - if (createRoleProductAssignmentRequest === null || createRoleProductAssignmentRequest === undefined) { - throw new Error('Required parameter createRoleProductAssignmentRequest was null or undefined when calling grantRoleProductAssignments.'); + const createRoleProductsAssignmentRequest = requestParameters.createRoleProductsAssignmentRequest; + if (createRoleProductsAssignmentRequest === null || createRoleProductsAssignmentRequest === undefined) { + throw new Error('Required parameter createRoleProductsAssignmentRequest was null or undefined when calling grantRoleProductsAssignments.'); } let localVarHeaders = this.defaultHeaders; @@ -517,11 +527,11 @@ export class AssignmentAPIService { } } - let localVarPath = `/assignments/grant/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/product`; + let localVarPath = `/assignments/grant/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/products`; return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: createRoleProductAssignmentRequest, + body: createRoleProductsAssignmentRequest, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -532,22 +542,22 @@ export class AssignmentAPIService { } /** - * Create new assignments for role and products + * Revoke assignments for role and application * @param requestParameters * @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 grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public grantRoleProductsAssignments(requestParameters: GrantRoleProductsAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + public revokeRoleApplicationAssignments(requestParameters: RevokeRoleApplicationAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public revokeRoleApplicationAssignments(requestParameters: RevokeRoleApplicationAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public revokeRoleApplicationAssignments(requestParameters: RevokeRoleApplicationAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public revokeRoleApplicationAssignments(requestParameters: RevokeRoleApplicationAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { const roleId = requestParameters.roleId; if (roleId === null || roleId === undefined) { - throw new Error('Required parameter roleId was null or undefined when calling grantRoleProductsAssignments.'); + throw new Error('Required parameter roleId was null or undefined when calling revokeRoleApplicationAssignments.'); } - const createRoleProductsAssignmentRequest = requestParameters.createRoleProductsAssignmentRequest; - if (createRoleProductsAssignmentRequest === null || createRoleProductsAssignmentRequest === undefined) { - throw new Error('Required parameter createRoleProductsAssignmentRequest was null or undefined when calling grantRoleProductsAssignments.'); + const revokeRoleApplicationAssignmentRequest = requestParameters.revokeRoleApplicationAssignmentRequest; + if (revokeRoleApplicationAssignmentRequest === null || revokeRoleApplicationAssignmentRequest === undefined) { + throw new Error('Required parameter revokeRoleApplicationAssignmentRequest was null or undefined when calling revokeRoleApplicationAssignments.'); } let localVarHeaders = this.defaultHeaders; @@ -590,11 +600,69 @@ export class AssignmentAPIService { } } - let localVarPath = `/assignments/grant/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/products`; + let localVarPath = `/assignments/revoke/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/application`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: revokeRoleApplicationAssignmentRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Revoke assignments for role + * @param requestParameters + * @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 revokeRoleAssignments(requestParameters: RevokeRoleAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; + public revokeRoleAssignments(requestParameters: RevokeRoleAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; + public revokeRoleAssignments(requestParameters: RevokeRoleAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; + public revokeRoleAssignments(requestParameters: RevokeRoleAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + const roleId = requestParameters.roleId; + if (roleId === null || roleId === undefined) { + throw new Error('Required parameter roleId was null or undefined when calling revokeRoleAssignments.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/assignments/revoke/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: createRoleProductsAssignmentRequest, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -605,18 +673,22 @@ export class AssignmentAPIService { } /** - * delete assignments by criteria + * Revoke assignments for role and products * @param requestParameters * @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 revokeAssignments(requestParameters: RevokeAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public revokeAssignments(requestParameters: RevokeAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public revokeAssignments(requestParameters: RevokeAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public revokeAssignments(requestParameters: RevokeAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - const revokeAssignmentRequest = requestParameters.revokeAssignmentRequest; - if (revokeAssignmentRequest === null || revokeAssignmentRequest === undefined) { - throw new Error('Required parameter revokeAssignmentRequest was null or undefined when calling revokeAssignments.'); + public revokeRoleProductsAssignments(requestParameters: RevokeRoleProductsAssignmentsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public revokeRoleProductsAssignments(requestParameters: RevokeRoleProductsAssignmentsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public revokeRoleProductsAssignments(requestParameters: RevokeRoleProductsAssignmentsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public revokeRoleProductsAssignments(requestParameters: RevokeRoleProductsAssignmentsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + const roleId = requestParameters.roleId; + if (roleId === null || roleId === undefined) { + throw new Error('Required parameter roleId was null or undefined when calling revokeRoleProductsAssignments.'); + } + const revokeRoleProductsAssignmentRequest = requestParameters.revokeRoleProductsAssignmentRequest; + if (revokeRoleProductsAssignmentRequest === null || revokeRoleProductsAssignmentRequest === undefined) { + throw new Error('Required parameter revokeRoleProductsAssignmentRequest was null or undefined when calling revokeRoleProductsAssignments.'); } let localVarHeaders = this.defaultHeaders; @@ -659,11 +731,11 @@ export class AssignmentAPIService { } } - let localVarPath = `/assignments/revoke`; + let localVarPath = `/assignments/revoke/${this.configuration.encodeParam({name: "roleId", value: roleId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/products`; return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: revokeAssignmentRequest, + body: revokeRoleProductsAssignmentRequest, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, diff --git a/src/app/shared/generated/model/createRoleProductAssignmentRequest.ts b/src/app/shared/generated/model/createRoleApplicationAssignmentRequest.ts similarity index 87% rename from src/app/shared/generated/model/createRoleProductAssignmentRequest.ts rename to src/app/shared/generated/model/createRoleApplicationAssignmentRequest.ts index a5c278d..9ffe369 100644 --- a/src/app/shared/generated/model/createRoleProductAssignmentRequest.ts +++ b/src/app/shared/generated/model/createRoleApplicationAssignmentRequest.ts @@ -11,7 +11,7 @@ */ -export interface CreateRoleProductAssignmentRequest { +export interface CreateRoleApplicationAssignmentRequest { appId: string; productName: string; } diff --git a/src/app/shared/generated/model/models.ts b/src/app/shared/generated/model/models.ts index e1d3ca9..6a2417a 100644 --- a/src/app/shared/generated/model/models.ts +++ b/src/app/shared/generated/model/models.ts @@ -7,7 +7,7 @@ export * from './assignmentSearchCriteria'; export * from './createAssignmentRequest'; export * from './createPermissionRequest'; export * from './createProductAssignmentsRequest'; -export * from './createRoleProductAssignmentRequest'; +export * from './createRoleApplicationAssignmentRequest'; export * from './createRoleProductsAssignmentRequest'; export * from './createRoleRequest'; export * from './createRolesRequest'; @@ -24,7 +24,8 @@ export * from './problemDetailParam'; export * from './problemDetailResponse'; export * from './product'; export * from './productDetails'; -export * from './revokeAssignmentRequest'; +export * from './revokeRoleApplicationAssignmentRequest'; +export * from './revokeRoleProductsAssignmentRequest'; export * from './role'; export * from './rolePageResult'; export * from './roleSearchCriteria'; diff --git a/src/app/shared/generated/model/revokeAssignmentRequest.ts b/src/app/shared/generated/model/revokeRoleApplicationAssignmentRequest.ts similarity index 71% rename from src/app/shared/generated/model/revokeAssignmentRequest.ts rename to src/app/shared/generated/model/revokeRoleApplicationAssignmentRequest.ts index e5f4179..292fa74 100644 --- a/src/app/shared/generated/model/revokeAssignmentRequest.ts +++ b/src/app/shared/generated/model/revokeRoleApplicationAssignmentRequest.ts @@ -11,10 +11,8 @@ */ -export interface RevokeAssignmentRequest { - roleId: string; - appId?: string; - permissionId?: string; - productNames?: Array; +export interface RevokeRoleApplicationAssignmentRequest { + appId: string; + productName: string; } diff --git a/src/app/shared/generated/model/revokeRoleProductsAssignmentRequest.ts b/src/app/shared/generated/model/revokeRoleProductsAssignmentRequest.ts new file mode 100644 index 0000000..d031c90 --- /dev/null +++ b/src/app/shared/generated/model/revokeRoleProductsAssignmentRequest.ts @@ -0,0 +1,17 @@ +/** + * onecx-permission-bff + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface RevokeRoleProductsAssignmentRequest { + productNames: Array; +} + diff --git a/src/assets/api/openapi-bff.yaml b/src/assets/api/openapi-bff.yaml index 5304830..61c7bde 100644 --- a/src/assets/api/openapi-bff.yaml +++ b/src/assets/api/openapi-bff.yaml @@ -389,31 +389,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetailResponse' - /assignments/grant: - post: - x-onecx: - permissions: - assignment: - - write - tags: - - assignment - description: Create new assignments by criteria - operationId: grantAssignments - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateProductAssignmentsRequest' - responses: - 201: - description: New assignments created - 400: - description: Bad request - content: - application/json: - schema: - $ref: '#/components/schemas/ProblemDetailResponse' /assignments/grant/{roleId}: post: tags: @@ -431,12 +406,12 @@ paths: description: New assignment created 404: description: Data not found - /assignments/grant/{roleId}/product: + /assignments/grant/{roleId}/application: post: tags: - assignment - description: Create new assignments for role and product - operationId: grantRoleProductAssignments + description: Create new assignments for role and application + operationId: grantRoleApplicationAssignments parameters: - name: roleId in: path @@ -448,7 +423,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CreateRoleProductAssignmentRequest' + $ref: '#/components/schemas/CreateRoleApplicationAssignmentRequest' responses: 201: description: New assignment created @@ -489,25 +464,76 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetailResponse' - /assignments/revoke: + # + /assignments/revoke/{roleId}: post: - x-onecx: - permissions: - assignment: - - delete tags: - assignment - description: delete assignments by criteria - operationId: revokeAssignments + description: Revoke assignments for role + operationId: revokeRoleAssignments + parameters: + - name: roleId + in: path + required: true + schema: + type: string + responses: + 204: + description: assignment revoked + 404: + description: Data not found + /assignments/revoke/{roleId}/application: + post: + tags: + - assignment + description: Revoke assignments for role and application + operationId: revokeRoleApplicationAssignments + parameters: + - name: roleId + in: path + required: true + schema: + type: string requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/RevokeAssignmentRequest' + $ref: '#/components/schemas/RevokeRoleApplicationAssignmentRequest' responses: 204: - description: revoked assignments + description: assignments revoked + 404: + description: Data not found + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetailResponse' + /assignments/revoke/{roleId}/products: + post: + tags: + - assignment + description: Revoke assignments for role and products + operationId: revokeRoleProductsAssignments + parameters: + - name: roleId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RevokeRoleProductsAssignmentRequest' + responses: + 204: + description: assignment revoked + 404: + description: Data not found 400: description: Bad request content: @@ -927,21 +953,6 @@ components: type: array items: type: string - RevokeAssignmentRequest: - type: object - required: - - roleId - properties: - roleId: - type: string - appId: - type: string - permissionId: - type: string - productNames: - type: array - items: - type: string Assignment: type: object properties: @@ -1137,7 +1148,27 @@ components: minItems: 1 items: type: string - CreateRoleProductAssignmentRequest: + CreateRoleApplicationAssignmentRequest: + type: object + required: + - productName + - appId + properties: + appId: + type: string + productName: + type: string + RevokeRoleProductsAssignmentRequest: + type: object + required: + - productNames + properties: + productNames: + type: array + minItems: 1 + items: + type: string + RevokeRoleApplicationAssignmentRequest: type: object required: - productName diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 49f7ca9..1f5b079 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -195,16 +195,16 @@ "ACTIONS": "Aktionen", "MANDATORY": "Unbedingt erforderlich", "MANDATORY.COLUMN": "Kann die Berechtigung bearbeitet werden?", - "MANDATORY.TOOLTIP": "Diese Berechtigung ist notwendig für den Betrieb und kann somit nicht bearbeitet oder gelöscht werden.", + "MANDATORY.TOOLTIP": "Diese Berechtigung ist notwendig für den Betrieb und kann deshalb nicht bearbeitet oder gelöscht werden.", "OPERATOR": "Durch Operator erstellt", "OPERATOR.TOOLTIP": "Wenn gesetzt, dann wurde diese Berechtigung durch den Oprator erzeugt.", "ASSIGNMENTS": { "ROLE_IS_ASSIGNED_0": "Keine Berechtigung", "ROLE_IS_ASSIGNED_1": "Berechtigung erteilt", - "ROLE_IS_ASSIGNED_1.MANDATORY": "Berechtigung erteilt, kann nicht geändert werden", + "ROLE_IS_ASSIGNED_1.MANDATORY": "Berechtigung erteilt - Kann nicht geändert werden", "ROLE_ASSIGNEMENT_CHANGEABLE": "Berechtigung ändern", - "GRANT_ALL_FOR_ROLE": "Alle Berechtigungen für das ausgewählte oder alle Produkte erteilen", - "REVOKE_ALL_FOR_ROLE": "Alle Berechtigungen für das ausgewählte oder alle Produkte entziehen", + "GRANT_ALL_FOR_ROLE": "Alle Berechtigungen entsprechend der Filter (Produkt, App) erteilen", + "REVOKE_ALL_FOR_ROLE": "Alle Berechtigungen entsprechend der Filter (Produkt, App) entziehen", "GRANT_ERROR": "Berechtigung konnte nicht erteilt werden", "GRANT_SUCCESS": "Berechtigung erteilt", "GRANT_ALL_SUCCESS": "Berechtigungen erteilt", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index ce12ca2..6300f3a 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -203,8 +203,8 @@ "ROLE_IS_ASSIGNED_1": "Permission granted", "ROLE_IS_ASSIGNED_1.MANDATORY": "Permission granted, cannot be changed", "ROLE_ASSIGNEMENT_CHANGEABLE": "Change Permission", - "GRANT_ALL_FOR_ROLE": "Grant all Permissions for the selected or all products", - "REVOKE_ALL_FOR_ROLE": "Revoke all Permissions for the selected or all products", + "GRANT_ALL_FOR_ROLE": "Grant all permissions according to the filters (product, app).", + "REVOKE_ALL_FOR_ROLE": "Revoke all permissions according to the filters (product, app).", "GRANT_ERROR": "Permission could not be granted", "GRANT_SUCCESS": "Permission granted", "GRANT_ALL_SUCCESS": "Permissions granted",