Adds user default login icon
This commit is contained in:
parent
1a160edece
commit
0b573e4256
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
<div *ngIf="isAuthenticated();else loginoption" class="col-auto">
|
<div *ngIf="isAuthenticated();else loginoption" class="col-auto">
|
||||||
<img mat-card-avatar *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()" (click)="openProfile()">
|
<img mat-card-avatar *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()" (click)="openProfile()">
|
||||||
|
<img mat-card-avatar *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()" (click)="openProfile()">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-template #loginoption>
|
<ng-template #loginoption>
|
||||||
|
|
|
@ -92,13 +92,17 @@ export class NavigationComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public principalHasAvatar(): boolean {
|
public principalHasAvatar(): boolean {
|
||||||
return this.authentication.current().avatarUrl != null;
|
return this.authentication.current().avatarUrl != null && this.authentication.current().avatarUrl.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrincipalAvatar(): string {
|
public getPrincipalAvatar(): string {
|
||||||
return this.authentication.current().avatarUrl;
|
return this.authentication.current().avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDefaultAvatar(): string {
|
||||||
|
return 'assets/images/profile-placeholder.png';
|
||||||
|
}
|
||||||
|
|
||||||
openProfile() {
|
openProfile() {
|
||||||
const dialogRef = this.dialog.open(UserDialogComponent, {
|
const dialogRef = this.dialog.open(UserDialogComponent, {
|
||||||
hasBackdrop: true,
|
hasBackdrop: true,
|
||||||
|
|
|
@ -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()"
|
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()">
|
||||||
[src]="this.getPrincipalAvatar()">
|
<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>
|
||||||
|
|
|
@ -36,13 +36,17 @@ export class UserDialogComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public principalHasAvatar(): boolean {
|
public principalHasAvatar(): boolean {
|
||||||
return this.authentication.current() && this.authentication.current().avatarUrl != null;
|
return this.authentication.current() && this.authentication.current().avatarUrl != null && this.authentication.current().avatarUrl.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrincipalAvatar(): string {
|
public getPrincipalAvatar(): string {
|
||||||
return this.authentication.current() && this.authentication.current().avatarUrl;
|
return this.authentication.current() && this.authentication.current().avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDefaultAvatar(): string {
|
||||||
|
return 'assets/images/profile-placeholder.png';
|
||||||
|
}
|
||||||
|
|
||||||
public navigateToProfile() {
|
public navigateToProfile() {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
this.router.navigate(['/profile']);
|
this.router.navigate(['/profile']);
|
||||||
|
|
|
@ -54,8 +54,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()"
|
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()" (click)="openProfile()">
|
||||||
[src]="this.getPrincipalAvatar()" (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'] ">
|
||||||
|
|
|
@ -152,13 +152,17 @@ export class NavbarComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public principalHasAvatar(): boolean {
|
public principalHasAvatar(): boolean {
|
||||||
return this.authentication.current().avatarUrl != null;
|
return this.authentication.current().avatarUrl != null && this.authentication.current().avatarUrl.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrincipalAvatar(): string {
|
public getPrincipalAvatar(): string {
|
||||||
return this.authentication.current().avatarUrl;
|
return this.authentication.current().avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDefaultAvatar(): string {
|
||||||
|
return 'assets/images/profile-placeholder.png';
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" *ngIf="isAuthenticated();else loginoption">
|
<a class="nav-link" *ngIf="isAuthenticated();else loginoption">
|
||||||
<p style="display: flex; align-items: center;" [routerLink]=" ['/profile']">
|
<p style="display: flex; align-items: center;" [routerLink]=" ['/profile']">
|
||||||
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()"
|
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()">
|
||||||
[src]="this.getPrincipalAvatar()">
|
<img mat-card-avatar class="my-mat-card-avatar" *ngIf="!this.principalHasAvatar()" [src]="this.getDefaultAvatar()">
|
||||||
<span class="d-lg-none d-md-block">{{ 'SIDE-BAR.ACCOUNT' | translate }}</span>
|
<span class="d-lg-none d-md-block">{{ 'SIDE-BAR.ACCOUNT' | translate }}</span>
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -146,13 +146,17 @@ export class SidebarComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public principalHasAvatar(): boolean {
|
public principalHasAvatar(): boolean {
|
||||||
return this.authentication.current().avatarUrl != null;
|
return this.authentication.current().avatarUrl != null && this.authentication.current().avatarUrl.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrincipalAvatar(): string {
|
public getPrincipalAvatar(): string {
|
||||||
return this.authentication.current().avatarUrl;
|
return this.authentication.current().avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDefaultAvatar(): string {
|
||||||
|
return 'assets/images/profile-placeholder.png';
|
||||||
|
}
|
||||||
|
|
||||||
public isAuthenticated(): boolean {
|
public isAuthenticated(): boolean {
|
||||||
const myBollean = this.isAdmin();
|
const myBollean = this.isAdmin();
|
||||||
return !(!this.authentication.current());
|
return !(!this.authentication.current());
|
||||||
|
|
Loading…
Reference in New Issue