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 = ['', // using comma as prefix hereafter for easy reordering
138 , 'DistributeTraffic'
139 , 'DistributeTrafficCheck'
143 , 'LicenseManagement'
170 , 'OpenStack Actions'
171 ]; //.. manual ordering
172 public groupAnotationValue = ['', 'Pair'];
173 public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
174 public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
175 public deviceTemplates = ['', 'Y', 'N'];
176 public sourceTypeColl = ['', 'vnfType', 'vnfcType'];
177 public ipAddressBoolean = ['', 'Y', 'N'];
178 public Sample: any = {
179 'vnfc-instance': '1',
180 'vnfc-function-code': '',
181 'ipaddress-v4-oam-vip': '',
182 'group-notation-type': '',
183 'group-notation-value': ''
185 hideModal: boolean = false;
187 public uploadTypes = [{
188 value: 'Reference Data',
189 display: 'Sample Json Param File'
192 value: 'Mapping Data',
193 display: 'Sample Json Param File'
196 public selectedUploadType: string = this.uploadTypes[0].value;
197 public vnfcTypeData: string = '';
198 public title: string;
199 public allowAction: boolean = true;
200 public actionExist: boolean = false;
201 public disableVnftype: boolean = false;
202 public otherActions: boolean = false;
203 public actionHealthCheck: boolean = false;
204 public actionChanged: boolean = false;
205 public initialAction: string = '';
206 public noCacheData: boolean;
207 public updateParams: any;
208 public vnfParams: any;
209 public firstArrayElement = [];
210 public remUploadedDataArray = [];
211 isConfigScaleOut = false
212 isConfigScaleIn = false
213 isConfigOrConfigModify = false
214 displayVnfc = 'false';
216 isVnfcTypeList: boolean = true;
217 public referencDataTab = [
220 name: 'Reference Data',
225 name: 'Reference Data',
229 url: 'templates/myTemplates',
231 name: 'Parameter Definition',
232 url: 'parameterDefinitions/create'
238 public actionList = require('../../../../cdt.application.properties.json').Actions;
240 public versionNoForApiCall = require('../../../../cdt.application.properties.json').versionNoForApiCall;
241 private displayVMBlock: boolean = true;
244 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,
245 private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService, private ngProgress: NgProgress,
246 private dialogService: DialogService)
248 console.log(this.classNm+
249 ": new: start: tracelvl="+this.utilityService.getTracelvl() );
253 let methName= "ngOnInit";
254 if( this.utilityService.getTracelvl() > 0 )
255 console.log( this.classNm+": "+methName+": start ");
256 // this.handleVMBlockDisplay();
257 if( this.utilityService.getTracelvl() > 0 ) {
258 console.log( this.classNm+": "+methName+
259 ": actions: count="+this.actions.length );
260 for( var i0=0; i0 < this.actions.length; i0++ ) {
261 console.log( this.classNm+": "+methName+
262 ": action #"+i0+" ["+this.actions[i0]+"]");
266 let path = this.location.path;
267 this.title = 'Reference Data';
268 this.displayVnfc = sessionStorage.getItem("vnfcSelectionFlag");
269 this.vnfcIdentifier= ' ';
270 if( this.utilityService.getTracelvl() > 0 )
271 console.log( this.classNm+": "+methName+
272 ": from storage: displayVnfc:["+this.displayVnfc+"]");
273 //.. setting the structure for the reference data object
274 this.referenceDataObject = {
276 'action-level': 'vnf',
277 scope: { 'vnf-type': '', 'vnfc-type-list': [] },
280 'device-protocol': '',
285 //getting the data from session data, calling get Artifact if the data is undefined
286 this.updateParams = sessionStorage.getItem('updateParams');
287 //getting the data from the referencenameobjects if the nav is changed and assiging it to the cace data
288 let cacheData = this.mappingEditorService.referenceNameObjects;
290 if (this.utilityService.checkNotNull(cacheData)) {
291 //if cache data exists then assiging the data to the latest temp all data object.
292 if( this.utilityService.getTracelvl() > 0 )
293 console.log( this.classNm+": ngOnInit: have cacheData.");
294 this.tempAllData = cacheData;
295 //calling the highligted method to highlight the selected actions in the action dropdown
296 this.highlightSelectedActions(this.tempAllData)
297 // 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
298 if (this.mappingEditorService.latestAction != undefined) {
299 //adding the latest action to the screen
300 this.referenceDataObject = this.mappingEditorService.latestAction;
301 this.toggleIdentifier(this.referenceDataObject.action);
302 //this.referenceDataObject['template-id-list'] = this.mappingEditorService.identifier
303 //use these commented objects to be used in template and pd pages
304 //this.templateIdentifier = this.mappingEditorService.identifier
305 //adding the scope from referencedata obj to referencescopeobject
306 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
307 //assigning the latest action fetched to the old action from reference data object
308 this.oldAction = this.referenceDataObject.action;
309 //this method is called with the action reterived and subsequent values are assigned to refdataobj for displaying
310 this.populateExistinAction(this.referenceDataObject.action);
311 this.displayHideVnfc();
313 } else if (this.updateParams != 'undefined') {
314 //calls the get artifact() to reterive the values if cache data is not present
317 //getting the appdata & downloadDataObject from mapping editor service and assiging it.
318 var appData = this.mappingEditorService.appDataObject;
319 if (appData != null || appData != undefined) this.appData = appData;
320 var downloadData = this.mappingEditorService.downloadDataObject;
321 if (downloadData != null || downloadData != undefined) this.downloadData = downloadData;
323 if (sessionStorage.getItem('vnfParams')) {
324 this.vnfParams = JSON.parse(sessionStorage.getItem('vnfParams'));
326 if (this.vnfParams && this.vnfParams.vnfType) {
327 if( this.utilityService.getTracelvl() > 0 )
328 console.log( this.classNm+": "+methName+": vnfParams.vnfType:["+
329 this.vnfParams.vnfType+"]");
330 this.referenceDataObject['scope']['vnf-type'] = this.vnfParams.vnfType;
332 if (this.vnfParams && this.vnfParams.vnfcType) {
333 if( this.utilityService.getTracelvl() > 0 )
334 console.log( this.classNm+": "+methName+": vnfParams.vnfcType:["+
335 this.vnfParams.vnfcType+"]");
336 this.referenceDataObject['scope']['vnfc-type'] = this.vnfParams.vnfcType;
338 this.uploadedDataArray = [];
339 this.remUploadedDataArray = [];
340 this.firstArrayElement = [];
341 this.uploadFileName = '';
342 this.templateIdentifier = this.mappingEditorService.identifier
343 // if (this.mappingEditorService.newObject) {
344 // this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
347 // this.vnfcIdentifier = '';
348 // this.referenceDataObject['vnfcIdentifier'] = '';
350 this.oldVnfcIdentifier = this.vnfcIdentifier;
351 if( this.utilityService.getTracelvl() > 1 )
352 console.log( this.classNm+": "+methName+": displayVnfc:["+
353 this.displayVnfc+"]");
354 if( this.utilityService.getTracelvl() > 1 )
355 console.log( this.classNm+": "+methName+": templateIdentifier:["+
356 this.templateIdentifier+"]");
357 // Enable or Block Template and PD Tabs
358 this.buildDesignComponent.getRefData(
359 { ...this.referenceDataObject, displayVnfc: this.displayVnfc },
360 { reqField: this.templateIdentifier });
361 //.. configure some drop-downs
362 this.configDrp(this.referenceDataObject.action);
363 if( this.utilityService.getTracelvl() > 0 )
364 console.log( this.classNm+": "+methName+": tempAllData:["+
365 JSON.stringify(this.tempAllData)+"]");
366 if( this.utilityService.getTracelvl() > 0 )
367 console.log( this.classNm+": "+methName+": finish.");
370 //setting the value to display or hide the template identifier dropdown in the screen
371 toggleIdentifier(data) {
372 if (data == 'ConfigScaleOut') {
373 this.isConfigScaleOut = true
376 this.isConfigScaleOut = false
379 if (data == 'ConfigScaleIn') {
380 this.isConfigScaleIn = true;
382 this.isConfigScaleIn = false;
386 //to retrive the data from appc and assign it to the vaiables, if no data display the message reterived from the API
388 if( this.utilityService.getTracelvl() > 0 )
389 console.log(this.classNm+": getArtifact: start...");
391 // setting the isVnfcTypeList & isVnfcType to false initially
392 this.isVnfcTypeList = false;
393 this.isVnfcType = false
394 let data = this.utilityService.createPayloadForRetrieve(true, '', '', '');
395 this.ngProgress.start();
396 let serviceCall = this.apiService.callGetArtifactsApi(data);
397 serviceCall.subscribe(resp => {
398 //getting the response and assigining it to the variables used and end the progress bar aftr the data is fetched.
399 if (resp.output.data.block != undefined) {
400 this.nService.success('Status', 'data fetched ');
401 let artifactInfo = JSON.parse(resp.output.data.block).artifactInfo[0];
402 let referenceDataAll = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
403 let reference_data = JSON.parse(artifactInfo['artifact-content'])['reference_data'][0];
404 this.referenceDataObject = reference_data;
405 this.toggleIdentifier(this.referenceDataObject.action);
406 if (this.referenceDataObject.action == 'ConfigScaleOut') {
407 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
409 if (this.referenceDataObject.action == 'ConfigScaleIn') {
410 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
412 this.highlightSelectedActions(referenceDataAll)
414 //chck vnfc or vnfcTypeList
415 this.displayHideVnfc();
417 // Enable or Block Template and PD Tabs
418 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
420 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
421 this.mappingEditorService.getReferenceList().push(JSON.parse(artifactInfo['artifact-content']));
422 this.tempAllData = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
423 this.oldAction = this.referenceDataObject.action;
424 this.oldVnfcIdentifier = this.vnfcIdentifier;
426 this.processReferenceDataAfterRetrieval();
427 this.getArtifactsOpenStack();
429 this.nService.success('Status', 'Sorry !!! I dont have any artifact Named : ' + (JSON.parse(sessionStorage.getItem('updateParams')))['artifact-name']);
431 this.ngProgress.done();
435 this.nService.warn('status', 'error while reteriving artifact');
438 this.ngProgress.done();
443 if( this.utilityService.getTracelvl() > 0 )
444 console.log(this.classNm+": displayHideVnfc: start...");
445 if( this.utilityService.getTracelvl() > 1 ) {
446 if( this.referenceDataObject.scope['vnfc-type-list'] ) {
447 console.log( this.classNm+
448 ": displayHideVnfc: refDataObj.scope.vnfc-type-list.length="+
449 this.referenceDataObject.scope['vnfc-type-list'].length );
451 console.log( this.classNm+
452 ": displayHideVnfc: refDataObj.scope.vnfc-type-list not defined");
454 console.log( this.classNm+": displayHideVnfc: scope.vnfc-type:["+
455 this.referenceDataObject.scope['vnfc-type']+"]");
457 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && (this.referenceDataObject.scope['vnfc-type'] != undefined || this.referenceDataObject.scope['vnfc-type'] != "")) {
458 this.isVnfcType = true
459 this.displayVnfc = 'true'
460 this.isVnfcTypeList = false
462 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'] == "")) {
463 this.isVnfcType = false
464 this.displayVnfc = 'true'
465 this.isVnfcTypeList = true
466 if(!this.mappingEditorService.newObject || !this.mappingEditorService.newObject.vnfc) {
467 this.vnfcIdentifier = this.referenceDataObject.scope['vnfc-type-list'][0];
468 // this.mappingEditorService.newObject.vnfc = this.vnfcIdentifier;
470 this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
472 this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
473 //this.vnfcChanged(this.vnfcIdentifier, FormData);
474 if( this.utilityService.getTracelvl() > 0 )
475 console.log(this.classNm+": displayHideVnfc: vnfcIdentifier:["+
476 this.vnfcIdentifier+"]");
478 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) {
479 if(this.displayVnfc == 'true') {
480 this.isVnfcType = false
481 this.displayVnfc = 'true'
482 this.isVnfcTypeList = true
484 this.isVnfcType = false
485 this.displayVnfc = 'false'
486 this.isVnfcTypeList = false
489 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && this.referenceDataObject.scope['vnfc-type'] == '') {
490 this.isVnfcType = false
491 this.displayVnfc = 'false'
492 this.isVnfcTypeList = false
494 if( this.utilityService.getTracelvl() > 0 )
495 console.log(this.classNm+": displayHideVnfc: finish. isVnfcType:["+
496 this.isVnfcType+" displayVnfc:["+this.displayVnfc+"] isVnfcTypeList:["+
497 this.isVnfcTypeList+"]");
500 //reinitializing the required values. when changing to template or pd sending the values to mapping service
502 let referenceObject = this.prepareReferenceObject();
503 this.mappingEditorService.changeNavAppData(this.appData);
504 this.mappingEditorService.changeNavDownloadData(this.downloadData);
505 this.uploadedDataArray = [];
506 this.remUploadedDataArray = [];
507 this.firstArrayElement = [];
508 this.uploadFileName = '';
510 // vaidating the number
511 numberValidation(event: any) {
512 if (this.numberTest.test(event) && event != 0) {
513 this.numberOfVmTest = true;
516 this.numberOfVmTest = false;
519 // update my vnf pop up session values
520 updateSessionValues(event: any, type: string) {
521 if( this.utilityService.getTracelvl() > 0 )
522 console.log(this.classNm+": updateSessionValues: type:["+type+"]");
523 if (type === 'action') {
524 sessionStorage.setItem('action', event);
526 if (type === 'vnfType') {
527 sessionStorage.setItem('vnfType', event);
530 // adding vnfc data for each vm
531 addVnfcData(vmNumber: number) {
532 if( this.utilityService.getTracelvl() > 0 )
533 console.log(this.classNm+": addVnfcData: start: vmNumber="+ vmNumber);
535 'vnfc-instance': this.referenceDataObject.vm[vmNumber].vnfc.length + 1,
536 'vnfc-type': this.vnfcTypeData,
537 'vnfc-function-code': '',
538 'ipaddress-v4-oam-vip': '',
539 'group-notation-type': '',
540 'group-notation-value': ''
542 this.referenceDataObject.vm[vmNumber].vnfc.push(newObj);
544 //validating the vnf and vnfc data in the pop up
545 validateVnfcName(name) {
546 if( this.utilityService.getTracelvl() > 0 )
547 console.log( this.classNm+": validateVnfcName: start: name:["+name+"]");
548 if (!name.trim() || name.length < 1) {
549 this.errorMessage = '';
551 } else if (name.startsWith(' ') || name.endsWith(' ')) {
552 this.errorMessage = 'Leading and trailing spaces are not allowed';
554 } else if (name.includes(' ')) {
555 this.errorMessage = 'More than one space is not allowed in VNFC Type';
557 } else if (name.length > 50) {
558 this.errorMessage = 'VNFC Type should be of minimum one character and maximum 50 character';
561 this.invalid = false;
562 this.errorMessage = '';
567 //to remove the VM's created by the user
568 removeFeature(vmNumber: any, index: any, templateId) {
569 if (this.referenceDataObject.action == "Configure") {
570 this.referenceDataObject.vm.splice(vmNumber, 1);
571 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
572 if (arrIndex >= vmNumber) {
573 obj["vm-instance"] = obj["vm-instance"] - 1
575 // obj["vm-instance"] = arrIndex+1
579 let data = this.referenceDataObject.vm.filter(obj => {
580 return obj['template-id'] == templateId;
583 let vmIndex = this.findVmindex(data, vmNumber, templateId)
584 this.referenceDataObject.vm.splice(vmIndex, 1);
586 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
587 if (obj['template-id'] == templateId) {
589 obj["vm-instance"] = index + 1
597 //utility function while adding VM to check index
598 findVmindex(data, vmNumber, templateId) {
599 return this.referenceDataObject.vm.findIndex(obj => {
600 let x = obj['vm-instance'] == (vmNumber + 1) && templateId == obj['template-id']//true
606 //add new VM's to the configure and configmodify.
610 let mberOFVm = Number(this.refernceScopeObj.from);
612 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
614 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
617 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
618 let existingVmsLength = this.referenceDataObject.vm.map(obj => {
619 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
620 return obj["vnfcType-id"] == this.templateIdentifier
621 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
622 return obj["template-id"] == this.templateIdentifier
625 //mberOFVm = existingVmsLength + mberOFVm;
628 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
629 identifierValue = this.templateIdentifier
630 } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
631 identifierValue = this.vnfcIdentifier
634 for (var i = 0; i < mberOFVm; i++) {
635 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
637 if (identifierValue && identifierValue != "") {
638 this.referenceDataObject.vm.push({ 'vnfcType-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
640 this.referenceDataObject.vm.push({ 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
643 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
644 if (identifierValue && identifierValue != "") {
645 this.referenceDataObject.vm.push({ 'template-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
654 let arrlength = this.referenceDataObject.vm.length;
655 mberOFVm = arrlength + mberOFVm;
656 for (var i = (arrlength); i < mberOFVm; i++) {
657 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
658 this.referenceDataObject.vm.push({ 'template-id': this.templateIdentifier, 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
660 this.referenceDataObject.vm.push({ 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
666 //preparing reference obj with required business use cases
667 prepareReferenceObject(isSaving?: any) {
668 let methName= "prepareReferenceObject";
669 if( this.utilityService.getTracelvl() > 0 )
670 console.log( this.classNm+": "+methName+": start: isSaving:["+
672 let scopeName = this.resetParamsOnVnfcType();
673 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
674 this.prepareArtifactList(scopeName, extension);
676 if (this.referenceDataObject.action === 'OpenStack Actions') {
677 this.referenceDataObject['template'] = 'N';
678 this.referenceDataObject['artifact-list'] = [];
679 this.referenceDataObject['firstRowVmSpreadSheet'] = this.firstArrayElement;
682 this.referenceDataObject['firstRowVmSpreadSheet']=undefined;
684 //ditaching the object from the form and processing pfurther
685 let newObj = $.extend(true, {}, this.referenceDataObject);
686 let action = this.referenceDataObject.action;
687 // if (action=="ConfigScaleOut"){
688 // this.referenceDataObject.action="true";
690 //preparing Obj for save/download
691 newObj = this.deleteVmsforNonActions(newObj, action)
693 if (newObj['device-protocol'] != 'REST') {
696 this.pushOrReplaceTempData(newObj, action);
697 this.addAllActionObj(newObj, scopeName);
703 //saving data to service
704 this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
705 this.buildDesignComponent.updateAccessUpdatePages(this.referenceDataObject.action, this.mappingEditorService.getReferenceList());
706 this.mappingEditorService.changeNav(this.tempAllData);
707 //on action change or template identifier change reset the form by restting values of Reference data object
708 this.resetVmsForScaleout(this.currentAction)
709 return { totlaRefDtaa: this.tempAllData, scopeName: scopeName };
712 // utility function to check element existence
713 public checkIfelementExistsInArray(element, array) {
714 var result: boolean = false;
716 array.forEach(function (item) {
717 if (element === item) {
724 // when uploading the file
726 /* wire up file reader */
727 const target: DataTransfer = <DataTransfer>(evt.target);
728 this.uploadFileName = evt.target.files[0].name;
729 var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
730 if (target.files.length != 1) {
731 throw new Error('Cannot upload multiple files on the entry');
733 if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') {
734 const reader = new FileReader();
735 reader.onload = (e: any) => {
737 const bstr = e.target.result;
738 const wb = XLSX.read(bstr, { type: 'binary' });
739 /* grab first sheet */
740 const wsname = wb.SheetNames[0];
741 const ws = wb.Sheets[wsname];
744 this.firstArrayElement = []
745 let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
746 this.uploadedDataArray = arrData;
747 for (var i = 0; i < arrData[0].length; i++) {
748 this.firstArrayElement.push(arrData[0][i].replace(/[\n\r]+/g, ''))
750 var remUploadedDataArray = arrData;
751 remUploadedDataArray.shift();
752 this.remUploadedDataArray = remUploadedDataArray;
753 if (arrData != null) {
754 this.getExcelUploadStatus = true;
755 this.nService.success('Success', 'Vm capabilities data uploaded successfully');
759 this.nService.success('Error', 'Empty Vm capabilities file uploaded');
762 reader.readAsBinaryString(target.files[0]);
765 this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
770 addVmCapabilitiesData() {
771 for (var i = 0; i < this.uploadedDataArray.length; i++) {
772 var vnfcFuncCodeArray = [];
773 var data = this.uploadedDataArray[i];
774 for (var j = 1; j < data.length; j++) {
775 if (data[j] != undefined) {
776 if (data[j].toUpperCase() === 'Y') {
777 vnfcFuncCodeArray.push(this.firstArrayElement[j]);
778 //vnfcFuncCodeArray.push({name:this.firstArrayElement[j]});
782 var action = this.uploadedDataArray[i][0];
783 if (action && action != undefined) {
786 'action-level': 'vm',
788 'vnf-type': this.referenceDataObject['scope']['vnf-type'], //need to confirm what should be this value
789 'vnfc-type-list': null
791 'vnfc-function-code-list': vnfcFuncCodeArray,
793 'device-protocol': 'OS'
796 this.tempAllData.push(json);
802 //download the templae pd and reference file with all the actions added.
803 save(form: any, isValid: boolean) {
804 // will show error message
805 this.showValidationErrors(this.referenceDataObject);
808 let referenceObject = this.prepareReferenceObject();
809 let removedKeysArray = []
810 this.tempAllData.forEach((data, index) => {
812 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
815 this.tempAllData = removedKeysArray;
816 /* var tempAllData = this.tempAllData;
817 tempAllData=this.removeParamFileNameBeforeSave(tempAllData)*/
819 //tempAllData["artifact_list"]=newArtifactList;
820 let theJSON = JSON.stringify({ 'reference_data': this.tempAllData }, null, '\t');
821 let uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(theJSON);
822 this.downloadData.reference = theJSON;
823 let referenceFileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
824 this.utilityService.downloadArtifactToPc(theJSON, 'json', referenceFileName, 100);
825 this.validateTempAllData();
826 var templateData = JSON.stringify(this.downloadData.template.templateData);
827 var templateFileName = this.downloadData.template.templateFileName;
828 if (templateFileName != null || templateFileName != '') {
829 var fileExtensionArr = templateFileName.split('.');
831 var nameValueFileName = this.downloadData.template.nameValueFileName;
832 let pdFileName = this.downloadData.pd.pdFileName;
833 var nameValueData = JSON.stringify(this.downloadData.template.nameValueData);
834 var pdData = this.downloadData.pd.pdData;
835 if (templateData != '{}' && templateData != null && templateData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.templateData, fileExtensionArr[1], templateFileName, 130);
836 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.nameValueData, 'json', nameValueFileName, 160);
837 if (pdData != '' && pdData != null && pdData != undefined) this.utilityService.downloadArtifactToPc(pdData, 'yaml', pdFileName, 180);
841 /* removeParamFileNameBeforeSave(tempAllData)
843 var newArtifactList = [];
845 for (var i = 0; i < tempAllData.length; i++) {
846 if (this.checkIfelementExistsInArray(tempAllData[i].action,this.actions)) {
847 var artifactList = tempAllData[i]["artifact-list"]
849 for (var j = 0; j < artifactList.length; j++) {
850 if (artifactList[j]["artifact-type"] != "param_values") {
851 element = artifactList[j];
852 newArtifactList.push(element);
855 tempAllData[i]["artifact-list"] = newArtifactList
856 newArtifactList = [];
862 // save the values to the cache, on action change without download
863 validateDataAndSaveToAppc( valid, form, event) {
864 let methName= "validateDataAndSaveToAppc";
865 if( this.utilityService.getTracelvl() > 0 )
866 console.log( this.classNm+": "+methName+": start: valid:["+valid+"]");
867 // will show error message
868 this.showValidationErrors(this.referenceDataObject);
869 if( this.utilityService.getTracelvl() > 0 )
870 console.log( this.classNm+": "+methName+": tempAllData:["+
871 JSON.stringify(this.tempAllData)+"]");
873 form._submitted = true;
875 let referenceObject = this.prepareReferenceObject(true);
876 let removedKeysArray = []
877 this.tempAllData.forEach((data, index) => {
879 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
882 this.tempAllData = removedKeysArray;
884 this.validateTempAllData();
886 if (this.actionChanged) {
888 if (this.currentAction) {
889 this.referenceDataObject.action = this.currentAction;
892 this.populateExistinAction(this.referenceDataObject.action);
893 this.actionChanged = false;
898 this.nService.warn('status', 'unable to save the artifact');
901 //this method saves reference, template, param and PD data to APPC
903 if( this.utilityService.getTracelvl() > 0 )
904 console.log( this.classNm+": saveToAppc: start: vnf-type:["+
905 this.referenceDataObject.scope['vnf-type']+"]");
906 let theJSON = JSON.stringify( this.tempAllData );
907 if( this.utilityService.getTracelvl() > 0 )
908 console.log( this.classNm+": saveToAppc: tempAllData:["+theJSON+"]");
909 let fileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
910 /*var tempAllData=this.removeParamFileNameBeforeSave(this.tempAllData);
911 this.tempAllData=tempAllData;*/
912 this.saveReferenceDataToAppc(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
914 var templateData = JSON.stringify(this.appData.template.templateData);
915 var nameValueData = JSON.stringify(this.appData.template.nameValueData);
916 var pdData = JSON.stringify(this.appData.pd);
917 if (templateData != '{}' && templateData != null && templateData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.templateData, 'template data');
918 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.nameValueData, 'name value pairs');
919 if (pdData != '{}' && pdData != null && pdData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.pd, 'PD file');
922 // valaidation of template data
923 validateTempAllData() {
924 if (this.tempAllData) {
925 var updatedData = [];
926 this.tempAllData.forEach(data => {
928 updatedData.push(data);
931 this.tempAllData = updatedData;
935 //preparig and send the data to the API.
936 saveReferenceDataToAppc(artifactData, dataJson, fileName) {
938 let slashedPayload = this.referenceDataFormUtil.appendSlashes(artifactData);
940 let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload);
941 this.ngProgress.start();
942 this.httpUtils.post({
943 url: environment.getDesigns,
945 }).subscribe((resp) => {
946 if (resp != null && resp.output.status.code == '400') {
947 window.scrollTo(0, 0);
948 this.nService.success('Status', 'successfully uploaded the Reference Data');
950 this.nService.warn('Status', 'Error while saving Reference Data');
952 this.uploadStatusError = false;
953 this.getRefStatus = false;
954 this.ngProgress.done();
956 this.nService.error('Status', 'Error Connecting to the APPC Network');
957 window.scrollTo(0, 0);
959 this.appData.reference = payload;
961 this.ngProgress.done();
964 // if no data present in the session, fetching data from API
966 if (sessionStorage.getItem('updateParams') != 'undefined') {
968 this.noCacheData = false;
970 this.noCacheData = true;
974 public showUpload() {
975 this.selectedUploadType = this.uploadTypes[0].value;
977 // used when user uploads a file using upload file
978 public fileChange(input) {
979 this.fileName = input.target.files[0].name.replace(/C:\\fakepath\\/i, '');
980 this.fileUploaded = true;
981 this.disableRetrieve = true;
982 if (input.target.files && input.target.files[0]) {
983 // Create the file reader
984 let reader = new FileReader();
985 this.readFile(input.target.files[0], reader, (result) => {
986 // After the callback fires do:
987 if ('Reference Data' === this.selectedUploadType) {
990 let jsonObject = (JSON.parse(result))['reference_data'];
991 this.uploadedData = JSON.parse(JSON.stringify(jsonObject));
992 //check for legacy artifact and do not allow it
993 for (let i = 0; i < this.uploadedData.length; i++) {
994 obj = this.uploadedData[i];
995 if (obj.scope['vnfc-type'] != undefined && obj.scope['vnfc-type'] != '') {
996 this.nService.error('Error', 'The legacy reference artifact not supported');
1001 this.displayVnfc = 'false';
1002 this.isVnfcType = false;
1003 this.isVnfcTypeList = false;
1004 for (let i = 0; i < this.uploadedData.length; i++) {
1005 obj = this.uploadedData[i];
1006 if (obj.scope['vnfc-type-list'] && obj.scope['vnfc-type-list'].length > 0) {
1007 this.displayVnfc = 'true';
1008 this.isVnfcTypeList = true;
1009 this.vnfcIdentifier = obj.scope['vnfc-type-list'][0];
1013 this.oldAction=obj.action;
1014 this.tempAllData = JSON.parse(JSON.stringify(jsonObject));
1015 //check vnfc tyoe list for old files
1016 // if (this.referenceDataObject.scope['vnfc-type-list'] == undefined) {
1017 // this.tempAllData = []
1018 // this.referenceDataObject = {
1020 // 'action-level': 'vnf',
1021 // scope: { 'vnf-type': '', 'vnfc-type-list': [] },
1024 // 'device-protocol': '',
1026 // 'port-number': '',
1027 // 'artifact-list': []
1029 // this.nService.error('Error', 'Incorrect file format');
1032 this.notificationService.notifySuccessMessage('Reference Data file successfully uploaded..');
1033 this.highlightSelectedActions(jsonObject)
1034 this.toggleIdentifier(this.referenceDataObject.action)
1035 this.populateExistinAction(this.referenceDataObject.action)
1036 this.configDrp(this.referenceDataObject.action)
1039 this.processReferenceDataAfterRetrieval();
1041 this.getArtifactsOpenStack();
1042 if (this.referenceDataObject.template == null) {
1043 this.referenceDataObject.template = 'Y';
1045 if (this.referenceDataObject['action-level'] == null) {
1046 this.referenceDataObject['action-level'] = 'VNF';
1050 // Enable or Block Template and PD Tabs
1051 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1053 this.nService.error('Error', 'Incorrect file format');
1056 this.hideModal = true;
1059 this.notificationService.notifyErrorMessage('Failed to read file..');
1064 // Highlights selected action on new file upload and on existing VNF
1065 public highlightSelectedActions(jsonObject) {
1066 if (jsonObject instanceof Array) {
1067 this.referenceDataObject = jsonObject[0];
1068 jsonObject.forEach(obj => {
1069 this.selectedActions.push(obj.action);
1072 this.referenceDataObject = jsonObject;
1074 this.selectedActions.push(jsonObject.action);
1078 public readFile(file, reader, callback) {
1079 // Set a callback funtion to fire after the file is fully loaded
1080 reader.onload = () => {
1081 // callback with the results
1082 callback(reader.result);
1084 this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size);
1086 reader.readAsText(file, 'UTF-8');
1089 fileChangeEvent(fileInput: any) {
1090 let obj: any = fileInput.target.files;
1092 //resetting the values
1095 'vnfc-instance': '1',
1096 'vnfc-function-code': '',
1097 'ipaddress-v4-oam-vip': '',
1098 'group-notation-type': '',
1099 'group-notation-value': ''
1103 setVmInstance(index) {
1104 this.referenceDataObject.vm[index]['vm-instance'] = index + 1;
1107 // setVnfcType(str: String) {
1108 // this.Sample['vnfc-type'] = str;
1111 // getChange(value: String) {
1112 // if (value === 'vnfType') {
1113 // this.referenceDataObject.scope['vnfc-type'] = '';
1116 // resetting the form
1118 console.log( this.classNm+": resetForm: start.");
1119 this.referenceDataObject['action-level'] = 'vnf';
1120 this.referenceDataObject.template = 'Y';
1121 this.referenceDataObject['device-protocol'] = '';
1122 this.referenceDataObject['user-name'] = '';
1123 this.referenceDataObject['port-number'] = '';
1124 this.refernceScopeObj.sourceType = '';
1125 this.Sample['vnfc-type'] = '';
1128 //.. this method gets called with the action as parameter and
1129 // the respective action details are fetched and assigned to the current page
1130 populateExistinAction( action) {
1131 let methName= "populateExistinAction";
1132 if( this.utilityService.getTracelvl() > 0 )
1133 console.log( this.classNm+": "+methName+": start: action:["+action+"]");
1134 if( this.utilityService.getTracelvl() > 0 )
1135 console.log( this.classNm+": "+methName+": tempAllData:["+
1136 JSON.stringify(this.tempAllData)+"]");
1137 let existAction = this.tempAllData.findIndex(obj => {
1138 return obj.action == action;
1140 if( this.utilityService.getTracelvl() > 0 )
1141 console.log( this.classNm+": "+methName+": existAction="+existAction );
1142 if( existAction > -1) {
1143 let obj = $.extend(true, {}, this.tempAllData[existAction]);
1144 this.referenceDataObject = obj;
1145 this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type'];
1146 this.referenceDataObject.scope['vnfc-type-list'] = obj['scope']['vnfc-type-list'];
1147 this.referenceDataObject['device-protocol'] = obj['device-protocol'];
1148 this.refernceScopeObj['sourceType'] = obj['scopeType'];
1149 if( obj['scope']['vnfc-type-list'] != undefined &&
1150 obj['scope']['vnfc-type-list'].length >0)
1152 this.referenceDataObject['vnfcIdentifier']=
1153 obj['scope']['vnfc-type-list'][0];
1157 console.log( this.classNm+": populateExistinAction: action not found");
1159 this.referenceDataObject.action = action;
1161 //# iof healthCeck change deviceprotocol drp vaues
1164 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST'];
1165 this.actionHealthCheck = true;
1167 case 'UpgradeBackout':
1168 case 'ResumeTraffic':
1169 case 'DistributeTraffic':
1170 case 'DistributeTrafficCheck':
1171 case 'QuiesceTraffic':
1172 case 'UpgradeBackup':
1173 case 'UpgradePostCheck':
1174 case 'UpgradePreCheck':
1175 case 'UpgradeSoftware':
1176 case 'DownloadNESw':
1177 case 'ActivateNESw':
1178 case 'ConfigRestore':
1179 case 'StartApplication':
1180 case 'StopApplication':
1181 case 'ConfigBackup':
1182 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE'];
1185 case 'LicenseManagement':
1186 case 'PostConfigure':
1187 case 'PostEvacuate':
1190 case 'PreConfigCheck':
1191 case 'PreConfigure':
1195 case 'ProvisionConfig':
1196 case 'ProvisionData':
1197 case 'Provisioning':
1198 case 'StartTraffic':
1199 case 'StatusTraffic':
1201 this.deviceProtocols = ['', 'ANSIBLE'];
1203 case 'OpenStack Actions':
1204 this.deviceProtocols = ['', 'OpenStack'];
1206 case 'ConfigScaleOut':
1207 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1209 case 'ConfigScaleIn':
1210 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1212 case 'GetRunningConfig':
1213 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF', 'CLI', 'REST'];
1216 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
1217 this.actionHealthCheck = false;
1219 if( this.utilityService.getTracelvl() > 0 )
1220 console.log( this.classNm+": "+methName+
1221 ": deviceProtocols count="+this.deviceProtocols.length+" finish.");
1224 //Modal pop up for action change with values entered.
1225 actionChange( data, userForm) {
1226 let methName= "actionChange";
1227 if( this.utilityService.getTracelvl() > 0 )
1228 console.log( this.classNm+": "+methName+": start: data:["+data+"]"+
1229 " userForm.valid:["+userForm.valid+"]");
1230 if( this.utilityService.getTracelvl() > 0 )
1231 console.log( this.classNm+": "+methName+": tempAllData:["+
1232 JSON.stringify(this.tempAllData)+"]");
1233 this.disableGrpNotationValue = false
1235 console.log( this.classNm+": "+methName+": data == null");
1238 if((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
1239 this.actionChanged = true;
1240 if( this.utilityService.getTracelvl() > 0 )
1241 console.log( this.classNm+": "+methName+
1242 ": userForm valid and oldAction defined");
1243 // Calling common Confirmation Modal
1244 let disposable = this.dialogService.addDialog(ConfirmComponent)
1245 .subscribe((isConfirmed)=>{
1246 //We get dialog result
1248 // User clicked on Yes
1249 this.currentAction = this.referenceDataObject.action;
1250 this.referenceDataObject.action = this.oldAction;
1251 $('#saveToAppc').click();//make sure the save all is done before the tempall obj is saved form the API
1252 this.toggleIdentifier(data)
1253 this.oldAction = this.currentAction;// this.referenceDataObject.action + '';
1254 this.referenceDataObject.action = this.currentAction
1256 this.populateExistinAction(data);
1257 if (this.oldAction === 'OpenStack Actions') {
1259 this.uploadedDataArray = [];
1260 this.remUploadedDataArray = [];
1261 this.firstArrayElement = [];
1262 this.uploadFileName = '';
1263 //this.tempAllData = [];
1266 this.refernceScopeObj.from = '';
1267 this.getArtifactsOpenStack();
1269 // Clears VNFC Information data on action change
1270 this.clearVnfcData()
1271 this.resetVmsForScaleout(data);
1274 // User clicked on No
1275 this.toggleIdentifier(data)
1276 this.currentAction = this.referenceDataObject.action;
1277 this.populateExistinAction(data);
1278 this.resetVmsForScaleout(data);
1279 this.oldAction = this.referenceDataObject.action + '';
1281 this.clearVnfcData()
1282 this.refernceScopeObj.from = '';
1285 if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic' || this.referenceDataObject.action === 'DistributeTrafficCheck') {
1286 this.isConfigOrConfigModify = true;
1288 this.isConfigOrConfigModify = false;
1289 delete this.mappingEditorService.newObject['vnfc'];
1292 // Enable or Block Template and PD Tabs
1293 if ((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleIn') && this.templateIdentifier && this.templateIdentifier != '') {
1294 // let referenceDataObjectTemp = this.referenceDataObject;
1295 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1296 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1297 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1300 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1304 console.log( this.classNm+": "+methName+
1305 ": userForm Not valid or oldAction not defined");
1306 this.actionChanged = true;
1307 this.currentAction = this.referenceDataObject.action;
1308 this.oldAction = this.referenceDataObject.action + '';
1309 this.populateExistinAction(data);
1310 this.resetVmsForScaleout(data);
1311 this.toggleIdentifier(data);
1313 // Enable or Block Template and PD Tabs
1314 if((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleOut') && this.templateIdentifier) {
1315 // let referenceDataObjectTemp = this.referenceDataObject;
1316 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1317 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1318 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1320 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1323 if( this.utilityService.getTracelvl() > 0 )
1324 console.log( this.classNm+": "+methName+": tempAllData:["+
1325 JSON.stringify(this.tempAllData)+"]");
1326 this.configDrp(data)
1330 console.log( this.classNm+": configDrp: start: data:["+data+"]");
1331 if (data == 'ConfigScaleOut' || data == 'ConfigScaleIn') {
1332 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
1334 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
1336 if (data == 'OpenStack Actions') {
1337 this.buildDesignComponent.tabs = this.referencDataTab;
1340 this.buildDesignComponent.tabs = this.allTabs;
1342 if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic' || data == 'DistributeTrafficCheck') {
1343 this.nonConfigureAction = false;
1345 this.nonConfigureAction = true;
1348 // removing and adding the url key based on the protocol selected
1349 deviceProtocolChange() {
1350 let methName= "deviceProtocolChange";
1351 if( this.utilityService.getTracelvl() > 0 )
1352 console.log( this.classNm+": "+methName+": start.");
1353 if (this.referenceDataObject['device-protocol'] == 'REST') {
1356 delete this.referenceDataObject['context-url']
1358 // Enable or Block Template and PD Tabs
1359 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, {reqField: this.templateIdentifier})
1360 if( this.utilityService.getTracelvl() > 0 )
1361 console.log( this.classNm+": "+methName+": tempAllData:["+
1362 JSON.stringify(this.tempAllData)+"]");
1365 // used to call or trigger save object on template Identifier changes
1366 idChange(data, userForm) {
1367 if( this.utilityService.getTracelvl() > 0 )
1368 console.log( this.classNm+": idChange: start: data:["+data+"]");
1373 // Enable or Block Template and PD Tabs
1374 // let referenceDataObjectTemp = this.referenceDataObject;
1375 // referenceDataObjectTemp['template-id'] = data;
1376 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1377 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1379 if ((userForm.valid)) {
1380 this.currentAction = "ConfigScaleOut"
1381 this.oldtemplateIdentifier = this.templateIdentifier
1382 let referenceObject = this.prepareReferenceObject();
1383 this.actionChanged = true;
1384 if (this.templateIdentifier) {
1385 // Calling common Confirmation Modal
1386 let disposable = this.dialogService.addDialog(ConfirmComponent)
1387 .subscribe((isConfirmed)=>{
1388 //We get dialog result
1390 // User clicked on Yes
1391 this.validateTempAllData();
1394 this.clearVnfcData();
1395 this.refernceScopeObj.from = '';
1398 // User clicked on No
1400 this.refernceScopeObj.from = '';
1405 this.oldtemplateIdentifier = this.templateIdentifier
1408 // if (this.referenceDataObject.action == 'ConfigScaleOut' && data ) {
1409 // let referenceDataObjectTemp = this.referenceDataObject;
1410 // referenceDataObjectTemp['selectedTemplateId'] = data;
1411 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1413 // this.buildDesignComponent.getRefData(this.referenceDataObject);
1417 // used to call or trigger save object on multiple VNFC's changes
1418 vnfcChanged( data, userForm) {
1419 if( this.utilityService.getTracelvl() > 0 )
1420 console.log( this.classNm+": vnfcChanged: new vnfcIdentifier:["+data+"]");
1421 if( this.utilityService.getTracelvl() > 1 )
1422 console.log( this.classNm+": vnfcChanged: oldVnfcIdentifier:["+
1423 this.oldVnfcIdentifier+"]");
1424 if( this.utilityService.getTracelvl() > 0 )
1425 console.log(this.classNm+": vnfcChanged: scope.vnfc-type:["+
1426 this.referenceDataObject.scope['vnfc-type']+"]");
1427 this.vnfcIdentifier = data;
1428 //this.clearCache();
1433 // Enable or Block Template and PD Tabs
1434 let referenceDataObjectTemp = this.referenceDataObject;
1435 referenceDataObjectTemp['vnfcIdentifier'] = data;
1436 if( this.utilityService.getTracelvl() > 0 )
1437 console.log( this.classNm+
1438 ": vnfcChanged: displayVnfc:["+this.displayVnfc+"]");
1439 //this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1440 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1443 console.log( this.classNm+
1444 ": vnfcChanged: userForm.valid:["+userForm.valid+"]");
1445 if ((userForm.valid) && this.oldVnfcIdentifier != '' && this.oldVnfcIdentifier != undefined) {
1446 this.currentAction = this.referenceDataObject.action
1447 this.oldVnfcIdentifier = this.vnfcIdentifier
1448 let referenceObject = this.prepareReferenceObject();
1449 this.actionChanged = true;
1450 if (this.vnfcIdentifier) {
1451 // Calling common Confirmation Modal
1452 let disposable = this.dialogService.addDialog(ConfirmComponent)
1453 .subscribe((isConfirmed)=>{
1454 //We get dialog result
1456 // User clicked on Yes
1457 this.validateTempAllData();
1460 this.clearVnfcData()
1461 this.refernceScopeObj.from = '';
1462 //.. populate VNFC Type in Sample field
1463 this.setVnfcTypeInSample( this.vnfcIdentifier );
1466 // User clicked on No
1468 this.clearVnfcData()
1469 this.refernceScopeObj.from = '';
1470 //.. populate VNFC Type in Sample field
1471 this.setVnfcTypeInSample( this.vnfcIdentifier );
1477 this.oldVnfcIdentifier = this.vnfcIdentifier
1483 //needed for the the clearing template cache.
1485 // get the value and save the userid and persist it.
1486 this.clearTemplateCache();
1487 this.clearPdCache();
1488 this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
1489 this.downloadData = {
1491 template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
1492 pd: { pdData: '', pdFileName: '' }
1496 clearTemplateCache() {
1497 this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
1498 localStorage['paramsContent'] = '{}';
1501 this.mappingEditorService.setParamContent(undefined);
1502 this.paramShareService.setSessionParamData(undefined);
1506 $('#inputFile').trigger('click');
1509 excelBrowseOption() {
1510 $('#excelInputFile').trigger('click');
1513 /* showIdentifier() {
1514 $('#identifierModal').modal();
1518 $('#vnfcModal').modal();
1522 if (!(this.referenceDataObject['template-id-list'])) {
1523 this.referenceDataObject['template-id-list'] = [];
1525 if (!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim()) > -1)) {
1526 this.referenceDataObject['template-id-list'].push(this.templateId.trim());
1529 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1530 this.templateId = ''
1532 // adds the vnfc to the vnfc dropdown list
1534 var newVnfcTypeV= this.newVnfcType.trim();
1535 if( this.utilityService.getTracelvl() > 0 )
1536 console.log(this.classNm+
1537 ": addVnfc: start: newVnfcTypeV:["+newVnfcTypeV+"]");
1538 if (!(this.referenceDataObject.scope['vnfc-type-list'])) {
1539 this.referenceDataObject.scope['vnfc-type-list'] = [];
1540 this.vnfcIdentifier = newVnfcTypeV;
1542 this.vnfcIdentifier = newVnfcTypeV;
1544 //this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
1545 if (!(this.referenceDataObject.scope['vnfc-type-list'].indexOf(newVnfcTypeV) > -1)) {
1546 this.referenceDataObject.scope['vnfc-type-list'].push(newVnfcTypeV);
1548 this.tempAllData.forEach(obj => {
1549 if (obj.action == "Configure" || obj.action == "ConfigModify" || obj.action == "DistributeTraffic" || obj.action == "DistributeTrafficCheck") {
1550 obj.scope['vnfc-type-list'] = this.referenceDataObject.scope['vnfc-type-list']
1552 this.resetArtifactList(obj);
1554 //this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1555 this.setVnfcTypeInSample( newVnfcTypeV );
1556 let userForm = {valid: true};
1557 this.vnfcChanged(this.newVnfcType, userForm)
1558 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1559 this.newVnfcType = ''
1563 this.referenceDataObject.vm = [];
1567 // this.referenceDataObject.vm = this.referenceDataObject.vm;
1569 // used to show and hide the group notation value in VNFC information
1570 resetGroupNotation() {
1571 if (this.Sample['group-notation-type'] == "existing-group-name") {
1572 this.Sample['group-notation-value'] = ""
1573 this.disableGrpNotationValue = true
1575 this.disableGrpNotationValue = false
1579 resetVmsForScaleout(action) {
1580 //reset currentform vms based on action
1581 if (action == "ConfigScaleOut" || action == "Configure") {
1582 let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
1583 return obj['action'] == action
1585 if (ConfigScaleOutIndex > -1) {
1586 this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
1588 if (this.actionChanged) {
1589 this.referenceDataObject.vm = []
1595 resetVmsForScaleIn(action) {
1596 //reset currentform vms based on action
1597 if (action == "ConfigScaleIn" || action == "Configure") {
1598 let ConfigScaleInIndex = this.tempAllData.findIndex(obj => {
1599 return obj['action'] == action
1601 if (ConfigScaleInIndex > -1) {
1602 this.referenceDataObject.vm = this.tempAllData[ConfigScaleInIndex].vm
1604 if (this.actionChanged) {
1605 this.referenceDataObject.vm = []
1611 resetParamsOnVnfcType() {
1613 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list']
1614 let vnfcType = this.referenceDataObject.scope['vnfc-type']
1615 let vnfType = this.referenceDataObject.scope['vnf-type'];
1616 //called only if only vnf is there
1617 if ((this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) && (this.referenceDataFormUtil.nullCheckForVnfcType(vnfcType))
1619 scopeName = vnfType;
1620 this.referenceDataObject.scope['vnfc-type'] = '';
1621 this.referenceDataObject['action-level'] = 'vnf';
1622 this.referenceDataObject['scopeType'] = 'vnf-type';
1623 scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1625 //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
1627 if (this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) {
1628 scopeName = vnfcType ? vnfcType : "";
1630 // scopeName = this.referenceDataObject.scope['vnfc-type-list'];
1633 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1634 this.referenceDataObject['action-level'] = 'vnf';
1635 this.referenceDataObject['scopeType'] = 'vnfc-type';
1637 this.referenceDataObject['action-level'] = 'vnf';
1638 this.referenceDataObject['scopeType'] = 'vnf-type';
1641 this.referenceDataObject.scope['vnfc-type'] = this.referenceDataObject.scope['vnfc-type'] ? this.referenceDataObject.scope['vnfc-type'] : "";
1645 //used to form the structure of the reference file
1646 prepareArtifactList(scopeName, extension) {
1647 this.referenceDataObject['artifact-list'] = [];
1651 let vnf = this.referenceDataObject.scope['vnf-type']
1652 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1653 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list'];
1655 let config_template_fileName
1658 if (vnfcTypeList && vnfcTypeList.length > 0) {
1661 for (var x = 0; x < vnfcTypeList.length; x++) {
1662 //for replacing spaces and "/" with "_"
1663 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1664 pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.yaml')
1665 config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, extension)
1666 param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.json')
1667 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1668 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1669 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1671 this.referenceDataObject['artifact-list'].push(configTemplate,
1672 pdTemplate, paramValue
1675 } else if (scopeName) {
1676 pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
1677 config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V' + extension;
1678 param_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
1679 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1680 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1681 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1682 this.referenceDataObject['artifact-list'].push(configTemplate,
1683 pdTemplate, paramValue
1689 //preparing the artifact list array file names along with extension
1690 let config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', extension);
1691 let pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.yaml');
1692 let reference_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1693 let param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1694 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1695 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1696 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1697 if (this.referenceDataObject.action != 'ConfigScaleOut' && this.referenceDataObject.action != 'ConfigScaleIn') {
1699 this.referenceDataObject['artifact-list'].push(configTemplate,
1700 pdTemplate, paramValue
1705 let identifiers = this.referenceDataObject['template-id-list'];
1707 for (var x = 0; x < identifiers.length; x++) {
1708 //for replacing spaces and "/" with "_"
1709 let type = identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1710 pd_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.yaml');
1711 config_template_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, extension);
1712 param_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.json');
1713 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1714 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1715 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1717 this.referenceDataObject['artifact-list'].push(configTemplate,
1718 pdTemplate, paramValue
1726 // used to remove the added vms for actions other than configure & scaleout
1727 deleteVmsforNonActions(newObj, action) {
1728 let configureObject = (action == 'Configure');
1729 let ConfigScale = (action == 'ConfigScaleOut') || (action == 'ConfigScaleIn');
1730 //delete VM's if selected action is not configure.
1731 if (!ConfigScale && !configureObject && this.tempAllData.length != 0) {
1739 delete newObj['template-id-list'];
1745 // used to replace the data in tempall obj and form the artifact names
1746 pushOrReplaceTempData(newObj, action) {
1750 if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic" || newObj.action == "DistributeTrafficCheck") {
1751 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
1752 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';
1753 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;
1754 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';
1755 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1756 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1757 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1759 if (newObj.scope['vnfc-type']) {
1760 idValue = newObj.scope['vnfc-type']
1761 } else if (this.vnfcIdentifier) {
1762 idValue = this.vnfcIdentifier
1765 let arr = [configTemplate, pdTemplate, paramValue]
1766 this.mappingEditorService.selectedObj({
1767 action: newObj.action,
1768 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1770 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1771 param_artifact: paramValue['param_artifact'],
1772 pd_artifact: pdTemplate['pd_artifact'],
1773 template_artifact: configTemplate['template_artifact']
1775 } else if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1776 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1777 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";
1778 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;
1779 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';
1780 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1781 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1782 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1783 let arr = [configTemplate, pdTemplate, paramValue]
1784 this.mappingEditorService.selectedObj({
1785 action: newObj.action,
1786 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1787 //vnfc: newObj['vnfcIdentifier'] ? newObj['vnfcIdentifier'] : "",
1788 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1789 templateId: this.templateIdentifier,
1790 param_artifact: paramValue['param_artifact'],
1791 pd_artifact: pdTemplate['pd_artifact'],
1792 template_artifact: configTemplate['template_artifact']
1796 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1797 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.yaml';
1798 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V' + extension;
1799 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
1800 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1801 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1802 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1803 let arr = [configTemplate, pdTemplate, paramValue]
1804 this.mappingEditorService.selectedObj({
1805 action: newObj.action,
1806 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1807 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1808 param_artifact: paramValue['param_artifact'],
1809 pd_artifact: pdTemplate['pd_artifact'],
1810 template_artifact: configTemplate['template_artifact']
1814 let actionObjIndex = this.tempAllData.findIndex(obj => {
1815 return obj['action'] == action;
1817 if (actionObjIndex > -1) {
1818 this.tempAllData[actionObjIndex] = newObj;
1819 this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
1820 if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1821 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1824 this.templateIdentifier = ('')
1825 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1828 if (newObj.action != '') {
1830 this.tempAllData.push(newObj);
1831 this.mappingEditorService.saveLatestAction(newObj);
1833 if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1834 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1837 this.templateIdentifier = ('')
1838 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1843 // removes the unwanted keys added in the artifact for vnfc level actions
1844 deleteUnwantedKeys(newObj) {
1845 newObj = JSON.parse(JSON.stringify(newObj))
1846 delete newObj['template-id']
1847 delete newObj['vnfcIdentifier']
1848 if (newObj.action != "ConfigScaleOut" && newObj.action != "ConfigScaleIn") {
1849 delete newObj['template-id-list']
1851 if (newObj.action != 'HealthCheck') {
1852 delete newObj['url'];
1854 if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action != "DistributeTraffic" && newObj.action != "DistributeTrafficCheck") {
1855 newObj.scope['vnfc-type-list'] = [];
1860 addAllActionObj(newObj, scopeName) {
1862 //Creating all action block to allow mulitple actions at once
1864 action: 'AllAction',
1865 'action-level': 'vnf',
1866 scope: newObj.scope,
1869 let vnfType = this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1871 allAction['artifact-list'].push({
1872 'artifact-name': 'reference_AllAction' + '_' + vnfType + '_' + '0.0.1V.json',
1873 'artifact-type': 'reference_template'
1876 let allActionIndex = this.tempAllData.findIndex(obj => {
1877 return obj['action'] == 'AllAction';
1879 if (allActionIndex > -1) {
1880 this.tempAllData[allActionIndex] = allAction;
1882 this.tempAllData.push(allAction);
1887 let methName= "resetTempData";
1888 if( this.utilityService.getTracelvl() > 0 )
1889 console.log( this.classNm+": "+methName+": start.");
1890 if( this.utilityService.getTracelvl() > 0 )
1891 console.log( this.classNm+": "+methName+": tempAllData:["+
1892 JSON.stringify(this.tempAllData)+"]");
1893 if (this.utilityService.checkNotNull(this.uploadedDataArray)) {
1895 if (this.utilityService.checkNotNull(this.tempAllData)) {
1896 for (var i = 0; i < this.tempAllData.length; i++) {
1899 if (this.tempAllData[i].action === 'AllAction') {
1903 result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
1906 this.tempAllData.splice(i, 1);
1912 this.addVmCapabilitiesData();
1916 trackByFn(index, item) {
1917 return index; // or item.id
1919 getArtifactsOpenStack() {
1921 var vnfcFunctionCodeArrayList = [];
1922 var vnfcSetArray = [];
1923 // var vnfcSet = new Set();
1924 for (var i = 0; i < this.tempAllData.length; i++) {
1925 if (!this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions) && (this.tempAllData[i].action != 'AllAction')) {
1926 var vnfcFunctionCodeArray = this.tempAllData[i]["vnfc-function-code-list"]
1927 // vnfcSet.add("Actions")
1928 /* for (var j = 0; j < vnfcFunctionCodeArray.length; j++) {
1929 vnfcSet.add(vnfcFunctionCodeArray[j])
1931 vnfcFunctionCodeArrayList.push([this.tempAllData[i].action].concat(this.tempAllData[i]["vnfc-function-code-list"]))
1933 if (this.tempAllData[i].action === 'OpenStack Actions') {
1934 vnfcSetArray = this.tempAllData[i]['firstRowVmSpreadSheet']
1939 let vnfcSetArrayLen = vnfcSetArray.length;
1941 for (let i = 0; i < vnfcFunctionCodeArrayList.length; i++) {
1942 let element = vnfcFunctionCodeArrayList[i];
1943 for (let j = 1; j < element.length; j++) {
1944 for (let k = j; k < vnfcSetArrayLen; k++) {
1945 if (element[j] === vnfcSetArray[k]) {
1949 element.splice(j, 0, '');
1955 this.firstArrayElement = vnfcSetArray;
1956 this.remUploadedDataArray = vnfcFunctionCodeArrayList;
1960 // Common method to show validation errors
1961 private showValidationErrors(referenceDataObject) {
1962 if (this.referenceDataObject.action === '') {
1963 this.nService.error('Error', 'Select a valid Action');
1966 if (this.referenceDataObject['device-protocol'] === '') {
1967 this.nService.error('Error', 'Select a valid Device protocol');
1971 if ((referenceDataObject.action === 'ConfigScaleOut'
1972 || referenceDataObject.action === 'ConfigScaleIn')
1973 && !this.templateIdentifier) {
1974 this.nService.error('Error', 'Select a valid Template Identifier');
1977 // if ((referenceDataObject.action === 'Configure' || referenceDataObject.action === 'ConfigModify') && !this.vnfcIdentifier && this.displayVnfc != 'false') {
1978 // this.nService.error('Error', 'Select a valid Vnfc Type');
1983 resetArtifactList(obj) {
1984 if( this.utilityService.getTracelvl() > 0 )
1985 console.log( this.classNm+": resetArtifactList: start...");
1986 let vnfcTypeList = obj.scope['vnfc-type-list'];
1987 let vnf = this.referenceDataObject.scope['vnf-type']
1989 let config_template_fileName
1994 obj['artifact-list'] = [];
1995 for (var x = 0; x < vnfcTypeList.length; x++) {
1996 let extension = this.referenceDataFormUtil.decideExtension(obj)
1997 //for replacing spaces and "/" with "_"
1998 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1999 pd_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.yaml';
2000 config_template_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V' + extension;
2001 param_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.json';
2003 'artifact-name': 'template_' + config_template_fileName,
2004 'artifact-type': 'config_template'
2007 'artifact-name': 'pd_' + pd_fileName,
2008 'artifact-type': 'parameter_definitions'
2011 'artifact-name': 'param_' + param_fileName,
2012 'artifact-type': 'param_values'
2015 this.referenceDataObject['artifact-list'].push(configTemplate,
2016 pdTemplate, paramValue
2018 obj['artifact-list'].push(configTemplate,
2019 pdTemplate, paramValue
2025 * Handles the display of VM block based on the action change
2027 handleVMBlockDisplay() {
2028 switch (this.referenceDataObject.action) {
2029 case this.actionList.ConfigScaleOut:
2030 case this.actionList.ConfigScaleIn:
2031 case this.actionList.Configure:
2034 this.displayVMBlock = true;
2037 this.displayVMBlock = false;
2041 //.. check VNFC Type equality in Upper Selection vs entered in Sample field
2042 checkVnfcTypeEqual( vnfctp: string ) {
2043 var methName= "checkVnfcTypeEqual";
2044 if( this.utilityService.getTracelvl() > 0 )
2045 console.log(this.classNm+": "+methName+": vnfctp:["+vnfctp+"]");
2046 if( this.utilityService.getTracelvl() > 0 )
2047 console.log( this.classNm+": "+methName+": vnfcIdentifier:["+
2048 this.vnfcIdentifier+"]");
2049 if( this.utilityService.getTracelvl() > 1 )
2050 console.log( this.classNm+": "+methName+": Sample[vnfc-type]:["+
2051 this.Sample['vnfc-type']+"]");
2052 if( vnfctp != null && vnfctp.length > 0 ) {
2053 if( this.vnfcIdentifier != null && this.vnfcIdentifier.length > 0 ) {
2055 this.classNm+": "+methName+": compare non empty VNFC Types...");
2056 if( vnfctp != this.vnfcIdentifier ) {
2057 if( this.utilityService.getTracelvl() > 0 )
2058 console.log( this.classNm+": "+methName+": Non-match WARNING !");
2059 //.. display in pop-up
2060 this.nService.warn( 'WARNING',
2061 "The specified VNFC Types don't match."+
2062 " Can cause discrepancy in the artifacts.", this.options );
2064 if( this.utilityService.getTracelvl() > 0 )
2065 console.log(this.classNm+": checkVnfcTypeEqual: VNFC Types're equal.");
2071 //.. populating VNFC Type in Sample fields
2072 setVnfcTypeInSample( vnfctp: string ) {
2073 //clear vnfc information samples
2074 this.clearVnfcData();
2076 if( this.utilityService.getTracelvl() > 0 )
2077 console.log( this.classNm+": setVnfcTypeInSample: vnfctp:["+vnfctp+"]");
2078 this.Sample['vnfc-type']= vnfctp;
2082 * Procesess reference data after retrieval from appc or after a reference file has been uploaded from PC.
2084 processReferenceDataAfterRetrieval() {
2085 if( this.utilityService.getTracelvl() > 0 )
2086 console.log( this.classNm+": processReferenceDataAfterRetr: start...");
2087 if (this.referenceDataObject.action === 'OpenStack Actions') {
2088 this.deviceProtocols = ['', 'OpenStack'];
2089 this.buildDesignComponent.tabs = this.referencDataTab;
2091 this.buildDesignComponent.tabs = this.allTabs;
2093 if( this.utilityService.getTracelvl() > 1 )
2094 console.log( this.classNm+": processReferenceDataAfterRetr: done.");
2095 if( this.utilityService.getTracelvl() > 0 )
2096 console.log( this.classNm+": vnfcIdentifier:["+this.vnfcIdentifier+"]");
2097 if( this.utilityService.getTracelvl() > 1 )
2098 console.log( this.classNm+": oldVnfcIdentifier:["+
2099 this.oldVnfcIdentifier+"]");
2100 if( this.utilityService.getTracelvl() > 0 )
2101 console.log( this.classNm+": refDataObj.scope.vnfc-type:["+
2102 this.referenceDataObject.scope['vnfc-type']+"]");
2103 this.setVnfcTypeInSample( this.vnfcIdentifier );