From af56b68e030085aa523152e83811705636ead79c Mon Sep 17 00:00:00 2001 From: asgar Date: Fri, 8 Mar 2019 19:52:33 +0530 Subject: added ansible server functionality multiple ansible server for CDT Issue-ID: APPC-1510 Change-Id: I383bc63705418654efb596c617309821ebbeb9b4 Signed-off-by: Mohamed Asgar Samiulla --- package.json | 4 +- src/app/about-us/aboutus.component.css | 4 +- src/app/about-us/aboutus.component.html | 21 +- src/app/about-us/aboutus.component.ts | 57 +- src/app/admin/admin.component.css | 34 + src/app/admin/admin.component.html | 93 ++ src/app/admin/admin.component.ts | 247 ++++ .../admin/view-edit/ansible-server.component.css | 143 ++ .../admin/view-edit/ansible-server.component.html | 139 ++ .../admin/view-edit/ansible-server.component.ts | 326 +++++ src/app/app.module.ts | 51 +- src/app/app.routing.ts | 13 + src/app/cdt.application.properties.json | 8 - src/app/home/home/home.component.html | 8 +- src/app/pipes/vm-filtering.pipe.ts | 26 +- .../components/navigation/navigation.component.ts | 17 +- src/app/shared/confirmModal/confirm.component.ts | 23 +- src/app/shared/pipes/vm-filtering.pipe.ts | 25 +- src/app/shared/services/cdt.apicall.ts | 51 + .../shared/services/httpUtil/http-util.service.ts | 9 +- src/app/shared/services/mapping-editor.service.ts | 57 +- src/app/shared/services/paramShare.service.ts | 3 +- src/app/shared/services/procOnSrvSide.service.ts | 343 +++++ .../services/utilityService/utility.service.ts | 10 +- src/app/shared/shared.module.ts | 32 +- src/app/test/test.component.html | 18 +- src/app/test/test.component.ts | 234 +++- .../vnfs/LoginGuardService/Login-guard-service.ts | 6 +- src/app/vnfs/auth-guard-modal/auth-guard-modal.ts | 4 +- .../build-artifacts/build-artifacts.component.html | 8 +- .../build-artifacts/build-artifacts.component.ts | 49 +- .../parameter-definition.service.ts | 145 +- .../parameter-definitions/parameter.component.html | 7 +- .../parameter-definitions/parameter.component.ts | 118 +- .../reference-dataform.component.css | 6 +- .../reference-dataform.component.html | 100 +- .../reference-dataform.component.ts | 1479 ++++++++++---------- .../reference-dataform/reference-dataform.util.ts | 15 +- .../param-name-value.component.html | 24 +- .../param-name-value/param-name-value.component.ts | 107 +- .../template-configuration.component.css | 13 +- .../template-configuration.component.html | 35 +- .../template-configuration.component.ts | 550 ++++---- src/app/vnfs/myvnfs/myvnfs.component.css | 6 +- src/app/vnfs/myvnfs/myvnfs.component.html | 28 +- src/app/vnfs/myvnfs/myvnfs.component.ts | 67 +- .../userlogin-form/userlogin-form.component.css | 8 +- .../userlogin-form/userlogin-form.component.html | 7 +- .../userlogin-form/userlogin-form.component.ts | 21 + src/app/vnfs/vnfs.module.ts | 74 +- src/cdt.application.properties.json | 15 + src/styles.css | 71 +- 52 files changed, 3385 insertions(+), 1574 deletions(-) create mode 100644 src/app/admin/admin.component.css create mode 100644 src/app/admin/admin.component.html create mode 100644 src/app/admin/admin.component.ts create mode 100644 src/app/admin/view-edit/ansible-server.component.css create mode 100644 src/app/admin/view-edit/ansible-server.component.html create mode 100644 src/app/admin/view-edit/ansible-server.component.ts delete mode 100644 src/app/cdt.application.properties.json create mode 100644 src/app/shared/services/cdt.apicall.ts create mode 100644 src/app/shared/services/procOnSrvSide.service.ts create mode 100644 src/cdt.application.properties.json diff --git a/package.json b/package.json index 8041857..6771223 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "file-saver": "^1.3.3", "font-awesome": "^4.7.0", "jquery": "^3.2.1", - "mdbootstrap": "4.5.3", - "ng2-ace-editor": "0.1.9", + "mdbootstrap": "4.5.5", + "ng2-ace-editor": "0.2.0", "ng2-bootstrap-modal": "1.0.1", "ng2-bs3-modal": "0.10.4", "ngx-progressbar": "^2.1.1", diff --git a/src/app/about-us/aboutus.component.css b/src/app/about-us/aboutus.component.css index 93ac11c..2bad3ee 100644 --- a/src/app/about-us/aboutus.component.css +++ b/src/app/about-us/aboutus.component.css @@ -17,11 +17,9 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ - .textarea { - width: 800px; + width: 100%; height: 200px } \ No newline at end of file diff --git a/src/app/about-us/aboutus.component.html b/src/app/about-us/aboutus.component.html index d7460f3..0d641b9 100644 --- a/src/app/about-us/aboutus.component.html +++ b/src/app/about-us/aboutus.component.html @@ -30,7 +30,8 @@ limitations under the License.      @@ -61,7 +62,7 @@ limitations under the License. @@ -70,3 +71,19 @@ limitations under the License. + + + + + + + + + + + + + + diff --git a/src/app/about-us/aboutus.component.ts b/src/app/about-us/aboutus.component.ts index 04eee0d..53b8a94 100644 --- a/src/app/about-us/aboutus.component.ts +++ b/src/app/about-us/aboutus.component.ts @@ -21,16 +21,13 @@ limitations under the License. ============LICENSE_END============================================ */ - -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Http } from '@angular/http'; import { Subscription } from 'rxjs/Subscription'; import { Observable } from 'rxjs/Observable'; import { NotificationsService } from 'angular2-notifications'; import { saveAs } from 'file-saver'; -import { DialogService } from 'ng2-bootstrap-modal'; -import { ConfirmComponent } from '../shared/confirmModal/confirm.component'; -import { appConstants } from '../../constants/app-constants'; +import { ModalDismissReasons, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {UtilityService} from '../shared/services/utilityService/utility.service'; @Component({ @@ -38,11 +35,13 @@ import {UtilityService} from '../shared/services/utilityService/utility.service' templateUrl: './aboutus.component.html', styleUrls: ['./aboutus.component.css'] }) -export class AboutUsComponent implements OnInit, OnDestroy { +export class AboutUsComponent implements OnInit { + clName= "AboutUsComponent"; public releaseName: any; public versionNo: any; public contactUsMail: any; + public data: any; closeResult: string; versionLogSubscription: Subscription; @@ -55,48 +54,30 @@ export class AboutUsComponent implements OnInit, OnDestroy { }; constructor( - private http: Http, private dialogService: DialogService, private notificationsService: NotificationsService, + private http: Http, private modalService: NgbModal, private utilSvc: UtilityService ) { } ngOnInit() { this.versionNo = require('./appVersion.json').versionNo; this.releaseName = require('./appVersion.json').releaseName; - this.contactUsMail = require('../cdt.application.properties.json').CONTACT_US; - } - - ngOnDestroy() { - if (this.versionLogSubscription) { - this.versionLogSubscription.unsubscribe(); - } + this.contactUsMail = require('../../cdt.application.properties.json').CONTACT_US; } - versionLogFile(): Observable { - return this.http.get('app/about-us/versionLog.txt'); + versionLogFile() { + this.http.get('app/about-us/versionLog.txt') + .subscribe(res => this.data = res.text()); } - open(content) { - this.versionLogSubscription = this.versionLogFile() - .subscribe((res) => { - this.data = res.text(); - this.dialogService.addDialog(ConfirmComponent, { - title: 'VERSION CHANGE LOG', - message: this.data, - cancelButtonText: 'CLOSE', - confirmButtonText: 'DOWNLOAD' - }).subscribe(isConfirmed => { - if (isConfirmed) { - this.downloadLogFile() - } else { - // do nothing - } - }); - - }, - (error)=>{ - this.notificationsService.error(appConstants.errors.error, 'unable to fetch change log details'); - }); - } + // open(content) { + // this.modalService.open(content).result.then((result) => { + // console.log('result', result) + // this.closeResult = `Closed with: ${ result }`; + // }, (reason) => { + // console.log('reson', reason) + // this.closeResult = `Dismissed ${ this.getDismissReason(reason) }`; + // }); + // } downloadLogFile() { var blob = new Blob([this.data], { diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css new file mode 100644 index 0000000..f6cbef3 --- /dev/null +++ b/src/app/admin/admin.component.css @@ -0,0 +1,34 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + +.build-button { + padding: 11px; + font-size: 20px; + color: green; + border: 1PX SOLID GREEN; + MARGIN-BOTTOM: 40PX +} + +table.table th, +table.table td { + padding: 0rem; +} \ No newline at end of file diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html new file mode 100644 index 0000000..1185957 --- /dev/null +++ b/src/app/admin/admin.component.html @@ -0,0 +1,93 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
CONFIGURATION SERVER CLOUD-OWNER/CLOUD-REGION/TENANTDESCRIPTIONMODIFIERDATE MODIFIED
{{item['serverandport']}} + + + + + + + +
{{info.ownerid}} / {{info.regionid}} / {{info.tenantid}}
+
{{item['descr']}} {{item['modifier']}} {{item['modified-date']}} + +
+ +
+ + +
+
+
+
+

There is no admin Artifacts

+
+
+ {{noDataMsg}} +
+
+
+
+
+ + + +
\ No newline at end of file diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts new file mode 100644 index 0000000..74fe86a --- /dev/null +++ b/src/app/admin/admin.component.ts @@ -0,0 +1,247 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { HttpUtilService } from '../shared/services/httpUtil/http-util.service'; +import { MappingEditorService } from '../shared/services/mapping-editor.service'; +import { ParamShareService } from '../shared/services/paramShare.service'; +import { environment } from '../../environments/environment'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgProgress } from 'ngx-progressbar'; +import { APIService } from "../shared/services/cdt.apicall"; +import { UtilityService } from '../shared/services/utilityService/utility.service'; +import { NotificationsService } from 'angular2-notifications'; + + +@Component({ selector: 'admin', templateUrl: './admin.component.html', styleUrls: ['./admin.component.css']}) +export class AdminComponent implements OnInit { + displayAnsibleServerData: Array = []; + ansibleServerData; + sortOrder = false; + noData = false; + sortBy: string; + filter: Object = {}; + noDataMsg: string; + errorMessage = ''; + invalid = true; + currentUser; + fileName = "ansible_admin_FQDN_Artifact_0.0.1V.json"; + + options = { + timeOut: 4000, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 200 + }; + + constructor ( + private paramShareService: ParamShareService, + private ngProgress: NgProgress, + private httpUtil: HttpUtilService, + private router: Router, + private activeROute: ActivatedRoute, + private mappingEditorService: MappingEditorService, + private modalService: NgbModal, + private apiService:APIService, + private utilService: UtilityService, + private nService: NotificationsService + ) { + } + + ngOnInit() { + const apiToken = localStorage['apiToken']; + this.currentUser = localStorage['userId']; + + if(this.paramShareService.ansibleServerData) { + this.ansibleServerData = this.paramShareService.ansibleServerData; + console.log("cached ansibleServerData===>"+JSON.stringify(this.ansibleServerData)); + this.formatRawData(); + } else { + //testing + //this.ansibleServerData = "{\"fqdn-list\":[{\"vnf-management-server-fqdn\": \"fqdn-value1:url\:port\",\"cloud-owner-list\":[{\"cloud-owner\": \"owner1\",\"region-id-list\": [{\"region-id\": \"regiodnid1\",\"tenant-id-list\": [\"tenantid1\",\"tenantid2\"]},{\"region-id\": \"regiondid2\",\"tenant-id-list\": [\"tenantid1\",\"tenantid2\"]}]},{\"cloud-owner\": \"owner2\",\"region-id-list\": [{\"region-id\": \"regionid1\",\"tenant-id-list\": [\"tenantid1\",\"tenantid2\"]}]}],\"description\": \"fqdn for east zone vUSP Production\",\"username\": \"albino attuid\",\"create-date\": \"\",\"modify-username\": \"Asgar\",\"modify-date\": \"10/26/2018\"}]}"; + //this.ansibleServerData = JSON.parse(this.ansibleServerData); + //this.formatRawData(); + this.getArtifacts(); + } + + } + + getArtifacts() { + + const input = { + "input":{ + "design-request":{ + "request-id":localStorage['apiToken'], + "action":"getArtifact", + "payload":"{\"vnf-type\":\"NULL\",\"vnfc-type\":\"NULL\",\"protocol\":\"\",\"incart\":\"N\",\"action\":\"NULL\",\"artifact-name\":\""+this.fileName+"\",\"artifact-type\":\"APPC-CONFIG\",\"userID\":\"admin\"}" + } + } + }; + //const x = JSON.parse(data.input['design-request']['payload']); + //x.userID = localStorage['userId']; + //data.input['design-request']['payload'] = JSON.stringify(x); + console.log("input to payload====", JSON.stringify(input)); + + this.ngProgress.start(); + + this.apiService.callGetArtifactsApi(input).subscribe(data => { + + if( this.utilService.checkResult(data)) { + console.log("response===>"+JSON.stringify(data)); + this.ansibleServerData = JSON.parse(data.output.data.block).artifactInfo[0]["artifact-content"]; + this.ansibleServerData = JSON.parse(this.ansibleServerData); + console.log("ansibleServerData===>"+JSON.stringify(this.ansibleServerData)) + this.paramShareService.ansibleServerData = this.ansibleServerData; + this.formatRawData(); + } + this.ngProgress.done(); + }, + error => { + + this.nService.error('Error', + 'Error in connecting to APPC Server', this.options ); + }); + + + } + + formatRawData(){ + this.displayAnsibleServerData = [this.ansibleServerData["fqdn-list"].length]; + console.log("length==>"+this.ansibleServerData["fqdn-list"].length) + for(let i=0;i 1) { + this.displayAnsibleServerData[i]['port'] = splitArray[splitArray.length-1]; + } + let clouditem = ""; + for(let j=0; j"+JSON.stringify({"ownerid": ownerid, "regionid": regionid, "tenantid": tenantid})) + } + + } + + } + console.log("info array==>"+JSON.stringify(cloudInfoArray)) + this.displayAnsibleServerData[i]["info"] = cloudInfoArray; + this.displayAnsibleServerData[i]["cloud"] = clouditem; + this.displayAnsibleServerData[i]["descr"] = fqdl["description"]; + this.displayAnsibleServerData[i]["creator"] = fqdl["username"]; + this.displayAnsibleServerData[i]["created-date"] = fqdl["create-date"]; + this.displayAnsibleServerData[i]["modifier"] = fqdl["modify-username"]; + this.displayAnsibleServerData[i]["modified-date"] = fqdl["modify-date"]; + + } + } + + + + viewAnbsibleServer(selectedConfig, updateIndex) { + sessionStorage.setItem('updateIndex', updateIndex); + sessionStorage.setItem('ansibleserver', JSON.stringify(selectedConfig)); + + this + .router + .navigate(['../ansible-server'], { + relativeTo: this.activeROute + }); + } + + createAnsibleServer() { + let newServer = {"server":"","port":"","info":[],"cloud":"","descr":"","creator":this.currentUser,"created-date":this.utilService.getDate(),"modifier":"","modified-date":""}; + sessionStorage.setItem('ansibleserver', JSON.stringify(newServer)); + + if(this.ansibleServerData) { + sessionStorage.setItem('updateIndex', this.ansibleServerData["fqdn-list"].length); + } else { + sessionStorage.setItem('updateIndex', '0'); + } + + this + .router + .navigate(['../ansible-server'], { + relativeTo: this.activeROute + }); + } + + + saveToAppc() { + let artifactContent = this.utilService.appendSlashes(JSON.stringify(this.paramShareService.ansibleServerData)); + let input = { + "input": { + "design-request": { + "request-id": localStorage['apiToken'], + "action": "uploadAdminArtifact", + "payload": "{\"userID\": \"admin\",\"vnf-type\" : \"NULL \",\"action\" : \"NULL\",\"artifact-name\" : \""+this.fileName+"\",\"artifact-type\" : \"APPC-CONFIG\",\"artifact-version\" : \"0.1\",\"artifact-contents\":\""+artifactContent+"\"}", + } + } + } + let response = this.apiService.callGetArtifactsApi(input); + response.subscribe(response => { + this.utilService.processApiSubscribe(response, this.utilService.putAction, "admin artifact"); + //this.clearCache(); + }, + error => this.utilService.processApiError()); + } + + // ngOnDestroy() { + // console.log("destry....") + // } + + clearCache() { + this.paramShareService.ansibleServerData = undefined; + sessionStorage.removeItem('ansibleserver'); + } + + download() { + if(this.ansibleServerData){ + this.utilService.downloadArtifactToPc(JSON.stringify(this.ansibleServerData, null, '\t'), "json", this.fileName, 100) + } + } + +} \ No newline at end of file diff --git a/src/app/admin/view-edit/ansible-server.component.css b/src/app/admin/view-edit/ansible-server.component.css new file mode 100644 index 0000000..1d4f6c0 --- /dev/null +++ b/src/app/admin/view-edit/ansible-server.component.css @@ -0,0 +1,143 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + +.form-group { + padding: 5px +} + +.panel { + margin-top: 20px; +} + +.form-control { + width: 100%; +} + +.panel-header { + padding: 20px 0px; +} + +.container { + border-radius: 0.375rem; + transition: all 0.3s ease; + padding: 40px; +} + +.container2 { + box-shadow: -4px 14px 20px 0px rgba(46, 61, 73, 0.15); + border-radius: 0.375rem; + transition: all 0.3s ease; + padding: 10px; + margin-top: 57px; +} + +.error-message { + color: red; +} + +.warning-message { + color: rgb(255,191,0); +} + +.create-wrapper { + text-align: left; +} + +.removevnfcClass { + text-align: right; +} + +.form-custom-group { + margin-bottom: 0; + vertical-align: middle; +} + +.side-by-side { + position: relative; +} + +.sidebtn { + position: absolute; + left: 26.5em; + top: 0em; +} + +.clear-control { + margin: 40px 20px; + display: inherit; +} + +.short-column { + width: 100px; +} + +.long-column { + width: 200px; +} + +th, +td { + min-width: 150px; +} + +.headlinesInBold { + font-weight: bold; +} + +.titleCustom { + padding-left: 25px; + overflow: visible; +} + +.anchorHover { + cursor: pointer; +} + +.custom-btn { + margin-top: 20px; + margin-bottom: 10px; +} + +.clear-btn { + margin-top: 23px; +} + +.col-md-button { + margin: auto; + margin-right: 20px; + text-align: center; + margin-bottom: 15px; +} + +.selectedAction { + /* change here */ + font-weight: bold; + color: #1A86E4 +} + +.file { + visibility: hidden; + position: absolute; +} + +.col-md-1point5 {width: 12%} +.col-md-2point5 {width: 21%;} \ No newline at end of file diff --git a/src/app/admin/view-edit/ansible-server.component.html b/src/app/admin/view-edit/ansible-server.component.html new file mode 100644 index 0000000..a8f2137 --- /dev/null +++ b/src/app/admin/view-edit/ansible-server.component.html @@ -0,0 +1,139 @@ + + + + +
+ +
+
+
+ + + {{errorMessage}}{{warningMessage}} +
+
+ + + {{porterrorMessage}}{{portwarningMessage}} +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+
+
+ +
+
+ + +
+
+ + + {{ownerIdErrMsg}} +
+
+ + + {{regionIdErrMsg}} +
+
+ + + {{tenantIdErrMsg}} +
+
+ +
+ +
+
+
+
+ {{zeroTenantIdsErrorMsg}} +
+ +
+
+
+ + +
Enter Owner ID
+
+
+ + +
Enter Region ID
+
+
+ + +
Enter Tenant ID
+
+
+ +
+ Remove +
+
+
+
+ +
+
+ +
+
+ Cancel + +
+
+ +
+
+
+
diff --git a/src/app/admin/view-edit/ansible-server.component.ts b/src/app/admin/view-edit/ansible-server.component.ts new file mode 100644 index 0000000..b629b65 --- /dev/null +++ b/src/app/admin/view-edit/ansible-server.component.ts @@ -0,0 +1,326 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + +import * as XLSX from 'xlsx'; +import * as _ from 'underscore'; + +import { ActivatedRoute, Router } from '@angular/router'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import { UtilityService } from '../../shared/services/utilityService/utility.service'; + +// Common Confirm Modal +import { DialogService } from 'ng2-bootstrap-modal'; +import { ParamShareService } from '../../shared/services/paramShare.service'; + + +declare var $: any; +type AOA = Array>; + +@Component({ + selector: 'ansible-server', + templateUrl: './ansible-server.component.html', + styleUrls: ['./ansible-server.component.css'], +}) +export class AnsibleServerComponent implements OnInit { + + //settings for the notifications. + options = { + timeOut: 4500, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 200 + }; + + public ownerIdErrMsg; + public regionIdErrMsg; + public tenantIdErrMsg + public zeroTenantIdsErrorMsg; + public porterrorMessage; + public portwarningMessage; + public errorMessage; + public warningMessage; + public invalid = true; + public portinvalid = true; + public item; + public sample = {ownerid:"", regionid:"", tenantid:""}; + public updateIndex; + public currentUser; + constructor( + private paramShareService: ParamShareService, + private router: Router, + private activeROute: ActivatedRoute, + private utilService: UtilityService + + ) + { + console.log("testing...."); + } + +ngOnInit() { + this.currentUser = localStorage['userId']; + this.item = JSON.parse(sessionStorage.getItem("ansibleserver")); + this.updateIndex = parseInt(sessionStorage.getItem("updateIndex")); + console.log("index===>"+this.updateIndex); + if(!this.paramShareService.ansibleServerData) { + this.invalid = true; + } else { + this.invalid = false; + } + console.log("selecteditem===>"+JSON.stringify(this.item)); +} + +addInfo() { + console.log("selectediteminfo===>"+JSON.stringify(this.item.info)); + if(this.validateTenantId()) { + this.item.info.push(this.sample) + this.sample = {ownerid:"", regionid:"", tenantid:""}; + this.zeroTenantIdsErrorMsg = ""; + } + +} + +removeInfo(index) { + console.log("selectediteminfo===>"+index+JSON.stringify(this.item.info)); + this.item.info.splice(index, 1); + console.log("selectediteminfo===>"+JSON.stringify(this.item.info)); + +} + +// save() { +// console.log("ansibleServerData===>"+ JSON.stringify(this.paramShareService.ansibleServerData)) +// let ansibleServer = this.createAnsibleserverData(this.item); +// this.paramShareService.ansibleServerData["fqdn-list"].push(ansibleServer); +// this.router.navigate(['../admin'], { +// relativeTo: this.activeROute +// }); +// } + +update() { + console.log("ansibleServerData===>"+ JSON.stringify(this.paramShareService.ansibleServerData)) + + + let ansibleServer = this.createAnsibleserverData(this.item); + //need to revisit to initialize paramShareService.ansibleServerData + if(!this.paramShareService.ansibleServerData) { + this.paramShareService.ansibleServerData = {"fqdn-list" : []}; + } + if(this.updateIndex != this.paramShareService.ansibleServerData["fqdn-list"].length) { + ansibleServer["modify-username"] = this.currentUser; + ansibleServer["modify-date"] = this.utilService.getDate(); + console.log("update........") + } + this.paramShareService.ansibleServerData["fqdn-list"][this.updateIndex] = ansibleServer; + this.router.navigate(['../admin'], { + relativeTo: this.activeROute + }); + + +} + +cancel() { + sessionStorage.removeItem("ansibleserver"); + this.router.navigate(['../admin'], { + relativeTo: this.activeROute + }); +} + +createAnsibleserverData(displayAnsibleServer){ + let cloudOwnerList = this.createCloudOwnerList(displayAnsibleServer); + let anisble = { + "vnf-management-server-fqdn": displayAnsibleServer.server+":"+displayAnsibleServer.port, + "cloud-owner-list":cloudOwnerList, + "description":displayAnsibleServer.descr, + "username":displayAnsibleServer.creator, + "create-date":displayAnsibleServer['created-date'], + "modify-username":displayAnsibleServer.modifier, + "modify-date":displayAnsibleServer['modified-date'] + }; + return anisble; + +} + +createCloudOwnerList(displayAnsibleServer) { + let cloudOwnerList = []; + + //prepare unique cloud-owner + for(let i=0; i { + if(element["cloud-owner"] == info.ownerid) { + exist = true; + + } + }); + if(!exist){ + cloudOwnerList.push(cloudOwner); + } + + } + console.log("cloudOwnerList===>"+JSON.stringify(cloudOwnerList)); + + //prepare region id + cloudOwnerList.forEach(cloudOwner => { + let regionIdList = []; + for(let i=0; i { + if(element["region-id"] == info.regionid) { + exist = true; + } + }); + if(!exist){ + regionIdList.push({"region-id":info.regionid}); + } + } + + } + cloudOwner["region-id-list"] = regionIdList; + }); + + console.log("cloudOwnerList===>"+JSON.stringify(cloudOwnerList)); + + //prepare tenant id + cloudOwnerList.forEach(cloudOwner => { + cloudOwner["region-id-list"].forEach(regionid => { + let teanantIdList = []; + for(let i=0; i { + if(element == info.tenantid) { + exist = true; + } + }); + if(!exist){ + teanantIdList.push(info.tenantid); + } + } + + } + regionid["tenant-id-list"] = teanantIdList; + }); + }); + console.log("cloudOwnerList===>"+JSON.stringify(cloudOwnerList)); + return cloudOwnerList; + } + + //validating the fdqn url + validateFdqn(fdqn) { + if (fdqn.trim().length < 1) { + this.errorMessage = 'Please enter Configuration Server FQDN'; + this.warningMessage = ''; + this.invalid = true; + } else if (fdqn.startsWith(' ') || fdqn.endsWith(' ')) { + this.errorMessage = 'Leading and trailing spaces are not allowed'; + this.warningMessage = ''; + this.invalid = true; + } else if (!(fdqn.startsWith('http') || fdqn.endsWith('https'))) { + this.warningMessage = 'FDQN can start with eighther http or https protocol'; + this.errorMessage = ''; + this.invalid = false; + + // } else if (name.includes(' ')) { + // this.errorMessage = 'More than one space is not allowed in VNFC Type'; + // this.invalid = true; + // } else if (name.length > 50) { + // this.errorMessage = 'VNFC Type should be of minimum one character and maximum 50 character'; + // this.invalid = true; + // + } else { + this.invalid = false; + this.errorMessage = ''; + this.warningMessage = ''; + } + } + + //validating the port + validatePort(port) { + if (port.trim().length < 1) { + this.porterrorMessage = 'Please enter port'; + this.portwarningMessage = ''; + this.invalid = true; + } else if (port.startsWith(' ') || port.endsWith(' ')) { + this.porterrorMessage = 'Leading and trailing spaces are not allowed'; + this.portwarningMessage = ''; + this.invalid = true; + + } else if (isNaN(port)) { + this.portwarningMessage = ''; + this.porterrorMessage = 'Port should be a number'; + this.invalid = true; + port = parseInt(port); + } else if (!(0 <= port && port <= 65535 )) { + this.portwarningMessage = 'Port should be a number in range of 0 to 65535'; + this.porterrorMessage = ''; + this.invalid = false; + } else { + this.invalid = false; + this.porterrorMessage = ''; + this.portwarningMessage = ''; + } + } + + validate() { + this.validateFdqn(this.item.server); + this.validatePort(this.item.port); + if(this.item.info.length <= 0) { + this.zeroTenantIdsErrorMsg = "Please add atleast one Tenant ID."; + this.invalid = true; + } + if(!this.invalid) { + this.update(); + } + } + + validateTenantId(){ + let valid = true; + if(this.sample.ownerid.trim().length == 0) { + this.ownerIdErrMsg = "Enter OwnerID"; + valid = false; + } else { + this.ownerIdErrMsg = ""; + } + if(this.sample.regionid.trim().length == 0) { + this.regionIdErrMsg = "Enter RegionID"; + valid = false; + } else { + this.regionIdErrMsg = ""; + } + if(this.sample.tenantid.trim().length == 0) { + this.tenantIdErrMsg = "Enter TenantID"; + valid = false; + } else { + this.tenantIdErrMsg = ""; + } + return valid; + } + + +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fcff1d5..372e8bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,36 +22,39 @@ limitations under the License. ============LICENSE_END============================================ */ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { SimpleNotificationsModule } from 'angular2-notifications'; -import { BootstrapModalModule } from 'ng2-bootstrap-modal'; -import { HomeModule } from './home/home.module'; -import { AppComponent } from './app.component'; -import { AppRoutingModule } from './app.routing'; -import { SharedModule } from './shared/shared.module'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { HashLocationStrategy, LocationStrategy } from '@angular/common'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterModule } from '@angular/router'; -import { TestComponent } from './test/test.component'; -import { AboutUsComponent } from './about-us/aboutus.component'; -import { NgProgressModule } from 'ngx-progressbar'; -import { LoginGuardService } from './vnfs/LoginGuardService/Login-guard-service'; -import { ConfirmComponent } from './shared/confirmModal/confirm.component'; +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {SimpleNotificationsModule} from 'angular2-notifications'; +import {HomeModule} from './home/home.module'; +import {AppComponent} from './app.component'; +import {AppRoutingModule} from './app.routing'; +import {SharedModule} from './shared/shared.module'; +import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; +import {HashLocationStrategy, LocationStrategy} from '@angular/common'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {RouterModule} from '@angular/router'; +import {TestComponent} from './test/test.component'; +import {AboutUsComponent} from './about-us/aboutus.component'; +import {NgProgressModule} from 'ngx-progressbar'; +import {LoginGuardService} from './vnfs/LoginGuardService/Login-guard-service'; +import {Ng2Bs3ModalModule} from 'ng2-bs3-modal/ng2-bs3-modal'; import { NgxSpinnerModule } from 'ngx-spinner'; +import {AdminComponent} from './admin/admin.component'; +import {AnsibleServerComponent} from './admin/view-edit/ansible-server.component'; + @NgModule({ - declarations: [AppComponent, TestComponent, AboutUsComponent, ConfirmComponent], + declarations: [AppComponent, TestComponent,AnsibleServerComponent, AdminComponent, AboutUsComponent], imports: [BrowserModule, FormsModule, HomeModule, SharedModule.forRoot(), - NgbModule.forRoot(), NoopAnimationsModule, AppRoutingModule, SimpleNotificationsModule, NgProgressModule, BootstrapModalModule, NgxSpinnerModule], + NgbModule.forRoot(), NoopAnimationsModule, AppRoutingModule, SimpleNotificationsModule, NgProgressModule, Ng2Bs3ModalModule, NgxSpinnerModule], exports: [RouterModule], - providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }, LoginGuardService], - entryComponents: [ConfirmComponent], + providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}, LoginGuardService], + + bootstrap: [AppComponent], + entryComponents: [AnsibleServerComponent] - bootstrap: [AppComponent] }) export class AppModule { -} +} \ No newline at end of file diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index edc7323..72da93b 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -29,6 +29,9 @@ import { LoginGuardService } from './vnfs/LoginGuardService/Login-guard-service' import {LogoutComponent} from './shared/components/logout/logout.component'; import {NgModule} from '@angular/core'; import {TestComponent} from './test/test.component'; +import {AdminComponent} from './admin/admin.component'; +import {AnsibleServerComponent} from './admin/view-edit/ansible-server.component'; + const routes: Routes = [ { @@ -42,6 +45,16 @@ const routes: Routes = [ component: TestComponent, canActivate:[LoginGuardService] }, + { + path: 'admin', + component: AdminComponent, + canActivate:[LoginGuardService] + }, + { + path: 'ansible-server', + component: AnsibleServerComponent, + canActivate:[LoginGuardService] + }, { path: 'help', component: HelpComponent, diff --git a/src/app/cdt.application.properties.json b/src/app/cdt.application.properties.json deleted file mode 100644 index 5040526..0000000 --- a/src/app/cdt.application.properties.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "CONTACT_US": { - "CONTACT_US_EMAIL": "cdtSupportTeam@yourCompany.com", - "CONTACT_US_SUBJECT": "CDT Contact Us" - }, - "username": "admin", - "password": "admin" -} \ No newline at end of file diff --git a/src/app/home/home/home.component.html b/src/app/home/home/home.component.html index 78189e5..ce6ec78 100644 --- a/src/app/home/home/home.component.html +++ b/src/app/home/home/home.component.html @@ -20,12 +20,14 @@ limitations under the License. ============LICENSE_END============================================ -->
-
WELCOME TO CONTROLLER DESIGN TOOL +
WELCOME TO CONTROLLER DESIGN TOOL
-

The Controller Design Tool allows technology owners to create artifacts for Configuration and Life Cycle Management functions that are required to manage the lifecycle of Virtual Network Functions (VNFs).
Select My VNFS to enter credentials and view existing designs or create new ones. +

The Controller Design Tool allows technology owners to create artifacts for Configuration and Life Cycle Management functions that are required + to manage the lifecycle of Virtual Network Functions (VNFs).
Select My VNFS to enter credentials and view existing designs or create new + ones.

-
+
\ No newline at end of file diff --git a/src/app/pipes/vm-filtering.pipe.ts b/src/app/pipes/vm-filtering.pipe.ts index fdeb272..eef39cf 100644 --- a/src/app/pipes/vm-filtering.pipe.ts +++ b/src/app/pipes/vm-filtering.pipe.ts @@ -17,22 +17,34 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import {Pipe, PipeTransform} from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({name: 'vmFiltering', pure: false}) +@Pipe({ name: 'vmFiltering', pure: false }) export class VmFilteringPipe implements PipeTransform { - transform(value: any, action: any, templateId): any { - + transform(value: any, action: any, templateId, newVnfc): any { + let filterValue + if(action == 'ConfigScaleOut'){ + filterValue= templateId + } else if(action == 'Configure' || action == 'ConfigModify'){ + filterValue= newVnfc + } if (action == 'ConfigScaleOut') { let x = value.filter(obj => { //return value - return obj['template-id'] == templateId; + return obj['template-id'] == filterValue; }); - console.log(x); + + return x; + } else if( action == 'Configure' || action == 'ConfigModify'){ + let x = value.filter(obj => { + //return value + return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined); + }); + + return x; } else { return value; diff --git a/src/app/shared/components/navigation/navigation.component.ts b/src/app/shared/components/navigation/navigation.component.ts index 522b11a..7271bb1 100644 --- a/src/app/shared/components/navigation/navigation.component.ts +++ b/src/app/shared/components/navigation/navigation.component.ts @@ -19,19 +19,19 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import { Component, Input, OnInit, OnDestroy } from '@angular/core'; -import { Router } from '@angular/router'; +import {Component, Input, OnInit} from '@angular/core'; +import {Router} from '@angular/router'; +import {EmitterService} from '../../services/emitter.service'; import { Subscription } from 'rxjs/Subscription'; -import { EmitterService } from '../../services/emitter.service'; -@Component({ selector: 'app-navigation', templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.css'] }) -export class NavigationComponent implements OnInit, OnDestroy { + +@Component({selector: 'app-navigation', templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.css']}) +export class NavigationComponent implements OnInit { navigationTabs: Array = []; //@ViewChild(GoldenConfigurationComponent) goldenConfig: GoldenConfigurationComponent; @Input() id: string; @@ -76,6 +76,11 @@ export class NavigationComponent implements OnInit, OnDestroy { name: 'Test', url: 'test', }, + { + name: 'Admin', + url: 'admin' + }, + { name: 'About us', url: 'aboutUs' diff --git a/src/app/shared/confirmModal/confirm.component.ts b/src/app/shared/confirmModal/confirm.component.ts index 5fbf4b3..7b764e2 100644 --- a/src/app/shared/confirmModal/confirm.component.ts +++ b/src/app/shared/confirmModal/confirm.component.ts @@ -19,7 +19,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ import { Component } from '@angular/core'; @@ -28,8 +27,6 @@ import { DialogComponent, DialogService } from 'ng2-bootstrap-modal'; export interface ConfirmModel { title: string; message: string; - cancelButtonText: string; - confirmButtonText: string; } @Component({ @@ -38,15 +35,15 @@ export interface ConfirmModel { ` @@ -54,22 +51,20 @@ export interface ConfirmModel { export class ConfirmComponent extends DialogComponent implements ConfirmModel { title: string; message: string; - cancelButtonText: string; - confirmButtonText: string; constructor(dialogService: DialogService) { super(dialogService); } - confirm() { - // we set dialog result as true on click on confirm button, + onConfirm() { + // we set dialog result as true on click on Yes button, // then we can get dialog result from caller code this.result = true; this.close(); } - cancel() { - // we set dialog result as false on click on cancel/close button, + onCancel() { + // we set dialog result as false on click on Yes button, // then we can get dialog result from caller code this.result = false; this.close(); diff --git a/src/app/shared/pipes/vm-filtering.pipe.ts b/src/app/shared/pipes/vm-filtering.pipe.ts index c20397b..eef39cf 100644 --- a/src/app/shared/pipes/vm-filtering.pipe.ts +++ b/src/app/shared/pipes/vm-filtering.pipe.ts @@ -17,21 +17,34 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import {Pipe, PipeTransform} from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({name: 'vmFiltering', pure: false}) +@Pipe({ name: 'vmFiltering', pure: false }) export class VmFilteringPipe implements PipeTransform { - transform(value: any, action: any, templateId): any { - + transform(value: any, action: any, templateId, newVnfc): any { + let filterValue + if(action == 'ConfigScaleOut'){ + filterValue= templateId + } else if(action == 'Configure' || action == 'ConfigModify'){ + filterValue= newVnfc + } if (action == 'ConfigScaleOut') { let x = value.filter(obj => { //return value - return obj['template-id'] == templateId; + return obj['template-id'] == filterValue; }); + + return x; + } else if( action == 'Configure' || action == 'ConfigModify'){ + let x = value.filter(obj => { + //return value + return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined); + }); + + return x; } else { return value; diff --git a/src/app/shared/services/cdt.apicall.ts b/src/app/shared/services/cdt.apicall.ts new file mode 100644 index 0000000..40a3f60 --- /dev/null +++ b/src/app/shared/services/cdt.apicall.ts @@ -0,0 +1,51 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + + +import {Injectable} from '@angular/core'; +import {NotificationsService} from 'angular2-notifications'; +import { HttpUtilService } from './httpUtil/http-util.service'; +import { environment } from '../../../environments/environment'; + + +@Injectable() +export class APIService { + + constructor(private notificationService: NotificationsService, private httpUtils: HttpUtilService) { + } + + public callGetArtifactsApi(payloadData){ + console.log("APIService: PAYLOAD====>"+JSON.stringify(payloadData)); + return this.httpUtils.post({ + url: environment.getDesigns, + data: payloadData + })/*.subscribe(response => { + if (this.checkResult(response, action, artifactType)) { + //Call the respective response handler. + } + }, + error => this.notificationService.error('Error', this.connectionErrorMessage))*/ + } + + + +} diff --git a/src/app/shared/services/httpUtil/http-util.service.ts b/src/app/shared/services/httpUtil/http-util.service.ts index 43e6d4f..688f3ea 100644 --- a/src/app/shared/services/httpUtil/http-util.service.ts +++ b/src/app/shared/services/httpUtil/http-util.service.ts @@ -28,23 +28,22 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http'; export class HttpUtilService { headers: Headers; options: RequestOptions - private username = require('../../../cdt.application.properties.json').username; - private password = require('../../../cdt.application.properties.json').password; + private username = require('../../../../cdt.application.properties.json').username; + private password = require('../../../../cdt.application.properties.json').password; constructor(private http: Http) { this.headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON - this.options = new RequestOptions({headers: this.headers}); // } - get(req) { + return this .http .get(req.url, this.options) .map((res: Response) => res.json()) } - post(req) { this.headers.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password)); this.options = new RequestOptions({ headers: this.headers }); + return this .http .post(req.url, req.data, this.options) diff --git a/src/app/shared/services/mapping-editor.service.ts b/src/app/shared/services/mapping-editor.service.ts index b9e2b53..cb47687 100644 --- a/src/app/shared/services/mapping-editor.service.ts +++ b/src/app/shared/services/mapping-editor.service.ts @@ -68,11 +68,11 @@ export class MappingEditorService { public latestAction: any; public selectedWord: any; identifier: any; + private selectedVNFCType; private _navItem = {}; private _observer: Observer; private referenceList = []; - newObject: any; - + newObject: any constructor() { this.navChange$ = new Observable(observer => this._observer = observer).share(); @@ -106,12 +106,20 @@ export class MappingEditorService { } selectedObj(data) { this.newObject = data; + } - saveLatestIdentifier(identifier) { this.identifier = identifier; } + setSelectedVNFCType(vnfcType) { + this.selectedVNFCType = vnfcType; + } + + getSelectedVNFCType() { + return this.selectedVNFCType; + } + public getParamContent() { return this.paramContent; } @@ -129,15 +137,15 @@ export class MappingEditorService { } - public initialise(editor: any, editorContent: string, modal: any): void { + public initialise(editor: any, editorContent: string): void { this.editor = editor; this.editor.session = editor.session; this.editor.selection.session.$backMarkers = {}; this.editorContent = editorContent; this.editor.$blockScrolling = Infinity; this.editor.$blockSelectEnabled = false; - this.initialiseCommands(modal); - this.editor.setValue(this.editorContent); + //this.initialiseCommands(modal); + //this.editor.setValue(this.editorContent); this.refreshEditor(); } @@ -198,7 +206,7 @@ export class MappingEditorService { for (var prop in paramJson) { let value: string = paramJson[prop]; if (value) { - var occurances = this.editor.findAll(value, {regExp: false}); + var occurances = this.editor.findAll(value, { regExp: false }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges && occurances && occurances > 0) { @@ -261,8 +269,8 @@ export class MappingEditorService { selectedRange.start.column = selectedRange.start.column - 1; selectedRange.end.column = selectedRange.end.column + 1; if ((this.editor.session.getTextRange(selectedRange).startsWith(' ') - || this.editor.session.getTextRange(selectedRange).startsWith('"') - || this.editor.session.getTextRange(selectedRange).startsWith('>')) + || this.editor.session.getTextRange(selectedRange).startsWith('"') + || this.editor.session.getTextRange(selectedRange).startsWith('>')) && (this.editor.session.getTextRange(selectedRange).endsWith(' ') || this.editor.session.getTextRange(selectedRange).endsWith('"') || this.editor.session.getTextRange(selectedRange).endsWith(',') @@ -313,7 +321,7 @@ export class MappingEditorService { } public autoAnnotateTemplateForParam(): void { - var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges) { for (var r = 0; r < ranges.length; r++) { @@ -362,19 +370,25 @@ export class MappingEditorService { } replaceNamesWithBlankValues() { - var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (occurances > 0) { if (ranges) { for (var r = 0; r < ranges.length; r++) { let selectedRange: any = ranges[r]; + // console.log("Selected range == " + selectedRange) let selectedWord: string = this.editor.session.getTextRange(selectedRange); let specialKeys = (selectedWord.substring(2, selectedWord.length - 1)).match(this.checkSpecialCharsReg); - if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys) { + // console.log("Selected word == " + selectedWord.length) + //if (!selectedWord.startsWith('<') || !selectedWord.startsWith('{')) { + if (specialKeys && specialKeys.length) { + } + + else if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys && this.checkComments(selectedRange)) { let replaceWord: any = this.KEY_START + '' + this.KEY_MID + selectedWord.substring(2, selectedWord.length - 1) + this.KEY_END; this.editor.session.replace(selectedRange, replaceWord); } - + // } } } } @@ -388,7 +402,8 @@ export class MappingEditorService { this.hasErrorCode = false; for (var r = 0; r < ranges.length; r++) { let keyValue: string = this.editor.session.getTextRange(ranges[r]); - if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { + //console.log("keyValues==="+keyValue) + if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END)); let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID)); let specialKeys = key.match(this.checkSpecialCharsReg); @@ -398,7 +413,7 @@ export class MappingEditorService { if (this.fromScreen === 'TemplateScreen') { if (key) { paramJson[key] = value; - var obj: any = {'paramName': '', 'paramValue': ''}; + var obj: any = { 'paramName': '', 'paramValue': '' }; obj.paramName = key; obj.paramValue = value; paramData.push(obj); @@ -408,7 +423,7 @@ export class MappingEditorService { else if (this.fromScreen === 'MappingScreen') { if (key) { paramJson[key] = value; - var obj: any = {'paramName': '', 'paramValue': ''}; + var obj: any = { 'paramName': '', 'paramValue': '' }; obj.paramName = key; obj.paramValue = value; @@ -449,13 +464,13 @@ export class MappingEditorService { public refreshMarker(): void { if (this.editor) { this.hasErrorCode = false; - var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); var keysList = []; // Populate missing keys for (var r = 0; r < ranges.length; r++) { let keyValue: string = this.editor.session.getTextRange(ranges[r]); - if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { + if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END)); let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID)); let specialKeys = key.match(this.checkSpecialCharsReg); @@ -508,7 +523,7 @@ export class MappingEditorService { public generateTemplate(templateEditor: any): void { if (templateEditor) { templateEditor.setValue(this.editor.getValue()); - var occurances = templateEditor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = templateEditor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = templateEditor.getSelection().getAllRanges(); if (ranges) { for (var r = 0; r < ranges.length; r++) { @@ -532,7 +547,7 @@ export class MappingEditorService { public generateParams(paramsEditor: any, paramsKeyValueEditor: any): JSON { if (paramsEditor && paramsKeyValueEditor) { - var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges) { let paramsJSON: JSON = JSON.parse('{}'); @@ -593,4 +608,4 @@ export class MappingEditorService { } -} +} \ No newline at end of file diff --git a/src/app/shared/services/paramShare.service.ts b/src/app/shared/services/paramShare.service.ts index 559b448..fcf065a 100644 --- a/src/app/shared/services/paramShare.service.ts +++ b/src/app/shared/services/paramShare.service.ts @@ -17,7 +17,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -33,6 +32,8 @@ export class ParamShareService { public templateData: {}; public displayData: {}; public paramData = []; + public ansibleServerData : {}; + setData(data) { diff --git a/src/app/shared/services/procOnSrvSide.service.ts b/src/app/shared/services/procOnSrvSide.service.ts new file mode 100644 index 0000000..17666d3 --- /dev/null +++ b/src/app/shared/services/procOnSrvSide.service.ts @@ -0,0 +1,343 @@ +//.. processing document on the server side +import { Injectable } from '@angular/core'; +//import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Http, Response, Headers, RequestOptions } from '@angular/http'; +import { Observable } from 'rxjs'; +import { NotificationsService } from 'angular2-notifications'; + +import { UtilityService } from '../../shared/services/utilityService/utility.service'; + +//const httpOptionsT = { + // headers: new HttpHeaders({ 'Content-Type': 'text/plain' }) +//}; + +@Injectable( +// { providedIn: 'root' } +) +export class ProcOnSrvSideSvc +{ + clName: string = "ProcOnSrvSideSvc"; + public theUrl: string = "/api/proc_cont"; + public resUrlPfx: string = "/api/get_result"; + public parmsUrlPfx: string = "/api/get_params"; + public taskId: string = ''; + public stringBuf: string; + public responBuf: string; + public procResult: string; + public parmsBuf: string; + public responObj: any; + // private respObs: Observable; + private respObs: Observable; + private respObsObj: Observable; + public ppartLen: number = 102400; //.. 102912 is too large payload + // public ppartLen: number = 10240; + public ppartCnt: number = 0; + public p_offset: number = 0; + public interval: any; + cycleCnt: number; + cycleMAX: number = 40; + editorHolder: any; + templSyncer: any; + fHeaders: Headers; + rOptions: RequestOptions; + noptions = { + timeOut: 4000, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 250 + }; + prevTstampInt: number = 0; + currTstampInt: number = 0; + notifDelayMsec: number = 1200; + + constructor( + // private http: HttpClient, + private http: Http, + private utilSvc: UtilityService, + private nService: NotificationsService ) + { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": new: start"); + this.fHeaders= new Headers({'Content-Type': 'text/plain'}); + this.rOptions= new RequestOptions({'responseType':0}); + } + + sendToSrv( content: string, editorHolder: any, templSyncer: any ) { + var methName= "sendToSrv"; + this.stringBuf= content; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": start: content length="+ + this.stringBuf.length ); + this.editorHolder= editorHolder; + this.templSyncer= templSyncer; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": emptying editor..."); + this.editorHolder.editor.session.setValue("temp empty"); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": theUrl:["+this.theUrl+"]"); + this.nService.info( "Start processing", + "sending: content length="+this.stringBuf.length, this.noptions ); + this.taskId= ''; + let contLen= this.stringBuf.length; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": content length="+contLen+ + " ppartLen="+this.ppartLen ); + this.ppartCnt= 1+ Math.floor(contLen / this.ppartLen); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": ppartCnt="+ this.ppartCnt ); + if( this.ppartCnt > 1 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": will send multiple parts..."); + this.nService.info( "Start processing", "will send multiple parts..."); + this.prevTstampInt= Date.now(); + this.p_offset= 0; + let ppart= this.stringBuf.substr( this.p_offset, this.ppartLen ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": First part:["+ppart+"]"); + //.. first + this.sendPart( this.theUrl, ppart, 1 ); + } + else { //.. ppartCnt == 1 + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": will send all-in-1"); + this.nService.info( "Start processing", + "will send all-in-1 part", this.noptions); + this.prevTstampInt= Date.now(); + //.. single + var sUrl= this.theUrl+"?part=1of1"; + this.sendPart( sUrl, this.stringBuf, 1 ); + }; + } + + sendPart( postUrl: string, contPart: string, partNum: number ) { + var methName= "sendPart"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": start: Url:["+postUrl+"]"); + this.currTstampInt= Date.now(); + let ntDiff= this.currTstampInt - this.prevTstampInt; + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+ + ": prevTstampInt="+this.prevTstampInt+ + " currTstampInt="+this.currTstampInt+" the diff="+ntDiff ); + if( ntDiff > this.notifDelayMsec ) { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(this.clName+": "+methName+": notif.delay's long enough."); + this.prevTstampInt= this.currTstampInt; + this.nService.info( "Transferring file", + " part Number="+partNum, this.noptions ); + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": part length="+ contPart.length ); + this.respObs= + this.http.post( postUrl, contPart, this.rOptions ); + // this.http.post( postUrl, contPart, httpOptionsT ); + // this.respObs.subscribe( (respo: string) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": got response:["+respo+"]"); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": json:["+ + JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": responBuf:["+this.responBuf+"]"); + if( this.taskId.length < 1 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": taskId is empty -get it from response"); + let respObj= JSON.parse(this.responBuf); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": respObj.taskId:["+ + respObj.taskId+"]"); + if( respObj.taskId == null || respObj.taskId.length == 0 ) { + let errMsg= this.clName+": "+methName+ + ": Error: failed to get taskId from the server response !"; + console.log( errMsg ); + this.nService.error( "Transferring file", errMsg, this.noptions ); + return; + } + else { //.. extracted respObj.taskId + this.taskId= respObj.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": obtained new taskId:["+ + this.taskId+"]"); + this.nService.info( "Transferring file", + "current taskId:["+this.taskId+"]", this.noptions); + }; + }; + let tpercent= (100.0*partNum/this.ppartCnt).toFixed(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": part#="+partNum+" transfer percent="+tpercent ); + this.currTstampInt= Date.now(); + let ntDiff= this.currTstampInt - this.prevTstampInt; + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+ + ": prevTstampInt="+this.prevTstampInt+ + " currTstampInt="+this.currTstampInt+" the diff="+ntDiff ); + if( ntDiff > this.notifDelayMsec ) { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(this.clName+": "+methName+": notif.delay long enough."); + this.prevTstampInt= this.currTstampInt; + this.nService.info( "Transferring file", + " progress: "+tpercent+" %", this.noptions ); + //" part Number="+partNum+" vs part Count="+this.ppartCnt, this.noptions ); + }; + if( partNum < this.ppartCnt ) { + // this.nService.info( methName,"need to send more parts..."); + let partN= partNum + 1; + this.p_offset= this.p_offset + this.ppartLen; + var ppart= ''; + if( partN < this.ppartCnt ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+ + ": next part is not the last: partN="+partN ); + ppart= this.stringBuf.substr( this.p_offset, this.ppartLen ); + } + else { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+ ": next part is the last."); + ppart= this.stringBuf.substr( this.p_offset ); + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": next part:["+ppart+"]"); + let nUrl= + this.theUrl+"?taskId="+this.taskId+"&part="+partN+"of"+this.ppartCnt; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": next Url:["+nUrl+"]"); + this.sendPart( nUrl, ppart, partN ); + } + else { //.. partNum == this.ppartCnt + this.nService.info( "Transferring file", + "all "+this.ppartCnt+ " parts are sent - check processing...", + this.noptions); + var progrUrl= "/api/get_progress?taskId="+this.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": progrUrl:["+progrUrl+"]"); + this.showProcProgr( progrUrl ); + }; + }, + error => { + console.log( this.clName+": "+methName+ + ": got Error:["+JSON.stringify(error)+']'); + this.responBuf= JSON.stringify(error); + this.nService.error( "Transferring file", + " Error:["+this.responBuf+"]", this.noptions); + }); + } + + showProcProgr( proUrl: string ) { + var methName= "showProcProgr"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": start: proUrl:["+proUrl+"]"); + this.cycleCnt= 0; + this.interval = setInterval( () => { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(methName+": call getProcProgr"); + this.getProcProgr( proUrl ); + }, 2500 ); + } + + getProcProgr( proUrl: string ) { + var methName= "getProcProgr"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": getProcProgr: start: proUrl:["+proUrl+"]"); + this.cycleCnt++; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": cycleCnt="+this.cycleCnt ); + this.nService.info( "Processing", + "Requesting server status...", this.noptions); + // this.respObsObj= + // this.http.get( proUrl ); + this.respObs= + this.http.get( proUrl ); + // this.respObs.subscribe( (respo: string) => { + //this.respObsObj.subscribe( (respo) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": response:["+JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": responBuf:["+this.responBuf+"]"); + let respObj= JSON.parse(this.responBuf); + // this.responObj= respo; //.. Object + if( respObj.percentage != undefined && + respObj.percentage != null ) + { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": got percentage:["+respObj.percentage+"]"); + if( respObj.percentage >= 100.0 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": percentage == 100 !"); + this.nService.info( "Processing completed", + "The server finished: 100% !", this.noptions); + clearInterval( this.interval ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": getting the processing result..."); + this.getProcResult(); + } + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": cycleCnt="+this.cycleCnt+ + " vs MAX="+this.cycleMAX ); + if( this.cycleCnt > this.cycleMAX ) { + this.nService.error( "Processing", + "Too many status requests - stop !",this.noptions ); + clearInterval( this.interval ); + } + }, + error => { + console.log( this.clName+": "+methName+": got Error:["+ + JSON.stringify(error)+']'); + this.responObj= error; //.. as Object + this.nService.error( "Processing"," Error:["+ + JSON.stringify(error)+']', this.noptions ); + clearInterval( this.interval ); + }); + } + + getProcResult() { + var methName= "getProcResult"; + let resUrl= this.resUrlPfx+"?taskId="+this.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": start: resUrl:["+resUrl+"]"); + this.respObs= + this.http.get( resUrl, this.rOptions ); + // this.http.get( resUrl, {responseType: 'text'} ); + // this.respObs.subscribe( (respo: string) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": got response:["+respo+"]"); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": json:["+ + JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": responBuf:["+this.responBuf+"]"); + if( this.utilSvc.getTracelvl() == 0 ) { + let respoBg= this.responBuf.substr(0, 300); + console.log(this.clName+": "+methName+": response Begin:["+respoBg+"...]"); + }; + this.procResult= this.responBuf; + this.nService.info( "Processing completed", + "the result length="+this.procResult.length, this.noptions ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": setting response to the editor..."); + this.editorHolder.editor.session.setValue( this.procResult ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": calling syncTemplate ..."); + this.templSyncer.syncTemplate('1'); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": finished."); + }, + error => { + console.log( this.clName+": "+methName+": subscribe Error:["+ + JSON.stringify(error)+']'); + this.procResult= JSON.stringify(error); + this.nService.error( "Getting Processing result", + " Error:["+JSON.stringify(error)+']', this.noptions); + }); + } +} diff --git a/src/app/shared/services/utilityService/utility.service.ts b/src/app/shared/services/utilityService/utility.service.ts index 8a9f945..6b29a2e 100644 --- a/src/app/shared/services/utilityService/utility.service.ts +++ b/src/app/shared/services/utilityService/utility.service.ts @@ -18,7 +18,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -73,6 +72,15 @@ export class UtilityService { return artifactData.replace(/"/g, '\\"'); } + // get current date in "mm/dd/yyyy" + getDate() { + let toDay = new Date(); + return (toDay.getMonth()+1) +"/"+ toDay.getDate() +"/"+ toDay.getFullYear(); + } + + + + public checkResult(result: any) { if (result.output.status.code == appConstants.errorCode["401"]) { diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 8959587..c911082 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -17,7 +17,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -43,31 +42,44 @@ import {NotificationService} from './services/notification.service'; import {ParamShareService} from './services/paramShare.service'; import {TidyTableModule} from './modules/tidy-table/tidy-table.module'; import {UtilityService} from './services/utilityService/utility.service'; -import {VmFilteringPipe} from '../pipes/vm-filtering.pipe'; +import {ProcOnSrvSideSvc} from './services/procOnSrvSide.service'; + import {SimpleNotificationsModule} from 'angular2-notifications'; import { NgProgressModule } from 'ngx-progressbar'; import {FormsModule} from '@angular/forms'; +import { VmFilteringPipe } from './pipes/vm-filtering.pipe'; +import {APIService} from './services/cdt.apicall' + @NgModule({ imports: [ FormsModule, - CommonModule, HttpModule, RouterModule, TidyTableModule, NgProgressModule, NgbModule, SimpleNotificationsModule.forRoot()], + CommonModule, HttpModule, RouterModule, TidyTableModule, + // HttpClient, HttpHeaders, + NgProgressModule, NgbModule, SimpleNotificationsModule.forRoot()], declarations: [VmFilteringPipe, - HelpComponent, - HeaderComponent, NavigationComponent, LogoutComponent, Collapse, Dropdown, DropdownNotClosableZone, DropdownOpen, DropDownToggleDirective + HeaderComponent, NavigationComponent, LogoutComponent, Collapse, + Dropdown, DropdownNotClosableZone, DropdownOpen, DropDownToggleDirective ], - exports: [VmFilteringPipe, NgProgressModule, NgbModule, HelpComponent, DropDownToggleDirective, HeaderComponent, NavigationComponent, LogoutComponent, TidyTableModule, Collapse, Dropdown, DropdownNotClosableZone, DropdownOpen] + exports: [ + VmFilteringPipe, NgProgressModule, NgbModule, HelpComponent, + DropDownToggleDirective, HeaderComponent, NavigationComponent, + LogoutComponent, TidyTableModule, Collapse, Dropdown, + DropdownNotClosableZone, DropdownOpen + ] }) export class SharedModule { static forRoot(): ModuleWithProviders { return { ngModule: SharedModule, - providers: [HttpUtilService, EmitterService, NotificationService, - UtilityService, - ParamShareService, MappingEditorService] + providers: [ + HttpUtilService, EmitterService, NotificationService, + UtilityService,APIService, ProcOnSrvSideSvc, + ParamShareService, MappingEditorService + ] }; } -} \ No newline at end of file +} diff --git a/src/app/test/test.component.html b/src/app/test/test.component.html index 8147f05..26165d9 100644 --- a/src/app/test/test.component.html +++ b/src/app/test/test.component.html @@ -61,6 +61,13 @@ limitations under the License. +
+
+ + +
+
+
@@ -119,7 +126,9 @@ limitations under the License.
- + +

@@ -131,14 +140,15 @@ limitations under the License.

-

- POLL TEST STATUS RESPONSE + POLL TEST STATUS RESPONSE
-
+
Poll test no {{pollCounter}}
diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts index f3f6a94..347bde6 100644 --- a/src/app/test/test.component.ts +++ b/src/app/test/test.component.ts @@ -25,6 +25,7 @@ import { NgxSpinnerService } from 'ngx-spinner'; import { saveAs } from 'file-saver'; import { Location } from '@angular/common'; import { ActivatedRoute, Router } from '@angular/router'; +import { NotificationService } from '.././shared/services/notification.service'; import { ParamShareService } from '.././shared/services/paramShare.service'; import { MappingEditorService } from '.././shared/services/mapping-editor.service'; import { NotificationsService } from 'angular2-notifications'; @@ -61,7 +62,7 @@ export class TestComponent implements OnInit { vnfcType: any; protocol: any; mode: any = 'NORMAL'; - force: any = 'True'; + public force = 'TRUE'; ttl: any; public formattedNameValuePairs = {}; public requestId = ''; @@ -87,10 +88,11 @@ export class TestComponent implements OnInit { public apiRequest = ''; public apiResponse = ''; public statusResponse; + public appcTimestampResponse; public outputTimeStamp; public status; public statusReason; - public errorResponse; + public errorResponse; public timer; public subscribe; public enableTestButton: boolean = false; @@ -101,30 +103,39 @@ export class TestComponent implements OnInit { public enableCounterDiv: boolean = false; public enableDownload: boolean = false; private userId = localStorage['userId']; - constructor ( - private location: Location, - private activeRoutes: ActivatedRoute, - private nService: NotificationsService, - private router: Router, - private paramShareService: ParamShareService, - private mappingEditorService: MappingEditorService, - private httpUtil: HttpUtilService, - private utiltiy: UtilityService, - private ngProgress: NgProgress, - private spinner: NgxSpinnerService - ) { + timeStampInt: number; + AppcTimeStampInt: number; + AppcTimeDiff: number; + isAppcTimestampReceived: boolean = false; + + constructor (private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService, private nService: NotificationsService, private router: Router, private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private httpUtil: HttpUtilService, + private utiltiy: UtilityService, private ngProgress: NgProgress, private spinner: NgxSpinnerService) { } ngOnInit() { + let timeStampI = new Date(); + console.log("ngOnInit: local timeStamp:[" + timeStampI + "]"); + let timeStampS = timeStampI.toISOString(); + console.log("ngOnInit: local ISO timestamp:[" + timeStampS + "]"); + //.. send HTTP request to APPC + this.getAppcTimestamp(); + } - } + /*public download() { + let stringData: any; + stringData = JSON.stringify(this.paramShareService.getSessionParamData()); + let paramsKeyValueFromEditor: JSON; + paramsKeyValueFromEditor = JSON.parse(stringData); + let fileName = 'param_' + this.action + '_' + this.type + '_' + "0.0.1" + 'V'; + this.JSONToCSVConvertor([paramsKeyValueFromEditor], fileName, true); + }*/ public download() { if (this.apiRequest) { - var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_request'; + var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_request.json'; var theJSON = this.apiRequest; if (fileName != null || fileName != '') { var blob = new Blob([theJSON], { @@ -138,7 +149,7 @@ export class TestComponent implements OnInit { } if (this.apiResponse) { - var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_response'; + var fileName = 'test_' + this.action + '_' + this.actionIdentifiers['vnf-id'] + '_response.json'; var theJSON = this.apiResponse; if (fileName != null || fileName != '') { var blob = new Blob([theJSON], { @@ -157,6 +168,7 @@ export class TestComponent implements OnInit { this.enableTestButton = true; this.enablePollButton = true; if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); + this.apiResponse="Test has been abandoned and polling stopped"; this.nService.info("Information", "Test has been abandoned and polling stopped"); } @@ -290,7 +302,7 @@ export class TestComponent implements OnInit { constructTestPayload(listName2, listName3, key, value) { - if (listName2 == undefined && listName3 == undefined) { + if ((listName2 == undefined || listName2 == '') && (listName3 == undefined || listName3 == '')) { this.subPayload[key] = value; } if (listName2) { @@ -305,7 +317,7 @@ export class TestComponent implements OnInit { } else { this.vnfcJson[key] = value; - this.vmJson['vnfc'] = this.vnfcJson; + this.vmJson['vnfc'] = [this.vnfcJson]; this.flag = 1; } if (this.vmJson) this.lastvmJson = this.vmJson; @@ -317,7 +329,22 @@ export class TestComponent implements OnInit { } constructRequest() { - let timeStamp = new Date().toISOString(); + this.timeStampInt = Date.now(); //.. milliseconds + let timeStamp; + console.log("constructRequest: isAppcTimestampReceived:" + + (this.isAppcTimestampReceived ? "true" : "false")); + if (this.isAppcTimestampReceived) { + console.log("constructRequest: AppcTimeDiff:[" + this.AppcTimeDiff + "]"); + this.timeStampInt += this.AppcTimeDiff; + timeStamp = new Date(this.timeStampInt).toISOString(); + console.log("constructRequest: got timeStamp from APPC:[" + timeStamp + "]"); + } + else { //.. still not received + console.log('constructRequest: Appc Timestamp is not ready (use local)'); + this.timeStampInt -= 100000; + timeStamp = new Date(this.timeStampInt).toISOString(); + }; + console.log('constructRequest: timeStamp:[' + timeStamp + ']'); let reqId; this.requestId = reqId = new Date().getTime().toString(); let data = { @@ -330,7 +357,7 @@ export class TestComponent implements OnInit { 'sub-request-id': this.requestId, 'flags': { 'mode': 'NORMAL', - 'force': 'TRUE', + 'force': this.force.toString().toUpperCase(), 'ttl': 3600 } }, @@ -339,6 +366,15 @@ export class TestComponent implements OnInit { 'payload': JSON.stringify(this.payload) } }; + if (this.action == 'Unlock') { + let payload = JSON.parse(data.input['payload']); + data.input['common-header']['request-id'] = payload['request-id']; + data.input['common-header']['sub-request-id'] = payload['request-id']; + } + + if(this.action == 'Unlock' || this.action == 'Lock' || this.action == 'CheckLock') { + delete data.input['payload']; + } return data; } @@ -348,13 +384,20 @@ export class TestComponent implements OnInit { this.enableTestButton = false; this.enablePollButton = false; this.timer = Observable.interval(10000); - this.subscribe = this.timer.subscribe((t) => this.pollTestStatus()); + if(this.action == 'Unlock' || this.action == 'Lock' || this.action == 'CheckLock') { + this.enablePollButton = true; + this.enableBrowse = true; + this.enableTestButton = true; + this.requestId = ''; + } else { + this.subscribe = this.timer.subscribe((t) => this.pollTestStatus()); + } this.ngProgress.start(); this.apiRequest = JSON.stringify(this.constructRequest()); this.httpUtil.post( { - url: environment.testVnf + "?urlAction=" + this.getUrlEndPoint(this.action.toLowerCase()), + url: environment.testVnf + "?urlAction=" + this.getUrlEndPoint(this.action), data: this.apiRequest }) .subscribe(resp => { @@ -365,10 +408,11 @@ export class TestComponent implements OnInit { }, error => { this.nService.error('Error', 'Error in connecting to APPC Server'); - this.enableBrowse = true; + // this.enableBrowse = true; this.enableTestButton = true; this.enablePollButton = true; this.enableCounterDiv = false; + this.enableBrowse = true; if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); }); @@ -378,10 +422,98 @@ export class TestComponent implements OnInit { }, 3500); } + getAppcTimestamp() { + this.timeStampInt = Date.now(); //.. milliseconds + console.log("getAppcTimestamp: timeStampInt:[" + this.timeStampInt + "]"); + let timeStampP = new Date(this.timeStampInt).toISOString(); + console.log("getAppcTimestamp: from int timestamp:[" + timeStampP + "]"); + this.isAppcTimestampReceived = false; + let reqId = new Date().getTime().toString(); + try { + let data = { + 'input': { + 'design-request': { + 'request-id': reqId, + 'action': 'getAppcTimestampUTC', + 'payload': '{}' + } + } + }; + console.log('getAppcTimestamp: sending httpUtil.post...'); + this.httpUtil.post( + { + url: environment.getDesigns, data: data + }) + .subscribe(resp => { + this.appcTimestampResponse = resp; + // this.appcTimestampResponse = JSON.stringify(resp); + console.log('appcTimestampResponse:[' + resp + ']'); + this.parseAppcTimestamp(this.appcTimestampResponse); + }); + } + catch (e) { + this.nService.warn('status', + 'Error while retrieving APPC Timestamp(using local by default)!'); + } + } + + parseAppcTimestamp(tstampStr: string) { + //.. parse the response to get timestamp as milliseconds + // input format: YYYY-MM-DDTHH:mm:ss.sssZ (24 chars) + var rexp = + new RegExp(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z/); + var mresult = rexp.exec(tstampStr); + if (mresult[0]) { + console.log("parseAppcTimestamp: response format is OK..."); + var aYearS = mresult[1]; + var aYear = parseInt(aYearS, 10); + var aMonS = mresult[2]; + var aMon = parseInt(aMonS, 10) - 1; + var aDayS = mresult[3]; + var aDay = parseInt(aDayS, 10); + var aHrS = mresult[4]; + var aHr = parseInt(aHrS, 10); + var aMntS = mresult[5]; + var aMnt = parseInt(aMntS, 10); + var aSecS = mresult[6]; + var aSec = parseInt(aSecS, 10); + var aMsecS = mresult[7]; + var aMsec = parseInt(aMsecS, 10); + this.AppcTimeStampInt = + Date.UTC(aYear, aMon, aDay, aHr, aMnt, aSec, aMsec); + console.log( + "parseAppcTimestamp: AppcTimeStampInt:[" + this.AppcTimeStampInt + "]"); + let timeStampP = new Date(this.AppcTimeStampInt).toISOString(); + console.log("parseAppcTimestamp: from int timestamp:[" + timeStampP + "]"); + //.. AppcTimeDiff - time difference in milliseconds + this.AppcTimeDiff = this.AppcTimeStampInt - this.timeStampInt; + console.log("parseAppcTimestamp: AppcTimeDiff:[" + this.AppcTimeDiff + "]"); + this.isAppcTimestampReceived = true; + } + else { + throw new Error( + 'The received APPC Timestamp is not matching expected format: YYYY-MM-DDTHH:mm:ss.sssZ !'); + } + } pollTestStatus() { if (this.requestId && this.actionIdentifiers['vnf-id']) { - let timeStamp = new Date().toISOString(); + // console.log("payload==" + JSON.stringify(this.payload)) + this.timeStampInt = Date.now(); //.. milliseconds + let timeStamp; + console.log("pollTestStatus: isAppcTimestampReceived:" + + (this.isAppcTimestampReceived ? "true" : "false")); + if (this.isAppcTimestampReceived) { + this.timeStampInt += this.AppcTimeDiff; + timeStamp = new Date(this.timeStampInt).toISOString(); + console.log("pollTestStatus: got timeStamp from APPC:[" + timeStamp + "]"); + } + else { //.. still not received + console.log('pollTestStatus: Appc Timestamp is not ready (use local)'); + this.timeStampInt -= 100000; + timeStamp = new Date(this.timeStampInt).toISOString(); + }; + console.log("pollTestStatus: timestamp:[" + timeStamp + "]"); let reqId = new Date().getTime().toString(); let data = { 'input': { @@ -393,7 +525,7 @@ export class TestComponent implements OnInit { 'sub-request-id': reqId, 'flags': { 'mode': 'NORMAL', - 'force': 'TRUE', + 'force': this.force.toString().toUpperCase(), 'ttl': 3600 } }, @@ -435,10 +567,14 @@ export class TestComponent implements OnInit { if (status.toUpperCase() === 'SUCCESS' || status.toUpperCase() === 'SUCCESSFUL') { if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); this.enablePollButton = true; + this.enableBrowse = true; + this.enableTestButton = true; } if (status.toUpperCase() === 'FAILED') { if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe(); this.enablePollButton = true; + this.enableBrowse = true; + this.enableTestButton = true; } } else { @@ -456,11 +592,14 @@ export class TestComponent implements OnInit { this.showStatusResponseDiv = false; this.errorResponse = 'Error Connecting to APPC server'; this.enableCounterDiv = false; + this.enableBrowse = true; + this.enableTestButton = true; if (this.subscribe && this.subscribe != undefined) { this.subscribe.unsubscribe(); this.enablePollButton = true; } }); + } else { this.nService.error("Error", "Please enter vnf Id & request Id"); @@ -469,43 +608,16 @@ export class TestComponent implements OnInit { } getUrlEndPoint(action) { - switch (action) { - case 'configmodify': - return 'config-modify'; - case 'configbackup': - return 'config-backup'; - case 'configrestore': - return 'config-restore'; - case 'healthcheck': - return 'health-check'; - case 'quiescetraffic': - return 'quiesce-traffic'; - case 'resumetraffic': - return 'resume-traffic'; - case 'distributetraffic': - return 'distribute-traffic'; - case 'startapplication': - return 'start-application'; - case 'stopapplication': - return 'stop-application'; - case 'upgradebackout': - return 'upgrade-backout'; - case 'upgradepostcheck': - return 'upgrade-post-check'; - case 'upgradeprecheck': - return 'upgrade-pre-check'; - case 'upgradesoftware': - return 'upgrade-software'; - case 'upgradebackup': - return 'upgrade-backup'; - case 'attachvolume': - return 'attach-volume'; - case 'detachvolume': - return 'detach-volume'; - default: - return action.toLowerCase(); + let charArray = action.split(''); + let url = ''; + for (let i = 0; i < charArray.length; i++) { + if (charArray[i] == charArray[i].toUpperCase() && i != 0) { + url = url + '-'; + } + url = url + charArray[i]; } + return url.toLowerCase(); } setValuesOnFileUploadFailure() { diff --git a/src/app/vnfs/LoginGuardService/Login-guard-service.ts b/src/app/vnfs/LoginGuardService/Login-guard-service.ts index ddec7b5..1e7e752 100644 --- a/src/app/vnfs/LoginGuardService/Login-guard-service.ts +++ b/src/app/vnfs/LoginGuardService/Login-guard-service.ts @@ -24,11 +24,13 @@ limitations under the License. import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; import {Injectable} from '@angular/core'; +import {MappingEditorService} from '../../shared/services/mapping-editor.service'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @Injectable() export class LoginGuardService implements CanActivate { - constructor(private router: Router) { + constructor(private ngbModal: NgbModal, private mapService: MappingEditorService, private router: Router) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { @@ -42,4 +44,4 @@ export class LoginGuardService implements CanActivate { } } -} +} \ No newline at end of file diff --git a/src/app/vnfs/auth-guard-modal/auth-guard-modal.ts b/src/app/vnfs/auth-guard-modal/auth-guard-modal.ts index ec03978..3f53d57 100644 --- a/src/app/vnfs/auth-guard-modal/auth-guard-modal.ts +++ b/src/app/vnfs/auth-guard-modal/auth-guard-modal.ts @@ -19,10 +19,10 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ import {Component, OnInit} from '@angular/core'; +import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap'; @Component({ selector: 'app-auth-guard-modal', @@ -31,7 +31,7 @@ import {Component, OnInit} from '@angular/core'; }) export class AuthGuardModalComponent implements OnInit { - constructor() { + constructor(public activeModal: NgbActiveModal) { } ngOnInit() { diff --git a/src/app/vnfs/build-artifacts/build-artifacts.component.html b/src/app/vnfs/build-artifacts/build-artifacts.component.html index 33d8064..fad94cb 100644 --- a/src/app/vnfs/build-artifacts/build-artifacts.component.html +++ b/src/app/vnfs/build-artifacts/build-artifacts.component.html @@ -23,9 +23,11 @@ limitations under the License.
-
- + +
- +
@@ -142,7 +143,7 @@ limitations under the License. diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts index f7d1837..6ba8e52 100644 --- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts +++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts @@ -38,6 +38,7 @@ import 'rxjs/add/operator/map'; import { NgProgress } from 'ngx-progressbar'; import { NgxSpinnerService } from 'ngx-spinner'; import { appConstants } from '../../../../constants/app-constants'; +import { APIService } from "../../../shared/services/cdt.apicall"; let YAML = require('yamljs'); @@ -50,9 +51,11 @@ declare var $: any; providers: [ParameterDefinitionService] }) export class ParameterComponent implements OnInit { + clName= "ParameterCompon"; public paramForm: any; public actionType: any; public showFilterFields: boolean; + public filterByFieldvalues = appConstants.filterByFieldvalues; public ruleTypeConfiguaration = appConstants.ruleTypeConfiguaration; public requiredValues: boolean[] = appConstants.requiredValues; @@ -106,11 +109,12 @@ export class ParameterComponent implements OnInit { public artifactName; public appDataObject: any; public downloadDataObject: any; - public artifact_fileName = ""; + public artifact_fileName=""; template_id: any; private selectedActionReference: any; constructor(private httpService: HttpUtilService, + private apiService:APIService, private parameterDefinitionService: ParameterDefinitionService, private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, @@ -122,33 +126,26 @@ export class ParameterComponent implements OnInit { } ngOnInit() { - this.selectedActionReference = this.parameterDefinitionService.prepareFileName(); + var methName= "ngOnInit"; + this.selectedActionReference = this.mappingEditorService.newObject; if (this.selectedActionReference && this.selectedActionReference != undefined) { - - this.vnfType = this.selectedActionReference.scope['vnf-type']; - this.vnfcType = this.selectedActionReference.scope['vnfc-type']; - this.protocol = this.selectedActionReference['device-protocol']; - this.action = this.selectedActionReference.action; - - for (let i = 0; i < this.selectedActionReference['artifact-list'].length; i++) { - let artifactList = this.selectedActionReference['artifact-list']; - if (artifactList[i]['artifact-type'] === 'parameter_definitions') { - var artifactName = artifactList[i]['artifact-name']; - var artifactNameWithoutExtension = ''; - if (artifactName) { - artifactNameWithoutExtension = artifactName.substring(0, artifactName.lastIndexOf(".")); - } - if (this.mappingEditorService.identifier) { - if (artifactNameWithoutExtension.endsWith(this.mappingEditorService.identifier)) { - this.artifact_fileName = artifactName; - } - - } - else { - this.artifact_fileName = artifactName; - } - } + this.vnfType = this.selectedActionReference.vnf; + this.protocol = this.selectedActionReference.protocol; + this.action = this.selectedActionReference.action; + if( this.utilService.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": vnfType:["+this.vnfType+ + "] action:["+this.action+"] protocol:["+this.protocol+"]"); + if(this.selectedActionReference.vnfc) { + this.vnfcType = this.selectedActionReference.vnfc; + if( this.utilService.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": have vnfcType:["+ + this.vnfcType+"]"); + } + if( this.action === 'ConfigScaleOut'){ + // this.template_id = this.selectedActionReference.templateId; + this.template_id = this.mappingEditorService.identifier; } + this.artifact_fileName = this.selectedActionReference.pd_artifact; this.parameterDefinitionService.setValues(this.vnfType, this.vnfcType, this.protocol, this.action, this.artifact_fileName); } else { @@ -165,22 +162,26 @@ export class ParameterComponent implements OnInit { 'scopeType': '' }; } - - this.template_id = this.mappingEditorService.identifier; + //let path = this.location.path + /* this.activeRoutes.url.subscribe(UrlSegment => { + this.actionType = UrlSegment[0].path + }) + */ } ngAfterViewInit() { - if (this.mappingEditorService.latestAction) { + if( this.mappingEditorService.latestAction) { this.displayParamObjects = []; this.modelParamDefinitionObjects = []; - if (this.paramShareService.getSessionParamData() != undefined && this.paramShareService.getSessionParamData().length > 0) { - this.getPDFromSession(); + this.displayParamObjects= this.paramShareService.getSessionParamData(); + // if( this.paramShareService.getSessionParamData() != undefined && + // this.paramShareService.getSessionParamData().length > 0) + if( this.displayParamObjects != undefined && + this.displayParamObjects.length > 0 ) + { + this.parameterDefinitionService.populateDataUponSource( this.displayParamObjects); } else { - this.ngProgress.start(); - this.getPD(); - setTimeout(() => { - this.ngProgress.done(); - }, 3500); + this.getPD(); } } else { this.nService.error(appConstants.errors.error, appConstants.errors["noAction&VNFTypeInRDscreenError"]); @@ -191,19 +192,20 @@ export class ParameterComponent implements OnInit { public getPD() { let result: any; - let input=this.utilService.createPayloadForRetrieve(false, this.action, this.vnfType,this.artifact_fileName); + let input= + this.utilService.createPayloadForRetrieve( false, this.action, this.vnfType,this.artifact_fileName); let artifactContent: any; - return this.httpService.post({ - url: environment.getDesigns, - data: input - }).subscribe(data => { - if (this.utilService.checkResult(data)) { - let result: any = JSON.parse(data.output.data.block).artifactInfo[0]; + this.ngProgress.start(); + return this.apiService.callGetArtifactsApi(input).subscribe( data => { + if( this.utilService.checkResult(data)) { + let result: any = JSON.parse(data.output.data.block).artifactInfo[0]; var pdObject = YAML.parse(result['artifact-content']); let fileModel = pdObject['vnf-parameter-list']; this.displayParamObjects = this.parameterDefinitionService.populatePD(fileModel); } - + else { + } + this.ngProgress.done(); }, error => this.nService.error(appConstants.errors.error, appConstants.errors.connectionError)); @@ -212,20 +214,19 @@ export class ParameterComponent implements OnInit { public getPDFromSession() { - this.ngProgress.start(); + this.ngProgress.start(); return this.httpService.get({ url: 'testurl', - }).subscribe(data => { - this.displayParamObjects = this.paramShareService.getSessionParamData(); - this.ngProgress.done(); + }).subscribe( data => { + this.displayParamObjects = this.paramShareService.getSessionParamData(); + this.ngProgress.done(); }, - error => { - this.displayParamObjects = this.paramShareService.getSessionParamData(); - this.ngProgress.done(); - }); + error => { + this.displayParamObjects = this.paramShareService.getSessionParamData(); + this.ngProgress.done(); + }); } - //========================== End of NGInit() Method============================================ selectedNavItem(item: any) { this.item = item; } @@ -266,6 +267,10 @@ export class ParameterComponent implements OnInit { // Create the file reader let reader = new FileReader(); this.readFile(input.files[0], reader, (result) => { + if ('keyfile' === uploadType) { + this.myKeyFileName = input.files[0].name; + this.displayParamObjects = this.parameterDefinitionService.processKeyFile(this.myKeyFileName, result); + } if ('pdfile' === uploadType) { this.myPdFileName = input.files[0].name; this.displayParamObjects = this.parameterDefinitionService.processPDfile(this.myPdFileName, result); @@ -294,8 +299,7 @@ export class ParameterComponent implements OnInit { let obj: any = fileInput.target.files; } - - sourceChanged(data, obj) { + sourceChanged( data, obj) { if (data == 'A&AI') { obj.ruleTypeValues = appConstants.ruleTypeValues; for (let x = 0; x < 5; x++) { @@ -317,7 +321,7 @@ export class ParameterComponent implements OnInit { } //========================== End of sourceChanged() Method============================================ - ruleTypeChanged(data, obj) { + ruleTypeChanged( data, obj) { if (data == null || data == undefined || data == 'null') { obj.showFilterFields = false; obj['rule-type'] = null; @@ -340,7 +344,7 @@ export class ParameterComponent implements OnInit { } for (let x = 0; x < sourceObject.length; x++) { obj['response-keys'][x]['key-name'] = sourceObject[x]['key-name']; - obj['response-keys'][x]['key-value'] = sourceObject[x]['key-value']; + obj['response-keys'][x]['key-value'] = sourceObject[x]['key-value']; } } diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.css b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.css index 1b4c470..54e0148 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.css +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.css @@ -17,7 +17,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -134,4 +133,7 @@ td { .file { visibility: hidden; position: absolute; -} \ No newline at end of file +} + +.col-md-1point5 {width: 12%} +.col-md-2point5 {width: 21%;} diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html index 564cd32..6225ea0 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html @@ -44,18 +44,19 @@ limitations under the License. Required Field
-
- +
+ - Add New VNFC Type
+ -
+
@@ -72,16 +73,19 @@ limitations under the License. - +
Assign New Template Identifier + (click)="identifierModal.open()">Assign New Template Identifier
+ +
+
@@ -137,6 +141,7 @@ limitations under the License.
+
VNFC Information @@ -150,15 +155,15 @@ limitations under the License.
- +
-
- +
+
- +
-
+
@@ -198,29 +203,29 @@ limitations under the License.
-
-
+
+
VM Number: {{j+1}}
-
+
- + Required Field
-
- +
+ Required Field
- + - {{errorMessage}} + {{errorMessage}}
@@ -328,45 +333,20 @@ limitations under the License. -