Skip to content

Commit f4e3b3b

Browse files
committed
refactor(admin): unify complementaryObject parameter
* Regenerate openapi with new comments about supported objects for complementaryObjet(s) parameter. * Unify a type of complementaryObject variable to PerunBean object across classes in admin-gui. * The information about supported objects has been left just in openapi documentation to avoid future need of changing it on several places. * Little refactor of edited files has been done.
1 parent 35f61da commit f4e3b3b

15 files changed

+67
-72
lines changed

apps/admin-gui/src/app/shared/components/dialogs/add-group-manager-dialog/add-group-manager-dialog.component.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
3-
import { TranslateService } from '@ngx-translate/core';
4-
import { NotificatorService } from '@perun-web-apps/perun/services';
3+
import { NotificatorService, PerunTranslateService } from '@perun-web-apps/perun/services';
54
import { ActivatedRoute, Router } from '@angular/router';
65
import { SelectionModel } from '@angular/cdk/collections';
76
import { Observable } from 'rxjs';
87
import { UntypedFormControl } from '@angular/forms';
98
import { map, startWith } from 'rxjs/operators';
109
import {
1110
AuthzResolverService,
12-
Facility,
1311
Group,
1412
GroupsManagerService,
13+
PerunBean,
1514
RoleManagementRules,
1615
Vo,
1716
VosManagerService,
@@ -21,7 +20,7 @@ import { TABLE_SELECT_GROUP_MANAGER_DIALOG } from '@perun-web-apps/config/table-
2120
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
2221

2322
export interface AddGroupManagerDialogData {
24-
complementaryObject: Vo | Group | Facility;
23+
complementaryObject: PerunBean;
2524
availableRoles: RoleManagementRules[];
2625
theme: string;
2726
selectedRole: Role;
@@ -60,15 +59,13 @@ export class AddGroupManagerDialogComponent implements OnInit {
6059
private authzService: AuthzResolverService,
6160
private voService: VosManagerService,
6261
private groupService: GroupsManagerService,
63-
private translate: TranslateService,
62+
private translate: PerunTranslateService,
6463
private notificator: NotificatorService,
6564
protected route: ActivatedRoute,
6665
protected router: Router
6766
) {
68-
translate.get('DIALOGS.ADD_GROUPS.TITLE').subscribe((value: string) => (this.title = value));
69-
translate
70-
.get('DIALOGS.ADD_GROUPS.SUCCESS')
71-
.subscribe((value: string) => (this.successMessage = value));
67+
this.title = this.translate.instant('DIALOGS.ADD_GROUPS.TITLE');
68+
this.successMessage = this.translate.instant('DIALOGS.ADD_GROUPS.SUCCESS');
7269
}
7370

7471
displayFn(vo?: Vo): string | undefined {

apps/admin-gui/src/app/shared/components/dialogs/add-manager-dialog/add-manager-dialog.component.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
3-
import { TranslateService } from '@ngx-translate/core';
4-
import { NotificatorService, StoreService } from '@perun-web-apps/perun/services';
3+
import {
4+
NotificatorService,
5+
PerunTranslateService,
6+
StoreService,
7+
} from '@perun-web-apps/perun/services';
58
import { SelectionModel } from '@angular/cdk/collections';
69
import { ActivatedRoute, Router } from '@angular/router';
710
import {
811
AuthzResolverService,
9-
Facility,
10-
Group,
12+
PerunBean,
1113
RichUser,
1214
RoleManagementRules,
1315
UsersManagerService,
14-
Vo,
1516
} from '@perun-web-apps/perun/openapi';
1617
import { Role } from '@perun-web-apps/perun/models';
1718
import { TABLE_ADD_MANAGER } from '@perun-web-apps/config/table-config';
1819
import { Urns } from '@perun-web-apps/perun/urns';
1920
import { UntypedFormControl, Validators } from '@angular/forms';
2021

2122
export interface AddManagerDialogData {
22-
complementaryObject: Vo | Group | Facility;
23+
complementaryObject: PerunBean;
2324
theme: string;
2425
availableRoles: RoleManagementRules[];
2526
selectedRole: Role;
@@ -48,16 +49,14 @@ export class AddManagerDialogComponent implements OnInit {
4849
@Inject(MAT_DIALOG_DATA) private data: AddManagerDialogData,
4950
private authzService: AuthzResolverService,
5051
private usersService: UsersManagerService,
51-
private translate: TranslateService,
52+
private translate: PerunTranslateService,
5253
private notificator: NotificatorService,
5354
private storeService: StoreService,
5455
protected route: ActivatedRoute,
5556
protected router: Router
5657
) {
57-
translate.get('DIALOGS.ADD_MANAGERS.TITLE').subscribe((value: string) => (this.title = value));
58-
translate
59-
.get('DIALOGS.ADD_MANAGERS.SUCCESS')
60-
.subscribe((value: string) => (this.successMessage = value));
58+
this.title = this.translate.instant('DIALOGS.ADD_MANAGERS.TITLE');
59+
this.successMessage = this.translate.instant('DIALOGS.ADD_MANAGERS.SUCCESS');
6160
}
6261

6362
ngOnInit(): void {

apps/admin-gui/src/app/shared/components/dialogs/add-role-dialog/add-role-dialog.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { SelectionModel } from '@angular/cdk/collections';
1616
import { ToEnrichedFacilityPipe } from '@perun-web-apps/perun/pipes';
1717
import { DebounceFilterComponent } from '@perun-web-apps/perun/components';
18+
import { combineLatestWith } from 'rxjs/operators';
1819

1920
export interface AddRoleDialogData {
2021
entityId: number;
@@ -64,6 +65,7 @@ export class AddRoleDialogComponent implements OnInit {
6465
}
6566

6667
loadObjects(): void {
68+
this.loading = true;
6769
if (this.rules.some((rule) => rule.primaryObject === 'Facility')) {
6870
// Not callable by SELF, need to check privilege
6971
this.facilityService.getAllFacilities().subscribe({
@@ -74,12 +76,18 @@ export class AddRoleDialogComponent implements OnInit {
7476
if (this.rules.some((rule) => rule.primaryObject === 'Vo')) {
7577
this.voService.getMyVos().subscribe({ next: (vos) => (this.vos = vos) });
7678
}
79+
7780
this.groupService
7881
.getAllGroupsFromAllVos()
79-
.subscribe({ next: (groups) => (this.groups = groups) });
80-
this.resourceService.getAllResources().subscribe({
81-
next: (resources) => (this.resources = resources),
82-
});
82+
.pipe(combineLatestWith(this.resourceService.getAllResources()))
83+
.subscribe({
84+
next: ([groups, resources]) => {
85+
this.groups = groups;
86+
this.resources = resources;
87+
this.loading = false;
88+
},
89+
error: () => (this.loading = false),
90+
});
8391
}
8492

8593
cancel(): void {

apps/admin-gui/src/app/shared/components/dialogs/remove-group-manager-dialog/remove-group-manager-dialog.component.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
33
import { MatTableDataSource } from '@angular/material/table';
4-
import { NotificatorService } from '@perun-web-apps/perun/services';
5-
import { TranslateService } from '@ngx-translate/core';
6-
import { AuthzResolverService, Facility, Group, Vo } from '@perun-web-apps/perun/openapi';
4+
import { NotificatorService, PerunTranslateService } from '@perun-web-apps/perun/services';
5+
import { AuthzResolverService, Group, PerunBean } from '@perun-web-apps/perun/openapi';
76
import { Role } from '@perun-web-apps/perun/models';
87

98
export interface RemoveGroupDialogData {
10-
complementaryObject: Vo | Group | Facility;
9+
complementaryObject: PerunBean;
1110
groups: Group[];
1211
role: Role;
1312
theme: string;
@@ -28,7 +27,7 @@ export class RemoveGroupManagerDialogComponent implements OnInit {
2827
public dialogRef: MatDialogRef<RemoveGroupManagerDialogComponent>,
2928
@Inject(MAT_DIALOG_DATA) public data: RemoveGroupDialogData,
3029
private notificator: NotificatorService,
31-
private translate: TranslateService,
30+
private translate: PerunTranslateService,
3231
private authzService: AuthzResolverService
3332
) {}
3433

@@ -49,18 +48,13 @@ export class RemoveGroupManagerDialogComponent implements OnInit {
4948
authorizedGroups: this.data.groups.map((group) => group.id),
5049
complementaryObject: this.data.complementaryObject,
5150
})
52-
.subscribe(
53-
() => {
54-
this.translate.get('DIALOGS.REMOVE_GROUPS.SUCCESS').subscribe(
55-
(successMessage: string) => {
56-
this.notificator.showSuccess(successMessage);
57-
this.loading = false;
58-
this.dialogRef.close(true);
59-
},
60-
() => (this.loading = false)
61-
);
51+
.subscribe({
52+
next: () => {
53+
this.notificator.showSuccess(this.translate.instant('DIALOGS.REMOVE_GROUPS.SUCCESS'));
54+
this.loading = false;
55+
this.dialogRef.close(true);
6256
},
63-
() => (this.loading = false)
64-
);
57+
error: () => (this.loading = false),
58+
});
6559
}
6660
}

apps/admin-gui/src/app/shared/components/dialogs/remove-manager-dialog/remove-manager-dialog.component.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
33
import { MatTableDataSource } from '@angular/material/table';
4-
import { GuiAuthResolver, NotificatorService, StoreService } from '@perun-web-apps/perun/services';
5-
import { TranslateService } from '@ngx-translate/core';
6-
import { AuthzResolverService, Facility, Group, RichUser, Vo } from '@perun-web-apps/perun/openapi';
4+
import {
5+
GuiAuthResolver,
6+
NotificatorService,
7+
PerunTranslateService,
8+
StoreService,
9+
} from '@perun-web-apps/perun/services';
10+
import { AuthzResolverService, PerunBean, RichUser } from '@perun-web-apps/perun/openapi';
711
import { Role } from '@perun-web-apps/perun/models';
812

913
export interface RemoveManagerDialogData {
10-
complementaryObject: Vo | Group | Facility;
14+
complementaryObject: PerunBean;
1115
managers: RichUser[];
1216
role: Role;
1317
theme: string;
@@ -29,7 +33,7 @@ export class RemoveManagerDialogComponent implements OnInit {
2933
public dialogRef: MatDialogRef<RemoveManagerDialogComponent>,
3034
@Inject(MAT_DIALOG_DATA) public data: RemoveManagerDialogData,
3135
private notificator: NotificatorService,
32-
private translate: TranslateService,
36+
private translate: PerunTranslateService,
3337
private authzService: AuthzResolverService,
3438
private store: StoreService,
3539
private authService: GuiAuthResolver
@@ -55,18 +59,13 @@ export class RemoveManagerDialogComponent implements OnInit {
5559
users: this.data.managers.map((manager) => manager.id),
5660
complementaryObject: this.data.complementaryObject,
5761
})
58-
.subscribe(
59-
() => {
60-
this.translate.get('DIALOGS.REMOVE_MANAGERS.SUCCESS').subscribe(
61-
(successMessage: string) => {
62-
this.notificator.showSuccess(successMessage);
63-
this.loading = false;
64-
this.dialogRef.close(true);
65-
},
66-
() => (this.loading = false)
67-
);
62+
.subscribe({
63+
next: () => {
64+
this.notificator.showSuccess(this.translate.instant('DIALOGS.REMOVE_MANAGERS.SUCCESS'));
65+
this.loading = false;
66+
this.dialogRef.close(true);
6867
},
69-
() => (this.loading = false)
70-
);
68+
error: () => (this.loading = false),
69+
});
7170
}
7271
}

apps/admin-gui/src/app/shared/components/managers-page/managers-page.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import { RemoveGroupManagerDialogComponent } from '../dialogs/remove-group-manag
77
import { AddGroupManagerDialogComponent } from '../dialogs/add-group-manager-dialog/add-group-manager-dialog.component';
88
import {
99
AuthzResolverService,
10-
Facility,
1110
Group,
12-
Resource,
11+
PerunBean,
1312
RichUser,
1413
RoleManagementRules,
15-
Vo,
1614
} from '@perun-web-apps/perun/openapi';
1715
import { Urns } from '@perun-web-apps/perun/urns';
1816
import { TABLE_GROUP_MANAGERS_PAGE } from '@perun-web-apps/config/table-config';
@@ -32,7 +30,7 @@ import { mergeMap, tap } from 'rxjs/operators';
3230
})
3331
export class ManagersPageComponent implements OnInit {
3432
@HostBinding('class.router-component') true;
35-
@Input() complementaryObject: Group | Vo | Facility | Resource;
33+
@Input() complementaryObject: PerunBean;
3634
@Input() availableRoles: RoleManagementRules[];
3735
@Input() complementaryObjectType: string;
3836
@Input() theme: string;

libs/perun/openapi/src/lib/api/authzResolver.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class AuthzResolverService {
330330
* Get all groups of managers (authorizedGroups) for complementaryObject and role
331331
* @param role
332332
* @param complementaryObjectId Property id of complementaryObject to get managers for
333-
* @param complementaryObjectName Property beanName of complementaryObject, meaning object type (Vo | Group | Facility | ... )
333+
* @param complementaryObjectName Property beanName of complementaryObject, meaning object type (supported object types: Group | RichGroup | Vo | Resource | Facility | SecurityTeam )
334334
* @param useNon if set to true sends the request to the backend server as 'non' instead of the usual (oauth, krb...).
335335
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
336336
* @param reportProgress flag to report request and response progress.
@@ -472,7 +472,7 @@ export class AuthzResolverService {
472472
* Get all valid richUser administrators (for group-based rights, status must be VALID for both Vo and group) for complementary object and role with specified attributes.
473473
* @param role
474474
* @param complementaryObjectId Property id of complementaryObject to get managers for
475-
* @param complementaryObjectName Property beanName of complementaryObject, meaning object type (Vo | Group | Facility | ... )
475+
* @param complementaryObjectName Property beanName of complementaryObject, meaning object type (supported object types: Group | RichGroup | Vo | Resource | Facility | SecurityTeam )
476476
* @param specificAttributes list of specified attributes which are needed in object richUser
477477
* @param allUserAttributes When true, do not specify attributes through list and return them all in objects richUser. Ignoring list of specific attributes
478478
* @param onlyDirectAdmins When true, return only direct users of the complementary object for role with specific attributes

libs/perun/openapi/src/lib/model/setRoleWithGroupComplementaryObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { PerunBean } from './perunBean';
1313

1414
/**
15-
* input to unsetRoleWithUserComplementaryObject
15+
* input to unsetRoleWithUserComplementaryObject (supported objects: Group | RichGroup | Vo | Resource | Facility | SecurityTeam )
1616
*/
1717
export interface SetRoleWithGroupComplementaryObject {
1818
role: string;

libs/perun/openapi/src/lib/model/setRoleWithGroupComplementaryObjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface SetRoleWithGroupComplementaryObjects {
1818
role: string;
1919
authorizedGroup?: number;
2020
/**
21-
* List of complementary objects
21+
* List of complementary objects (supported objects: Group | RichGroup | Vo | Resource | Facility | SecurityTeam )
2222
*/
2323
complementaryObjects?: Array<PerunBean>;
2424
}

libs/perun/openapi/src/lib/model/setRoleWithUserComplementaryObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { PerunBean } from './perunBean';
1313

1414
/**
15-
* input to setRoleWithUserComplementaryObject
15+
* input to setRoleWithUserComplementaryObject (supported objects: Group | RichGroup | Vo | Resource | Facility | SecurityTeam )
1616
*/
1717
export interface SetRoleWithUserComplementaryObject {
1818
role: string;

0 commit comments

Comments
 (0)