Skip to content

Commit c9a5121

Browse files
KuliakJohaney-s
authored andcommitted
fix(admin): do not loop in vo groups reloading
* usage of filterValue replaced by filter in add-role-dialog * redundant filterValue Input removed * redundant methods from groups-list component removed
1 parent 74f311a commit c9a5121

File tree

2 files changed

+3
-53
lines changed

2 files changed

+3
-53
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ <h1 mat-dialog-title>{{'DIALOGS.ADD_ROLE.TITLE' | translate}}</h1>
2121
[disableRouting]="true">
2222
</perun-web-apps-vos-list>
2323
<perun-web-apps-groups-list
24-
[filterValue]="filterValue"
2524
*ngIf="!loading && selectedRule?.primaryObject === 'Group'"
2625
[groups]="groups | manageableEntities: selectedRule | unassignedRole: roles : selectedRule"
2726
[displayedColumns]="['select', 'id', 'vo', 'name', 'description']"
2827
[selection]="selected"
28+
[filter]="filterValue"
2929
[disableRouting]="true">
3030
</perun-web-apps-groups-list>
3131
<perun-web-apps-facilities-list

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

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
Component,
3-
EventEmitter,
4-
HostListener,
5-
Input,
6-
OnChanges,
7-
Output,
8-
ViewChild,
9-
} from '@angular/core';
1+
import { Component, EventEmitter, HostListener, Input, Output, ViewChild } from '@angular/core';
102
import {
113
ChangeGroupExpirationDialogComponent,
124
EditFacilityResourceGroupVoDialogComponent,
@@ -17,7 +9,6 @@ import {
179
Group,
1810
Member,
1911
PaginatedRichGroups,
20-
Vo,
2112
VosManagerService,
2213
} from '@perun-web-apps/perun/openapi';
2314
import { GuiAuthResolver, TableCheckbox } from '@perun-web-apps/perun/services';
@@ -51,10 +42,9 @@ import { GroupUtilsService } from '@perun-web-apps/perun/services';
5142
styleUrls: ['./groups-list.component.scss'],
5243
providers: [DisableGroupSelectPipe],
5344
})
54-
export class GroupsListComponent implements OnChanges {
45+
export class GroupsListComponent {
5546
@Input() theme = 'group-theme';
5647
@Input() selection = new SelectionModel<GroupWithStatus>(true, []);
57-
@Input() filterValue: string;
5848
@Input() disableMembers: boolean;
5949
@Input() disableGroups: boolean;
6050
@Input() groupsToDisableCheckbox: Set<number> = new Set<number>();
@@ -151,13 +141,6 @@ export class GroupsListComponent implements OnChanges {
151141
return this.groupUtils.getSortDataForColumn(data, column, this.voNames, this.recentIds);
152142
};
153143

154-
ngOnChanges(): void {
155-
if (!this.authResolver.isPerunAdminOrObserver()) {
156-
this.displayedColumns = this.displayedColumns.filter((column) => column !== 'id');
157-
}
158-
this.setDataSource();
159-
}
160-
161144
exportAllData(format: string): void {
162145
if (isDynamicDataSource(this.dataSource)) {
163146
this.downloadAll.emit({ format: format, length: this.dataSource.paginator.length });
@@ -299,39 +282,6 @@ export class GroupsListComponent implements OnChanges {
299282
);
300283
};
301284

302-
setDataSource(): void {
303-
if (!this.dataSource) {
304-
this.dataSource = new MatTableDataSource<GroupWithStatus>();
305-
this.dataSource.sort = this.sort;
306-
this.dataSource.paginator = this.tableWrapper.paginator;
307-
this.dataSource.filterPredicate = (data: Vo, filter: string): boolean =>
308-
customDataSourceFilterPredicate(
309-
data,
310-
filter,
311-
this.displayedColumns,
312-
this.getDataForColumnFun
313-
);
314-
this.dataSource.sortData = (data: GroupWithStatus[], sort: MatSort): GroupWithStatus[] =>
315-
customDataSourceSort(data, sort, this.getDataForColumnFun);
316-
}
317-
this.dataSource.filter = this.filterValue;
318-
319-
// if groups not loaded yet, skip
320-
if (!this.groups) {
321-
return;
322-
}
323-
324-
const paginated = this.isPaginated(this.groups);
325-
if (isDynamicDataSource(this.dataSource) || paginated) {
326-
this.dataSource.data = (this.groups as PaginatedRichGroups).data;
327-
(this.dataSource as DynamicDataSource<GroupWithStatus>).count = (
328-
this.groups as PaginatedRichGroups
329-
).totalCount;
330-
} else if (!isDynamicDataSource(this.dataSource) && !paginated) {
331-
this.dataSource.data = this.groups as GroupWithStatus[];
332-
}
333-
}
334-
335285
private dataSourceInit(groups: GroupWithStatus[] | PaginatedRichGroups): void {
336286
const paginated = this.isPaginated(groups);
337287

0 commit comments

Comments
 (0)