Add User Avatar fallback to placeholder
This commit is contained in:
parent
1750a4a308
commit
28074a7f17
|
@ -2,8 +2,8 @@
|
||||||
<div mat-dialog-title>
|
<div mat-dialog-title>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()">
|
<img mat-card-avatar class="my-mat-card-avatar" [src]="this.getPrincipalAvatar()" (error)="applyFallbackAvatar($event)">
|
||||||
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()">
|
<!-- <img mat-card-avatar class="my-mat-card-avatar" *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()"> -->
|
||||||
</div>
|
</div>
|
||||||
<span class="user-label col">{{this.getPrincipalName()}}</span>
|
<span class="user-label col">{{this.getPrincipalName()}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -47,6 +47,10 @@ export class UserDialogComponent implements OnInit {
|
||||||
return 'assets/images/profile-placeholder.png';
|
return 'assets/images/profile-placeholder.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public applyFallbackAvatar(ev: Event) {
|
||||||
|
(ev.target as HTMLImageElement).src = this.getDefaultAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
public navigateToProfile() {
|
public navigateToProfile() {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
this.router.navigate(['/profile']);
|
this.router.navigate(['/profile']);
|
||||||
|
|
|
@ -79,8 +79,8 @@
|
||||||
|
|
||||||
<!-- Login -->
|
<!-- Login -->
|
||||||
<li class="nav-item" *ngIf="isAuthenticated();else loginoption">
|
<li class="nav-item" *ngIf="isAuthenticated();else loginoption">
|
||||||
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()" (click)="openProfile()">
|
<img mat-card-avatar class="my-mat-card-avatar" [src]="this.getPrincipalAvatar()" (error)="this.applyFallbackAvatar($event)" (click)="openProfile()">
|
||||||
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()" (click)="openProfile()">
|
<!-- <img mat-card-avatar class="my-mat-card-avatar" *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()" (click)="openProfile()"> -->
|
||||||
</li>
|
</li>
|
||||||
<ng-template #loginoption>
|
<ng-template #loginoption>
|
||||||
<button mat-button [routerLink]=" ['/login'] ">
|
<button mat-button [routerLink]=" ['/login'] ">
|
||||||
|
|
|
@ -178,6 +178,10 @@ export class NavbarComponent extends BaseComponent implements OnInit {
|
||||||
return 'assets/images/profile-placeholder.png';
|
return 'assets/images/profile-placeholder.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public applyFallbackAvatar(ev: Event) {
|
||||||
|
(ev.target as HTMLImageElement).src = this.getDefaultAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
public isAdmin(): boolean {
|
public isAdmin(): boolean {
|
||||||
if (!this.authentication.current()) { return false; }
|
if (!this.authentication.current()) { return false; }
|
||||||
const principalRoles = this.authentication.current().authorities;
|
const principalRoles = this.authentication.current().authorities;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row profile-card-center-row">
|
<div class="row profile-card-center-row">
|
||||||
<div class="col-auto"><img mat-card-avatar [src]="userProfile.additionalinfo.avatarUrl">
|
<div class="col-auto"><img mat-card-avatar [src]="userProfile.additionalinfo.avatarUrl" (error)="applyFallbackAvatar($event)">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row profile-card-center-row">
|
<div class="row profile-card-center-row">
|
||||||
|
|
|
@ -146,4 +146,8 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public applyFallbackAvatar(ev: Event) {
|
||||||
|
(ev.target as HTMLImageElement).src = 'assets/images/profile-placeholder.png';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue