diff options
author | Sudarshan Kumar <sudarshan.kumar@att.com> | 2020-06-02 19:29:08 +0530 |
---|---|---|
committer | Sudarshan Kumar <sudarshan.kumar@att.com> | 2020-06-03 16:39:50 +0530 |
commit | 1484acff4ddce388b61f46761c188d859a4309c5 (patch) | |
tree | 4c57886d841718c8ca6521d2e46b3159c1438cee | |
parent | 6d48b04c34a009323b92b23efc507c63e40b1d87 (diff) |
Improved Profile Search performance
Improved Profile Search performance
Issue-ID: PORTAL-915
Change-Id: I05fa030ff326ff38b1f12a10f40c4bb28590ed61
Signed-off-by: Sudarshan Kumar <sudarshan.kumar@att.com>
12 files changed, 85 insertions, 72 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java index ff80d413..24e44d4b 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java @@ -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) diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts index a86ea759..6dcdda67 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts @@ -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 {} diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts index 7d14ee39..1c631347 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts @@ -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); } diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts index e53aeb67..a0f59731 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts @@ -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', diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts index 0114df00..214c39df 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts @@ -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', diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts index 1240e981..c42235be 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts @@ -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); } } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html index 5f131fb6..a6682306 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html @@ -50,12 +50,12 @@ <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"> @@ -63,12 +63,12 @@ <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> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss index 3b9e9d3b..ec84c3b0 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss @@ -37,35 +37,18 @@ */ 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{ diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts index 9ae59ca8..734aaf09 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts @@ -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) => { diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts index 5a5a41a8..50973763 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts @@ -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{ diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java index 9a43a203..880b6d73 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java @@ -51,4 +51,6 @@ public interface UserProfileService { public List<User> findAllUserWithOnOffline(String originOrgUserId); List<User> findAllActive(); + + List<User> listAllUsers(); } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java index 879a11de..67dfefab 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java @@ -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; + } + } |