import {Component, ElementRef, Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Location} from '@angular/common'; import {User,Session} from './utils/helper.class'; import {RouterHelper} from '../utils/routerHelper.class'; import {StringUtils} from '../utils/string-utils.class'; import{EnvProperties} from '../utils/properties/env-properties'; // declare var logoutClicked; @Component({ selector: 'user-mini', template: `
  • {{user.fullname+" "}} Sign in
  • ` }) export class UserMiniComponent { @Input() user: User; public loggedIn: boolean = false; public isAuthorized: boolean = false; @Input() public mobileView:boolean = false ; public server: boolean = true; public routerHelper:RouterHelper = new RouterHelper(); @Input() userMenuItems; @Input() logInUrl; @Input() logOutUrl; @Input() cookieDomain; @Input() redirectUrl: string; sub:any; constructor( private router: Router, private route: ActivatedRoute, private location: Location) {} ngOnInit() { if( typeof document !== 'undefined') { this.server = false; } this.initialize(); this.sub = this.route.queryParams.subscribe(params => { this.initialize(); }); } ngOnDestroy(){ if(this.sub) { this.sub.unsubscribe(); } } initialize(){ if(!this.redirectUrl && typeof location !== 'undefined') { this.redirectUrl = location.pathname; } if(this.user){ this.loggedIn = true; this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user); }else { this.loggedIn = false; this.isAuthorized = false; this.user = null; } } logOut(){ if(this.user){ Session.removeUser(); window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href); } this.loggedIn = false; this.isAuthorized = false; this.user = new User(); } logIn(){ Session.setReloadUrl(location.protocol +"//"+location.host, this.redirectUrl, location.search); window.location.href = this.logInUrl; } onClick(id: string) { let el: HTMLElement = document.getElementById(id); el.classList.remove('uk-open'); } }