2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
20 ============LICENSE_END============================================
23 import * as XLSX from 'xlsx';
24 import * as _ from 'underscore';
26 import { ActivatedRoute, Router } from '@angular/router';
27 import { Component, OnInit, ViewChild } from '@angular/core';
28 import { Observable } from 'rxjs/Observable';
29 import { BuildDesignComponent } from '../build-artifacts.component';
30 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
31 import { Location } from '@angular/common';
32 import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
33 import { NgProgress } from 'ngx-progressbar';
34 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
35 import { NotificationService } from '../../../shared/services/notification.service';
36 import { NotificationsService } from 'angular2-notifications';
37 import { ParamShareService } from '../../..//shared/services/paramShare.service';
38 import { environment } from '../../../../environments/environment';
39 import { saveAs } from 'file-saver';
40 import { Jsonp } from '@angular/http';
41 import { ReferenceDataFormUtil } from './reference-dataform.util';
42 import { UtilityService } from '../../../shared/services/utilityService/utility.service';
43 import { APIService } from "../../../shared/services/cdt.apicall";
45 // Common Confirm Modal
46 import { DialogService } from 'ng2-bootstrap-modal';
47 import { ConfirmComponent } from "../../../shared/confirmModal/confirm.component";
51 type AOA = Array<Array<any>>;
54 selector: 'reference-dataform',
55 templateUrl: './reference-dataform.component.html',
56 styleUrls: ['./reference-dataform.component.css'],
57 providers: [ReferenceDataFormUtil]
59 export class ReferenceDataformComponent implements OnInit {
60 public classNm= "ReferenceDataformComp";
61 public showUploadStatus: boolean = false;
62 public fileUploaded: boolean = false;
63 public uploadedData: any;
64 public statusMsg: string;
65 public uploadStatus: boolean = false;
66 public isCollapsedContent: boolean = true;
67 public vnfcCollLength: number = 0;
68 public vfncCollection = [];
70 public actionType: any;
71 numberTest: RegExp = /^[^.a-z]+$/;
72 public numberOfVmTest: boolean = true;
73 public tempAllData = [];
74 disableGrpNotationValue: boolean;
75 public noRefData = false;
76 public disableRetrieve = false;
77 public getRefStatus = false;
78 public uploadStatusError: boolean;
79 public showUploadErrorStatus: boolean;
80 public noData: string;
82 public appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
83 public downloadData = {
85 template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
86 pd: { pdData: '', pdFileName: '' }
92 oldVnfcIdentifier: any
93 public uploadFileName: any;
94 public addVmClickedFlag: boolean = false;
95 public getExcelUploadStatus: boolean = false;
96 public uploadedDataArray: any;
97 public actionFlag = false;
100 nonConfigureAction: any;
104 public actionLevels = [
107 oldtemplateIdentifier: any
109 identifierDrpValues: any = [];
110 //settings for the notifications.
113 showProgressBar: true,
118 //initializing this object to contain all the parameters to be captured later
119 public referenceDataObject = {
121 'action-level': 'vnf',
122 scope: { 'vnf-type': '', 'vnfc-type-list': [] },
125 'device-protocol': '',
130 public refernceScopeObj = { sourceType: '', from: '', to: '' };
131 public actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
132 public groupAnotationValue = ['', 'Pair'];
133 public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
134 public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
135 public deviceTemplates = ['', 'Y', 'N'];
136 public sourceTypeColl = ['', 'vnfType', 'vnfcType'];
137 public ipAddressBoolean = ['', 'Y', 'N'];
138 public Sample: any = {
139 'vnfc-instance': '1',
140 'vnfc-function-code': '',
141 'ipaddress-v4-oam-vip': '',
142 'group-notation-type': '',
143 'group-notation-value': ''
145 hideModal: boolean = false;
147 public uploadTypes = [{
148 value: 'Reference Data',
149 display: 'Sample Json Param File'
152 value: 'Mapping Data',
153 display: 'Sample Json Param File'
156 public selectedUploadType: string = this.uploadTypes[0].value;
157 public vnfcTypeData: string = '';
158 public title: string;
159 public allowAction: boolean = true;
160 public actionExist: boolean = false;
161 public disableVnftype: boolean = false;
162 public otherActions: boolean = false;
163 public actionHealthCheck: boolean = false;
164 public actionChanged: boolean = false;
165 public initialAction: string = '';
166 public noCacheData: boolean;
167 public updateParams: any;
168 public vnfParams: any;
169 public firstArrayElement = [];
170 public remUploadedDataArray = [];
171 isConfigScaleOut = false
172 isConfigOrConfigModify = false
173 configScaleOutExist: boolean
174 displayVnfc = 'false';
176 isVnfcTypeList: boolean = true;
177 public referencDataTab = [
180 name: 'Reference Data',
185 name: 'Reference Data',
189 url: 'templates/myTemplates',
191 name: 'Parameter Definition',
192 url: 'parameterDefinitions/create'
198 public actionList = require('../../../../cdt.application.properties.json').Actions;
200 public versionNoForApiCall = require('../../../../cdt.application.properties.json').versionNoForApiCall;
201 private displayVMBlock: boolean = true;
204 private buildDesignComponent: BuildDesignComponent, private apiService: APIService, private utilityService: UtilityService, private httpUtils: HttpUtilService, private referenceDataFormUtil: ReferenceDataFormUtil, private route: Router, private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService,
205 private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService, private ngProgress: NgProgress,
206 private dialogService: DialogService)
208 console.log(this.classNm+
209 ": new: start: tracelvl="+this.utilityService.getTracelvl() );
213 let methName= "ngOnInit";
214 if( this.utilityService.getTracelvl() > 0 )
215 console.log( this.classNm+": ngOnInit: start ");
216 // this.handleVMBlockDisplay();
218 //initializing the variables and checking for configscaleout fromm properties file
219 this.configScaleOutExist = require('../../../../cdt.application.properties.json').displayConfigScaleout;
220 this.displayVnfc = sessionStorage.getItem("vnfcSelectionFlag");
221 if (this.configScaleOutExist) {
222 this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
224 this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions'];
227 let path = this.location.path;
228 this.title = 'Reference Data';
229 // setting the structure for the reference data object
230 this.referenceDataObject = {
232 'action-level': 'vnf',
233 scope: { 'vnf-type': '', 'vnfc-type-list': [] },
236 'device-protocol': '',
241 //getting the data from session data, calling get Artifact if the data is undefined
242 this.updateParams = sessionStorage.getItem('updateParams');
243 //getting the data from the referencenameobjects if the nav is changed and assiging it to the cace data
244 let cacheData = this.mappingEditorService.referenceNameObjects;
246 if (this.utilityService.checkNotNull(cacheData)) {
247 //if cache data exists then assiging the data to the latest temp all data object.
248 if( this.utilityService.getTracelvl() > 0 )
249 console.log( this.classNm+": ngOnInit: have cacheData.");
250 this.tempAllData = cacheData;
251 //calling the highligted method to highlight the selected actions in the action dropdown
252 this.highlightSelectedActions(this.tempAllData)
253 // getting the latest action that the user has selected and assiging it to the reference data object once the user toggles between tabs from reference
254 if (this.mappingEditorService.latestAction != undefined) {
255 //adding the latest action to the screen
256 this.referenceDataObject = this.mappingEditorService.latestAction;
257 this.toggleIdentifier(this.referenceDataObject.action);
258 //this.referenceDataObject['template-id-list'] = this.mappingEditorService.identifier
259 //use these commented objects to be used in template and pd pages
260 //this.templateIdentifier = this.mappingEditorService.identifier
261 //adding the scope from referencedata obj to referencescopeobject
262 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
263 //assigning the latest action fetched to the old action from reference data object
264 this.oldAction = this.referenceDataObject.action;
265 //this method is called with the action reterived and subsequent values are assigned to refdataobj for displaying
266 this.populateExistinAction(this.referenceDataObject.action);
267 this.displayHideVnfc();
269 } else if (this.updateParams != 'undefined') {
270 //calls the get artifact() to reterive the values if cache data is not present
273 //getting the appdata & downloadDataObject from mapping editor service and assiging it.
274 var appData = this.mappingEditorService.appDataObject;
275 if (appData != null || appData != undefined) this.appData = appData;
276 var downloadData = this.mappingEditorService.downloadDataObject;
277 if (downloadData != null || downloadData != undefined) this.downloadData = downloadData;
279 if (sessionStorage.getItem('vnfParams')) {
280 this.vnfParams = JSON.parse(sessionStorage.getItem('vnfParams'));
282 if (this.vnfParams && this.vnfParams.vnfType) {
283 if( this.utilityService.getTracelvl() > 0 )
284 console.log( this.classNm+": "+methName+": vnfParams.vnfType:["+
285 this.vnfParams.vnfType+"]");
286 this.referenceDataObject['scope']['vnf-type'] = this.vnfParams.vnfType;
288 if (this.vnfParams && this.vnfParams.vnfcType) {
289 if( this.utilityService.getTracelvl() > 0 )
290 console.log( this.classNm+": "+methName+": vnfParams.vnfcType:["+
291 this.vnfParams.vnfcType+"]");
292 this.referenceDataObject['scope']['vnfc-type'] = this.vnfParams.vnfcType;
294 this.uploadedDataArray = [];
295 this.remUploadedDataArray = [];
296 this.firstArrayElement = [];
297 this.uploadFileName = '';
298 this.templateIdentifier = this.mappingEditorService.identifier
299 // if (this.mappingEditorService.newObject) {
300 // this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
303 // this.vnfcIdentifier = '';
304 // this.referenceDataObject['vnfcIdentifier'] = '';
306 this.oldVnfcIdentifier = this.vnfcIdentifier;
307 if( this.utilityService.getTracelvl() > 1 )
308 console.log( this.classNm+": "+methName+": displayVnfc:["+
309 this.displayVnfc+"]");
310 if( this.utilityService.getTracelvl() > 1 )
311 console.log( this.classNm+": "+methName+": templateIdentifier:["+
312 this.templateIdentifier+"]");
313 // Enable or Block Template and PD Tabs
314 this.buildDesignComponent.getRefData(
315 { ...this.referenceDataObject, displayVnfc: this.displayVnfc },
316 { reqField: this.templateIdentifier });
317 //.. configure some drop-downs
318 this.configDrp(this.referenceDataObject.action);
319 if( this.utilityService.getTracelvl() > 0 )
320 console.log( this.classNm+": "+methName+": tempAllData:["+
321 JSON.stringify(this.tempAllData)+"]");
322 if( this.utilityService.getTracelvl() > 0 )
323 console.log( this.classNm+": "+methName+": finish.");
326 //setting the value to display or hide the template identifier dropdown in the screen
327 toggleIdentifier(data) {
328 if (data == 'ConfigScaleOut') {
329 this.isConfigScaleOut = true
332 this.isConfigScaleOut = false
336 //to retrive the data from appc and assign it to the vaiables, if no data display the message reterived from the API
338 if( this.utilityService.getTracelvl() > 0 )
339 console.log(this.classNm+": getArtifact: start...");
341 // setting the isVnfcTypeList & isVnfcType to false initially
342 this.isVnfcTypeList = false;
343 this.isVnfcType = false
344 let data = this.utilityService.createPayloadForRetrieve(true, '', '', '');
345 this.ngProgress.start();
346 let serviceCall = this.apiService.callGetArtifactsApi(data);
347 serviceCall.subscribe(resp => {
348 //getting the response and assigining it to the variables used and end the progress bar aftr the data is fetched.
349 if (resp.output.data.block != undefined) {
350 this.nService.success('Status', 'data fetched ');
351 let artifactInfo = JSON.parse(resp.output.data.block).artifactInfo[0];
352 let referenceDataAll = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
353 let reference_data = JSON.parse(artifactInfo['artifact-content'])['reference_data'][0];
354 this.referenceDataObject = reference_data;
355 this.toggleIdentifier(this.referenceDataObject.action);
356 if (this.referenceDataObject.action == 'ConfigScaleOut') {
357 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
359 this.highlightSelectedActions(referenceDataAll)
361 //chck vnfc or vnfcTypeList
362 this.displayHideVnfc();
364 // Enable or Block Template and PD Tabs
365 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
367 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
368 this.mappingEditorService.getReferenceList().push(JSON.parse(artifactInfo['artifact-content']));
369 this.tempAllData = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
370 this.oldAction = this.referenceDataObject.action;
371 this.oldVnfcIdentifier = this.vnfcIdentifier;
373 this.processReferenceDataAfterRetrieval();
374 this.getArtifactsOpenStack();
376 this.nService.success('Status', 'Sorry !!! I dont have any artifact Named : ' + (JSON.parse(sessionStorage.getItem('updateParams')))['artifact-name']);
378 this.ngProgress.done();
382 this.nService.warn('status', 'error while reteriving artifact');
385 this.ngProgress.done();
390 if( this.utilityService.getTracelvl() > 0 )
391 console.log(this.classNm+": displayHideVnfc: start...");
392 if( this.utilityService.getTracelvl() > 1 ) {
393 if( this.referenceDataObject.scope['vnfc-type-list'] ) {
394 console.log( this.classNm+
395 ": displayHideVnfc: refDataObj.scope.vnfc-type-list.length="+
396 this.referenceDataObject.scope['vnfc-type-list'].length );
398 console.log( this.classNm+
399 ": displayHideVnfc: refDataObj.scope.vnfc-type-list not defined");
401 console.log( this.classNm+": displayHideVnfc: scope.vnfc-type:["+
402 this.referenceDataObject.scope['vnfc-type']+"]");
404 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && (this.referenceDataObject.scope['vnfc-type'] != undefined || this.referenceDataObject.scope['vnfc-type'] != "")) {
405 this.isVnfcType = true
406 this.displayVnfc = 'true'
407 this.isVnfcTypeList = false
409 if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length != 0 && (this.referenceDataObject.scope['vnfc-type'] == undefined || this.referenceDataObject.scope['vnfc-type'] == "")) {
410 this.isVnfcType = false
411 this.displayVnfc = 'true'
412 this.isVnfcTypeList = true
413 if(!this.mappingEditorService.newObject || !this.mappingEditorService.newObject.vnfc) {
414 this.vnfcIdentifier = this.referenceDataObject.scope['vnfc-type-list'][0];
415 // this.mappingEditorService.newObject.vnfc = this.vnfcIdentifier;
417 this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
419 this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
420 //this.vnfcChanged(this.vnfcIdentifier, FormData);
421 if( this.utilityService.getTracelvl() > 0 )
422 console.log(this.classNm+": displayHideVnfc: vnfcIdentifier:["+
423 this.vnfcIdentifier+"]");
425 if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length == 0 && this.referenceDataObject.scope['vnfc-type'] != undefined && this.referenceDataObject.scope['vnfc-type'].length == 0) {
426 if(this.displayVnfc == 'true') {
427 this.isVnfcType = false
428 this.displayVnfc = 'true'
429 this.isVnfcTypeList = true
431 this.isVnfcType = false
432 this.displayVnfc = 'false'
433 this.isVnfcTypeList = false
436 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && this.referenceDataObject.scope['vnfc-type'] == '') {
437 this.isVnfcType = false
438 this.displayVnfc = 'false'
439 this.isVnfcTypeList = false
441 if( this.utilityService.getTracelvl() > 0 )
442 console.log(this.classNm+": displayHideVnfc: finish. isVnfcType:["+
443 this.isVnfcType+" displayVnfc:["+this.displayVnfc+"] isVnfcTypeList:["+
444 this.isVnfcTypeList+"]");
447 //reinitializing the required values. when changing to template or pd sending the values to mapping service
449 let referenceObject = this.prepareReferenceObject();
450 this.mappingEditorService.changeNavAppData(this.appData);
451 this.mappingEditorService.changeNavDownloadData(this.downloadData);
452 this.uploadedDataArray = [];
453 this.remUploadedDataArray = [];
454 this.firstArrayElement = [];
455 this.uploadFileName = '';
457 // vaidating the number
458 numberValidation(event: any) {
459 if (this.numberTest.test(event) && event != 0) {
460 this.numberOfVmTest = true;
463 this.numberOfVmTest = false;
466 // update my vnf pop up session values
467 updateSessionValues(event: any, type: string) {
468 if( this.utilityService.getTracelvl() > 0 )
469 console.log(this.classNm+": updateSessionValues: type:["+type+"]");
470 if (type === 'action') {
471 sessionStorage.setItem('action', event);
473 if (type === 'vnfType') {
474 sessionStorage.setItem('vnfType', event);
477 // adding vnfc data for each vm
478 addVnfcData(vmNumber: number) {
479 if( this.utilityService.getTracelvl() > 0 )
480 console.log(this.classNm+": addVnfcData: start: vmNumber="+ vmNumber);
482 'vnfc-instance': this.referenceDataObject.vm[vmNumber].vnfc.length + 1,
483 'vnfc-type': this.vnfcTypeData,
484 'vnfc-function-code': '',
485 'ipaddress-v4-oam-vip': '',
486 'group-notation-type': '',
487 'group-notation-value': ''
489 this.referenceDataObject.vm[vmNumber].vnfc.push(newObj);
491 //validating the vnf and vnfc data in the pop up
492 validateVnfcName(name) {
493 if( this.utilityService.getTracelvl() > 0 )
494 console.log( this.classNm+": validateVnfcName: start: name:["+name+"]");
495 if (!name.trim() || name.length < 1) {
496 this.errorMessage = '';
498 } else if (name.startsWith(' ') || name.endsWith(' ')) {
499 this.errorMessage = 'Leading and trailing spaces are not allowed';
501 } else if (name.includes(' ')) {
502 this.errorMessage = 'More than one space is not allowed in VNFC Type';
504 } else if (name.length > 50) {
505 this.errorMessage = 'VNFC Type should be of minimum one character and maximum 50 character';
508 this.invalid = false;
509 this.errorMessage = '';
514 //to remove the VM's created by the user
515 removeFeature(vmNumber: any, index: any, templateId) {
516 if (this.referenceDataObject.action == "Configure") {
517 this.referenceDataObject.vm.splice(vmNumber, 1);
518 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
519 if (arrIndex >= vmNumber) {
520 obj["vm-instance"] = obj["vm-instance"] - 1
522 // obj["vm-instance"] = arrIndex+1
526 let data = this.referenceDataObject.vm.filter(obj => {
527 return obj['template-id'] == templateId;
530 let vmIndex = this.findVmindex(data, vmNumber, templateId)
531 this.referenceDataObject.vm.splice(vmIndex, 1);
533 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
534 if (obj['template-id'] == templateId) {
536 obj["vm-instance"] = index + 1
544 //utility function while adding VM to check index
545 findVmindex(data, vmNumber, templateId) {
546 return this.referenceDataObject.vm.findIndex(obj => {
547 let x = obj['vm-instance'] == (vmNumber + 1) && templateId == obj['template-id']//true
553 //add new VM's to the configure and configmodify.
557 let mberOFVm = Number(this.refernceScopeObj.from);
559 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
561 } else if (this.referenceDataObject.action == 'ConfigScaleOut') {
564 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
565 let existingVmsLength = this.referenceDataObject.vm.map(obj => {
566 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
567 return obj["vnfcType-id"] == this.templateIdentifier
568 } else if (this.referenceDataObject.action == 'ConfigScaleOut') {
569 return obj["template-id"] == this.templateIdentifier
572 //mberOFVm = existingVmsLength + mberOFVm;
575 if (this.referenceDataObject.action == 'ConfigScaleOut') {
576 identifierValue = this.templateIdentifier
577 } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
578 identifierValue = this.vnfcIdentifier
581 for (var i = 0; i < mberOFVm; i++) {
582 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
584 if (identifierValue && identifierValue != "") {
585 this.referenceDataObject.vm.push({ 'vnfcType-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
587 this.referenceDataObject.vm.push({ 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
590 } else if (this.referenceDataObject.action == 'ConfigScaleOut') {
591 if (identifierValue && identifierValue != "") {
592 this.referenceDataObject.vm.push({ 'template-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
601 let arrlength = this.referenceDataObject.vm.length;
602 mberOFVm = arrlength + mberOFVm;
603 for (var i = (arrlength); i < mberOFVm; i++) {
604 if (this.referenceDataObject.action == 'ConfigScaleOut') {
605 this.referenceDataObject.vm.push({ 'template-id': this.templateIdentifier, 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
607 this.referenceDataObject.vm.push({ 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
613 //preparing reference obj with required business use cases
614 prepareReferenceObject(isSaving?: any) {
615 let methName= "prepareReferenceObject";
616 if( this.utilityService.getTracelvl() > 0 )
617 console.log( this.classNm+": "+methName+": start: isSaving:["+
619 let scopeName = this.resetParamsOnVnfcType();
620 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
621 this.prepareArtifactList(scopeName, extension);
623 if (this.referenceDataObject.action === 'OpenStack Actions') {
624 this.referenceDataObject['template'] = 'N';
625 this.referenceDataObject['artifact-list'] = [];
626 this.referenceDataObject['firstRowVmSpreadSheet'] = this.firstArrayElement;
629 this.referenceDataObject['firstRowVmSpreadSheet']=undefined;
631 //ditaching the object from the form and processing pfurther
632 let newObj = $.extend(true, {}, this.referenceDataObject);
633 let action = this.referenceDataObject.action;
634 // if (action=="ConfigScaleOut"){
635 // this.referenceDataObject.action="true";
637 //preparing Obj for save/download
638 newObj = this.deleteVmsforNonActions(newObj, action)
640 if (newObj['device-protocol'] != 'REST') {
643 this.pushOrReplaceTempData(newObj, action);
644 this.addAllActionObj(newObj, scopeName);
650 //saving data to service
651 this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
652 this.buildDesignComponent.updateAccessUpdatePages(this.referenceDataObject.action, this.mappingEditorService.getReferenceList());
653 this.mappingEditorService.changeNav(this.tempAllData);
654 //on action change or template identifier change reset the form by restting values of Reference data object
655 this.resetVmsForScaleout(this.currentAction)
656 return { totlaRefDtaa: this.tempAllData, scopeName: scopeName };
659 // utility function to check element existence
660 public checkIfelementExistsInArray(element, array) {
661 var result: boolean = false;
663 array.forEach(function (item) {
664 if (element === item) {
671 // when uploading the file
673 /* wire up file reader */
674 const target: DataTransfer = <DataTransfer>(evt.target);
675 this.uploadFileName = evt.target.files[0].name;
676 var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
677 if (target.files.length != 1) {
678 throw new Error('Cannot upload multiple files on the entry');
680 if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') {
681 const reader = new FileReader();
682 reader.onload = (e: any) => {
684 const bstr = e.target.result;
685 const wb = XLSX.read(bstr, { type: 'binary' });
686 /* grab first sheet */
687 const wsname = wb.SheetNames[0];
688 const ws = wb.Sheets[wsname];
691 this.firstArrayElement = []
692 let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
693 this.uploadedDataArray = arrData;
694 for (var i = 0; i < arrData[0].length; i++) {
695 this.firstArrayElement.push(arrData[0][i].replace(/[\n\r]+/g, ''))
697 var remUploadedDataArray = arrData;
698 remUploadedDataArray.shift();
699 this.remUploadedDataArray = remUploadedDataArray;
700 if (arrData != null) {
701 this.getExcelUploadStatus = true;
702 this.nService.success('Success', 'Vm capabilities data uploaded successfully');
706 this.nService.success('Error', 'Empty Vm capabilities file uploaded');
709 reader.readAsBinaryString(target.files[0]);
712 this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
717 addVmCapabilitiesData() {
718 for (var i = 0; i < this.uploadedDataArray.length; i++) {
719 var vnfcFuncCodeArray = [];
720 var data = this.uploadedDataArray[i];
721 for (var j = 1; j < data.length; j++) {
722 if (data[j] != undefined) {
723 if (data[j].toUpperCase() === 'Y') {
724 vnfcFuncCodeArray.push(this.firstArrayElement[j]);
725 //vnfcFuncCodeArray.push({name:this.firstArrayElement[j]});
729 var action = this.uploadedDataArray[i][0];
730 if (action && action != undefined) {
733 'action-level': 'vm',
735 'vnf-type': this.referenceDataObject['scope']['vnf-type'], //need to confirm what should be this value
736 'vnfc-type-list': null
738 'vnfc-function-code-list': vnfcFuncCodeArray,
740 'device-protocol': 'OS'
743 this.tempAllData.push(json);
749 //download the templae pd and reference file with all the actions added.
750 save(form: any, isValid: boolean) {
751 // will show error message
752 this.showValidationErrors(this.referenceDataObject);
755 let referenceObject = this.prepareReferenceObject();
756 let removedKeysArray = []
757 this.tempAllData.forEach((data, index) => {
759 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
762 this.tempAllData = removedKeysArray;
763 /* var tempAllData = this.tempAllData;
764 tempAllData=this.removeParamFileNameBeforeSave(tempAllData)*/
766 //tempAllData["artifact_list"]=newArtifactList;
767 let theJSON = JSON.stringify({ 'reference_data': this.tempAllData }, null, '\t');
768 let uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(theJSON);
769 this.downloadData.reference = theJSON;
770 let referenceFileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
771 this.utilityService.downloadArtifactToPc(theJSON, 'json', referenceFileName, 100);
772 this.validateTempAllData();
773 var templateData = JSON.stringify(this.downloadData.template.templateData);
774 var templateFileName = this.downloadData.template.templateFileName;
775 if (templateFileName != null || templateFileName != '') {
776 var fileExtensionArr = templateFileName.split('.');
778 var nameValueFileName = this.downloadData.template.nameValueFileName;
779 let pdFileName = this.downloadData.pd.pdFileName;
780 var nameValueData = JSON.stringify(this.downloadData.template.nameValueData);
781 var pdData = this.downloadData.pd.pdData;
782 if (templateData != '{}' && templateData != null && templateData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.templateData, fileExtensionArr[1], templateFileName, 130);
783 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.nameValueData, 'json', nameValueFileName, 160);
784 if (pdData != '' && pdData != null && pdData != undefined) this.utilityService.downloadArtifactToPc(pdData, 'yaml', pdFileName, 180);
788 /* removeParamFileNameBeforeSave(tempAllData)
790 var newArtifactList = [];
792 for (var i = 0; i < tempAllData.length; i++) {
793 if (this.checkIfelementExistsInArray(tempAllData[i].action,this.actions)) {
794 var artifactList = tempAllData[i]["artifact-list"]
796 for (var j = 0; j < artifactList.length; j++) {
797 if (artifactList[j]["artifact-type"] != "param_values") {
798 element = artifactList[j];
799 newArtifactList.push(element);
802 tempAllData[i]["artifact-list"] = newArtifactList
803 newArtifactList = [];
809 // save the values to the cache, on action change without download
810 validateDataAndSaveToAppc( valid, form, event) {
811 let methName= "validateDataAndSaveToAppc";
812 if( this.utilityService.getTracelvl() > 0 )
813 console.log( this.classNm+": "+methName+": start: valid:["+valid+"]");
814 // will show error message
815 this.showValidationErrors(this.referenceDataObject);
816 if( this.utilityService.getTracelvl() > 0 )
817 console.log( this.classNm+": "+methName+": tempAllData:["+
818 JSON.stringify(this.tempAllData)+"]");
820 form._submitted = true;
822 let referenceObject = this.prepareReferenceObject(true);
823 let removedKeysArray = []
824 this.tempAllData.forEach((data, index) => {
826 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
829 this.tempAllData = removedKeysArray;
831 this.validateTempAllData();
833 if (this.actionChanged) {
835 if (this.currentAction) {
836 this.referenceDataObject.action = this.currentAction;
839 this.populateExistinAction(this.referenceDataObject.action);
840 this.actionChanged = false;
845 this.nService.warn('status', 'unable to save the artifact');
848 //this method saves reference, template, param and PD data to APPC
850 if( this.utilityService.getTracelvl() > 0 )
851 console.log( this.classNm+": saveToAppc: start: vnf-type:["+
852 this.referenceDataObject.scope['vnf-type']+"]");
853 let theJSON = JSON.stringify( this.tempAllData );
854 if( this.utilityService.getTracelvl() > 0 )
855 console.log( this.classNm+": saveToAppc: tempAllData:["+theJSON+"]");
856 let fileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
857 /*var tempAllData=this.removeParamFileNameBeforeSave(this.tempAllData);
858 this.tempAllData=tempAllData;*/
859 this.saveReferenceDataToAppc(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
861 var templateData = JSON.stringify(this.appData.template.templateData);
862 var nameValueData = JSON.stringify(this.appData.template.nameValueData);
863 var pdData = JSON.stringify(this.appData.pd);
864 if (templateData != '{}' && templateData != null && templateData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.templateData, 'template data');
865 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.nameValueData, 'name value pairs');
866 if (pdData != '{}' && pdData != null && pdData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.pd, 'PD file');
869 // valaidation of template data
870 validateTempAllData() {
871 if (this.tempAllData) {
872 var updatedData = [];
873 this.tempAllData.forEach(data => {
875 updatedData.push(data);
878 this.tempAllData = updatedData;
882 //preparig and send the data to the API.
883 saveReferenceDataToAppc(artifactData, dataJson, fileName) {
885 let slashedPayload = this.referenceDataFormUtil.appendSlashes(artifactData);
887 let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload);
888 this.ngProgress.start();
889 this.httpUtils.post({
890 url: environment.getDesigns,
892 }).subscribe((resp) => {
893 if (resp != null && resp.output.status.code == '400') {
894 window.scrollTo(0, 0);
895 this.nService.success('Status', 'successfully uploaded the Reference Data');
897 this.nService.warn('Status', 'Error while saving Reference Data');
899 this.uploadStatusError = false;
900 this.getRefStatus = false;
901 this.ngProgress.done();
903 this.nService.error('Status', 'Error Connecting to the APPC Network');
904 window.scrollTo(0, 0);
906 this.appData.reference = payload;
908 this.ngProgress.done();
911 // if no data present in the session, fetching data from API
913 if (sessionStorage.getItem('updateParams') != 'undefined') {
915 this.noCacheData = false;
917 this.noCacheData = true;
921 public showUpload() {
922 this.selectedUploadType = this.uploadTypes[0].value;
924 // used when user uploads a file using upload file
925 public fileChange(input) {
926 this.fileName = input.target.files[0].name.replace(/C:\\fakepath\\/i, '');
927 this.fileUploaded = true;
928 this.disableRetrieve = true;
929 if (input.target.files && input.target.files[0]) {
930 // Create the file reader
931 let reader = new FileReader();
932 this.readFile(input.target.files[0], reader, (result) => {
933 // After the callback fires do:
934 if ('Reference Data' === this.selectedUploadType) {
937 let jsonObject = (JSON.parse(result))['reference_data'];
938 this.uploadedData = JSON.parse(JSON.stringify(jsonObject));
939 //check for legacy artifact and do not allow it
940 for (let i = 0; i < this.uploadedData.length; i++) {
941 obj = this.uploadedData[i];
942 if (obj.scope['vnfc-type'] != undefined && obj.scope['vnfc-type'] != '') {
943 this.nService.error('Error', 'The legacy reference artifact not supported');
948 this.displayVnfc = 'false';
949 this.isVnfcType = false;
950 this.isVnfcTypeList = false;
951 for (let i = 0; i < this.uploadedData.length; i++) {
952 obj = this.uploadedData[i];
953 if (obj.scope['vnfc-type-list'] && obj.scope['vnfc-type-list'].length > 0) {
954 this.displayVnfc = 'true';
955 this.isVnfcTypeList = true;
956 this.vnfcIdentifier = obj.scope['vnfc-type-list'][0];
960 this.oldAction=obj.action;
961 this.tempAllData = JSON.parse(JSON.stringify(jsonObject));
962 //check vnfc tyoe list for old files
963 // if (this.referenceDataObject.scope['vnfc-type-list'] == undefined) {
964 // this.tempAllData = []
965 // this.referenceDataObject = {
967 // 'action-level': 'vnf',
968 // scope: { 'vnf-type': '', 'vnfc-type-list': [] },
971 // 'device-protocol': '',
973 // 'port-number': '',
974 // 'artifact-list': []
976 // this.nService.error('Error', 'Incorrect file format');
979 this.notificationService.notifySuccessMessage('Reference Data file successfully uploaded..');
980 this.highlightSelectedActions(jsonObject)
981 this.toggleIdentifier(this.referenceDataObject.action)
982 this.populateExistinAction(this.referenceDataObject.action)
983 this.configDrp(this.referenceDataObject.action)
986 this.processReferenceDataAfterRetrieval();
988 this.getArtifactsOpenStack();
989 if (this.referenceDataObject.template == null) {
990 this.referenceDataObject.template = 'Y';
992 if (this.referenceDataObject['action-level'] == null) {
993 this.referenceDataObject['action-level'] = 'VNF';
997 // Enable or Block Template and PD Tabs
998 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1000 this.nService.error('Error', 'Incorrect file format');
1003 this.hideModal = true;
1006 this.notificationService.notifyErrorMessage('Failed to read file..');
1011 // Highlights selected action on new file upload and on existing VNF
1012 public highlightSelectedActions(jsonObject) {
1013 if (jsonObject instanceof Array) {
1014 this.referenceDataObject = jsonObject[0];
1015 jsonObject.forEach(obj => {
1016 this.selectedActions.push(obj.action);
1019 this.referenceDataObject = jsonObject;
1021 this.selectedActions.push(jsonObject.action);
1025 public readFile(file, reader, callback) {
1026 // Set a callback funtion to fire after the file is fully loaded
1027 reader.onload = () => {
1028 // callback with the results
1029 callback(reader.result);
1031 this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size);
1033 reader.readAsText(file, 'UTF-8');
1036 fileChangeEvent(fileInput: any) {
1037 let obj: any = fileInput.target.files;
1039 //resetting the values
1042 'vnfc-instance': '1',
1043 'vnfc-function-code': '',
1044 'ipaddress-v4-oam-vip': '',
1045 'group-notation-type': '',
1046 'group-notation-value': ''
1050 setVmInstance(index) {
1051 this.referenceDataObject.vm[index]['vm-instance'] = index + 1;
1054 // setVnfcType(str: String) {
1055 // this.Sample['vnfc-type'] = str;
1058 // getChange(value: String) {
1059 // if (value === 'vnfType') {
1060 // this.referenceDataObject.scope['vnfc-type'] = '';
1063 // resetting the form
1065 console.log( this.classNm+": resetForm: start.");
1066 this.referenceDataObject['action-level'] = 'vnf';
1067 this.referenceDataObject.template = 'Y';
1068 this.referenceDataObject['device-protocol'] = '';
1069 this.referenceDataObject['user-name'] = '';
1070 this.referenceDataObject['port-number'] = '';
1071 this.refernceScopeObj.sourceType = '';
1072 this.Sample['vnfc-type'] = '';
1075 // this method gets called with the action as parameter and the respective action details are fetched and assigned to the current page
1076 populateExistinAction(data) {
1077 let methName= "populateExistinAction";
1078 if( this.utilityService.getTracelvl() > 0 )
1079 console.log( this.classNm+": "+methName+": start: data:["+data+"]");
1080 if( this.utilityService.getTracelvl() > 0 )
1081 console.log( this.classNm+": "+methName+": tempAllData:["+
1082 JSON.stringify(this.tempAllData)+"]");
1083 let existAction = this.tempAllData.findIndex(obj => {
1084 return obj.action == data;
1086 if (existAction > -1) {
1087 let obj = $.extend(true, {}, this.tempAllData[existAction]);
1088 this.referenceDataObject = obj;
1089 this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type'];
1090 this.referenceDataObject.scope['vnfc-type-list'] = obj['scope']['vnfc-type-list'];
1091 this.referenceDataObject['device-protocol'] = obj['device-protocol'];
1092 this.refernceScopeObj['sourceType'] = obj['scopeType'];
1093 if(obj['scope']['vnfc-type-list'] != undefined && obj['scope']['vnfc-type-list'].length >0) {
1094 this.referenceDataObject['vnfcIdentifier'] = obj['scope']['vnfc-type-list'][0];
1097 console.log( this.classNm+": populateExistinAction: action not found");
1099 this.referenceDataObject.action = data;
1101 //# iof healthCeck change deviceprotocol drp vaues
1104 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST'];
1105 this.actionHealthCheck = true;
1107 case 'UpgradeBackout':
1108 case 'ResumeTraffic':
1109 case 'DistributeTraffic':
1110 case 'QuiesceTraffic':
1111 case 'UpgradeBackup':
1112 case 'UpgradePostCheck':
1113 case 'UpgradePreCheck':
1114 case 'UpgradeSoftware':
1115 case 'ConfigRestore':
1116 case 'StartApplication':
1117 case 'StopApplication':
1118 case 'ConfigBackup':
1119 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE'];
1121 case 'OpenStack Actions':
1122 this.deviceProtocols = ['', 'OpenStack'];
1124 case 'ConfigScaleOut':
1125 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1127 case 'GetRunningConfig':
1128 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF', 'CLI', 'REST'];
1131 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
1132 this.actionHealthCheck = false;
1136 //Modal pop up for action change with values entered.
1137 actionChange( data, userForm) {
1138 let methName= "actionChange";
1139 if( this.utilityService.getTracelvl() > 0 )
1140 console.log( this.classNm+": "+methName+": start: data:["+data+"]"+
1141 " userForm.valid:["+userForm.valid+"]");
1142 if( this.utilityService.getTracelvl() > 0 )
1143 console.log( this.classNm+": "+methName+": tempAllData:["+
1144 JSON.stringify(this.tempAllData)+"]");
1145 this.disableGrpNotationValue = false
1147 console.log( this.classNm+": "+methName+": data == null");
1150 if((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
1151 this.actionChanged = true;
1152 if( this.utilityService.getTracelvl() > 0 )
1153 console.log( this.classNm+": "+methName+
1154 ": userForm valid and oldAction defined");
1155 // Calling common Confirmation Modal
1156 let disposable = this.dialogService.addDialog(ConfirmComponent)
1157 .subscribe((isConfirmed)=>{
1158 //We get dialog result
1160 // User clicked on Yes
1161 this.currentAction = this.referenceDataObject.action;
1162 this.referenceDataObject.action = this.oldAction;
1163 $('#saveToAppc').click();//make sure the save all is done before the tempall obj is saved form the API
1164 this.toggleIdentifier(data)
1165 this.oldAction = this.currentAction;// this.referenceDataObject.action + '';
1166 this.referenceDataObject.action = this.currentAction
1168 this.populateExistinAction(data);
1169 if (this.oldAction === 'OpenStack Actions') {
1171 this.uploadedDataArray = [];
1172 this.remUploadedDataArray = [];
1173 this.firstArrayElement = [];
1174 this.uploadFileName = '';
1175 //this.tempAllData = [];
1178 this.refernceScopeObj.from = '';
1179 this.getArtifactsOpenStack();
1181 // Clears VNFC Information data on action change
1182 this.clearVnfcData()
1183 this.resetVmsForScaleout(data);
1186 // User clicked on No
1187 this.toggleIdentifier(data)
1188 this.currentAction = this.referenceDataObject.action;
1189 this.populateExistinAction(data);
1190 this.resetVmsForScaleout(data);
1191 this.oldAction = this.referenceDataObject.action + '';
1193 this.clearVnfcData()
1194 this.refernceScopeObj.from = '';
1197 if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic') {
1198 this.isConfigOrConfigModify = true;
1200 this.isConfigOrConfigModify = false;
1201 delete this.mappingEditorService.newObject['vnfc'];
1204 // Enable or Block Template and PD Tabs
1205 if (this.currentAction == 'ConfigScaleOut' && this.templateIdentifier && this.templateIdentifier != '') {
1206 // let referenceDataObjectTemp = this.referenceDataObject;
1207 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1208 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1209 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1212 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1216 console.log( this.classNm+": "+methName+
1217 ": userForm Not valid or oldAction not defined");
1218 this.actionChanged = true;
1219 this.currentAction = this.referenceDataObject.action;
1220 this.oldAction = this.referenceDataObject.action + '';
1221 this.populateExistinAction(data);
1222 this.resetVmsForScaleout(data);
1223 this.toggleIdentifier(data);
1225 // Enable or Block Template and PD Tabs
1226 if(this.currentAction == 'ConfigScaleOut' && this.templateIdentifier) {
1227 // let referenceDataObjectTemp = this.referenceDataObject;
1228 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1229 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1230 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1232 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1235 if( this.utilityService.getTracelvl() > 0 )
1236 console.log( this.classNm+": "+methName+": tempAllData:["+
1237 JSON.stringify(this.tempAllData)+"]");
1238 this.configDrp(data)
1242 console.log( this.classNm+": configDrp: start: data:["+data+"]");
1243 if (data == 'ConfigScaleOut') {
1244 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
1246 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
1248 if (data == 'OpenStack Actions') {
1249 this.buildDesignComponent.tabs = this.referencDataTab;
1252 this.buildDesignComponent.tabs = this.allTabs;
1254 if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic') {
1255 this.nonConfigureAction = false;
1257 this.nonConfigureAction = true;
1260 // removing and adding the url key based on the protocol selected
1261 deviceProtocolChange() {
1262 let methName= "deviceProtocolChange";
1263 if( this.utilityService.getTracelvl() > 0 )
1264 console.log( this.classNm+": "+methName+": start.");
1265 if (this.referenceDataObject['device-protocol'] == 'REST') {
1268 delete this.referenceDataObject['context-url']
1270 // Enable or Block Template and PD Tabs
1271 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, {reqField: this.templateIdentifier})
1272 if( this.utilityService.getTracelvl() > 0 )
1273 console.log( this.classNm+": "+methName+": tempAllData:["+
1274 JSON.stringify(this.tempAllData)+"]");
1277 // used to call or trigger save object on template Identifier changes
1278 idChange(data, userForm) {
1279 if( this.utilityService.getTracelvl() > 0 )
1280 console.log( this.classNm+": idChange: start: data:["+data+"]");
1285 // Enable or Block Template and PD Tabs
1286 // let referenceDataObjectTemp = this.referenceDataObject;
1287 // referenceDataObjectTemp['template-id'] = data;
1288 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1289 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1291 if ((userForm.valid)) {
1292 this.currentAction = "ConfigScaleOut"
1293 this.oldtemplateIdentifier = this.templateIdentifier
1294 let referenceObject = this.prepareReferenceObject();
1295 this.actionChanged = true;
1296 if (this.templateIdentifier) {
1297 // Calling common Confirmation Modal
1298 let disposable = this.dialogService.addDialog(ConfirmComponent)
1299 .subscribe((isConfirmed)=>{
1300 //We get dialog result
1302 // User clicked on Yes
1303 this.validateTempAllData();
1306 this.clearVnfcData();
1307 this.refernceScopeObj.from = '';
1310 // User clicked on No
1312 this.refernceScopeObj.from = '';
1317 this.oldtemplateIdentifier = this.templateIdentifier
1320 // if (this.referenceDataObject.action == 'ConfigScaleOut' && data ) {
1321 // let referenceDataObjectTemp = this.referenceDataObject;
1322 // referenceDataObjectTemp['selectedTemplateId'] = data;
1323 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1325 // this.buildDesignComponent.getRefData(this.referenceDataObject);
1329 // used to call or trigger save object on multiple VNFC's changes
1330 vnfcChanged( data, userForm) {
1331 if( this.utilityService.getTracelvl() > 0 )
1332 console.log( this.classNm+": vnfcChanged: new vnfcIdentifier:["+data+"]");
1333 if( this.utilityService.getTracelvl() > 1 )
1334 console.log( this.classNm+": vnfcChanged: oldVnfcIdentifier:["+
1335 this.oldVnfcIdentifier+"]");
1336 if( this.utilityService.getTracelvl() > 0 )
1337 console.log(this.classNm+": vnfcChanged: scope.vnfc-type:["+
1338 this.referenceDataObject.scope['vnfc-type']+"]");
1339 this.vnfcIdentifier = data;
1340 //this.clearCache();
1345 // Enable or Block Template and PD Tabs
1346 let referenceDataObjectTemp = this.referenceDataObject;
1347 referenceDataObjectTemp['vnfcIdentifier'] = data;
1348 if( this.utilityService.getTracelvl() > 0 )
1349 console.log( this.classNm+
1350 ": vnfcChanged: displayVnfc:["+this.displayVnfc+"]");
1351 //this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1352 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1355 console.log( this.classNm+
1356 ": vnfcChanged: userForm.valid:["+userForm.valid+"]");
1357 if ((userForm.valid) && this.oldVnfcIdentifier != '' && this.oldVnfcIdentifier != undefined) {
1358 this.currentAction = this.referenceDataObject.action
1359 this.oldVnfcIdentifier = this.vnfcIdentifier
1360 let referenceObject = this.prepareReferenceObject();
1361 this.actionChanged = true;
1362 if (this.vnfcIdentifier) {
1363 // Calling common Confirmation Modal
1364 let disposable = this.dialogService.addDialog(ConfirmComponent)
1365 .subscribe((isConfirmed)=>{
1366 //We get dialog result
1368 // User clicked on Yes
1369 this.validateTempAllData();
1372 this.clearVnfcData()
1373 this.refernceScopeObj.from = '';
1374 //.. populate VNFC Type in Sample field
1375 this.setVnfcTypeInSample( this.vnfcIdentifier );
1378 // User clicked on No
1380 this.clearVnfcData()
1381 this.refernceScopeObj.from = '';
1382 //.. populate VNFC Type in Sample field
1383 this.setVnfcTypeInSample( this.vnfcIdentifier );
1389 this.oldVnfcIdentifier = this.vnfcIdentifier
1395 //needed for the the clearing template cache.
1397 // get the value and save the userid and persist it.
1398 this.clearTemplateCache();
1399 this.clearPdCache();
1400 this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
1401 this.downloadData = {
1403 template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
1404 pd: { pdData: '', pdFileName: '' }
1408 clearTemplateCache() {
1409 this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
1410 localStorage['paramsContent'] = '{}';
1413 this.mappingEditorService.setParamContent(undefined);
1414 this.paramShareService.setSessionParamData(undefined);
1418 $('#inputFile').trigger('click');
1421 excelBrowseOption() {
1422 $('#excelInputFile').trigger('click');
1425 /* showIdentifier() {
1426 $('#identifierModal').modal();
1430 $('#vnfcModal').modal();
1434 if (!(this.referenceDataObject['template-id-list'])) {
1435 this.referenceDataObject['template-id-list'] = [];
1437 if (!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim()) > -1)) {
1438 this.referenceDataObject['template-id-list'].push(this.templateId.trim());
1441 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1442 this.templateId = ''
1444 // adds the vnfc to the vnfc dropdown list
1446 var newVnfcTypeV= this.newVnfcType.trim();
1447 if( this.utilityService.getTracelvl() > 0 )
1448 console.log(this.classNm+
1449 ": addVnfc: start: newVnfcTypeV:["+newVnfcTypeV+"]");
1450 if (!(this.referenceDataObject.scope['vnfc-type-list'])) {
1451 this.referenceDataObject.scope['vnfc-type-list'] = [];
1452 this.vnfcIdentifier = newVnfcTypeV;
1454 this.vnfcIdentifier = newVnfcTypeV;
1456 //this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
1457 if (!(this.referenceDataObject.scope['vnfc-type-list'].indexOf(newVnfcTypeV) > -1)) {
1458 this.referenceDataObject.scope['vnfc-type-list'].push(newVnfcTypeV);
1460 this.tempAllData.forEach(obj => {
1461 if (obj.action == "Configure" || obj.action == "ConfigModify" || obj.action == "DistributeTraffic") {
1462 obj.scope['vnfc-type-list'] = this.referenceDataObject.scope['vnfc-type-list']
1464 this.resetArtifactList(obj);
1466 //this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1467 this.setVnfcTypeInSample( newVnfcTypeV );
1468 let userForm = {valid: true};
1469 this.vnfcChanged(this.newVnfcType, userForm)
1470 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1471 this.newVnfcType = ''
1475 this.referenceDataObject.vm = [];
1479 // this.referenceDataObject.vm = this.referenceDataObject.vm;
1481 // used to show and hide the group notation value in VNFC information
1482 resetGroupNotation() {
1483 if (this.Sample['group-notation-type'] == "existing-group-name") {
1484 this.Sample['group-notation-value'] = ""
1485 this.disableGrpNotationValue = true
1487 this.disableGrpNotationValue = false
1491 resetVmsForScaleout(action) {
1492 //reset currentform vms based on action
1493 if (action == "ConfigScaleOut" || action == "Configure") {
1494 let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
1495 return obj['action'] == action
1497 if (ConfigScaleOutIndex > -1) {
1498 this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
1500 if (this.actionChanged) {
1501 this.referenceDataObject.vm = []
1507 resetParamsOnVnfcType() {
1509 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list']
1510 let vnfcType = this.referenceDataObject.scope['vnfc-type']
1511 let vnfType = this.referenceDataObject.scope['vnf-type'];
1512 //called only if only vnf is there
1513 if ((this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) && (this.referenceDataFormUtil.nullCheckForVnfcType(vnfcType))
1515 scopeName = vnfType;
1516 this.referenceDataObject.scope['vnfc-type'] = '';
1517 this.referenceDataObject['action-level'] = 'vnf';
1518 this.referenceDataObject['scopeType'] = 'vnf-type';
1519 scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1521 //if VNFC is entered set action level & Scope type to VNFC for configure and configure modify, and default the values to vnf and vnf type for all other actions
1523 if (this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) {
1524 scopeName = vnfcType ? vnfcType : "";
1526 // scopeName = this.referenceDataObject.scope['vnfc-type-list'];
1529 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
1530 this.referenceDataObject['action-level'] = 'vnf';
1531 this.referenceDataObject['scopeType'] = 'vnfc-type';
1533 this.referenceDataObject['action-level'] = 'vnf';
1534 this.referenceDataObject['scopeType'] = 'vnf-type';
1537 this.referenceDataObject.scope['vnfc-type'] = this.referenceDataObject.scope['vnfc-type'] ? this.referenceDataObject.scope['vnfc-type'] : "";
1541 //used to form the structure of the reference file
1542 prepareArtifactList(scopeName, extension) {
1543 this.referenceDataObject['artifact-list'] = [];
1547 let vnf = this.referenceDataObject.scope['vnf-type']
1548 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
1549 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list'];
1551 let config_template_fileName
1554 if (vnfcTypeList && vnfcTypeList.length > 0) {
1557 for (var x = 0; x < vnfcTypeList.length; x++) {
1558 //for replacing spaces and "/" with "_"
1559 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1560 pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.yaml')
1561 config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, extension)
1562 param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.json')
1563 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1564 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1565 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1567 this.referenceDataObject['artifact-list'].push(configTemplate,
1568 pdTemplate, paramValue
1571 } else if (scopeName) {
1572 pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
1573 config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V' + extension;
1574 param_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
1575 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1576 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1577 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1578 this.referenceDataObject['artifact-list'].push(configTemplate,
1579 pdTemplate, paramValue
1585 //preparing the artifact list array file names along with extension
1586 let config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', extension);
1587 let pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.yaml');
1588 let reference_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1589 let param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1590 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1591 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1592 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1593 if (this.referenceDataObject.action != 'ConfigScaleOut') {
1595 this.referenceDataObject['artifact-list'].push(configTemplate,
1596 pdTemplate, paramValue
1601 let identifiers = this.referenceDataObject['template-id-list'];
1603 for (var x = 0; x < identifiers.length; x++) {
1604 //for replacing spaces and "/" with "_"
1605 let type = identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1606 pd_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.yaml');
1607 config_template_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, extension);
1608 param_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.json');
1609 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1610 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1611 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1613 this.referenceDataObject['artifact-list'].push(configTemplate,
1614 pdTemplate, paramValue
1622 // used to remove the added vms for actions other than configure & scaleout
1623 deleteVmsforNonActions(newObj, action) {
1624 let configureObject = (action == 'Configure');
1625 let ConfigScaleOut = (action == 'ConfigScaleOut');
1626 //delete VM's if selected action is not configure.
1627 if (!ConfigScaleOut && !configureObject && this.tempAllData.length != 0) {
1628 if (ConfigScaleOut) {
1633 if (ConfigScaleOut) {
1635 delete newObj['template-id-list'];
1640 // used to replace the data in tempall obj and form the artifact names
1641 pushOrReplaceTempData(newObj, action) {
1645 if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic") {
1646 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
1647 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.yaml';
1648 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V' + extension;
1649 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.json';
1650 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1651 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1652 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1654 if (newObj.scope['vnfc-type']) {
1655 idValue = newObj.scope['vnfc-type']
1656 } else if (this.vnfcIdentifier) {
1657 idValue = this.vnfcIdentifier
1660 let arr = [configTemplate, pdTemplate, paramValue]
1661 this.mappingEditorService.selectedObj({
1662 action: newObj.action,
1663 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1665 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1666 param_artifact: paramValue['param_artifact'],
1667 pd_artifact: pdTemplate['pd_artifact'],
1668 template_artifact: configTemplate['template_artifact']
1670 } else if (newObj.action == "ConfigScaleOut") {
1671 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1672 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_0.0.1V' + '_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '')) : "") + ".yaml";
1673 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + extension;
1674 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + '.json';
1675 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1676 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1677 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1678 let arr = [configTemplate, pdTemplate, paramValue]
1679 this.mappingEditorService.selectedObj({
1680 action: newObj.action,
1681 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1682 //vnfc: newObj['vnfcIdentifier'] ? newObj['vnfcIdentifier'] : "",
1683 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1684 templateId: this.templateIdentifier,
1685 param_artifact: paramValue['param_artifact'],
1686 pd_artifact: pdTemplate['pd_artifact'],
1687 template_artifact: configTemplate['template_artifact']
1691 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1692 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.yaml';
1693 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V' + extension;
1694 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
1695 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1696 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1697 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1698 let arr = [configTemplate, pdTemplate, paramValue]
1699 this.mappingEditorService.selectedObj({
1700 action: newObj.action,
1701 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1702 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1703 param_artifact: paramValue['param_artifact'],
1704 pd_artifact: pdTemplate['pd_artifact'],
1705 template_artifact: configTemplate['template_artifact']
1709 let actionObjIndex = this.tempAllData.findIndex(obj => {
1710 return obj['action'] == action;
1712 if (actionObjIndex > -1) {
1713 this.tempAllData[actionObjIndex] = newObj;
1714 this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
1715 if (newObj.action == "ConfigScaleOut") {
1716 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1719 this.templateIdentifier = ('')
1720 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1723 if (newObj.action != '') {
1725 this.tempAllData.push(newObj);
1726 this.mappingEditorService.saveLatestAction(newObj);
1728 if (newObj.action == "ConfigScaleOut") {
1729 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1732 this.templateIdentifier = ('')
1733 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1738 // removes the unwanted keys added in the artifact for vnfc level actions
1739 deleteUnwantedKeys(newObj) {
1740 newObj = JSON.parse(JSON.stringify(newObj))
1741 delete newObj['template-id']
1742 delete newObj['vnfcIdentifier']
1743 if (newObj.action != "ConfigScaleOut") {
1744 delete newObj['template-id-list']
1746 if (newObj.action != 'HealthCheck') {
1747 delete newObj['url'];
1749 if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action == "DistributeTraffic") {
1750 newObj.scope['vnfc-type-list'] = [];
1755 addAllActionObj(newObj, scopeName) {
1757 //Creating all action block to allow mulitple actions at once
1759 action: 'AllAction',
1760 'action-level': 'vnf',
1761 scope: newObj.scope,
1764 let vnfType = this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1766 allAction['artifact-list'].push({
1767 'artifact-name': 'reference_AllAction' + '_' + vnfType + '_' + '0.0.1V.json',
1768 'artifact-type': 'reference_template'
1771 let allActionIndex = this.tempAllData.findIndex(obj => {
1772 return obj['action'] == 'AllAction';
1774 if (allActionIndex > -1) {
1775 this.tempAllData[allActionIndex] = allAction;
1777 this.tempAllData.push(allAction);
1782 let methName= "resetTempData";
1783 if( this.utilityService.getTracelvl() > 0 )
1784 console.log( this.classNm+": "+methName+": start.");
1785 if( this.utilityService.getTracelvl() > 0 )
1786 console.log( this.classNm+": "+methName+": tempAllData:["+
1787 JSON.stringify(this.tempAllData)+"]");
1788 if (this.utilityService.checkNotNull(this.uploadedDataArray)) {
1790 if (this.utilityService.checkNotNull(this.tempAllData)) {
1791 for (var i = 0; i < this.tempAllData.length; i++) {
1794 if (this.tempAllData[i].action === 'AllAction') {
1798 result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
1801 this.tempAllData.splice(i, 1);
1807 this.addVmCapabilitiesData();
1811 trackByFn(index, item) {
1812 return index; // or item.id
1814 getArtifactsOpenStack() {
1816 var vnfcFunctionCodeArrayList = [];
1817 var vnfcSetArray = [];
1818 // var vnfcSet = new Set();
1819 for (var i = 0; i < this.tempAllData.length; i++) {
1820 if (!this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions) && (this.tempAllData[i].action != 'AllAction')) {
1821 var vnfcFunctionCodeArray = this.tempAllData[i]["vnfc-function-code-list"]
1822 // vnfcSet.add("Actions")
1823 /* for (var j = 0; j < vnfcFunctionCodeArray.length; j++) {
1824 vnfcSet.add(vnfcFunctionCodeArray[j])
1826 vnfcFunctionCodeArrayList.push([this.tempAllData[i].action].concat(this.tempAllData[i]["vnfc-function-code-list"]))
1828 if (this.tempAllData[i].action === 'OpenStack Actions') {
1829 vnfcSetArray = this.tempAllData[i]['firstRowVmSpreadSheet']
1834 let vnfcSetArrayLen = vnfcSetArray.length;
1836 for (let i = 0; i < vnfcFunctionCodeArrayList.length; i++) {
1837 let element = vnfcFunctionCodeArrayList[i];
1838 for (let j = 1; j < element.length; j++) {
1839 for (let k = j; k < vnfcSetArrayLen; k++) {
1840 if (element[j] === vnfcSetArray[k]) {
1844 element.splice(j, 0, '');
1850 this.firstArrayElement = vnfcSetArray;
1851 this.remUploadedDataArray = vnfcFunctionCodeArrayList;
1855 // Common method to show validation errors
1856 private showValidationErrors(referenceDataObject) {
1857 if (this.referenceDataObject.action === '') {
1858 this.nService.error('Error', 'Select a valid Action');
1861 if (this.referenceDataObject['device-protocol'] === '') {
1862 this.nService.error('Error', 'Select a valid Device protocol');
1866 if (referenceDataObject.action === 'ConfigScaleOut' && !this.templateIdentifier) {
1867 this.nService.error('Error', 'Select a valid Template Identifier');
1870 // if ((referenceDataObject.action === 'Configure' || referenceDataObject.action === 'ConfigModify') && !this.vnfcIdentifier && this.displayVnfc != 'false') {
1871 // this.nService.error('Error', 'Select a valid Vnfc Type');
1876 resetArtifactList(obj) {
1877 if( this.utilityService.getTracelvl() > 0 )
1878 console.log( this.classNm+": resetArtifactList: start...");
1879 let vnfcTypeList = obj.scope['vnfc-type-list'];
1880 let vnf = this.referenceDataObject.scope['vnf-type']
1882 let config_template_fileName
1887 obj['artifact-list'] = [];
1888 for (var x = 0; x < vnfcTypeList.length; x++) {
1889 let extension = this.referenceDataFormUtil.decideExtension(obj)
1890 //for replacing spaces and "/" with "_"
1891 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1892 pd_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.yaml';
1893 config_template_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V' + extension;
1894 param_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.json';
1896 'artifact-name': 'template_' + config_template_fileName,
1897 'artifact-type': 'config_template'
1900 'artifact-name': 'pd_' + pd_fileName,
1901 'artifact-type': 'parameter_definitions'
1904 'artifact-name': 'param_' + param_fileName,
1905 'artifact-type': 'param_values'
1908 this.referenceDataObject['artifact-list'].push(configTemplate,
1909 pdTemplate, paramValue
1911 obj['artifact-list'].push(configTemplate,
1912 pdTemplate, paramValue
1918 * Handles the display of VM block based on the action change
1920 handleVMBlockDisplay() {
1921 switch (this.referenceDataObject.action) {
1922 case this.actionList.ConfigScaleOut:
1923 case this.actionList.Configure:
1926 this.displayVMBlock = true;
1929 this.displayVMBlock = false;
1933 //.. check VNFC Type equality in Upper Selection vs entered in Sample field
1934 checkVnfcTypeEqual( vnfctp: string ) {
1935 var methName= "checkVnfcTypeEqual";
1936 if( this.utilityService.getTracelvl() > 0 )
1937 console.log(this.classNm+": "+methName+": vnfctp:["+vnfctp+"]");
1938 if( this.utilityService.getTracelvl() > 0 )
1939 console.log( this.classNm+": "+methName+": vnfcIdentifier:["+
1940 this.vnfcIdentifier+"]");
1941 if( this.utilityService.getTracelvl() > 1 )
1942 console.log( this.classNm+": "+methName+": Sample[vnfc-type]:["+
1943 this.Sample['vnfc-type']+"]");
1944 if( vnfctp != null && vnfctp.length > 0 ) {
1945 if( this.vnfcIdentifier != null && this.vnfcIdentifier.length > 0 ) {
1947 this.classNm+": "+methName+": compare non empty VNFC Types...");
1948 if( vnfctp != this.vnfcIdentifier ) {
1949 if( this.utilityService.getTracelvl() > 0 )
1950 console.log( this.classNm+": "+methName+": Non-match WARNING !");
1951 //.. display in pop-up
1952 this.nService.warn( 'WARNING',
1953 "The specified VNFC Types don't match."+
1954 " Can cause discrepancy in the artifacts.", this.options );
1956 if( this.utilityService.getTracelvl() > 0 )
1957 console.log(this.classNm+": checkVnfcTypeEqual: VNFC Types're equal.");
1963 //.. populating VNFC Type in Sample fields
1964 setVnfcTypeInSample( vnfctp: string ) {
1965 //clear vnfc information samples
1966 this.clearVnfcData();
1968 if( this.utilityService.getTracelvl() > 0 )
1969 console.log( this.classNm+": setVnfcTypeInSample: vnfctp:["+vnfctp+"]");
1970 this.Sample['vnfc-type']= vnfctp;
1974 * Procesess reference data after retrieval from appc or after a reference file has been uploaded from PC.
1976 processReferenceDataAfterRetrieval() {
1977 if( this.utilityService.getTracelvl() > 0 )
1978 console.log( this.classNm+": processReferenceDataAfterRetr: start...");
1979 if (this.referenceDataObject.action === 'OpenStack Actions') {
1980 this.deviceProtocols = ['', 'OpenStack'];
1981 this.buildDesignComponent.tabs = this.referencDataTab;
1983 this.buildDesignComponent.tabs = this.allTabs;
1985 if( this.utilityService.getTracelvl() > 1 )
1986 console.log( this.classNm+": processReferenceDataAfterRetr: done.");
1987 if( this.utilityService.getTracelvl() > 0 )
1988 console.log( this.classNm+": vnfcIdentifier:["+this.vnfcIdentifier+"]");
1989 if( this.utilityService.getTracelvl() > 1 )
1990 console.log( this.classNm+": oldVnfcIdentifier:["+
1991 this.oldVnfcIdentifier+"]");
1992 if( this.utilityService.getTracelvl() > 0 )
1993 console.log( this.classNm+": refDataObj.scope.vnfc-type:["+
1994 this.referenceDataObject.scope['vnfc-type']+"]");
1995 this.setVnfcTypeInSample( this.vnfcIdentifier );