diff --git a/login/userMini.component.ts b/login/userMini.component.ts index f988945a..9725f158 100644 --- a/login/userMini.component.ts +++ b/login/userMini.component.ts @@ -8,82 +8,87 @@ import {EnvProperties} from '../utils/properties/env-properties'; // declare var logoutClicked; @Component({ - selector: 'user-mini', - template: ` - + selector: 'user-mini', + template: ` + - + - + -
  • +
  • - - {{user.fullname + " "}} + {{user.fullname + " "}} + + d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"> + - + Sign in - -
  • -
    - - + + + + - - - - - {{firstLetters}} - - - - - + + + + + + {{firstLetters}} + + + + - -
    - -
    -
    + + +
    + +
    +
    -
    - ` +
    + ` }) export class UserMiniComponent implements OnInit, OnChanges { - @Input() user: User; - public loggedIn: boolean = false; - public isAuthorized: boolean = false; - @Input() public mobileView: boolean = false; - public firstLetters: string = ""; - @Input() public dashboard: boolean = false; - public server: boolean = true; - public routerHelper: RouterHelper = new RouterHelper(); - @Input() userMenuItems; - @Input() logInUrl; - @Input() logOutUrl; - @Input() cookieDomain; - @Input() redirectUrl: string; - search: string = ''; - sub: any; - - constructor(private router: Router, private route: ActivatedRoute, private location: Location) { + @Input() user: User; + public loggedIn: boolean = false; + public isAuthorized: boolean = false; + @Input() public mobileView: boolean = false; + public firstLetters: string = ""; + @Input() public dashboard: boolean = false; + public server: boolean = true; + public routerHelper: RouterHelper = new RouterHelper(); + @Input() userMenuItems; + @Input() logInUrl; + @Input() logOutUrl; + @Input() cookieDomain; + @Input() redirectUrl: string; + search: string = ''; + sub: any; + + constructor(private router: Router, private route: ActivatedRoute, private location: Location) { + } + + ngOnInit() { + + if (typeof document !== 'undefined') { + this.server = false; } - - ngOnInit() { - - if (typeof document !== 'undefined') { - this.server = false; - } - this.initialize(); - this.sub = this.route.queryParams.subscribe(params => { - this.initialize(); - }); - - + this.initialize(); + this.sub = this.route.queryParams.subscribe(params => { + this.initialize(); + }); + + + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes.user) { + this.initialize(); } - - ngOnChanges(changes: SimpleChanges): void { - if (changes.user) { - this.initialize(); - } + } + + ngOnDestroy() { + if (this.sub) { + this.sub.unsubscribe(); } - - ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } + } + + initialize() { + if (!this.redirectUrl && typeof location !== 'undefined') { + this.redirectUrl = location.pathname; + this.search = location.search; } - - initialize() { - if (!this.redirectUrl && typeof location !== 'undefined') { - this.redirectUrl = location.pathname; - this.search = location.search; - } - if (this.user) { - this.loggedIn = true; - this.parseName(); - this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user); - - } else { - this.loggedIn = false; - this.isAuthorized = false; - this.user = null; - } - + if (this.user) { + this.loggedIn = true; + this.parseName(); + 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(); + + } + + logOut() { + if (this.user) { + Session.removeUser(); + window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href); + } - - logIn() { - Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search); - window.location.href = this.logInUrl; + this.loggedIn = false; + this.isAuthorized = false; + this.user = new User(); + } + + logIn() { + Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search); + window.location.href = this.logInUrl; + } + + onClick(id: string) { + let el: HTMLElement = document.getElementById(id); + el.classList.remove('uk-open'); + } + + parseName() { + this.firstLetters = ""; + if (this.user && this.user.firstname) { + this.firstLetters += this.user.firstname.substr(0, 1); } - - onClick(id: string) { - let el: HTMLElement = document.getElementById(id); - el.classList.remove('uk-open'); + if (this.user && this.user.lastname) { + this.firstLetters += this.user.lastname.substr(0, 1); } - - parseName() { - this.firstLetters = ""; - if (this.user && this.user.firstname) { - this.firstLetters += this.user.firstname.substr(0, 1); - } - if (this.user && this.user.lastname) { - this.firstLetters += this.user.lastname.substr(0, 1); - } - if (!this.firstLetters && this.user && this.user.fullname) { - let matches = this.user.fullname.match(/\b(\w)/g); - this.firstLetters += matches.join(''); - } + if (!this.firstLetters && this.user && this.user.fullname) { + let matches = this.user.fullname.match(/\b(\w)/g); + this.firstLetters += matches.join(''); } + } }