Skip to content

Commit fad1186

Browse files
xflordHejdaJakub
authored andcommitted
feat(admin): update User section Perun Admin menu
* 'Organizations' and 'Groups' pages were removed from the admin version of the 'User' section since information from both of these pages is contained in 'Accounts' * 'Resources' and 'Facilities' pages were merged into new 'Assignments' page that works similarly to 'Accounts' * Updated two entity attribute component to allow fixed second entity and did some necessary tweaks to allow displaying Member-Resource attributes per resource in fixed facility * Fixed a bug where the initial selected object didn't match the displayed attributes on two-entity attributes page * Aligned loading spinner on 'Accounts' page * Updated openapi DEPLOYMENT NOTE: Removed 'Organizations', 'Groups', 'Resources' and 'Facilities' from the admin version of the User section. Refer admins to 'Accounts' and new 'Assignments' page for info on entities
1 parent dadb546 commit fad1186

File tree

12 files changed

+437
-175
lines changed

12 files changed

+437
-175
lines changed

apps/admin-gui/src/app/admin/admin-routing.module.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,27 @@ import { UserDestinationGraphComponent } from './pages/admin-page/admin-visualiz
1111
import { AdminUsersComponent } from './pages/admin-page/admin-users/admin-users.component';
1212
import { AdminUserDetailPageComponent } from './pages/admin-user-detail-page/admin-user-detail-page.component';
1313
import { UserOverviewComponent } from '../users/pages/user-detail-page/user-overview/user-overview.component';
14-
import { UserOrganizationsComponent } from '../users/pages/user-detail-page/user-organizations/user-organizations.component';
15-
import { UserGroupsComponent } from '../users/pages/user-detail-page/user-groups/user-groups.component';
1614
import { UserAttributesComponent } from '../users/pages/user-detail-page/user-attributes/user-attributes.component';
1715
import { AdminExtSourcesComponent } from './pages/admin-page/admin-ext-sources/admin-ext-sources.component';
1816
import { UserRolesComponent } from '../users/pages/user-detail-page/user-settings/user-roles/user-roles.component';
1917
import { UserSettingsServiceIdentitiesComponent } from '../users/pages/user-detail-page/user-settings/user-settings-service-identities/user-settings-service-identities.component';
2018
import { UserIdentitiesComponent } from '../users/pages/user-detail-page/user-identities/user-identities.component';
2119
import { AdminServicesComponent } from './pages/admin-page/admin-services/admin-services.component';
22-
import { UserResourcesComponent } from '../users/pages/user-detail-page/user-resources/user-resources.component';
2320
import { IdentityDetailComponent } from '../shared/components/identity-detail/identity-detail.component';
2421
import { ServiceDetailPageComponent } from './pages/admin-page/admin-services/service-detail-page/service-detail-page.component';
2522
import { ServiceOverviewComponent } from './pages/admin-page/admin-services/service-detail-page/service-overview/service-overview.component';
2623
import { ServiceRequiredAttributesComponent } from './pages/admin-page/admin-services/service-detail-page/service-required-attributes/service-required-attributes.component';
2724
import { UserSettingsAssociatedUsersComponent } from '../users/pages/user-detail-page/user-settings/user-settings-associated-users/user-settings-associated-users.component';
2825
import { ServiceDestinationsComponent } from './pages/admin-page/admin-services/service-detail-page/service-destinations/service-destinations.component';
2926
import { AdminOwnersComponent } from './pages/admin-page/admin-owners/admin-owners.component';
30-
import { UserFacilitiesComponent } from '../users/pages/user-detail-page/user-facilities/user-facilities.component';
3127
import { UserAccountsComponent } from '../users/pages/user-detail-page/user-accounts/user-accounts.component';
3228
import { AdminAuditLogComponent } from './pages/admin-page/admin-audit-log/admin-audit-log.component';
3329
import { AdminConsentHubsComponent } from './pages/admin-page/admin-consent-hubs/admin-consent-hubs.component';
3430
import { AdminSearcherComponent } from './pages/admin-page/admin-searcher/admin-searcher.component';
3531
import { RouteAuthGuardService } from '../shared/route-auth-guard.service';
3632
import { UserBansComponent } from '../users/pages/user-detail-page/user-bans/user-bans.component';
3733
import { AdminBlockedLoginsComponent } from './pages/admin-page/admin-blocked-logins/admin-blocked-logins.component';
34+
import { UserAssignmentsComponent } from '../users/pages/user-detail-page/user-assignments/user-assignments.component';
3835

