AW-1881 Avatar
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter (extern) 2021-02-27 10:16:07 +01:00
parent 535f6bd064
commit ece6096064
3 changed files with 19 additions and 3 deletions

View File

@ -1 +1,9 @@
<ngx-avatar [size]="size" [round]="round" name="getName()" (clickOnAvatar)="onClick()"></ngx-avatar>
<span [title]="user.name">
<ngx-avatar
[size]="size"
[round]="round"
[name]="getName()"
[src]="getAvatar()"
(clickOnAvatar)="onClick()">
</ngx-avatar>
</span>

View File

@ -1,5 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { IUser } from '../../models/user';
import { AppConfig } from '../../shared/app.config';
@Component({
selector: 'fm-avatar',
@ -16,11 +17,18 @@ export class AvatarComponent implements OnInit {
@Output() click = new EventEmitter();
constructor() { }
constructor(private appConfig: AppConfig) {
}
ngOnInit(): void {
}
getAvatar():string {
if (!this.user) return null;
const apiEndpoint = this.appConfig.getConfig("apiEndPoint");
return `${apiEndpoint}/api/v1/users//${this.user.code}/avatar`;
}
getName():string {
if (!this.user) return null;
if (this.user.firstName && this.user.lastName)

View File

@ -1,6 +1,6 @@
<div>
<div (click)="toggle($event)" class="rounded-circle menu-button hidden" [ngClass]="{'hidden':!user}">
<span *ngIf="user"><span [title]="user.name">{{getLetter()}}</span></span>
<span *ngIf="user"><fm-avatar [user]="user"></fm-avatar></span>
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
<div class="card" *ngIf="user">
<div class="card-body">