Added avatar
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit

This commit is contained in:
Peter (extern) 2021-02-25 17:17:52 +01:00
parent b537239c96
commit 74e7f41583
7 changed files with 95 additions and 6 deletions

View File

@ -1,5 +1,27 @@
{
"name": "@farmmaps/common",
"version": "0.0.1",
"lockfileVersion": 1
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"is-retina": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-retina/-/is-retina-1.0.3.tgz",
"integrity": "sha1-10AbKGvqKuN/Ykd1iN5QTQuGR+M="
},
"ngx-avatar": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/ngx-avatar/-/ngx-avatar-4.0.0.tgz",
"integrity": "sha512-Uk40UXl26RvDy1ori9NDsGFB+f84AaxMnsIwZA6JPJK0pLcbo3F4vZTmzLZeOusOw1Qtgk5IzF630jo06keXwQ==",
"requires": {
"is-retina": "^1.0.3",
"ts-md5": "^1.2.4"
}
},
"ts-md5": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/ts-md5/-/ts-md5-1.2.7.tgz",
"integrity": "sha512-emODogvKGWi1KO1l9c6YxLMBn6CEH3VrH5mVPIyOtxBG52BvV4jP3GWz6bOZCz61nLgBc3ffQYE4+EHfCD+V7w=="
}
}
}

View File

@ -17,6 +17,7 @@
"@microsoft/signalr": "^3.1.3",
"ngx-uploadx": "^3.3.4",
"angular-oauth2-oidc": "^10.0.3",
"moment": "^2.27.0"
"moment": "^2.27.0",
"ngx-avatar": "^4.0.0"
}
}

View File

@ -60,6 +60,8 @@ import { AppMenuComponent } from './components/app-menu/app-menu.component';
import { NotificationMenuComponent} from './components/notification-menu/notification-menu.component';
import { HelpMenuComponent} from './components/help-menu/help-menu.component';
import { BackButtonComponent } from './components/back-button/back-button.component';
import { AvatarComponent } from './components/avatar/avatar.component';
import { AvatarModule } from 'ngx-avatar';
export {
SafePipe,
@ -102,7 +104,8 @@ export {
IDataLayer,
IColor,
IGradientstop,
BackButtonComponent
BackButtonComponent,
AvatarComponent
};
@NgModule({
@ -115,7 +118,8 @@ export {
OAuthModule.forRoot(),
NgbModule,
FormsModule,
UploadxModule
UploadxModule,
AvatarModule
],
declarations: [
AppComponent,
@ -138,7 +142,8 @@ export {
NotificationMenuComponent,
HelpMenuComponent,
BackButtonComponent,
ThumbnailComponent
ThumbnailComponent,
AvatarComponent
],
exports: [
NgbModule,
@ -162,7 +167,8 @@ export {
GradientComponent,
GradientSelectComponent,
BackButtonComponent,
ThumbnailComponent
ThumbnailComponent,
AvatarComponent
]
})
export class AppCommonModule {

View File

@ -0,0 +1 @@
<ngx-avatar [size]="size" [round]="round" name="getName()" (clickOnAvatar)="onClick()"></ngx-avatar>

View File

@ -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();
});
});

View 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();
}
}