diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp')
12 files changed, 500 insertions, 82 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts index f06719fc..7bf5c649 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts @@ -78,7 +78,7 @@ export class HeaderComponent implements OnInit { } this.pushRightClass = 'push-right'; - this.appName= 'ONAP ENMT' ; + this.appName= 'ONAP Portal' ; let result = this.headerService.getTopMenuItems(); result.subscribe(res => { this.response = res; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.scss b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.scss index 0f868ab4..d5bf6ac0 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.scss +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.scss @@ -57,4 +57,8 @@ td[_ngcontent-c4], th[_ngcontent-c4] { font-size: 14px; width: 20%; float: left; +} + +rdp-data-table{ + overflow-x : scroll; }
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts index 5d996964..c6fbc8c4 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.ts @@ -72,12 +72,12 @@ export class MenusComponent implements OnInit { public columns: any = []; activeStatusOptions = [ - {index: 0, value: 'true', name: 'Y'}, - {index: 1, value: 'false', name: 'N'} + {id: '0', name: 'Y'}, + {id: '1', name: 'N'} ]; separatorStatusOptions = [ - {index: 0, value: 'true', name: 'Y'}, - {index: 1, value: 'false', name: 'N'} + {id: '0', name: 'Y'}, + {id: '1', name: 'N'} ]; functionCDselectData = []; parentListSelectData = []; @@ -192,6 +192,7 @@ export class MenusComponent implements OnInit { this.parentList.push({id: _data[i][0], name: _data[i][1]}); } console.log("Actual parent list : ", this.parentList); + this.menuService.getParentList(this.parentList); } }, error => { this.showSpinner = false; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts new file mode 100644 index 00000000..8d5c6637 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts @@ -0,0 +1,134 @@ + +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +import { TestBed} from '@angular/core/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClientModule } from '@angular/common/http'; +import { MenusService } from './menus.service'; +import { AdminService } from '../admin.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; + +describe('MenusService', () => { + + let component:MenusService; + let service:AdminService; + var stubData={"data":['{"active":"data"}','{"separator":"data1"}']}; + + beforeEach(() =>{ + TestBed.configureTestingModule({ + imports:[HttpClientTestingModule], + providers: [HttpClientModule,MenusService] + }) + component = TestBed.get(MenusService); + service = TestBed.get(AdminService); + }); + + it('should be created', () => { + const component: MenusService = TestBed.get(MenusService); + expect(component).toBeTruthy(); + }); + + // it('should test getTotalRowCount method',()=>{ + // component.getTotalRowCount(); + // }) + + it('should test updateStatus method',()=>{ + component['updateStatus']('N'); + }) + + it('should test updateBooleanValue method',()=>{ + component['updateBooleanValue'](true); + component['updateBooleanValue'](false); + }) + + it('should test updateParentNameToID method',()=>{ + component.parentList=[{'name':'data'}]; + component['updateParentNameToID']('data'); + }) + + it('should test menu',()=>{ + console.log(component.menu); + expect(component.menu.action).toEqual(null); + }) + + it('should test add method',()=>{ + component.add("data"); + }) + + it('should test update method',()=>{ + let spy=spyOn(service,'updateFnMenuItem').and.returnValue(Observable.of("")); + component.update(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getParentData method2 error part ',()=>{ + let spy=spyOn(service,'updateFnMenuItem').and.returnValue(Observable.throw({status:404})); + component.update(stubData) + expect(spy).toHaveBeenCalled(); + }) + + + it('should test delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.of("")); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test error part of delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.throw({status:404})); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getParentList method',()=>{ + component.getParentList("getParentList"); + expect(component.parentList).toEqual("getParentList"); + }) + + it('should test get method',()=>{ + let spy=spyOn(service,'getFnMenuItems').and.returnValue(Observable.of()); + component.get(); + expect(spy).toHaveBeenCalled(); + }) +}); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts index 9df51b51..912b65bb 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts @@ -104,24 +104,32 @@ export class MenusService implements RdpCrudInterface { data.active = this.updateStatus(data.active); data.separator = this.updateStatus(data.separator); let keys = Object.keys(data); + let menuCache = this.menu; keys.forEach(element => { if (data[element] != null || data[element] != undefined) { if (element == 'parentId') { - this.menu[element] = 1; + if (isNaN(data[element])) { + menuCache[element] = this.updateParentNameToID(data[element]); + } else{ + menuCache[element] = data[element]; + } + console.log("Parent Id to update : ", menuCache[element]); } else { - this.menu[element] = data[element]; + menuCache[element] = data[element]; } } }); - let result = { availableFnMenuItem: this.menu }; + let result = { availableFnMenuItem: menuCache }; let postData = JSON.stringify(result); console.log("postData >>>>>>", postData); this.adminService.updateFnMenuItem(postData) .subscribe(_data => { console.log("Response : ", _data); this.statusResponse.next("200"); + menuCache = this.menu; }, error => { console.log("Error : ", error); + menuCache = this.menu; }); } @@ -131,11 +139,10 @@ export class MenusService implements RdpCrudInterface { console.log(data.active); data.active = this.updateStatus(data.active); data.separator = this.updateStatus(data.separator); - let result = { availableFnMenuItem: data }; - this.adminService.deleteMenu(result).subscribe(response => { + this.adminService.deleteMenu(data).subscribe(response => { console.log("Response ", response); this.statusResponse.next("200"); - }, error =>{ + }, error => { console.log("Error : ", error); }) } @@ -148,15 +155,44 @@ export class MenusService implements RdpCrudInterface { } } + private updateBooleanValue(data) { + if (data) { + return 'Y'; + } else { + return 'N'; + } + } + + parentList: any; + + getParentList(list) { + this.parentList = list; + } + + private updateParentNameToID(data) { + let val; + this.parentList.forEach(ele => { + if (ele['name'] == data) { + val = ele['id']; + } + }); + console.log("ParentId value ", val); + return val; + } + get() { - console.log("get method is getting called from AppServie data:: "); + console.log("get method is getting called from MenuServie data:: "); let response = this.adminService.getFnMenuItems(); let resp; response.subscribe(res => { - console.log("Get Response : ", res); resp = res; - console.log("edited : ",JSON.parse(resp.data).fnMenuItems); - this.updatedData.next(JSON.parse(resp.data).fnMenuItems); + let responseData = JSON.parse(resp.data).fnMenuItems; + responseData.forEach(element => { + element.active = this.updateBooleanValue(element.active); + element.separator = this.updateBooleanValue(element.separator); + }) + this.updatedData.next(responseData); }) } + } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/new-role-function/new-role-function.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/new-role-function/new-role-function.component.spec.ts index ecc0947d..7ef63baf 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/new-role-function/new-role-function.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/new-role-function/new-role-function.component.spec.ts @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -41,7 +43,12 @@ import { NewRoleFunctionComponent } from './new-role-function.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import {MatRadioModule } from '@angular/material'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; describe('NewRoleFunctionComponent', () => { let component: NewRoleFunctionComponent; @@ -50,10 +57,25 @@ describe('NewRoleFunctionComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ schemas:[CUSTOM_ELEMENTS_SCHEMA], - declarations: [ NewRoleFunctionComponent ], - imports:[FormsModule,HttpClientTestingModule], + declarations: [ + NewRoleFunctionComponent, + ConfirmationModalComponent, + InformationModalComponent + ], + imports:[ + FormsModule, + HttpClientTestingModule, + MatRadioModule, + RouterTestingModule, + NgbModule.forRoot() + ], providers:[NgbActiveModal] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[ConfirmationModalComponent,InformationModalComponent] + } + }) .compileComponents(); })); @@ -63,7 +85,19 @@ describe('NewRoleFunctionComponent', () => { fixture.detectChanges(); }); - // it('should create', () => { - // expect(component).toBeTruthy(); - // }); + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should test ngOnInit method',()=>{ + component.ngOnInit(); + }) + + it('should test saveRoleFunction method',()=>{ + component.saveRoleFunction(); + }) + + it('should test openConfirmationModal method',()=>{ + component.openConfirmationModal("indrijeet","kumar") + }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts new file mode 100644 index 00000000..0e59f9eb --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts @@ -0,0 +1,62 @@ + +import { TestBed} from '@angular/core/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClientModule } from '@angular/common/http'; +import { AdminService } from '../admin.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; +import { RoleFunctionsService } from './role-functions.service'; + +describe('RoleFunctionsService', () => { + + let component:RoleFunctionsService; + let service:AdminService; + //var stubData=['{"data":'{"active":"data2"}'}'] + //var stubData1='{stubData}' + + beforeEach(() =>{ + TestBed.configureTestingModule({ + imports:[HttpClientTestingModule], + providers: [HttpClientModule,RoleFunctionsService] + }) + component = TestBed.get(RoleFunctionsService); + service = TestBed.get(AdminService); + }); + + it('should be created', () => { + const component: RoleFunctionsService = TestBed.get(RoleFunctionsService); + expect(component).toBeTruthy(); + }); + + it('should test add method',()=>{ + component.add("data"); + }) + + it('should test update method',()=>{ + let spy=spyOn(service,'saveRoleFunction').and.returnValue(Observable.of('your object')); + component.update("data"); + expect(spy).toHaveBeenCalled(); + }) + + it('should test error part of update method',()=>{ + let spy=spyOn(service,'saveRoleFunction').and.returnValue(Observable.throw({status:404})); + component.update("data"); + expect(spy).toHaveBeenCalled(); +}) + + + it('should test delete method',()=>{ + let spy=spyOn(service,'deleteRoleFunction').and.returnValue(Observable.of('your object')); + component.delete("data"); + expect(spy).toHaveBeenCalled(); + }) + + it('should test get method',()=>{ + let spy=spyOn(service,'getRoleFunctionList').and.returnValue(Observable.of()) + component.get(); + expect(spy).toHaveBeenCalled(); + }) + +});
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts index 4b496f1b..8a30f2a3 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts @@ -43,9 +43,10 @@ import {FormsModule} from '@angular/forms'; import { NewRoleComponent } from './new-role.component'; import { MatTableModule } from '@angular/material' import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { HttpClient, HttpClientModule } from '@angular/common/http'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; describe('NewRoleComponent', () => { let component: NewRoleComponent; @@ -56,8 +57,21 @@ describe('NewRoleComponent', () => { TestBed.configureTestingModule({ providers: [NgbActiveModal], schemas: [CUSTOM_ELEMENTS_SCHEMA] , - declarations: [ NewRoleComponent ], - imports: [FormsModule, MatTableModule, HttpClientTestingModule] + declarations: [ + NewRoleComponent, + ConfirmationModalComponent + ], + imports: [ + FormsModule, + MatTableModule, + HttpClientTestingModule, + NgbModule.forRoot() + ] + }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[ConfirmationModalComponent] + } }) .compileComponents(); })); @@ -69,7 +83,26 @@ describe('NewRoleComponent', () => { fixture.detectChanges(); }); - // it('should create', () => { - // expect(component).toBeTruthy(); - // }); + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should test toggleRoleFunction method',()=>{ + component.ociavailableRoleFunctions=1; + component.toggleRoleFunction("toggleRoleFunction") + }) + + it('should test populateTableData method',()=>{ + component.populateTableData("populateTableData"); + expect(component.roleFunctionDataSource.sort).toEqual(component.sort); + expect(component.roleFunctionDataSource.paginator).toEqual(component.paginator) + }) + + it('should test isRoleAlreadyExist method',()=>{ + component.isRoleAlreadyExist("currentRoleName") + }) + + it('it should test openConfirmationModal method',()=>{ + component.openConfirmationModal("indrijeet","kumar"); + }) });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts index dcd637fc..92d96135 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts @@ -47,9 +47,10 @@ import { MatTableModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModule, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { NewRoleComponent } from './new-role/new-role.component'; describe('RolesComponent', () => { let component: RolesComponent; @@ -102,4 +103,20 @@ describe('RolesComponent', () => { // it('should test openAdoleModaldNewR method',()=>{ // component.openAdoleModaldNewR('dummydata2') // }) + + it('should test openAdoleModaldNewR method',()=>{ + component.toggleRole("") + }) + + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + + // it('should test applyFilter method',()=>{ + // component.applyFilter("filterValue T"); + // expect(component.dataSource.filter).toEqual("filtervalue"); + // }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts index 7481acc8..ee8f7b64 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts @@ -48,6 +48,9 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; +import { ActivatedRoute } from '@angular/router'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; describe('SelfComponent', () => { let component: SelfComponent; @@ -66,7 +69,8 @@ describe('SelfComponent', () => { MatSelectModule, MatSlideToggleModule, BrowserAnimationsModule, - HttpClientTestingModule + HttpClientTestingModule, + RouterTestingModule ] }) .compileComponents(); @@ -91,4 +95,10 @@ describe('SelfComponent', () => { }) }) + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts index 45210f80..61b2a343 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts @@ -46,6 +46,7 @@ import { InformationModalComponent } from 'src/app/modals/information-modal/info import { ErrorModalComponent } from 'src/app/modals/error-modal/error-modal.component'; import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; import { Column, ColumnTypes, DataTableSettings } from 'portalsdk-tag-lib'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-self', @@ -54,7 +55,10 @@ import { Column, ColumnTypes, DataTableSettings } from 'portalsdk-tag-lib'; }) export class SelfComponent implements OnInit { - constructor(public userService: UserService, public profileService: ProfileService, private ngModal: NgbModal) { } + constructor(public userService: UserService, + public profileService: ProfileService, + private ngModal: NgbModal, + private route: ActivatedRoute) { } user: User; isAppCentralized; @@ -98,6 +102,11 @@ export class SelfComponent implements OnInit { ngOnInit() { + this.profileId = ""; + console.log("ngOnInit called ",this.profileId); + if(this.route.snapshot.queryParams['profile_id']){ + this.profileId = this.route.snapshot.queryParams['profile_id']; + } this.showSpinner = false; this.finalSelectedRoles = []; let result = this.userService.getFunctionalMenuStaticDetailSession(); @@ -106,7 +115,11 @@ export class SelfComponent implements OnInit { this.user = user; this.isAppCentralized = this.user.isAppCentralized; }); - this.getSelfProfileDetail(); + if (this.profileId != undefined && this.profileId != "") { + this.getProfileById(this.profileId); + } else { + this.getSelfProfileDetail(); + } } /** @@ -116,65 +129,77 @@ export class SelfComponent implements OnInit { this.showSpinner = true; this.response = this.profileService.getSelfProfile(); this.response.subscribe(data => { - let res; - res = data; - this.result = JSON.parse(res.data); - this.profile = JSON.parse(this.result.profile); - this.oriProfile = JSON.parse(this.result.profile); /*original value*/ + this.assignProfileDetails(data); + }); + this.showSpinner = false; + } - this.profileId = this.profile.id; - this.ociavailableRoles = JSON.parse(this.result.availableRoles); - this.ociTimeZones = JSON.parse(this.result.timeZones); - this.ociCountries = JSON.parse(this.result.countries); - this.stateList = JSON.parse(this.result.stateList); + /** + * Get Profile Details by ProfileId + */ + getProfileById(profileId) { + this.showSpinner = true; + this.profileService.getProfileById(profileId).subscribe(response => { + this.assignProfileDetails(response); + }) + this.showSpinner = false; + } - for( let state of this.stateList) - { - if(state.value == this.profile.state){ - this.profile.state= state.value; - } - } + assignProfileDetails(data) { + let res; + res = data; + this.result = JSON.parse(res.data); + + this.profile = JSON.parse(this.result.profile); + this.oriProfile = JSON.parse(this.result.profile); /*original value*/ - for( let country of this.ociCountries) - { - if(country.value == this.profile.country){ - this.profile.country= country.value; - } - } + this.profileId = this.profile.id; + this.ociavailableRoles = this.profile.roles; + console.log("Profile specific roles : ", this.ociavailableRoles); + this.ociTimeZones = JSON.parse(this.result.timeZones); + this.ociCountries = JSON.parse(this.result.countries); + this.stateList = JSON.parse(this.result.stateList); - for( let timeZone of this.ociTimeZones) - { - if(timeZone.value == this.profile.timeZoneId){ - this.profile.timeZoneId= timeZone.value; - } - } + for (let state of this.stateList) { + if (state.value == this.profile.state) { + this.profile.state = state.value; + } + } + + for (let country of this.ociCountries) { + if (country.value == this.profile.country) { + this.profile.country = country.value; + } + } + + for (let timeZone of this.ociTimeZones) { + if (timeZone.value == this.profile.timeZoneId) { + this.profile.timeZoneId = timeZone.value; + } + } - console.log("Data : ", this.ociavailableRoles); - this.columns.push(new Column("name", "Name", ColumnTypes.TEXT, false, null)); - this.settings = new DataTableSettings() - this.settings.columns = this.columns; - this.settings.isPaginationEnabled = false; - this.settings.isReadOnly = true; - this.settings.isTableSearchEnabled = false; - this.settings.isToggleEnabled = true; + this.columns.push(new Column("name", "Name", ColumnTypes.TEXT, false, null)); + this.settings = new DataTableSettings() + this.settings.columns = this.columns; + this.settings.isPaginationEnabled = false; + this.settings.isReadOnly = true; + this.settings.isTableSearchEnabled = false; + this.settings.isToggleEnabled = true; - if (this.ociavailableRoles != null) { - for (let role of this.ociavailableRoles) { - role.selected = false; - for (let profileRole of this.profile.roles) { - if (profileRole.id === role.id) { - role.selected = true; - } - if (role.id === 1) { - this.isUserSystemAdmin = true; - } + if (this.ociavailableRoles != null) { + for (let role of this.ociavailableRoles) { + role.selected = false; + for (let profileRole of this.profile.roles) { + if (profileRole.id === role.id) { + role.selected = true; + } + if (role.id === 1) { + this.isUserSystemAdmin = true; } - this.availableRoles.push(role); } + this.availableRoles.push(role); } - - }); - this.showSpinner = false; + } } /** diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts new file mode 100644 index 00000000..e82a7ebc --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HeaderInterceptor } from './header-interceptor'; + +describe('HeaderInterceptor', () => { + let component: HeaderInterceptor; + let fixture: ComponentFixture<HeaderInterceptor>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + }) + .compileComponents(); + })); + + beforeEach(() => { + component=new HeaderInterceptor() + }); + + it('should create', () => { + expect(component).toBeTruthy(); + component.intercept; + }); +}); |