Improved Profile Search performance 71/108671/2
authorSudarshan Kumar <sudarshan.kumar@att.com>
Tue, 2 Jun 2020 13:59:08 +0000 (19:29 +0530)
committerSudarshan Kumar <sudarshan.kumar@att.com>
Wed, 3 Jun 2020 11:09:50 +0000 (16:39 +0530)
Improved Profile Search performance

Issue-ID: PORTAL-915
Change-Id: I05fa030ff326ff38b1f12a10f40c4bb28590ed61
Signed-off-by: Sudarshan Kumar <sudarshan.kumar@att.com>
12 files changed:
ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java
ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts
ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts
ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts
ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts
ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java
ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java

index ff80d41..24e44d4 100644 (file)
@@ -139,6 +139,24 @@ public class ProfileSearchController extends RestrictedBaseController {
                        logger.error(EELFLoggerDelegate.applicationLogger, "getUserPagination failed", e);
                }
        }
+       
+       @RequestMapping(value = { "/get_all_users" }, method = RequestMethod.GET)
+       public void getAllUsers(HttpServletRequest request, HttpServletResponse response) {
+               Map<String, Object> model = new HashMap<>();
+               ObjectMapper mapper = new ObjectMapper();
+               logger.info(EELFLoggerDelegate.applicationLogger, "Initiating get_all_users in ProfileSearchController");
+               List<User> profileList = null;
+               try {
+                       profileList = service.listAllUsers();
+                       model.put("profileList", mapper.writeValueAsString(profileList));
+                       JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
+                       JSONObject j = new JSONObject(msg);
+                       response.setContentType(APPLICATION_JSON);
+                       response.getWriter().write(j.toString());
+               } catch (Exception e) {
+                       logger.error(EELFLoggerDelegate.applicationLogger, "getAllUsers failed", e);
+               }
+       }
 
        @SuppressWarnings("unchecked")
        private Map<String, Object> setDashboardData(HttpServletRequest request)
index a86ea75..6dcdda6 100644 (file)
@@ -36,7 +36,7 @@
  * 
  */
 import { CommonModule } from '@angular/common';
-import { HttpClientModule } from '@angular/common/http';
+import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
 import { NgModule } from '@angular/core';
 import { BrowserModule } from '@angular/platform-browser';
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@@ -47,6 +47,7 @@ import { SidebarService } from './shared/services/index';
 import { AppRoutingModule } from './app-routing.module';
 import { AppComponent } from './app.component';
 import { UserService } from './shared/services/user/user.service';
+import { HeaderInterceptor } from './shared/interceptors/header-interceptor';
 
 @NgModule({
     imports: [
@@ -60,7 +61,11 @@ import { UserService } from './shared/services/user/user.service';
         ReactiveFormsModule,
     ],
     declarations: [AppComponent],
-    providers: [SidebarService,UserService],
+    providers: [SidebarService,UserService,{
+        provide: HTTP_INTERCEPTORS,
+        useClass: HeaderInterceptor,
+        multi: true,
+    }],
     bootstrap: [AppComponent]
 })
 export class AppModule {}
