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 import {IUserResource} from "../services/user-resource-service";
24 export enum UserRole {
32 export interface IUserManager {
37 export interface IUserProperties extends IUserManager {
48 export interface IUser {
49 resource:IUserResource;
51 getRoleToView():string;
53 getFirstName():string;
57 export class User implements IUser {
59 constructor(public resource:IUserResource) {
62 public getLastName = () => {
63 return this.resource.lastName;
66 public getFirstName = () => {
67 return this.resource.firstName;
70 public getName = () => {
71 return this.resource.firstName + ' ' + this.resource.lastName;
74 public getLastLogin = () => {
75 if (!this.resource.lastLoginTime || this.resource.lastLoginTime === "0") {
78 return this.resource.lastLoginTime;
82 public getRole = ():UserRole => {
84 switch (UserRole[this.resource.role.toUpperCase()]) {
86 role = UserRole.ADMIN;
88 case UserRole.DESIGNER:
89 role = UserRole.DESIGNER;
92 role = UserRole.TESTER;
94 case UserRole.GOVERNOR:
95 role = UserRole.GOVERNOR;
104 public getRoleToView = ():string => {
105 let role:string = this.resource.role.toLowerCase().replace('governor', 'governance_Rep');
106 return role.charAt(0).toUpperCase() + role.slice(1).replace('_', ' ');