Skip to content

Commit 8bf8db2

Browse files
xkureckbodnara
authored andcommitted
feat(admin): anonymize user
* on user detail added new functionality of anonymizing the user
1 parent 3d1d69d commit 8bf8db2

29 files changed

+267
-89
lines changed

apps/admin-gui/src/app/admin/pages/admin-user-detail-page/admin-user-detail-page.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
{{user | userFullName}}
1515
</a>
1616
<span class="text-muted"> &nbsp;#{{user.id}} </span>
17-
<button (click)="editUser()" *ngIf="authResolver.isPerunAdmin()" mat-icon-button>
18-
<mat-icon>edit</mat-icon>
19-
</button>
17+
<span *ngIf="authResolver.isPerunAdmin()">
18+
<button (click)="editUser()" mat-icon-button>
19+
<mat-icon>edit</mat-icon>
20+
</button>
21+
<button (click)="anonymizeUser()" mat-icon-button>
22+
<mat-icon>no_accounts</mat-icon>
23+
</button>
24+
</span>
2025
</div>
2126
<div>{{'ADMIN_USER.UUID' | translate}}: {{user.uuid}}</div>
2227
<span class="mt-1 entity-info">

apps/admin-gui/src/app/admin/pages/admin-user-detail-page/admin-user-detail-page.component.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { ActivatedRoute } from '@angular/router';
2+
import { ActivatedRoute, Router } from '@angular/router';
33
import { SideMenuService } from '../../../core/services/common/side-menu.service';
44
import { SideMenuItemService } from '../../../shared/side-menu/side-menu-item.service';
55
import { User, UsersManagerService } from '@perun-web-apps/perun/openapi';
66
import { getDefaultDialogConfig } from '@perun-web-apps/perun/utils';
77
import { MatDialog } from '@angular/material/dialog';
88
import { EditUserDialogComponent } from '../../../shared/components/dialogs/edit-user-dialog/edit-user-dialog.component';
99
import { EntityStorageService, GuiAuthResolver } from '@perun-web-apps/perun/services';
10+
import { AnonymizeUserDialogComponent } from '@perun-web-apps/perun/dialogs';
1011