index 7d14ee3..1c63134 100644 (file)
@@ -10,56 +10,59 @@ export class ProfileService {
   constructor(private http:HttpClient) { }
 
   getUserPagination(){
-    return this.http.get(environment.getUserPagination,{ withCredentials: true });         
+    return this.http.get(environment.getUserPagination);         
   }
 
+  getAllUsers(){
+    return this.http.get(environment.getAllUsers);         
+  }
 
   getPostSearch(postSearchBean:any)
   {
-    return this.http.post(environment.postSearch,JSON.stringify({postSearchBean: postSearchBean}),{ withCredentials: true });
+    return this.http.post(environment.postSearch,JSON.stringify({postSearchBean: postSearchBean}));
 
   }
 
   importUser(postSearchBean:any)
   {
-    return this.http.post(environment.importSearch,JSON.stringify({postSearchBean: postSearchBean}),{ withCredentials: true });
+    return this.http.post(environment.importSearch,JSON.stringify({postSearchBean: postSearchBean}));
 
   }
 
   getPostProfile()
   {
-    return this.http.get(environment.getPostProfile,{ withCredentials: true });         
+    return this.http.get(environment.getPostProfile);         
 
   }
 
   getSelfProfile()
   {
-    return this.http.get(environment.getSelfProfile,{ withCredentials: true });         
+    return this.http.get(environment.getSelfProfile);         
 
   }
 
   getProfileById(profileId){
-    return this.http.get(environment.getProfileById+"?profile_id="+profileId, {withCredentials: true });
+    return this.http.get(environment.getProfileById+"?profile_id="+profileId);
   }
 
   removeRole(data,profileId)
   {
-    return this.http.post(environment.removeUserRole+'?profile_id='+profileId,JSON.stringify({role: data}),{ withCredentials: true });
+    return this.http.post(environment.removeUserRole+'?profile_id='+profileId,JSON.stringify({role: data}));
   }
 
   addUserRole(data,profileId)
   {
-    return this.http.post(environment.addUserRole+'?profile_id='+profileId,JSON.stringify({role: data}),{ withCredentials: true });
+    return this.http.post(environment.addUserRole+'?profile_id='+profileId,JSON.stringify({role: data}));
   }
   
   saveProfile(data,profileId)
   {
-    return this.http.post(environment.saveProfile+'?profile_id='+profileId,JSON.stringify({profile: data.profile,selectedCountry:data.selectedCountry, selectedState:data.selectedState, selectedTimeZone:data.selectedTimeZone}),{ withCredentials: true });
+    return this.http.post(environment.saveProfile+'?profile_id='+profileId,JSON.stringify({profile: data.profile,selectedCountry:data.selectedCountry, selectedState:data.selectedState, selectedTimeZone:data.selectedTimeZone}));
 
   }
 
   toggleProfileActive(profileId){
-   return this.http.get(environment.toggleProfileActive+profileId,{ withCredentials: true });  
+   return this.http.get(environment.toggleProfileActive+profileId);  
   }
   
 
index e53aeb6..a0f5973 100644 (file)
@@ -11,6 +11,7 @@ export const environment = {
   getFunctionCdList:'admin_fn_menu/get_function_cd_list',
   getParentList:'admin_fn_menu/get_parent_list',
   getUserPagination:'get_user_pagination?pageNum=0&viewPerPage=0',
+  getAllUsers:'get_all_users',
   deleteRole:'role_list/removeRole',
   getTopMenu:'get_topMenuInfo',
   deleteRoleFunction:'role_function_list/removeRoleFunction',
index 0114df0..214c39d 100644 (file)
@@ -15,6 +15,7 @@ export const environment = {
   getFunctionCdList:'http://www.sdk.onap.org:8080/epsdk-app-os/admin_fn_menu/get_function_cd_list',
   getParentList:'http://www.sdk.onap.org:8080/epsdk-app-os/admin_fn_menu/get_parent_list',
   getUserPagination:'http://www.sdk.onap.org:8080/epsdk-app-os/get_user_pagination?pageNum=0&viewPerPage=0',
+  getAllUsers:'http://www.sdk.onap.org:8080/epsdk-app-os/get_all_users',
   deleteRole:'http://www.sdk.onap.org:8080/epsdk-app-os/role_list/removeRole',
   getTopMenu:'http://www.sdk.onap.org:8080/epsdk-app-os/get_topMenuInfo',
   deleteRoleFunction:'http://www.sdk.onap.org:8080/epsdk-app-os/role_function_list/removeRoleFunction',
index 1240e98..c42235b 100644 (file)
@@ -51,7 +51,7 @@ export class AdminService {
   constructor(private http:HttpClient) { }
 
    getRoleFunctionList(){
-       return this.http.get(environment.roleFunctionList,{ withCredentials: true });         
+       return this.http.get(environment.roleFunctionList);         
   }
 
   saveRoleFunction(roleData:string){
@@ -60,65 +60,65 @@ export class AdminService {
 
   getUsageList()
   {
-    return this.http.get(environment.usageList,{ withCredentials: true });         
+    return this.http.get(environment.usageList);         
 
   }
 
   getCacheRegions(){
-    return this.http.get(environment.cachedRegions,{ withCredentials: true });         
+    return this.http.get(environment.cachedRegions);         
 
   }
 
   getRole(roleId){
-    return this.http.get(environment.getRole+'?role_id=' + roleId,{ withCredentials: true });         
+    return this.http.get(environment.getRole+'?role_id=' + roleId);         
 
   }
   getFnMenuItems()
   {
-    return this.http.get(environment.getFnMenuItems,{ withCredentials: true });         
+    return this.http.get(environment.getFnMenuItems);         
   }
 
   updateFnMenuItem(menuObj: any): Observable<any> {
     let  updateMenuURL = environment.updateFnMenuItem;
-    return this.http.post(updateMenuURL, menuObj, {withCredentials: true})
+    return this.http.post(updateMenuURL, menuObj)
   }
 
   getFunctionCdList(): Observable<any>{ 
     let getFunctionCdListURL  = environment.getFunctionCdList;
-    return this.http.get(getFunctionCdListURL , { withCredentials: true } );
+    return this.http.get(getFunctionCdListURL);
   }
 
   getParentData(): Observable<any>{ 
     let getParentDataURL  = environment.getParentList;
-    return this.http.get(getParentDataURL , { withCredentials: true } );
+    return this.http.get(getParentDataURL);
   }
 
   deleteRole(roleData:any){
-    return this.http.post(environment.deleteRole,JSON.stringify({role: roleData}),{ withCredentials: true });
+    return this.http.post(environment.deleteRole,JSON.stringify({role: roleData}));
   }
 
   deleteRoleFunction(roleFunc:any)
   {
-    return this.http.post(environment.deleteRoleFunction,roleFunc,{ withCredentials: true });
+    return this.http.post(environment.deleteRoleFunction,roleFunc);
 
   }
 
   removeRoleFunction(roleFunc:any, roleId:any){
     let removeRoleFunctionURL = environment.removeRoleFunction+roleId;
-    return this.http.post(removeRoleFunctionURL,JSON.stringify({roleFunction:roleFunc}),{ withCredentials: true });
+    return this.http.post(removeRoleFunctionURL,JSON.stringify({roleFunction:roleFunc}));
   }
 
   saveRole(roleObj:any, roleId:any){
     let saveRoleURL = environment.saveRole+roleId;
-    return this.http.post(saveRoleURL,JSON.stringify(roleObj),{ withCredentials: true });
+    return this.http.post(saveRoleURL,JSON.stringify(roleObj));
   }
 
   deleteMenu(fnMenuItem:any){
-    return this.http.post(environment.deleteMenu,JSON.stringify({fnMenuItem: fnMenuItem}),{ withCredentials: true });
+    return this.http.post(environment.deleteMenu,JSON.stringify({fnMenuItem: fnMenuItem}));
   }
 
   getCacheRegionDetails(cacheName:any){
-    return this.http.get(environment.getRegion+'?cacheName='+cacheName,{ withCredentials: true });         
+    return this.http.get(environment.getRegion+'?cacheName='+cacheName);         
 
   }
 }
index 5f131fb..a668230 100644 (file)
   
       <ng-container matColumnDef="Last Name">
         <th mat-header-cell *matHeaderCellDef  id="heading2"> {{userHeaders[1]}} </th>
-        <td mat-cell *matCellDef="let rowData"> {{rowData.lastName}} </td>
+        <td mat-cell *matCellDef="let rowData"> {{rowData.last_name}} </td>
       </ng-container>
   
       <ng-container matColumnDef="First Name">
         <th mat-header-cell *matHeaderCellDef  id="heading3">{{userHeaders[2]}} </th>
-        <td mat-cell *matCellDef="let rowData"> {{rowData.firstName}}</td>
+        <td mat-cell *matCellDef="let rowData"> {{rowData.first_name}}</td>
       </ng-container>
 
       <ng-container matColumnDef="Email">
         <td mat-cell *matCellDef="let rowData" > {{rowData.email}} </td>
       </ng-container>
 
-      <ng-container matColumnDef="orgUserId">
+      <ng-container matColumnDef="Org User ID">
         <th mat-header-cell *matHeaderCellDef  id="heading4"> {{userHeaders[4]}} </th>
         <td mat-cell *matCellDef="let rowData" > {{rowData.orgUserId}} </td>
       </ng-container>
 
-      <ng-container matColumnDef="orgManagerUserId">
+      <ng-container matColumnDef="Org Manager User ID">
         <th mat-header-cell *matHeaderCellDef  id="heading4"> {{userHeaders[5]}} </th>
         <td mat-cell *matCellDef="let rowData" > {{rowData.orgManagerUserId}} </td>
       </ng-container>
@@ -86,7 +86,7 @@
       <ng-container matColumnDef="Active?">
         <th mat-header-cell *matHeaderCellDef id="heading6"> {{userHeaders[7]}} </th>
         <td mat-cell *matCellDef="let rowData">
-          <mat-slide-toggle [(ngModel)]="rowData.active" (change)="toggleUserActive(rowData)"></mat-slide-toggle>      
+          <mat-slide-toggle [checked]="(rowData.active_yn =='Y' || rowData.active_yn == true) ? true : false" (change)="toggleUserActive(rowData,$event)"></mat-slide-toggle>      
         </td>
       </ng-container>
 
index 3b9e9d3..ec84c3b 100644 (file)
  */
  
 table {
-    width: 100%;
-  }
-  
-  .mat-form-field {
-    font-size: 14px;
-    width: 100%;
-  }
-  
-  td, th {
-    width: 25%;
-  }
-  .mat-form-field[_ngcontent-c4] {
-    font-size: 14px;
-    width: 20%;
-    float: right;
-  }
+  width: 100%;
+}
 
-  /*td.mat-cell, td.mat-footer-cell{
-    padding: 0;
-    border-bottom-width: 1px;
-    border-bottom-style: solid;
-    border-right-style: solid;
-    border-right-color: rgba(0,0,0,.12);
-    border-right-width: 1px;
-  }
-*/
+::ng-deep .mat-header-cell{
+  font-weight: bold;
+  font-size: 14px;
+  color: #343a40;
+}
 
-td[_ngcontent-c4], th[_ngcontent-c4] {
-  width: 15%;
+::ng-deep .mat-form-field[_ngcontent-c4] {
+  font-size: 14px;
+  width: 20%;
 }
 
 #edit-button{
index 9ae59ca..734aaf0 100644 (file)
@@ -57,14 +57,13 @@ export class SearchComponent implements OnInit {
   response: any;
   result: any;
   profileList:any;
-  userHeaders = ["User ID","Last Name","First Name","Email","orgUserId","orgManagerUserId","Edit","Active?"];
+  userHeaders = ["User ID","Last Name","First Name","Email","Org User ID","Org Manager User ID","Edit","Active?"];
   constructor(public profileservice:ProfileService, public ngbModal: NgbModal,private _router: Router) { }
   dataSource: MatTableDataSource<[]>;
     
   @ViewChild(MatPaginator, {}) paginator: MatPaginator;
   @ViewChild(MatSort, {}) sort: MatSort;
 
-
   ngOnInit() {
     this.getUsers();
   }
@@ -72,7 +71,7 @@ export class SearchComponent implements OnInit {
   getUsers(){
     this.showSpinner = true;
     let response;
-    this.response = this.profileservice.getUserPagination();
+    this.response = this.profileservice.getAllUsers();
     this.response.subscribe(data => {
       response = data;
       this.result = JSON.parse(response.data);
@@ -84,9 +83,9 @@ export class SearchComponent implements OnInit {
     });
   }
 
-  toggleUserActive(user){
-    let activeOrInactive = (user.active) ? 'activate' : 'inactivate';
-    let confirmationMsg = 'You are about to ' + activeOrInactive + ' the user ' + user.firstName +" "+user.lastName+ '. Do you want to continue?';
+  toggleUserActive(user, e){
+    let activeOrInactive = (e.checked) ? 'activate' : 'inactivate';
+    let confirmationMsg = 'You are about to ' + activeOrInactive + ' the user ' + user.first_name +" "+user.last_name+ '. Do you want to continue?';
     const modalInfoRef = this.ngbModal.open(InformationModalComponent);
     modalInfoRef.componentInstance.title = 'Confirmation';
     modalInfoRef.componentInstance.message = confirmationMsg;
@@ -104,7 +103,7 @@ export class SearchComponent implements OnInit {
               this.openConfirmationModal("Error",error);
             });
       } else {
-        user.active = !user.active;
+        this.ngOnInit();
       }
     }, (result) => {
 
index 5a5a41a..5097376 100644 (file)
@@ -45,18 +45,11 @@ import {
 } from '@angular/common/http';
 import { Observable } from 'rxjs';
 import { v4 as uuid } from 'uuid';
-declare const getWebJunctionXSRFToken: any;
 export class HeaderInterceptor implements HttpInterceptor {
     intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
-        // Clone the request to add the new header
-        // HttpHeader object immutable - copy values
-        var XSRFToken = getWebJunctionXSRFToken();
-        console.log('XSRFToken:', XSRFToken);
         const headerSettings: { [name: string]: string | string[]; } = {};
         headerSettings['X-ECOMP-RequestID'] = uuid();
         const requestType = req.params.get('requestType');
-        if (XSRFToken.name && XSRFToken.value)
-            headerSettings['X-XSRF-TOKEN'] = XSRFToken.value;
         if(requestType!=null && requestType==='fileUpload'){
           //headerSettings['Content-Type'] = 'multipart/form-data';
         }else{
index 9a43a20..880b6d7 100644 (file)
@@ -51,4 +51,6 @@ public interface UserProfileService {
        public List<User> findAllUserWithOnOffline(String originOrgUserId);
 
        List<User> findAllActive();
+       
+       List<User> listAllUsers();
 }
index 879a11d..67dfefa 100644 (file)
@@ -45,6 +45,7 @@ import java.util.SortedSet;
 
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Restrictions;
+import org.onap.portalsdk.core.domain.Profile;
 import org.onap.portalsdk.core.domain.Role;
 import org.onap.portalsdk.core.domain.User;
 import org.onap.portalsdk.core.domain.support.CollaborateList;
@@ -132,4 +133,11 @@ public class UserProfileServiceImpl implements UserProfileService {
                return users;
        }
 
+       @Override
+       public List<User> listAllUsers() {
+               @SuppressWarnings("unchecked")
+               List<User> users = getDataAccessService().getList(Profile.class, null);
+               return users;
+       }
+
 }