All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { Component, OnInit,Input } from '@angular/core';
|
|
import { OAuthService} from 'angular-oauth2-oidc'
|
|
import { IUser } from '../../models/user';
|
|
import {Store} from '@ngrx/store';
|
|
import * as appReducers from '../../reducers/app-common.reducer';
|
|
import * as appActions from '../../actions/app-common.actions';
|
|
|
|
@Component({
|
|
selector: 'fm-user-menu',
|
|
templateUrl: './user-menu.component.html',
|
|
styleUrls: ['./user-menu.component.scss']
|
|
})
|
|
export class UserMenuComponent implements OnInit {
|
|
|
|
@Input() user:IUser;
|
|
@Input() showMenu:boolean;
|
|
|
|
constructor(private oauthService:OAuthService, private store: Store<appReducers.State>) { }
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
getLetter():string {
|
|
if (this.user && this.user.firstName && this.user.lastName)
|
|
return this.user.firstName.substr(0,1).toUpperCase() +
|
|
this.user.lastName.substr(0,1).toUpperCase();
|
|
return this.user && this.user.name ? this.user.name.substr(0,1).toUpperCase():"";
|
|
}
|
|
|
|
logout(event:MouseEvent) {
|
|
event.preventDefault();
|
|
this.store.dispatch(new appActions.Logout());
|
|
}
|
|
|
|
|
|
toggle(event:MouseEvent) {
|
|
event.stopPropagation();
|
|
this.store.dispatch(new appActions.ToggleAccountMenu());
|
|
}
|
|
}
|