1112
@Component({
1213
selector: 'app-admin-user-detail-page',
@@ -27,7 +28,8 @@ export class AdminUserDetailPageComponent implements OnInit {
2728
private sideMenuItemService: SideMenuItemService,
2829
private dialog: MatDialog,
2930
public authResolver: GuiAuthResolver,
30-
private entityStorageService: EntityStorageService
31+
private entityStorageService: EntityStorageService,
32+
private router: Router
3133
) {}
3234

3335
ngOnInit(): void {
@@ -80,4 +82,21 @@ export class AdminUserDetailPageComponent implements OnInit {
8082
}
8183
return 'Person';
8284
}
85+
86+
anonymizeUser(): void {
87+
const config = getDefaultDialogConfig();
88+
config.width = '550px';
89+
config.data = {
90+
theme: 'admin-theme',
91+
user: this.user,
92+
};
93+
94+
const dialogRef = this.dialog.open(AnonymizeUserDialogComponent, config);
95+
96+
dialogRef.afterClosed().subscribe((result) => {
97+
if (result) {
98+
void this.router.navigate(['/admin', 'users'], { queryParamsHandling: 'merge' });
99+
}
100+
});
101+
}
83102
}

apps/admin-gui/src/app/shared/components/dialogs/delete-entity-dialog/delete-entity-dialog.component.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="{{theme}}">
2-
<app-delete-entity-dialog
2+
<perun-web-apps-delete-entity-dialog
33
[entityNames]="dataSource"
44
[entityType]="'facilities'"
55
(deleted)="onSubmit($event)"
66
[loading]="loading"
77
[relations]="relations">
8-
</app-delete-entity-dialog>
8+
</perun-web-apps-delete-entity-dialog>
99
</div>

apps/admin-gui/src/app/shared/components/dialogs/delete-facility-dialog/delete-facility-dialog.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
44
import { NotificatorService } from '@perun-web-apps/perun/services';
55
import { TranslateService } from '@ngx-translate/core';
66
import { MatTableDataSource } from '@angular/material/table';
7+
import { DeleteDialogResult } from '@perun-web-apps/perun/dialogs';
78

89
export interface DeleteFacilityDialogData {
910
theme: string;
@@ -58,7 +59,7 @@ export class DeleteFacilityDialogComponent implements OnInit {
5859
this.dialogRef.close(false);
5960
}
6061

61-
onSubmit(result: { deleted: boolean; force: boolean }): void {
62+
onSubmit(result: DeleteDialogResult): void {
6263
this.force = result.force;
6364
if (result.deleted) {
6465
this.onConfirm();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="{{theme}}">
2-
<app-delete-entity-dialog
2+
<perun-web-apps-delete-entity-dialog
33
[entityNames]="dataSource"
44
[entityType]="'groups'"
55
(deleted)="onSubmit($event)"
66
[loading]="loading"
77
[relations]="relations">
8-
</app-delete-entity-dialog>
8+
</perun-web-apps-delete-entity-dialog>
99
</div>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table';
44
import { TranslateService } from '@ngx-translate/core';
55
import { NotificatorService } from '@perun-web-apps/perun/services';
66
import { Group, GroupsManagerService } from '@perun-web-apps/perun/openapi';
7+
import { DeleteDialogResult } from '@perun-web-apps/perun/dialogs';
78

89
export interface DeleteGroupDialogData {
910
theme: string;
@@ -60,7 +61,7 @@ export class DeleteGroupDialogComponent implements OnInit {
6061
);
6162
}
6263

63-
onSubmit(result: { deleted: boolean; force: boolean }): void {
64+
onSubmit(result: DeleteDialogResult): void {
6465
this.force = result.force;
6566
if (result.deleted) {
6667
this.onDelete();
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div class="{{theme}}">
2-
<app-delete-entity-dialog
2+
<perun-web-apps-delete-entity-dialog
33
[entityNames]="dataSource"
44
[entityType]="'services'"
55
(deleted)="onSubmit($event)"
66
[anotherMessage]="anotherMessage"
77
[loading]="loading"
88
[relations]="relations">
9-
</app-delete-entity-dialog>
9+
</perun-web-apps-delete-entity-dialog>
1010
</div>

apps/admin-gui/src/app/shared/components/dialogs/delete-service-dialog/delete-service-dialog.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
44
import { NotificatorService } from '@perun-web-apps/perun/services';
55
import { TranslateService } from '@ngx-translate/core';
66
import { MatTableDataSource } from '@angular/material/table';
7+
import { DeleteDialogResult } from '@perun-web-apps/perun/dialogs';
78

89
export interface DeleteServiceDialogData {
910
theme: string;
@@ -65,7 +66,7 @@ export class DeleteServiceDialogComponent implements OnInit {
6566
this.dialogRef.close(false);
6667
}
6768

68-
onSubmit(result: { deleted: boolean; force: boolean }): void {
69+
onSubmit(result: DeleteDialogResult): void {
6970
this.force = result.force;
7071
if (result.deleted) {
7172
this.onConfirm();
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="{{theme}}">
2-
<app-delete-entity-dialog
2+
<perun-web-apps-delete-entity-dialog
33
[entityNames]="dataSource"
44
[entityType]="'resources'"
55
(deleted)="onSubmit($event)"
66
[disableForce]="true"
77
[loading]="loading">
8-
</app-delete-entity-dialog>
8+
</perun-web-apps-delete-entity-dialog>
99
</div>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table';
44
import { NotificatorService } from '@perun-web-apps/perun/services';
55
import { TranslateService } from '@ngx-translate/core';
66
import { ResourcesManagerService, RichResource } from '@perun-web-apps/perun/openapi';
7+
import { DeleteDialogResult } from '@perun-web-apps/perun/dialogs';
78

89
export interface RemoveResourceDialogData {
910
theme: string;
@@ -59,7 +60,7 @@ export class RemoveResourceDialogComponent implements OnInit {
5960
}
6061
}
6162

62-
onSubmit(result: { deleted: boolean; force: boolean }): void {
63+
onSubmit(result: DeleteDialogResult): void {
6364
if (result.deleted) {
6465
this.onDelete();
6566
} else {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="{{theme}}">
2-
<app-delete-entity-dialog
2+
<perun-web-apps-delete-entity-dialog
33
(deleted)="onSubmit($event)"
44
[entityNames]="dataSource"
55
[entityType]="'organizations'"
66
[loading]="loading"
77
[relations]="relations">
8-
</app-delete-entity-dialog>
8+
</perun-web-apps-delete-entity-dialog>
99
</div>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table';
44
import { TranslateService } from '@ngx-translate/core';
55
import { NotificatorService } from '@perun-web-apps/perun/services';
66
import { Vo, VosManagerService } from '@perun-web-apps/perun/openapi';
7+
import { DeleteDialogResult } from '@perun-web-apps/perun/dialogs';
78

89
export interface RemoveVoDialogData {
910
vos: Vo[];
@@ -61,7 +62,7 @@ export class RemoveVoDialogComponent implements OnInit {
6162
);
6263
}
6364

64-
onSubmit(result: { deleted: boolean; force: boolean }): void {
65+
onSubmit(result: DeleteDialogResult): void {
6566
this.force = result.force;
6667
if (result.deleted) {
6768
this.onDelete();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ import { DeleteOwnerDialogComponent } from './components/delete-owner-dialog/del
154154
import { StatisticsCardComponent } from './components/statistics-card/statistics-card.component';
155155
import { ApplicationFormItemDisabledPipe } from './pipes/application-form-item-disabled.pipe';
156156
import { ApplicationFormItemHiddenPipe } from './pipes/application-form-item-hidden.pipe';
157-
import { DeleteEntityDialogComponent } from './components/dialogs/delete-entity-dialog/delete-entity-dialog.component';
158157
import { MatListModule } from '@angular/material/list';
159158
import { EditApplicationFormItemLineComponent } from './components/dialogs/edit-application-form-item-dialog/edit-application-form-item-line/edit-application-form-item-line.component';
160159
import { AddGroupToRegistrationComponent } from './components/dialogs/add-group-to-registration/add-group-to-registration.component';
@@ -172,6 +171,7 @@ import { ConsentHubsListComponent } from './components/consent-hubs-list/consent
172171
import { EditEnforceConsentsDialogComponent } from './components/dialogs/edit-enforce-consents-dialog/edit-enforce-consents-dialog.component';
173172
import { ConsentRelatedAttributePipe } from './pipes/consent-related-attribute.pipe';
174173
import { MemberTypePipe } from './pipes/member-type.pipe';
174+
import { PerunDialogsModule } from '@perun-web-apps/perun/dialogs';
175175

176176
@NgModule({
177177
imports: [
@@ -222,6 +222,7 @@ import { MemberTypePipe } from './pipes/member-type.pipe';
222222
MatListModule,
223223
PerunUtilsModule,
224224
PerunNamespacePasswordFormModule,
225+
PerunDialogsModule,
225226
],
226227
exports: [
227228
NgxMatSelectSearchModule,
@@ -423,7 +424,6 @@ import { MemberTypePipe } from './pipes/member-type.pipe';
423424
StatisticsCardComponent,
424425
ApplicationFormItemDisabledPipe,
425426
ApplicationFormItemHiddenPipe,
426-
DeleteEntityDialogComponent,
427427
EditApplicationFormItemLineComponent,
428428
AddGroupToRegistrationComponent,
429429
OneEntityAttributePageComponent,

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,15 +2043,22 @@
20432043
"SUCCESS": "Owners successfully removed"
20442044
},
20452045
"DELETE_ENTITY": {
2046-
"BASIC": "Do you want to delete",
2046+
"BASIC": "Do you want to {{action}}",
20472047
"ONLY": "only this",
20482048
"OR": "or",
20492049
"RELATIONS": "with all relations",
2050-
"DELETE": "Delete",
2050+
"DELETE": "{{action}}",
20512051
"CANCEL": "Cancel",
2052-
"CONTROL": "Type \"DELETE\" to confirm",
2053-
"ASK": "Are you sure you want to permanently delete following",
2054-
"WARN": "This action will also delete all"
2052+
"CONTROL": "Type \"{{action}}\" to confirm",
2053+
"ASK": "Are you sure you want to permanently {{action}} following",
2054+
"WARN": "This action will also delete all",
2055+
"TYPE_DELETE": "delete",
2056+
"TYPE_ANONYMIZE": "anonymize"
2057+
},
2058+
"ANONYMIZE_USER": {
2059+
"VO_RELATION": "User's membership in all organizations",
2060+
"GROUP_RELATION": "User's membership in all groups",
2061+
"SUCCESS_NOTIFICATION": "User was successfully anonymized"
20552062
},
20562063
"CHANGE_VO_EXPIRATION": {
20572064
"TITLE": "Change member expiration"

libs/perun/dialogs/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export * from './lib/change-vo-expiration-dialog/change-vo-expiration-dialog.com
1919
export * from './lib/change-sponsorship-expiration-dialog/change-sponsorship-expiration-dialog.component';
2020
export * from './lib/universal-confirmation-dialog/universal-confirmation-dialog.component';
2121
export * from './lib/change-group-resource-assigment-dialog/change-group-resource-assigment-dialog.component';
22+
export * from './lib/delete-entity-dialog/delete-entity-dialog.component';
23+
export * from './lib/anonymize-user-dialog/anonymize-user-dialog.component';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="{{theme}}">
2+
<perun-web-apps-delete-entity-dialog
3+
[entityNames]="dataSource"
4+
[entityType]="'user'"
5+
[relations]="relations"
6+
[loading]="loading"
7+
[anonymize]="true"
8+
(deleted)="onSubmit($event)">
9+
</perun-web-apps-delete-entity-dialog>
10+
</div>

libs/perun/dialogs/src/lib/anonymize-user-dialog/anonymize-user-dialog.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)