Files
FarmMapsLib/projects/common/src/fm/components/user-menu/user-menu.component.ts
Willem Dantuma e682b375e7
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
Add user-menu router outlet
2020-09-04 10:10:01 +02:00

38 lines
1.0 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 {
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());
}
}