3936
const routes: Routes = [
4037
{
@@ -135,36 +132,21 @@ const routes: Routes = [
135132
component: UserAccountsComponent,
136133
data: { animation: 'UserAccountsPage' },
137134
},
135+
{
136+
path: 'assignments',
137+
component: UserAssignmentsComponent,
138+
data: { animation: 'UserAssignmentsPage' },
139+
},
138140
{
139141
path: 'attributes',
140142
component: UserAttributesComponent,
141143
data: { animation: 'UserAttributesPage' },
142144
},
143-
{
144-
path: 'organizations',
145-
component: UserOrganizationsComponent,
146-
data: { animation: 'UserOrganizationsPage', showPrincipal: false },
147-
},
148-
{
149-
path: 'groups',
150-
component: UserGroupsComponent,
151-
data: { animation: 'UserGroupsPage', showPrincipal: false },
152-
},
153145
{
154146
path: 'identities',
155147
component: UserIdentitiesComponent,
156148
data: { animation: 'UserIdentitiesPage' },
157149
},
158-
{
159-
path: 'facilities',
160-
component: UserFacilitiesComponent,
161-
data: { animation: 'UserFacilitiesPage' },
162-
},
163-
{
164-
path: 'resources',
165-
component: UserResourcesComponent,
166-
data: { animation: 'UserRoles' },
167-
},
168150
{
169151
path: 'identities/:identityId',
170152
component: IdentityDetailComponent,

apps/admin-gui/src/app/shared/components/two-entity-attribute-page/two-entity-attribute-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
>
88

99
<div *ngIf="entityValues.length !== 0">
10-
<div class="flex-row">
10+
<div *ngIf="showSelect" class="flex-row">
1111
<perun-web-apps-group-search-select
1212
*ngIf="secondEntity === 'group'"
1313
(groupSelected)="specifySecondEntity($event)"

apps/admin-gui/src/app/shared/components/two-entity-attribute-page/two-entity-attribute-page.component.ts

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ import {
1111
ResourcesManagerService,
1212
RichMember,
1313
User,
14+
UsersManagerService,
1415
} from '@perun-web-apps/perun/openapi';
1516
import { MatDialog } from '@angular/material/dialog';
1617
import { AttributesListComponent } from '@perun-web-apps/perun/components';
1718
import { SelectionModel } from '@angular/cdk/collections';
1819
import { DeleteAttributeDialogComponent } from '../dialogs/delete-attribute-dialog/delete-attribute-dialog.component';
19-
import { getDefaultDialogConfig, getRecentlyVisitedIds } from '@perun-web-apps/perun/utils';
20+
import {
21+
compareFnName,
22+
compareFnUser,
23+
getDefaultDialogConfig,
24+
getRecentlyVisitedIds,
25+
} from '@perun-web-apps/perun/utils';
2026
import { EditAttributeDialogComponent } from '@perun-web-apps/perun/dialogs';
2127
import { CreateAttributeDialogComponent } from '../dialogs/create-attribute-dialog/create-attribute-dialog.component';
2228
import { Urns } from '@perun-web-apps/perun/urns';
@@ -32,27 +38,31 @@ export class TwoEntityAttributePageComponent implements OnInit {
3238
@Input() firstEntityId: number;
3339
@Input() firstEntity: string;
3440
@Input() secondEntity: string;
41+
@Input() specificSecondEntity: Resource | Facility | Group | RichMember | User = null;
42+
@Input() facilityId: number;
3543
entityValues: Resource[] | Facility[] | Group[] | RichMember[] | User[] = [];
3644
attributes: Attribute[] = [];
3745
selection = new SelectionModel<Attribute>(true, []);
38-
specificSecondEntity: Resource | Facility | Group | RichMember | User;
3946
allowedStatuses: string[] = ['INVALID', 'VALID'];
4047
loading = false;
4148
innerLoading = false;
4249
filterValue = '';
4350
filterEmpty = true;
4451
noEntityMessage: string;
52+
showSelect = true;
4553

4654
constructor(
4755
private attributesManagerService: AttributesManagerService,
4856
private resourcesManagerService: ResourcesManagerService,
4957
private facilitiesManagerService: FacilitiesManagerService,
5058
private groupsManagerService: GroupsManagerService,
5159
private membersManager: MembersManagerService,
60+
private usersManager: UsersManagerService,
5261
private dialog: MatDialog
5362
) {}
5463

5564
ngOnInit(): void {
65+
this.showSelect = this.specificSecondEntity === null;
5666
this.loadEntityValues();
5767
this.setMessages(this.secondEntity.toLowerCase());
5868
}
@@ -113,13 +123,26 @@ export class TwoEntityAttributePageComponent implements OnInit {
113123
}
114124
break;
115125
case 'user':
116-
this.facilitiesManagerService
117-
.getAssignedFacilitiesByUser(this.firstEntityId)
118-
.subscribe((facilities) => {
119-
this.entityValues = facilities;
120-
this.preselectEntity();
121-
this.loading = false;
122-
});
126+
switch (this.secondEntity) {
127+
case 'resource':
128+
this.usersManager
129+
.getAssociatedResourcesForUser(this.facilityId, this.firstEntityId)
130+
.subscribe((resources) => {
131+
this.entityValues = resources;
132+
this.preselectEntity();
133+
this.loading = false;
134+
});
135+
break;
136+
default:
137+
this.facilitiesManagerService
138+
.getAssignedFacilitiesByUser(this.firstEntityId)
139+
.subscribe((facilities) => {
140+
this.entityValues = facilities;
141+
this.preselectEntity();
142+
this.loading = false;
143+
});
144+
break;
145+
}
123146
break;
124147
case 'resource':
125148
switch (this.secondEntity) {
@@ -158,13 +181,18 @@ export class TwoEntityAttributePageComponent implements OnInit {
158181
}
159182

160183
preselectEntity(): void {
161-
if (this.entityValues.length !== 0) {
184+
if (this.specificSecondEntity !== null) {
185+
this.specifySecondEntity(this.specificSecondEntity);
186+
} else if (this.entityValues.length !== 0) {
162187
this.findInitiallySelectedEntity();
163188
}
164189
}
165190

166191
findInitiallySelectedEntity(): void {
167-
let initialEntity = this.entityValues[0];
192+
let initialEntity =
193+
this.secondEntity === 'member' || this.secondEntity === 'user'
194+
? this.entityValues.sort(compareFnUser)[0]
195+
: this.entityValues.sort(compareFnName)[0];
168196
const recentIds = getRecentlyVisitedIds(this.entityKey());
169197
if (recentIds) {
170198
for (const entity of this.entityValues) {
@@ -231,12 +259,28 @@ export class TwoEntityAttributePageComponent implements OnInit {
231259
}
232260
break;
233261
case 'user':
234-
this.attributesManagerService
235-
.getUserFacilityAttributes(this.firstEntityId, entityId)
236-
.subscribe((attributes) => {
237-
this.attributes = attributes;
238-
this.innerLoading = false;
239-
});
262+
switch (this.secondEntity) {
263+
case 'resource':
264+
this.membersManager
265+
.getMemberByUser((this.specificSecondEntity as Resource).voId, this.firstEntityId)
266+
.subscribe((member) => {
267+
this.attributesManagerService
268+
.getMemberResourceAttributes(member.id, entityId)
269+
.subscribe((attributes) => {
270+
this.attributes = attributes;
271+
this.innerLoading = false;
272+
});
273+
});
274+
break;
275+
default:
276+
this.attributesManagerService
277+
.getUserFacilityAttributes(this.firstEntityId, entityId)
278+
.subscribe((attributes) => {
279+
this.attributes = attributes;
280+
this.innerLoading = false;
281+
});
282+
break;
283+
}
240284
break;
241285
case 'resource':
242286
switch (this.secondEntity) {

apps/admin-gui/src/app/shared/side-menu/side-menu-item.service.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -628,48 +628,27 @@ export class SideMenuItemService {
628628
activatedRegex: `${regex}$`,
629629
});
630630

631-
// Organizations
632-
links.push({
633-
label: 'MENU_ITEMS.ADMIN.ORGANIZATIONS',
634-
url: [`${path}/organizations`],
635-
activatedRegex: `${regex}/organizations`,
636-
});
637-
638-
// Groups
639-
links.push({
640-
label: 'MENU_ITEMS.ADMIN.GROUPS',
641-
url: [`${path}/groups`],
642-
activatedRegex: `${regex}/groups`,
643-
});
644-
645631
// Accounts
646632
links.push({
647633
label: 'MENU_ITEMS.USER.ACCOUNTS',
648634
url: [`${path}/accounts`],
649635
activatedRegex: `${regex}/accounts`,
650636
});
651637

638+
// Assignments
639+
links.push({
640+
label: 'MENU_ITEMS.USER.ASSIGNMENTS',
641+
url: [`${path}/assignments`],
642+
activatedRegex: `${regex}/assignments`,
643+
});
644+
652645
// Identities
653646
links.push({
654647
label: 'MENU_ITEMS.USER.IDENTITIES',
655648
url: [`${path}/identities`],
656649
activatedRegex: `${regex}/identities`,
657650
});
658651

659-
// Facilities
660-
links.push({
661-
label: 'MENU_ITEMS.USER.FACILITIES',
662-
url: [`${path}/facilities`],
663-
activatedRegex: `${regex}/facilities`,
664-
});
665-
666-
// Resources
667-
links.push({
668-
label: 'MENU_ITEMS.USER.RESOURCES',
669-
url: [`${path}/resources`],
670-
activatedRegex: `${regex}/resources`,
671-
});
672-
673652
// Attributes
674653
links.push({
675654
label: 'MENU_ITEMS.MEMBER.ATTRIBUTES',

0 commit comments

Comments
 (0)