From 879438d1e50567149e1f03aeb87c43147f30325d Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 12 Dec 2019 14:11:01 +0000 Subject: [PATCH] [Trunk | Library]: login/userMini.component.ts: Add dashboard view & name parsing to get first letters. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57864 d315682c-612b-4755-9ff5-7f18f6832af3 --- login/userMini.component.ts | 160 ++++++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 53 deletions(-) diff --git a/login/userMini.component.ts b/login/userMini.component.ts index 25a2021a..d9342bb1 100644 --- a/login/userMini.component.ts +++ b/login/userMini.component.ts @@ -10,71 +10,112 @@ import{EnvProperties} from '../utils/properties/env-properties'; @Component({ selector: 'user-mini', template: ` - + + -
  • - - - {{user.fullname+" "}} - - - Sign in + + + Sign in - - - -
  • -
    + + + + + {{firstLetters}} + + + +
    +
    +
    + +
    +
    +
    + + +
    ` }) export class UserMiniComponent implements OnInit, OnChanges{ @Input() user: User; + public firstLetters: string = ""; public loggedIn: boolean = false; public isAuthorized: boolean = false; @Input() public mobileView:boolean = false ; + @Input() public dashboard: boolean = false; public server: boolean = true; public routerHelper:RouterHelper = new RouterHelper(); @Input() userMenuItems; @@ -117,6 +158,7 @@ export class UserMiniComponent implements OnInit, OnChanges{ } if(this.user){ this.loggedIn = true; + this.parseName(); this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user); }else { @@ -144,8 +186,20 @@ export class UserMiniComponent implements OnInit, OnChanges{ } onClick(id: string) { - let el: HTMLElement = document.getElementById(id); - el.classList.remove('uk-open'); - } + let el: HTMLElement = document.getElementById(id); + el.classList.remove('uk-open'); + } + parseName() { + 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(''); + } + } }