Skip to content

Commit 4086bf1

Browse files
committed
feat(admin): include groups from members organization
* added new feature to include groups from member organizations
1 parent 23f7cca commit 4086bf1

File tree

6 files changed

+83
-31
lines changed

6 files changed

+83
-31
lines changed

apps/admin-gui/src/app/shared/components/dialogs/create-relation-dialog/create-relation-dialog.component.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<h1 mat-dialog-title>{{"DIALOGS.CREATE_RELATION.TITLE" | translate}}</h1>
22
<div class="{{theme}}">
3-
<mat-spinner *ngIf="loading" class="ml-auto mr-auto"></mat-spinner>
3+
<mat-spinner *ngIf="initLoading" class="ml-auto mr-auto"></mat-spinner>
44
</div>
5-
<div *ngIf="!loading" class="{{theme}}">
5+
<div *ngIf="!initLoading" class="{{theme}}">
6+
<perun-web-apps-vo-search-select
7+
*ngIf="vosToSelect.length > 1"
8+
[vo]="thisVo.vo"
9+
[vos]="vosToSelect"
10+
(voSelected)="getGroupsToInclude($event.id)"></perun-web-apps-vo-search-select>
611
<perun-web-apps-immediate-filter
712
(filter)="applyFilter($event)"
813
[placeholder]="'GROUP_DETAIL.SETTINGS.RELATIONS.FILTER'"></perun-web-apps-immediate-filter>
914
<div class="dialog-container" mat-dialog-content>
1015
<perun-web-apps-groups-list
16+
*ngIf="!loading"
1117
[authType]="'create-relation-dialog'"
1218
[groupsToDisableCheckbox]="groupsToDisable"
1319
[disableGroups]="true"
@@ -19,6 +25,7 @@ <h1 mat-dialog-title>{{"DIALOGS.CREATE_RELATION.TITLE" | translate}}</h1>
1925
[filter]="filterValue"
2026
[tableId]="tableId"></perun-web-apps-groups-list>
2127
</div>
28+
<mat-spinner *ngIf="loading" class="ml-auto mr-auto"></mat-spinner>
2229
<div mat-dialog-actions>
2330
<button (click)="onCancel()" class="ml-auto" mat-flat-button>
2431
{{'DIALOGS.CREATE_RELATION.CANCEL' | translate}}
@@ -27,7 +34,7 @@ <h1 mat-dialog-title>{{"DIALOGS.CREATE_RELATION.TITLE" | translate}}</h1>
2734
(click)="onSubmit()"
2835
class="ml-2"
2936
color="accent"
30-
[disabled]="loading || selection.selected.length === 0"
37+
[disabled]="loading || initLoading || selection.selected.length === 0"
3138
mat-flat-button>
3239
{{'DIALOGS.CREATE_RELATION.CREATE' | translate}}
3340
</button>

