Added avatar
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<ngx-avatar [size]="size" [round]="round" name="getName()" (clickOnAvatar)="onClick()"></ngx-avatar>
|
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AvatarComponent } from './avatar.component';
|
||||
|
||||
describe('AvatarComponent', () => {
|
||||
let component: AvatarComponent;
|
||||
let fixture: ComponentFixture<AvatarComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ AvatarComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AvatarComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
34
projects/common/src/fm/components/avatar/avatar.component.ts
Normal file
34
projects/common/src/fm/components/avatar/avatar.component.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { IUser } from '../../models/user';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-avatar',
|
||||
templateUrl: './avatar.component.html',
|
||||
styleUrls: ['./avatar.component.css']
|
||||
})
|
||||
export class AvatarComponent implements OnInit {
|
||||
|
||||
@Input() user: IUser;
|
||||
@Input() bgColor: string;
|
||||
@Input() fgColor: string;
|
||||
@Input() size: number;
|
||||
@Input() round: boolean;
|
||||
|
||||
@Output() click = new EventEmitter();
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
getName():string {
|
||||
if (!this.user) return null;
|
||||
if (this.user.firstName && this.user.lastName)
|
||||
return this.user.firstName + ' ' + this.user.lastName;
|
||||
return this.user.name;
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.click.emit();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user