44 lines
1.1 KiB
TypeScript
44 lines
1.1 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 {
|
|
}
|
|
|
|
getProvider():string | null {
|
|
const ownedClaims = this.oauthService.getIdentityClaims();
|
|
if(ownedClaims) {
|
|
if (ownedClaims["idp"] != "local") {
|
|
return ownedClaims["idp"];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
logout(event:MouseEvent) {
|
|
event.preventDefault();
|
|
this.store.dispatch(new appActions.Logout());
|
|
}
|
|
|
|
|
|
toggle(event:MouseEvent) {
|
|
event.stopPropagation();
|
|
this.store.dispatch(new appActions.ToggleAccountMenu());
|
|
}
|
|
}
|