2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 export enum UserRole {
27 // tslint:disable-next-line:interface-name
28 export interface IUserManager {
29 isInEditMode: boolean;
33 // tslint:disable-next-line:interface-name
34 export interface IUserProperties extends IUserManager {
41 lastLoginTime: string;
45 // tslint:disable-next-line:interface-name
46 export interface IUser {
47 userInfo: IUserProperties;
49 getRoleToView(): string;
51 getFirstName(): string;
52 getLastName(): string;
55 export class User implements IUser {
57 constructor(public userInfo: IUserProperties) {
60 public getLastName = () => {
61 return this.userInfo.lastName;
64 public getFirstName = () => {
65 return this.userInfo.firstName;
68 public getName = () => {
69 return this.userInfo.firstName + ' ' + this.userInfo.lastName;
72 public getLastLogin = () => {
73 if (!this.userInfo.lastLoginTime || this.userInfo.lastLoginTime === '0') {
76 return this.userInfo.lastLoginTime;
80 public getRole = (): UserRole => {
82 switch (UserRole[this.userInfo.role.toUpperCase()]) {
84 role = UserRole.ADMIN;
86 case UserRole.DESIGNER:
87 role = UserRole.DESIGNER;
93 public getRoleToView = (): string => {
94 const role: string = this.userInfo.role.toLowerCase().replace('governor', 'governance_Rep');
95 return role.charAt(0).toUpperCase() + role.slice(1).replace('_', ' ');