apps/admin-gui/src/app/shared/components/dialogs/create-relation-dialog/create-relation-dialog.component.ts

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
3-
import { Group, GroupsManagerService } from '@perun-web-apps/perun/openapi';
3+
import {
4+
EnrichedVo,
5+
Group,
6+
GroupsManagerService,
7+
Vo,
8+
VosManagerService,
9+
} from '@perun-web-apps/perun/openapi';
410
import { SelectionModel } from '@angular/cdk/collections';
511
import { GuiAuthResolver, NotificatorService } from '@perun-web-apps/perun/services';
612
import { TranslateService } from '@ngx-translate/core';
@@ -24,9 +30,13 @@ export class CreateRelationDialogComponent implements OnInit {
2430
groups: Group[];
2531
theme: string;
2632
filterValue = '';
33+
initLoading: boolean;
2734
loading: boolean;
2835
tableId = TABLE_CREATE_RELATION_GROUP_DIALOG;
36+
thisVo: EnrichedVo;
37+
groupsToNotInclude: number[];
2938
groupsToDisable: Set<number> = new Set<number>();
39+
vosToSelect: Vo[] = [];
3040
private successMessage: string;
3141

3242
constructor(
@@ -35,6 +45,7 @@ export class CreateRelationDialogComponent implements OnInit {
3545
private notificator: NotificatorService,
3646
private translate: TranslateService,
3747
private guiAuthResolver: GuiAuthResolver,
48+
private voService: VosManagerService,
3849
@Inject(MAT_DIALOG_DATA) public data: CreateRelationDialogData
3950
) {
4051
translate
@@ -43,23 +54,22 @@ export class CreateRelationDialogComponent implements OnInit {
4354
}
4455

4556
ngOnInit(): void {
46-
this.loading = true;
57+
this.initLoading = true;
4758
this.groupService.getGroupUnions(this.data.group.id, !this.data.reverse).subscribe(
4859
(unionGroups) => {
4960
unionGroups = unionGroups.concat(this.data.groups);
50-
this.groupService.getAllGroups(this.data.voId).subscribe(
51-
(allGroups) => {
52-
const groupIds = unionGroups.map((elem) => elem.id);
53-
this.groups = allGroups.filter(
54-
(group) => !groupIds.includes(group.id) && group.id !== this.data.group.id
55-
);
56-
this.setGroupsToDisable();
57-
this.loading = false;
58-
},
59-
() => (this.loading = false)
60-
);
61+
this.groupsToNotInclude = unionGroups.map((elem) => elem.id);
62+
this.voService.getEnrichedVoById(this.data.voId).subscribe((enrichedVo) => {
63+
this.thisVo = enrichedVo;
64+
this.vosToSelect = enrichedVo.memberVos.filter((vo) =>
65+
this.guiAuthResolver.isAuthorized('getAllAllowedGroupsToHierarchicalVo_Vo_policy', [vo])
66+
);
67+
this.vosToSelect.push(enrichedVo.vo);
68+
this.getGroupsToInclude(this.data.voId);
69+
this.initLoading = false;
70+
});
6171
},
62-
() => (this.loading = false)
72+
() => (this.initLoading = false)
6373
);
6474
this.theme = this.data.theme;
6575
}
@@ -68,6 +78,25 @@ export class CreateRelationDialogComponent implements OnInit {
6878
this.dialogRef.close(false);
6979
}
7080

81+
getGroupsToInclude(voId: number): void {
82+
this.loading = true;
83+
if (voId === this.data.voId) {
84+
this.groupService.getAllGroups(this.data.voId).subscribe(
85+
(allGroups) => {
86+
this.finishLoadingGroups(allGroups);
87+
},
88+
() => (this.loading = false)
89+
);
90+
} else {
91+
this.groupService.getVoAllAllowedGroupsToHierarchicalVo(this.data.voId, voId).subscribe(
92+
(groups) => {
93+
this.finishLoadingGroups(groups);
94+
},
95+
() => (this.loading = false)
96+
);
97+
}
98+
}
99+
71100
onSubmit(): void {
72101
this.loading = true;
73102
this.groupService.createGroupUnion(this.data.group.id, this.selection.selected[0].id).subscribe(
@@ -96,4 +125,13 @@ export class CreateRelationDialogComponent implements OnInit {
96125
}
97126
}
98127
}
128+
129+
private finishLoadingGroups(groups: Group[]): void {
130+
this.groups = groups.filter(
131+
(group) => !this.groupsToNotInclude.includes(group.id) && group.id !== this.data.group.id
132+
);
133+
this.setGroupsToDisable();
134+
this.selection.clear();
135+
this.loading = false;
136+
}
99137
}

apps/admin-gui/src/app/vos/pages/group-detail-page/group-settings/group-settings-relations/group-settings-relations.component.html

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
<div>
22
<h1 class="page-subtitle">{{'GROUP_DETAIL.SETTINGS.RELATIONS.TITLE' | translate}}</h1>
33
<perun-web-apps-refresh-button (refresh)="refreshTable()"></perun-web-apps-refresh-button>
4-
<button (click)="onCreate()" class="mr-2 action-button" color="accent" mat-flat-button>
5-
{{'GROUP_DETAIL.SETTINGS.RELATIONS.CREATE' | translate}}
6-
</button>
74
<button
8-
[disabled]="selection.selected.length === 0 || (this.list !== undefined && !this.list.removeAuth)"
9-
class="mr-2"
10-
color="warn"
11-
(click)="onDelete()"
12-
mat-flat-button
13-
[matTooltipDisabled]="selection.selected.length === 0 || (this.list !== undefined && this.list.removeAuth)"
14-
matTooltip="{{'GROUP_DETAIL.SETTINGS.RELATIONS.DELETE_TOOLTIP' | translate}}">
15-
{{'GROUP_DETAIL.SETTINGS.RELATIONS.DELETE' | translate}}
5+
(click)="onCreate()"
6+
class="mr-2 action-button"
7+
color="accent"
8+
[disabled]="reverse"
9+
mat-flat-button>
10+
{{'GROUP_DETAIL.SETTINGS.RELATIONS.CREATE' | translate}}
1611
</button>
12+
<span
13+
matTooltip="{{'GROUP_DETAIL.SETTINGS.RELATIONS.DELETE_TOOLTIP' | translate}}"
14+
[matTooltipDisabled]="selection.selected.length === 0 || (list !== undefined && list.removeAuth)">
15+
<button
16+
[disabled]="selection.selected.length === 0 || (list !== undefined && !list.removeAuth) || reverse"
17+
class="mr-2"
18+
color="warn"
19+
(click)="onDelete()"
20+
mat-flat-button>
21+
{{'GROUP_DETAIL.SETTINGS.RELATIONS.DELETE' | translate}}
22+
</button>
23+
</span>
1724
<perun-web-apps-immediate-filter
1825
(filter)="applyFilter($event)"
1926
[placeholder]="'GROUP_DETAIL.SETTINGS.RELATIONS.FILTER'"></perun-web-apps-immediate-filter>

apps/admin-gui/src/app/vos/pages/group-detail-page/group-settings/group-settings-relations/group-settings-relations.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ export class GroupSettingsRelationsComponent implements OnInit {
7979

8080
refreshTable(): void {
8181
this.loading = true;
82+
this.selection.clear();
8283
this.groupService.getGroupUnions(this.group.id, this.reverse).subscribe(
8384
(groups) => {
8485
this.groups = groups;
85-
this.selection.clear();
8686
this.loading = false;
8787
},
8888
() => (this.loading = false)

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@
712712
},
713713
"RELATIONS": {
714714
"TITLE": "Relations",
715-
"DELETE": "Remove selected",
715+
"DELETE": "Remove",
716716
"CREATE": "Add",
717717
"FILTER": "Filter by name, Id or description",
718718
"REVERSE_UNIONS": "Show reverse unions",

libs/perun/components/src/lib/groups-list/groups-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
[class.cursor-pointer]="!disableRouting && !groupsToDisableRouting.has(group.id)"
166166
[class.disable-outline]="disabledRouting || groupsToDisableRouting.has(group.id)"
167167
[perunWebAppsMiddleClickRouterLink]="(disabledRouting || groupsToDisableRouting.has(group.id)) ? null : ['/organizations', group.voId, 'groups', group.id]"
168-
[routerLink]="(disabledRouting || groupsToDisableRouting.has(group.id)) ? null : ['/organizations', group.voId, 'groups', group.id]"
168+
[perunWebAppsForceRouterLink]="(disabledRouting || groupsToDisableRouting.has(group.id)) ? null : ['/organizations', group.voId, 'groups', group.id]"
169169
class="dark-hover-list-item"
170170
mat-row></tr>
171171
</table>

0 commit comments

Comments
 (0)