Feature 10941: User Management Enhancements

	- Added NG-UI support for user management enhancements
	- It includes login history along with password expiry & account
	  expiry warnings, unlock & renew user for admin users
	- Change password field for admin: visible at user actions field
	  Change password field for users: visible at header of UI

Change-Id: If952069b62efd6226b633b35b3634cf3f7848096
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/app/users/add-user/AddEditUserComponent.ts b/src/app/users/add-user/AddEditUserComponent.ts
index 076cfba..e7592e4 100644
--- a/src/app/users/add-user/AddEditUserComponent.ts
+++ b/src/app/users/add-user/AddEditUserComponent.ts
@@ -227,6 +227,8 @@
             if (this.isFirstLogin) {
                 this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.CHANGEPASSWORD'));
                 this.authService.destoryToken();
+            } else if (this.userType === 'changePassword' && (!this.isFirstLogin)) {
+                this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.CHANGEDSUCCESSFULLY'));
             } else {
                 this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.EDITEDSUCCESSFULLY'));
             }
diff --git a/src/app/users/user-details/UserDetailsComponent.html b/src/app/users/user-details/UserDetailsComponent.html
index 9d11186..49661cb 100644
--- a/src/app/users/user-details/UserDetailsComponent.html
+++ b/src/app/users/user-details/UserDetailsComponent.html
@@ -26,6 +26,14 @@
   </span>
 </div>
 <div class="row mt-2 mb-0 form-group justify-content-end list-utilites-actions">
+  <div *ngIf="isAdminShow" class="col-auto mr-auto">
+    <nav class="custom-items-config">
+      <span><i class="fas fa-user-check text-success"></i>{{userActive}}</span>
+      <span><i class="fas fa-user-lock text-danger"></i>{{userLocked}}</span>
+      <span><i class="fas fa-user-times text-warning"></i>{{userExpired}}</span>
+      <span><i class="fas fa-user-shield text-info"></i>{{userAlwaysActive}}</span>
+    </nav>
+  </div>
   <page-per-row class="mr-2" (pagePerRow)="onChange($event)"></page-per-row>
   <page-reload></page-reload>
 </div>
diff --git a/src/app/users/user-details/UserDetailsComponent.ts b/src/app/users/user-details/UserDetailsComponent.ts
index ba24454..51047ba 100644
--- a/src/app/users/user-details/UserDetailsComponent.ts
+++ b/src/app/users/user-details/UserDetailsComponent.ts
@@ -15,6 +15,7 @@
 
  Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
 */
+/* eslint-disable security/detect-object-injection */
 /**
  * @file users details Component.
  */
@@ -23,7 +24,7 @@
 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { TranslateService } from '@ngx-translate/core';
 import { AddEditUserComponent } from 'AddEditUserComponent';
-import { ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
 import { DataService } from 'DataService';
 import { environment } from 'environment';
 import { LocalDataSource } from 'ng2-smart-table';
@@ -65,6 +66,21 @@
   /** Class for empty and present data @public */
   public checkDataClass: string;
 
+  /** user active data @public */
+  public userActive: string = CONFIGCONSTANT.userActive;
+
+  /** user locked data @public */
+  public userLocked: string = CONFIGCONSTANT.userLocked;
+
+  /** user expired data @public */
+  public userExpired: string = CONFIGCONSTANT.userExpired;
+
+  /** user always-active data @public */
+  public userAlwaysActive: string = CONFIGCONSTANT.userAlwaysActive;
+
+  /** Admin Visibility Check  @public */
+  public isAdminShow: boolean;
+
   /** Instance of the rest service @private */
   private restService: RestService;
 
@@ -109,20 +125,61 @@
     this.projectService.getAllProjects().subscribe((projects: {}[]) => {
       this.projectList = projects;
     });
+    this.isAdminShow = localStorage.getItem('admin_show') === 'true' ? true : false;
     this.generateColumns();
     this.generateSettings();
     this.generateData();
+    this.hideColumnForUser();
     this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
   }
 
   /** smart table Header Colums @public */
   public generateColumns(): void {
     this.columnLists = {
-      username: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
-      projects: { title: this.translateService.instant('PAGE.DASHBOARD.PROJECTS'), width: '25%' },
-      identifier: { title: this.translateService.instant('IDENTIFIER'), width: '20%' },
-      modified: { title: this.translateService.instant('MODIFIED'), width: '15%' },
-      created: { title: this.translateService.instant('CREATED'), width: '15%' },
+      username: { title: this.translateService.instant('NAME'), width: '10%', sortDirection: 'asc' },
+      projects: { title: this.translateService.instant('PAGE.DASHBOARD.PROJECTS'), width: '15%' },
+      identifier: { title: this.translateService.instant('IDENTIFIER'), width: '10%' },
+      user_status: {
+        type: 'html',
+        title: this.translateService.instant('STATUS'),
+        width: '15%',
+        filter: {
+          type: 'list',
+          config: {
+            selectText: 'Select',
+            list: [
+              { value: this.userActive, title: this.userActive },
+              { value: this.userLocked, title: this.userLocked },
+              { value: this.userExpired, title: this.userExpired },
+              { value: this.userAlwaysActive, title: this.userAlwaysActive }
+            ]
+          }
+        },
+        valuePrepareFunction: (cell: UserData, row: UserData): string => {
+          if (row.user_status === this.userActive) {
+            return `<span class="icon-label" title="${row.user_status}">
+                 <i class="fas fa-user-check text-success"></i>
+                 </span>`;
+          } else if (row.user_status === this.userLocked) {
+            return `<span class="icon-label" title="${row.user_status}">
+                 <i class="fas fa-user-lock text-danger"></i>
+                 </span>`;
+          } else if (row.user_status === this.userExpired) {
+            return `<span class="icon-label" title="${row.user_status}">
+                 <i class="fas fa-user-times text-warning"></i>
+                 </span>`;
+          } else if (row.user_status === this.userAlwaysActive) {
+            return `<span class="icon-label" title="${row.user_status}">
+                 <i class="fas fa-user-shield text-info"></i>
+                 </span>`;
+          } else {
+            return `<span>${row.user_status}</span>`;
+          }
+        }
+      },
+      account_expire_time: { title: this.translateService.instant('Expires in'), width: '10%' },
+      modified: { title: this.translateService.instant('MODIFIED'), width: '10%' },
+      created: { title: this.translateService.instant('CREATED'), width: '10%' },
       Actions: {
         name: 'Action', width: '5%', filter: false, sort: false, title: this.translateService.instant('ACTIONS'), type: 'custom',
         valuePrepareFunction: (cell: UserData, row: UserData): UserData => row,
@@ -144,6 +201,22 @@
     };
   }
 
+  /** To hide coulmns in smart table @public */
+  public hideColumnForUser(): void {
+    if (!this.isAdminShow) {
+      const userStatus: string = 'user_status';
+      const expire: string = 'account_expire_time';
+      // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
+      delete this.columnLists[userStatus];
+      // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
+      delete this.columnLists[expire];
+    } else {
+      const modified: string = 'modified';
+      // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
+      delete this.columnLists[modified];
+    }
+  }
+
   /** on Navigate to Composer Page @public */
   public composeUser(): void {
     // eslint-disable-next-line security/detect-non-literal-fs-filename
@@ -177,7 +250,10 @@
       modified: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ? userData._admin.modified : null),
       created: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ? userData._admin.created : null),
       projects: userData.projectListName,
-      identifier: userData._id
+      identifier: userData._id,
+      user_status: userData._admin.user_status,
+      account_expire_time: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ?
+        userData._admin.account_expire_time : null)
     };
     this.userData.push(userDataObj);
   }