From fa65ff3142f318ae308a5271e5c33d1933e58b58 Mon Sep 17 00:00:00 2001 From: Sudarshan Kumar Date: Tue, 10 Dec 2019 22:22:41 +0530 Subject: Added portal-FE-common - angular upgrade code Added Microservice-Onboarding Component Issue-ID: PORTAL-795 Change-Id: I3cc9836155a5935e754c7ad25929bdd6e5e63e3f Signed-off-by: Sudarshan Kumar --- .../microservice-add-details.component.html | 214 +++++++++++++++ .../microservice-add-details.component.scss | 211 ++++++++++++++ .../microservice-add-details.component.spec.ts | 62 +++++ .../microservice-add-details.component.ts | 303 +++++++++++++++++++++ .../microservice-onboarding.component.html | 89 ++++++ .../microservice-onboarding.component.scss | 46 ++++ .../microservice-onboarding.component.spec.ts | 63 +++++ .../microservice-onboarding.component.ts | 156 +++++++++++ .../model/microservice-onboarding/microservices.ts | 58 ++++ .../microservice/microservice.service.spec.ts | 49 ++++ .../services/microservice/microservice.service.ts | 86 ++++++ 11 files changed, 1337 insertions(+) create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.html create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.scss create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.ts create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.html create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.scss create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts create mode 100644 portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.ts create mode 100644 portal-FE-common/src/app/shared/model/microservice-onboarding/microservices.ts create mode 100644 portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts create mode 100644 portal-FE-common/src/app/shared/services/microservice/microservice.service.ts diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.html b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.html new file mode 100644 index 00000000..4ec8ae3d --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.html @@ -0,0 +1,214 @@ + + +
+
+ + + + + + + + +
+
\ No newline at end of file diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.scss b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.scss new file mode 100644 index 00000000..1ea39095 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.scss @@ -0,0 +1,211 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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============================================ + * + * + */ + +::ng-deep .modal-dialog { + max-width: 600px; + width: 600px; + overflow-x: auto; + overflow-y: auto; +} + +::ng-deep .modal-body { + padding: -1rem; +} + +::ng-deep .mat-form-field-infix { + width: 400px; +} + +.microservice-add-details-model .microservice-properties-main { + padding-left: 20px; + padding-right: 20px; + margin-bottom: 50px; + height: 430px; + width: 100%; + overflow-x: auto; +} + +.microservice-add-details-model .microservice-properties-main .item { + position: relative; + margin-bottom: 15px; + width: 400px; +} + +.microservice-add-details-model .microservice-properties-main .item .error-container { + position: absolute; + width: 280px; + display: block; + height: 12px; + line-height: 12px; +} + +.microservice-add-details-model .microservice-properties-main .item .error-container .err-message { + color: #cf2a2a; + font-size: 10px; +} + +.microservice-add-details-model .microservice-properties-main .item .item-label { + color: #5a5a5a; + font-family: Omnes-ECOMP-W02,Arial; + font-size: 14px; +} + +.microservice-add-details-model .microservice-properties-main .item .left-test-item { + display: inline-block; + width: 85%; + background: #fff; +} + +.microservice-add-details-model .microservice-properties-main .item .right-test-item { + position: relative; + display: inline-block; + width: 15%; + float: right; +} + +.microservice-add-details-model .microservice-properties-main .item .test-button { + color: #fff; + font-family: Omnes-ECOMP-W02-Medium,Arial; + font-size: 14px; + border-style: solid; + border-width: 1px; + border-radius: 6px; + box-shadow: 0 1px 0.99px 0.01px rgba(2,60,89,.004); + height: 29px; + line-height: 29px; + cursor: pointer; + text-align: center; + background: #067ab4; +} + +.microservice-add-details-model .microservice-properties-main .item { + position: relative; + margin-bottom: 15px; + width: 400px; +} + +.microservice-add-details-model .microservice-properties-main .add-para-item { + position: relative; + display: inline-flex; +} + +.microservice-add-details-model .microservice-properties-main .add-para-item .add-label-left { + line-height: 25px; + height: 30px; + vertical-align: middle; + display: inline-block; + margin-right: 10px; + background: #fff; + color: #5a5a5a; + font-family: Omnes-ECOMP-W02,Arial; + font-size: 14px; +} + +.microservice-add-details-model .microservice-properties-main .microservice-property { + margin-top: 10px; + position: relative; +} + +.icon-primary-accordion-minus, .icon-primary-expanded, .icon-primary-accordion-plus, .icon-primary-collapsed { + font-size: 20px !important; +} + +#microservice-details-input-name{ + width: 16em; +} + +#widgets-details-input-desc{ + width: 25em; +} + +.microservice-desc { + overflow: auto; + resize: vertical; + width: 29em; +} + +.json-field { + overflow: auto; + resize: vertical; + width: 25em; +} + +#microservice-details-input-app{ + width: 25em; + height: 32px; +} + +#microservice-details-input-endpoint-url{ + width: 25em; +} + +#microservice-details-input-security-type{ + width: 25em; + height: 32px; +} + +.microservice-add-details-model .microservice-properties-main .item .para-label-item-right { + margin-left: 201px!important; + position: absolute!important; + margin-top: -19px!important; + width: 50%!important; +} + +.microservice-add-details-model .microservice-properties-main .item .para-item-right { + margin-top: -27px; + position: absolute; + margin-left: 500px; +} + +.table-search-field { + width: 48% !important; + margin-bottom: 5px; +} + +#microservice-details-user-paramters{ + display: inline-flex; +} + +.required:before { + color: #cf2a2a; + margin-right: 2px; + content: "* "; + position: absolute; + top: 28px; + left: -10px; +} \ No newline at end of file diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts new file mode 100644 index 00000000..5589854c --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { MicroserviceAddDetailsComponent } from './microservice-add-details.component'; + +describe('MicroserviceAddDetailsComponent', () => { + let component: MicroserviceAddDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MicroserviceAddDetailsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MicroserviceAddDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.ts new file mode 100644 index 00000000..5e359dd4 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.ts @@ -0,0 +1,303 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { IMircroservies } from 'src/app/shared/model/microservice-onboarding/microservices'; +import { MicroserviceService, WidgetOnboardingService } from '../../../shared/services/index'; +import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + selector: 'app-microservice-add-details', + templateUrl: './microservice-add-details.component.html', + styleUrls: ['./microservice-add-details.component.scss'] +}) +export class MicroserviceAddDetailsComponent implements OnInit { + + @Input() public ms: IMircroservies; + @Output() passEntry: EventEmitter = new EventEmitter(); + result: any; + selected: any; + isEditMode: any; + originalName: string; + dupliateName = false; + emptyServiceName = false; + emptyServiceDesc = false; + emptyServiceURL = false; + emptyServiceApp = false; + availableSecurityTypes = []; + availableWidgets = []; + applicationList: Array = []; + + constructor(public microservice: MicroserviceService, public widgetOnboardingService: WidgetOnboardingService, + public activeModal: NgbActiveModal, public ngbModal: NgbModal) { } + + ngOnInit() { + if(this.ms.name){ + this.isEditMode = true; + }else{ + this.isEditMode = false; + } + this.ms.parameterList = []; + this.ms.active = true; + this.populateAvailableApps(); + this.getAvailableSecurityTypes(); + } + + getAvailableWidgets(serviceId){ + console.log("getAvailableWidgets called"); + this.microservice.getWidgetListByService(serviceId) + .subscribe(data => { + this.result = data; + if (this.result == null || this.result) { + console.log('MicroserviceService::getServiceList Failed: Result or result.data is null'); + }else { + this.availableWidgets = []; + for(var i = 0; i < data.length; i++){ + this.availableWidgets.push({ + name: data[i] + }) + } + } + }, error =>{ + console.log(error); + }); + }; + + getAvailableSecurityTypes(): Array { + this.availableSecurityTypes = []; + this.availableSecurityTypes.push({ + id: 0, + name: 'No Authentication' + }); + this.availableSecurityTypes.push({ + id: 1, + name: 'Basic Authentication' + }); + this.availableSecurityTypes.push({ + id: 2, + name: 'Cookie based Authentication' + }); + + return this.availableSecurityTypes; + }; + + populateAvailableApps(){ + this.widgetOnboardingService.populateAvailableApps() + .subscribe( _data => { + let allPortalsFilterObject = {index: 0, title: 'Select Application', value: ''}; + this.applicationList = [allPortalsFilterObject]; + var realAppIndex = 1; + for (let i = 1; i <= _data.length; i++) { + if (!_data[i-1].restrictedApp) { + this.applicationList.push({ + index: realAppIndex, + title: _data[i - 1].name, + value: _data[i - 1].id + }) + realAppIndex = realAppIndex + 1; + } + } + }, error => { + console.log(error); + }); + }; + + addParameter() { + this.ms.parameterList.push({}); + } + + testServiceURL(){ + console.log("testServiceURL called id is :: ",this.ms.id) + this.microservice.getServiceJSON(this.ms.id) + .subscribe( _data => { + this.result = _data; + console.log("testServiceURL response :: ",this.result); + document.getElementById("microservice-details-input-json").innerHTML = (JSON.stringify(this.result)); + }, error => { + document.getElementById("microservice-details-input-json").innerHTML = "Something went wrong. Please go back to the previous page or try again later."; + console.log(error); + }); + } + + removeParamItem(parameter: any){ + console.log("removeParamItem called", parameter); + this.ms.parameterList.splice(parameter.para_key, 1); + this.microservice.getUserParameterById(parameter) + .subscribe(data => { + this.result = data; + if (this.result == null || this.result) { + console.log('MicroserviceService::removeParamItem Failed: Result or result.data is null'); + }else if(this.result && this.result.length > 0) { + this.microservice.deleteUserParameterById(parameter.id) + .subscribe(__data => { + for(var i = 0; i < this.ms.parameterList.length; i++){ + if(this.ms.parameterList[i].para_key == parameter.para_key + && this.ms.parameterList[i].para_value == parameter.para_value){ + this.ms.parameterList.splice(i, 1); + return; + } + } + + }, error =>{ + console.log(error); + }); + }else{ + for(var i = 0; i < this.ms.parameterList.length; i++){ + if(this.ms.parameterList[i].para_key == parameter.para_key + && this.ms.parameterList[i].para_value == parameter.para_value){ + this.ms.parameterList.splice(i, 1); + return; + } + } + } + }, error =>{ + console.log(error); + }); + } + + //Add Or Update Microservices. + saveChanges(){ + console.log("saveChanges..",this.ms); + if(this.ms && this.ms.id && this.ms.id !='undefined'){ + this.isEditMode = true; + } + var isValid = true; + + if(this.ms.name == '' + || this.ms.name == undefined){ + this.emptyServiceName = true; + isValid = false; + } + console.log("a >",isValid); + if(this.dupliateName == true){ + isValid = false; + } + console.log("b> ",isValid); + if(this.ms.desc == '' + || this.ms.desc == undefined){ + this.emptyServiceDesc = true; + isValid = false; + } + console.log("c> ",isValid); + + if(this.ms.url == '' + || this.ms.url == undefined){ + this.emptyServiceURL = true; + isValid = false; + } + console.log("d> ",isValid); + + if(this.ms.appId == undefined + || this.ms.appId == null){ + this.emptyServiceApp = true; + isValid = false; + } + + console.log("IsValid flag add/update microservices ",isValid ) + + if(!isValid) + return; + /* + * Check the parameter list, delete those parameters that don't + * have key + */ + if(this.ms && this.ms.parameterList){ + for(var i = 0; i < this.ms.parameterList.length; i++){ + if(this.ms.parameterList[i].para_key == undefined + || this.ms.parameterList[i].para_key == null + || this.ms.parameterList[i].para_key == ""){ + this.ms.parameterList.splice(i, 1); + i--; + } + } + } + if(this.ms.securityType == undefined || + this.ms.securityType == null) + this.ms.securityType = "No Authentication"; + else{ + this.ms.securityType = this.ms.securityType; + this.ms.username = this.ms.username; + this.ms.password = this.ms.password; + } + + var active = 'N'; + if(this.ms.active == true) + active = 'Y'; + + let paramList = []; + if(this.ms.parameterList && this.ms.parameterList.length >0){ + paramList = this.ms.parameterList; + } + var newService = { + name: this.ms.name, + desc: this.ms.desc, + appId: this.ms.appId, + url: this.ms.url, + securityType: this.ms.securityType, + username: this.ms.username, + password: this.ms.password, + active: active, + parameterList: paramList + }; + + if(this.isEditMode){ + console.log("Edit microservice mode called"); + this.microservice.updateService(this.ms.id , newService) + .subscribe( data => { + this.result = data; + console.log("update microservice response :: ",this.result); + this.passEntry.emit(this.result); + this.ngbModal.dismissAll(); + }, error => { + console.log(error); + this.ngbModal.dismissAll(); + }); + }else{ + console.log("Add microservice mode called") + this.microservice.createService(newService) + .subscribe( data => { + this.result = data; + console.log("add microservice response :: ",this.result); + this.passEntry.emit(this.result); + this.ngbModal.dismissAll(); + }, error => { + this.ngbModal.dismissAll(); + console.log(error); + }); + } + } +} diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.html b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.html new file mode 100644 index 00000000..45a68650 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.html @@ -0,0 +1,89 @@ + + +
+
+

Microservice Onboarding

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Microservice Name {{element.name}} + Service End Point URL {{element.url}} Security Type {{element.securityType}} Delete + + + +
+ +
\ No newline at end of file diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.scss b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.scss new file mode 100644 index 00000000..135fbda2 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.scss @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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============================================ + * + * + */ + +.container th{ + padding-bottom: 15px; + font-weight: bold; +} + +.ion-md-trash{ + cursor: pointer; +} \ No newline at end of file diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts new file mode 100644 index 00000000..09d30a14 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { MicroserviceOnboardingComponent } from './microservice-onboarding.component'; + +describe('MicroserviceOnboardingComponent', () => { + let component: MicroserviceOnboardingComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MicroserviceOnboardingComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MicroserviceOnboardingComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.ts new file mode 100644 index 00000000..d2d66974 --- /dev/null +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.ts @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { Component, OnInit, ViewChild, Input } from '@angular/core'; +import { MicroserviceService, WidgetOnboardingService } from '../../shared/services/index' +import { IMircroservies } from 'src/app/shared/model/microservice-onboarding/microservices'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { MatTableDataSource } from '@angular/material'; +import { MatSort, MatPaginator } from '@angular/material'; +import { MicroserviceAddDetailsComponent } from './microservice-add-details/microservice-add-details.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; + +@Component({ + selector: 'app-microservice-onboarding', + templateUrl: './microservice-onboarding.component.html', + styleUrls: ['./microservice-onboarding.component.scss'] +}) +export class MicroserviceOnboardingComponent implements OnInit { + + showSpinner = true; + microServiceList: Array = []; + result: any; + isEditMode: boolean = false; + + displayedColumns: string[] = ['microserviceName', 'serviceEndPointURL', 'securityType','delete']; + dataSource = new MatTableDataSource(this.microServiceList); + @ViewChild(MatSort) sort: MatSort; + @ViewChild(MatPaginator) paginator: MatPaginator; + + constructor(public microservice: MicroserviceService, public ngbModal: NgbModal ) { } + + ngOnInit() { + this.getOnboardingServices(); + } + + getOnboardingServices(){ + //console.log("getOnboardingServices called"); + this.microservice.getServiceList() + .subscribe(_data => { + this.result = _data; + if (this.result == null || this.result == 'undefined') { + console.log('MicroserviceService::getServiceList Failed: Result or result.data is null'); + }else { + this.microServiceList = this.result; + this.populateTableData(this.microServiceList); + } + }, error =>{ + console.log(error); + }); + } + + deleteService(microserviceObj: IMircroservies, isConfirmed: boolean): void { + let confirmationMsg = 'You are about to delete this Microservice : ' + microserviceObj.name+ '. Click OK to continue.'; + this.openInformationModal("Confirmation",confirmationMsg).result.then((result) => { + if (result === 'Ok') { + if(!microserviceObj || microserviceObj == null){ + console.log('MicroserviceOnboardingCtrl::deleteService: No service or ID... cannot delete'); + return; + } + //console.log("service id to delete", microserviceObj.id) + this.microServiceList.splice(this.microServiceList.indexOf(microserviceObj), 1); + this.populateTableData(this.microServiceList); + this.microservice.deleteService(microserviceObj.id) + .subscribe( data => { + this.result = data; + this.microServiceList = []; + this.getOnboardingServices(); + }, error => { + console.log(error); + }); + } + }, (resut) => { + return; + }) + } + + + openAddNewMicroserviceModal(rowData: any){ + //console.log("openAddNewMicroserviceModal getting called..."); + const modalRef = this.ngbModal.open(MicroserviceAddDetailsComponent, { size: 'lg' }); + modalRef.componentInstance.title = 'Microservice Onboarding'; + if(rowData != 'undefined' && rowData){ + modalRef.componentInstance.ms = rowData; + this.isEditMode = true; + }else{ + modalRef.componentInstance.ms = {}; + this.isEditMode = false; + } + modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => { + //console.log("receivedEntry >>> ",receivedEntry); + if(receivedEntry){ + this.microServiceList = []; + this.getOnboardingServices(); + } + }); + } + + populateTableData(microServiceList: Array){ + this.dataSource = new MatTableDataSource(microServiceList); + this.dataSource.sort = this.sort; + this.dataSource.paginator = this.paginator; + } + + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + openConfirmationModal(_title: string, _message: string) { + const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent); + modalInfoRef.componentInstance.title = _title; + modalInfoRef.componentInstance.message = _message; + } + + openInformationModal(_title: string, _message: string){ + const modalInfoRef = this.ngbModal.open(InformationModalComponent); + modalInfoRef.componentInstance.title = _title; + modalInfoRef.componentInstance.message = _message; + return modalInfoRef; + } +} diff --git a/portal-FE-common/src/app/shared/model/microservice-onboarding/microservices.ts b/portal-FE-common/src/app/shared/model/microservice-onboarding/microservices.ts new file mode 100644 index 00000000..db607ef3 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/microservice-onboarding/microservices.ts @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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============================================ + * + * + */ + +export interface IMircroservies { + id ?: any; + appId ?: any; + created ?: any; + modified ?: any; + createdId ?: any; + modifiedId ?: any; + rowNum ?: any; + auditUserId ?: any; + auditTrail ?: any; + name ?: any; + active ?: any; + desc ?: any; + url ?: any; + securityType ?: any; + username ?: any; + password ?: any; + parameterList ?: any; + option ?: any; +} \ No newline at end of file diff --git a/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts b/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts new file mode 100644 index 00000000..439a9480 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { MicroserviceService } from './microservice.service'; + +describe('MicroserviceService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: MicroserviceService = TestBed.get(MicroserviceService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/microservice/microservice.service.ts b/portal-FE-common/src/app/shared/services/microservice/microservice.service.ts new file mode 100644 index 00000000..da73139b --- /dev/null +++ b/portal-FE-common/src/app/shared/services/microservice/microservice.service.ts @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * 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 { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../../environments/environment'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class MicroserviceService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + createService(newMicroservice: any): Observable { + return this.http.post(this.api.widgetCommon, newMicroservice, { withCredentials: true } ); + } + + updateService(serviceId: string, newMicroservice: any): Observable { + return this.http.put(this.api.widgetCommon + "/" + serviceId, newMicroservice, { withCredentials: true } ); + } + + deleteService(serviceId: any): Observable { + let deleteServiceURL = this.api.widgetCommon + "/" + serviceId; + return this.http.delete(deleteServiceURL, { withCredentials: true }); + } + + getServiceList(): Observable { + return this.http.get(this.api.widgetCommon, { withCredentials: true }); + } + + getWidgetListByService(serviceId: string): Observable { + return this.http.get(this.api.widgetCommon + '/' + serviceId, { withCredentials: true }); + } + + getUserParameterById(paramId: string): Observable { + return this.http.get(this.api.widgetCommon + '/services/' + paramId, { withCredentials: true }); + } + + deleteUserParameterById(paramId: string): Observable { + return this.http.delete(this.api.widgetCommon + '/services/' + paramId, { withCredentials: true }); + } + + getServiceJSON(serviceId: string): Observable { + return this.http.get(this.api.microserviceProxy + "/" + serviceId, { withCredentials: true }); + } + +} -- cgit 1.2.3-korg