1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02:00

Use UserNamePipe (#1085)

This commit is contained in:
Oscar Hinton 2021-07-19 10:47:34 +02:00 committed by GitHub
parent 87d37dd29e
commit d85ee9780f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 43 deletions

View File

@ -35,7 +35,7 @@
</thead> </thead>
<tr *ngFor="let user of filteredUsers"> <tr *ngFor="let user of filteredUsers">
<td width="30"> <td width="30">
<app-avatar [data]="user.name || user.email" [email]="user.email" size="25" [circle]="true" <app-avatar [data]="user | userName" [email]="user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>
@ -48,7 +48,7 @@
</tr> </tr>
<tr *ngFor="let user of excludedUsers"> <tr *ngFor="let user of excludedUsers">
<td width="30"> <td width="30">
<app-avatar [data]="user.name || user.email" [email]="user.email" size="25" [circle]="true" <app-avatar [data]="user | userName" [email]="user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>
@ -71,7 +71,7 @@
</thead> </thead>
<tr *ngFor="let user of filteredUsers"> <tr *ngFor="let user of filteredUsers">
<td width="30"> <td width="30">
<app-avatar [data]="user.name || user.email" [email]="user.email" size="25" [circle]="true" <app-avatar [data]="user | userName" [email]="user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -32,7 +32,7 @@
</thead> </thead>
<tr *ngFor="let user of users"> <tr *ngFor="let user of users">
<td width="30"> <td width="30">
<app-avatar [data]="user.name || user.email" [email]="user.email" size="25" [circle]="true" <app-avatar [data]="user | userName" [email]="user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>
@ -52,7 +52,7 @@
</thead> </thead>
<tr *ngFor="let user of users"> <tr *ngFor="let user of users">
<td width="30"> <td width="30">
<app-avatar [data]="user.name || user.email" [email]="user.email" size="25" [circle]="true" <app-avatar [data]="user | userName" [email]="user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -23,7 +23,7 @@
</thead> </thead>
<tr *ngFor="let item of users"> <tr *ngFor="let item of users">
<td width="30"> <td width="30">
<app-avatar [data]="item.user.name || item.user.email" [email]="item.user.email" size="25" [circle]="true" <app-avatar [data]="item.user | userName" [email]="item.user.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -11,6 +11,8 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { EventService } from '../../services/event.service'; import { EventService } from '../../services/event.service';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { EventResponse } from 'jslib-common/models/response/eventResponse'; import { EventResponse } from 'jslib-common/models/response/eventResponse';
import { ListResponse } from 'jslib-common/models/response/listResponse'; import { ListResponse } from 'jslib-common/models/response/listResponse';
@ -38,7 +40,8 @@ export class EntityEventsComponent implements OnInit {
private orgUsersIdMap = new Map<string, any>(); private orgUsersIdMap = new Map<string, any>();
constructor(private apiService: ApiService, private i18nService: I18nService, constructor(private apiService: ApiService, private i18nService: I18nService,
private eventService: EventService, private toasterService: ToasterService) { } private eventService: EventService, private toasterService: ToasterService,
private userNamePipe: UserNamePipe) { }
async ngOnInit() { async ngOnInit() {
const defaultDates = this.eventService.getDefaultDateFilters(); const defaultDates = this.eventService.getDefaultDateFilters();
@ -51,7 +54,7 @@ export class EntityEventsComponent implements OnInit {
if (this.showUser) { if (this.showUser) {
const response = await this.apiService.getOrganizationUsers(this.organizationId); const response = await this.apiService.getOrganizationUsers(this.organizationId);
response.data.forEach(u => { response.data.forEach(u => {
const name = u.name == null || u.name.trim() === '' ? u.email : u.name; const name = this.userNamePipe.transform(u);
this.orgUsersIdMap.set(u.id, { name: name, email: u.email }); this.orgUsersIdMap.set(u.id, { name: name, email: u.email });
this.orgUsersUserIdMap.set(u.userId, { name: name, email: u.email }); this.orgUsersUserIdMap.set(u.userId, { name: name, email: u.email });
}); });

View File

@ -61,7 +61,7 @@
(change)="selectedChanged(u)" appStopProp> (change)="selectedChanged(u)" appStopProp>
</td> </td>
<td width="30" (click)="check(u)"> <td width="30" (click)="check(u)">
<app-avatar [data]="u.name || u.email" [email]="u.email" size="25" [circle]="true" <app-avatar [data]="u | userName" [email]="u.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -6,14 +6,14 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { ApiService } from 'jslib-common/abstractions/api.service'; import { ApiService } from 'jslib-common/abstractions/api.service';
import { ExportService } from 'jslib-common/abstractions/export.service'; import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service'; import { UserService } from 'jslib-common/abstractions/user.service';
import { EventResponse } from 'jslib-common/models/response/eventResponse';
import { ListResponse } from 'jslib-common/models/response/listResponse';
import { EventView } from 'jslib-common/models/view/eventView'; import { EventView } from 'jslib-common/models/view/eventView';
import { EventService } from '../../services/event.service'; import { EventService } from '../../services/event.service';
@ -41,7 +41,7 @@ export class EventsComponent implements OnInit {
constructor(private apiService: ApiService, private route: ActivatedRoute, private eventService: EventService, constructor(private apiService: ApiService, private route: ActivatedRoute, private eventService: EventService,
private i18nService: I18nService, private toasterService: ToasterService, private userService: UserService, private i18nService: I18nService, private toasterService: ToasterService, private userService: UserService,
private exportService: ExportService, private platformUtilsService: PlatformUtilsService, private exportService: ExportService, private platformUtilsService: PlatformUtilsService,
private router: Router) { } private router: Router, private userNamePipe: UserNamePipe) { }
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => { this.route.parent.parent.params.subscribe(async params => {
@ -61,7 +61,7 @@ export class EventsComponent implements OnInit {
async load() { async load() {
const response = await this.apiService.getOrganizationUsers(this.organizationId); const response = await this.apiService.getOrganizationUsers(this.organizationId);
response.data.forEach(u => { response.data.forEach(u => {
const name = u.name == null || u.name.trim() === '' ? u.email : u.name; const name = this.userNamePipe.transform(u);
this.orgUsersIdMap.set(u.id, { name: name, email: u.email }); this.orgUsersIdMap.set(u.id, { name: name, email: u.email });
this.orgUsersUserIdMap.set(u.userId, { name: name, email: u.email }); this.orgUsersUserIdMap.set(u.userId, { name: name, email: u.email });
}); });

View File

@ -80,7 +80,7 @@
<input type="checkbox" [(ngModel)]="u.checked" appStopProp> <input type="checkbox" [(ngModel)]="u.checked" appStopProp>
</td> </td>
<td width="30"> <td width="30">
<app-avatar [data]="u.name || u.email" [email]="u.email" size="25" [circle]="true" <app-avatar [data]="u | userName" [email]="u.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -39,6 +39,7 @@ import { OrganizationUserType } from 'jslib-common/enums/organizationUserType';
import { PolicyType } from 'jslib-common/enums/policyType'; import { PolicyType } from 'jslib-common/enums/policyType';
import { SearchPipe } from 'jslib-angular/pipes/search.pipe'; import { SearchPipe } from 'jslib-angular/pipes/search.pipe';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { Utils } from 'jslib-common/misc/utils'; import { Utils } from 'jslib-common/misc/utils';
@ -99,7 +100,7 @@ export class PeopleComponent implements OnInit {
private cryptoService: CryptoService, private userService: UserService, private router: Router, private cryptoService: CryptoService, private userService: UserService, private router: Router,
private storageService: StorageService, private searchService: SearchService, private storageService: StorageService, private searchService: SearchService,
private validationService: ValidationService, private policyService: PolicyService, private validationService: ValidationService, private policyService: PolicyService,
private searchPipe: SearchPipe, private syncService: SyncService) { } private searchPipe: SearchPipe, private userNamePipe: UserNamePipe, private syncService: SyncService) { }
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => { this.route.parent.parent.params.subscribe(async params => {
@ -258,7 +259,7 @@ export class PeopleComponent implements OnInit {
const childComponent = this.modal.show<UserAddEditComponent>( const childComponent = this.modal.show<UserAddEditComponent>(
UserAddEditComponent, this.addEditModalRef); UserAddEditComponent, this.addEditModalRef);
childComponent.name = user != null ? user.name || user.email : null; childComponent.name = this.userNamePipe.transform(user);
childComponent.organizationId = this.organizationId; childComponent.organizationId = this.organizationId;
childComponent.organizationUserId = user != null ? user.id : null; childComponent.organizationUserId = user != null ? user.id : null;
childComponent.onSavedUser.subscribe(() => { childComponent.onSavedUser.subscribe(() => {
@ -289,7 +290,7 @@ export class PeopleComponent implements OnInit {
const childComponent = this.modal.show<UserGroupsComponent>( const childComponent = this.modal.show<UserGroupsComponent>(
UserGroupsComponent, this.groupsModalRef); UserGroupsComponent, this.groupsModalRef);
childComponent.name = user != null ? user.name || user.email : null; childComponent.name = this.userNamePipe.transform(user);
childComponent.organizationId = this.organizationId; childComponent.organizationId = this.organizationId;
childComponent.organizationUserId = user != null ? user.id : null; childComponent.organizationUserId = user != null ? user.id : null;
childComponent.onSavedUser.subscribe(() => { childComponent.onSavedUser.subscribe(() => {
@ -303,7 +304,7 @@ export class PeopleComponent implements OnInit {
async remove(user: OrganizationUserUserDetailsResponse) { async remove(user: OrganizationUserUserDetailsResponse) {
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('removeUserConfirmation'), user.name || user.email, this.i18nService.t('removeUserConfirmation'), this.userNamePipe.transform(user),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
if (!confirmed) { if (!confirmed) {
return false; return false;
@ -312,7 +313,7 @@ export class PeopleComponent implements OnInit {
this.actionPromise = this.apiService.deleteOrganizationUser(this.organizationId, user.id); this.actionPromise = this.apiService.deleteOrganizationUser(this.organizationId, user.id);
try { try {
await this.actionPromise; await this.actionPromise;
this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', user.name || user.email)); this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', this.userNamePipe.transform(user)));
this.removeUser(user); this.removeUser(user);
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
@ -328,7 +329,7 @@ export class PeopleComponent implements OnInit {
this.actionPromise = this.apiService.postOrganizationUserReinvite(this.organizationId, user.id); this.actionPromise = this.apiService.postOrganizationUserReinvite(this.organizationId, user.id);
try { try {
await this.actionPromise; await this.actionPromise;
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenReinvited', user.name || user.email)); this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenReinvited', this.userNamePipe.transform(user)));
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
} }
@ -419,7 +420,7 @@ export class PeopleComponent implements OnInit {
this.actionPromise = this.doConfirmation(user, publicKey); this.actionPromise = this.doConfirmation(user, publicKey);
await this.actionPromise; await this.actionPromise;
updateUser(this); updateUser(this);
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', user.name || user.email)); this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', this.userNamePipe.transform(user)));
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
throw e; throw e;
@ -443,7 +444,7 @@ export class PeopleComponent implements OnInit {
const childComponent = this.modal.show<UserConfirmComponent>( const childComponent = this.modal.show<UserConfirmComponent>(
UserConfirmComponent, this.confirmModalRef); UserConfirmComponent, this.confirmModalRef);
childComponent.name = user != null ? user.name || user.email : null; childComponent.name = this.userNamePipe.transform(user);
childComponent.organizationId = this.organizationId; childComponent.organizationId = this.organizationId;
childComponent.organizationUserId = user != null ? user.id : null; childComponent.organizationUserId = user != null ? user.id : null;
childComponent.userId = user != null ? user.userId : null; childComponent.userId = user != null ? user.userId : null;
@ -488,7 +489,7 @@ export class PeopleComponent implements OnInit {
const childComponent = this.modal.show<EntityEventsComponent>( const childComponent = this.modal.show<EntityEventsComponent>(
EntityEventsComponent, this.eventsModalRef); EntityEventsComponent, this.eventsModalRef);
childComponent.name = user.name || user.email; childComponent.name = this.userNamePipe.transform(user);
childComponent.organizationId = this.organizationId; childComponent.organizationId = this.organizationId;
childComponent.entityId = user.id; childComponent.entityId = user.id;
childComponent.showUser = false; childComponent.showUser = false;
@ -526,7 +527,7 @@ export class PeopleComponent implements OnInit {
const childComponent = this.modal.show<ResetPasswordComponent>( const childComponent = this.modal.show<ResetPasswordComponent>(
ResetPasswordComponent, this.resetPasswordModalRef); ResetPasswordComponent, this.resetPasswordModalRef);
childComponent.name = user != null ? user.name || user.email : null; childComponent.name = this.userNamePipe.transform(user);
childComponent.email = user != null ? user.email : null; childComponent.email = user != null ? user.email : null;
childComponent.organizationId = this.organizationId; childComponent.organizationId = this.organizationId;
childComponent.id = user != null ? user.id : null; childComponent.id = user != null ? user.id : null;

View File

@ -190,6 +190,7 @@ import { ColorPasswordPipe } from 'jslib-angular/pipes/color-password.pipe';
import { I18nPipe } from 'jslib-angular/pipes/i18n.pipe'; import { I18nPipe } from 'jslib-angular/pipes/i18n.pipe';
import { SearchCiphersPipe } from 'jslib-angular/pipes/search-ciphers.pipe'; import { SearchCiphersPipe } from 'jslib-angular/pipes/search-ciphers.pipe';
import { SearchPipe } from 'jslib-angular/pipes/search.pipe'; import { SearchPipe } from 'jslib-angular/pipes/search.pipe';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import localeAz from '@angular/common/locales/az'; import localeAz from '@angular/common/locales/az';
import localeBg from '@angular/common/locales/bg'; import localeBg from '@angular/common/locales/bg';
@ -426,13 +427,14 @@ registerLocaleData(localeZhTw, 'zh-TW');
UserBillingComponent, UserBillingComponent,
UserLayoutComponent, UserLayoutComponent,
UserSubscriptionComponent, UserSubscriptionComponent,
UserNamePipe,
VaultComponent, VaultComponent,
VerifyEmailComponent, VerifyEmailComponent,
VerifyEmailTokenComponent, VerifyEmailTokenComponent,
VerifyRecoverDeleteComponent, VerifyRecoverDeleteComponent,
WeakPasswordsReportComponent, WeakPasswordsReportComponent,
], ],
providers: [DatePipe, SearchPipe], providers: [DatePipe, SearchPipe, UserNamePipe],
bootstrap: [], bootstrap: [],
}) })
export class OssModule { } export class OssModule { }

View File

@ -31,7 +31,7 @@
<tbody> <tbody>
<tr *ngFor="let c of trustedContacts; let i = index"> <tr *ngFor="let c of trustedContacts; let i = index">
<td width="30"> <td width="30">
<app-avatar [data]="c.name || c.email" [email]="c.email" size="25" [circle]="true" <app-avatar [data]="c | userName" [email]="c.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>
@ -101,7 +101,7 @@
<tbody> <tbody>
<tr *ngFor="let c of grantedContacts; let i = index"> <tr *ngFor="let c of grantedContacts; let i = index">
<td width="30"> <td width="30">
<app-avatar [data]="c.name || c.email" [email]="c.email" size="25" [circle]="true" <app-avatar [data]="c | userName" [email]="c.email" size="25" [circle]="true"
[fontSize]="14"></app-avatar> [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>

View File

@ -16,6 +16,8 @@ import { EmergencyAccessConfirmRequest } from 'jslib-common/models/request/emerg
import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse } from 'jslib-common/models/response/emergencyAccessResponse'; import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse } from 'jslib-common/models/response/emergencyAccessResponse';
import { ConstantsService } from 'jslib-common/services/constants.service'; import { ConstantsService } from 'jslib-common/services/constants.service';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { ModalComponent } from '../modal.component'; import { ModalComponent } from '../modal.component';
import { EmergencyAccessAddEditComponent } from './emergency-access-add-edit.component'; import { EmergencyAccessAddEditComponent } from './emergency-access-add-edit.component';
import { EmergencyAccessConfirmComponent } from './emergency-access-confirm.component'; import { EmergencyAccessConfirmComponent } from './emergency-access-confirm.component';
@ -45,7 +47,7 @@ export class EmergencyAccessComponent implements OnInit {
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private toasterService: ToasterService, private cryptoService: CryptoService, private toasterService: ToasterService, private cryptoService: CryptoService,
private storageService: StorageService, private userService: UserService, private storageService: StorageService, private userService: UserService,
private messagingService: MessagingService) { } private messagingService: MessagingService, private userNamePipe: UserNamePipe) { }
async ngOnInit() { async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium(); this.canAccessPremium = await this.userService.canAccessPremium();
@ -76,7 +78,7 @@ export class EmergencyAccessComponent implements OnInit {
const childComponent = this.modal.show<EmergencyAccessAddEditComponent>( const childComponent = this.modal.show<EmergencyAccessAddEditComponent>(
EmergencyAccessAddEditComponent, this.addEditModalRef); EmergencyAccessAddEditComponent, this.addEditModalRef);
childComponent.name = details?.name ?? details?.email; childComponent.name = this.userNamePipe.transform(details);
childComponent.emergencyAccessId = details?.id; childComponent.emergencyAccessId = details?.id;
childComponent.readOnly = !this.canAccessPremium; childComponent.readOnly = !this.canAccessPremium;
childComponent.onSaved.subscribe(() => { childComponent.onSaved.subscribe(() => {
@ -127,7 +129,7 @@ export class EmergencyAccessComponent implements OnInit {
const childComponent = this.modal.show<EmergencyAccessConfirmComponent>( const childComponent = this.modal.show<EmergencyAccessConfirmComponent>(
EmergencyAccessConfirmComponent, this.confirmModalRef); EmergencyAccessConfirmComponent, this.confirmModalRef);
childComponent.name = contact?.name ?? contact?.email; childComponent.name = this.userNamePipe.transform(contact);
childComponent.emergencyAccessId = contact.id; childComponent.emergencyAccessId = contact.id;
childComponent.userId = contact?.granteeId; childComponent.userId = contact?.granteeId;
childComponent.onConfirmed.subscribe(async () => { childComponent.onConfirmed.subscribe(async () => {
@ -137,7 +139,7 @@ export class EmergencyAccessComponent implements OnInit {
await childComponent.formPromise; await childComponent.formPromise;
updateUser(); updateUser();
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', contact.name || contact.email)); this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', this.userNamePipe.transform(contact)));
}); });
this.modal.onClosed.subscribe(() => { this.modal.onClosed.subscribe(() => {
@ -150,13 +152,13 @@ export class EmergencyAccessComponent implements OnInit {
await this.actionPromise; await this.actionPromise;
updateUser(); updateUser();
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', contact.name || contact.email)); this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', this.userNamePipe.transform(contact)));
this.actionPromise = null; this.actionPromise = null;
} }
async remove(details: EmergencyAccessGranteeDetailsResponse | EmergencyAccessGrantorDetailsResponse) { async remove(details: EmergencyAccessGranteeDetailsResponse | EmergencyAccessGrantorDetailsResponse) {
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('removeUserConfirmation'), details.name || details.email, this.i18nService.t('removeUserConfirmation'), this.userNamePipe.transform(details),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
if (!confirmed) { if (!confirmed) {
return false; return false;
@ -164,7 +166,7 @@ export class EmergencyAccessComponent implements OnInit {
try { try {
await this.apiService.deleteEmergencyAccess(details.id); await this.apiService.deleteEmergencyAccess(details.id);
this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', details.name || details.email)); this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', this.userNamePipe.transform(details)));
if (details instanceof EmergencyAccessGranteeDetailsResponse) { if (details instanceof EmergencyAccessGranteeDetailsResponse) {
this.removeGrantee(details); this.removeGrantee(details);
@ -177,7 +179,7 @@ export class EmergencyAccessComponent implements OnInit {
async requestAccess(details: EmergencyAccessGrantorDetailsResponse) { async requestAccess(details: EmergencyAccessGrantorDetailsResponse) {
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('requestAccessConfirmation', details.waitTimeDays.toString()), this.i18nService.t('requestAccessConfirmation', details.waitTimeDays.toString()),
details.name || details.email, this.userNamePipe.transform(details),
this.i18nService.t('requestAccess'), this.i18nService.t('requestAccess'),
this.i18nService.t('no'), this.i18nService.t('no'),
'warning', 'warning',
@ -190,15 +192,15 @@ export class EmergencyAccessComponent implements OnInit {
await this.apiService.postEmergencyAccessInitiate(details.id); await this.apiService.postEmergencyAccessInitiate(details.id);
details.status = EmergencyAccessStatusType.RecoveryInitiated; details.status = EmergencyAccessStatusType.RecoveryInitiated;
this.toasterService.popAsync('success', null, this.i18nService.t('requestSent', details.name || details.email)); this.toasterService.popAsync('success', null, this.i18nService.t('requestSent', this.userNamePipe.transform(details)));
} }
async approve(details: EmergencyAccessGranteeDetailsResponse) { async approve(details: EmergencyAccessGranteeDetailsResponse) {
const type = this.i18nService.t(details.type === EmergencyAccessType.View ? 'view' : 'takeover'); const type = this.i18nService.t(details.type === EmergencyAccessType.View ? 'view' : 'takeover');
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('approveAccessConfirmation', details.name || details.email, type), this.i18nService.t('approveAccessConfirmation', this.userNamePipe.transform(details), type),
details.name || details.email, this.userNamePipe.transform(details),
this.i18nService.t('approve'), this.i18nService.t('approve'),
this.i18nService.t('no'), this.i18nService.t('no'),
'warning', 'warning',
@ -211,14 +213,14 @@ export class EmergencyAccessComponent implements OnInit {
await this.apiService.postEmergencyAccessApprove(details.id); await this.apiService.postEmergencyAccessApprove(details.id);
details.status = EmergencyAccessStatusType.RecoveryApproved; details.status = EmergencyAccessStatusType.RecoveryApproved;
this.toasterService.popAsync('success', null, this.i18nService.t('emergencyApproved', details.name || details.email)); this.toasterService.popAsync('success', null, this.i18nService.t('emergencyApproved', this.userNamePipe.transform(details)));
} }
async reject(details: EmergencyAccessGranteeDetailsResponse) { async reject(details: EmergencyAccessGranteeDetailsResponse) {
await this.apiService.postEmergencyAccessReject(details.id); await this.apiService.postEmergencyAccessReject(details.id);
details.status = EmergencyAccessStatusType.Confirmed; details.status = EmergencyAccessStatusType.Confirmed;
this.toasterService.popAsync('success', null, this.i18nService.t('emergencyRejected', details.name || details.email)); this.toasterService.popAsync('success', null, this.i18nService.t('emergencyRejected', this.userNamePipe.transform(details)));
} }
async takeover(details: EmergencyAccessGrantorDetailsResponse) { async takeover(details: EmergencyAccessGrantorDetailsResponse) {
@ -231,13 +233,13 @@ export class EmergencyAccessComponent implements OnInit {
const childComponent = this.modal.show<EmergencyAccessTakeoverComponent>( const childComponent = this.modal.show<EmergencyAccessTakeoverComponent>(
EmergencyAccessTakeoverComponent, this.takeoverModalRef); EmergencyAccessTakeoverComponent, this.takeoverModalRef);
childComponent.name = details != null ? details.name || details.email : null; childComponent.name = this.userNamePipe.transform(details);
childComponent.email = details.email; childComponent.email = details.email;
childComponent.emergencyAccessId = details != null ? details.id : null; childComponent.emergencyAccessId = details != null ? details.id : null;
childComponent.onDone.subscribe(() => { childComponent.onDone.subscribe(() => {
this.modal.close(); this.modal.close();
this.toasterService.popAsync('success', null, this.i18nService.t('passwordResetFor', details.name || details.email)); this.toasterService.popAsync('success', null, this.i18nService.t('passwordResetFor', this.userNamePipe.transform(details)));
}); });
this.modal.onClosed.subscribe(() => { this.modal.onClosed.subscribe(() => {

View File

@ -21,7 +21,7 @@
</div> </div>
<div class="col-6"> <div class="col-6">
<div class="mb-3"> <div class="mb-3">
<app-avatar data="{{profile.name || profile.email}}" [email]="profile.email" dynamic="true" size="75" <app-avatar data="{{profile | userName}}" [email]="profile.email" dynamic="true" size="75"
fontSize="35"></app-avatar> fontSize="35"></app-avatar>
</div> </div>
<hr> <hr>