Resolved the issues with configscaleout
[appc/cdt.git] / src / app / vnfs / build-artifacts / reference-dataform / reference-dataform.component.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
6
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
11
12     http://www.apache.org/licenses/LICENSE-2.0
13
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.
19 ============LICENSE_END============================================
20 */
21
22 import * as XLSX from 'xlsx';
23 import * as _ from 'underscore';
24 import { ActivatedRoute, Router } from '@angular/router';
25 import { Component, OnInit, ViewChild } from '@angular/core';
26 import { BuildDesignComponent } from '../build-artifacts.component';
27 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
28 import { Location } from '@angular/common';
29 import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
30 import { ModalComponent } from '../../../shared/modal/modal.component';
31 import { NgProgress } from 'ngx-progressbar';
32 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
33 import { NotificationService } from '../../../shared/services/notification.service';
34 import { NotificationsService } from 'angular2-notifications';
35 import { ParamShareService } from '../../..//shared/services/paramShare.service';
36 import { environment } from '../../../../environments/environment';
37 import { saveAs } from 'file-saver';
38 declare var $: any;
39 type AOA = Array<Array<any>>;
40
41 @Component({
42     selector: 'reference-dataform',
43     templateUrl: './reference-dataform.component.html',
44     styleUrls: ['./reference-dataform.component.css']
45 })
46 export class ReferenceDataformComponent implements OnInit {
47     @ViewChild(ModalComponent) modalComponent: ModalComponent;
48     public showUploadStatus: boolean = false;
49     public fileUploaded: boolean = false;
50     public uploadedData: any;
51     public statusMsg: string;
52     public uploadStatus: boolean = false;
53     public isCollapsedContent: boolean = true;
54     public vnfcCollLength: number = 0;
55     public vfncCollection = [];
56     public userForm: any;
57     public actionType: any;
58     numberTest: RegExp = /^[^.a-z]+$/;
59     public numberOfVmTest: boolean = true;
60     public tempAllData = [];
61     disableGrpNotationValue: boolean;
62     public noRefData = false;
63     public disableRetrieve = false;
64     public getRefStatus = false;
65     public uploadStatusError: boolean;
66     public showUploadErrorStatus: boolean;
67     public noData: string;
68     selectedActions = [];
69     public appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
70     public downloadData = {
71         reference: {},
72         template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
73         pd: { pdData: '', pdFileName: '' }
74     };
75     fileName: any;
76     public uploadFileName: any;
77     public addVmClickedFlag: boolean = false;
78     public getExcelUploadStatus: boolean = false;
79     public uploadedDataArray: any;
80     public actionFlag = false;
81     currentAction: any;
82     oldAction: any;
83     nonConfigureAction: any;
84     templateId;
85     templateIdentifier;
86     public actionLevels = [
87         'vnfc', 'vnf'
88     ];
89
90     identifierDrp: any;
91     identifierDrpValues: any = [];
92     //settings for the notifications.
93     options = {
94         timeOut: 1000,
95         showProgressBar: true,
96         pauseOnHover: true,
97         clickToClose: true,
98         maxLength: 200
99     };
100     //initializing this object to contain all the parameters to be captured
101     public referenceDataObject = {
102         action: '',
103         'action-level': 'vnf',
104         scope: { 'vnf-type': '', 'vnfc-type': '' },
105         'template': 'Y',
106         vm: [],
107         'device-protocol': '',
108         'user-name': '',
109         'port-number': '',
110         'artifact-list': []
111     };
112     public refernceScopeObj = { sourceType: '', from: '', to: '' };
113     public actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
114     public groupAnotationValue = ['', 'Pair'];
115     public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
116     public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
117     public deviceTemplates = ['', 'Y', 'N'];
118     public sourceTypeColl = ['', 'vnfType', 'vnfcType'];
119     public ipAddressBoolean = ['', 'Y', 'N'];
120     public Sample: any = {
121         'vnfc-instance': '1',
122         'vnfc-function-code': '',
123         'ipaddress-v4-oam-vip': '',
124         'group-notation-type': '',
125         'group-notation-value': ''
126     };
127     hideModal: boolean = false;
128     public self: any;
129     public uploadTypes = [{
130         value: 'Reference Data',
131         display: 'Sample Json Param File'
132     },
133     {
134         value: 'Mapping Data',
135         display: 'Sample Json Param File'
136     }
137     ];
138     public selectedUploadType: string = this.uploadTypes[0].value;
139     public vnfcTypeData: string = '';
140     public title: string;
141     public allowAction: boolean = true;
142     public actionExist: boolean = false;
143     public disableVnftype: boolean = false;
144     public otherActions: boolean = false;
145     public actionHealthCheck: boolean = false;
146     public actionChanged: boolean = false;
147     public initialAction: string = '';
148     public noCacheData: boolean;
149     public updateParams: any;
150     public vnfParams: any;
151     public firstArrayElement = [];
152     public remUploadedDataArray = [];
153     isConfigScaleOut = false
154
155     constructor(private buildDesignComponent: BuildDesignComponent, private httpUtils: HttpUtilService, private route: Router, private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService,
156         private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService, private ngProgress: NgProgress) {
157     }
158
159     ngOnInit() {
160         this.self = this;
161         let path = this.location.path;
162         this.title = 'Reference Data';
163         this.referenceDataObject = {
164             action: '',
165             'action-level': 'vnf',
166             scope: { 'vnf-type': '', 'vnfc-type': '' },
167             'template': 'Y',
168             vm: [],
169             'device-protocol': '',
170             'user-name': '',
171             'port-number': '',
172             'artifact-list': []
173         };
174         this.updateParams = sessionStorage.getItem('updateParams');
175         let cacheData = this.mappingEditorService.referenceNameObjects;
176         if (cacheData != undefined && cacheData != null && cacheData.length > 0) {
177             this.tempAllData = cacheData;
178             // console.log("latest action")
179             // console.log(this.mappingEditorService.latestAction)
180             if (this.mappingEditorService.latestAction != undefined) {
181                 this.referenceDataObject = this.mappingEditorService.latestAction;
182                 this.toggleIdentifier(this.referenceDataObject.action);
183                 //this.referenceDataObject['template-id-list'] = this.mappingEditorService.identifier
184                 //use these commented objects to be used in template and pd pages
185                 //this.templateIdentifier = this.mappingEditorService.identifier
186                 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
187                 this.oldAction = this.referenceDataObject.action;
188                 this.populateExistinAction(this.referenceDataObject.action);
189             }
190         } else if (this.updateParams != 'undefined') {
191             this.getArtifact();
192         }
193         var appData = this.mappingEditorService.appDataObject;
194         if (appData != null || appData != undefined) this.appData = appData;
195         var downloadData = this.mappingEditorService.downloadDataObject;
196         if (downloadData != null || downloadData != undefined) this.downloadData = downloadData;
197         this.vnfParams = JSON.parse(sessionStorage.getItem('vnfParams'));
198         if (this.vnfParams && this.vnfParams.vnfType) {
199             this.referenceDataObject['scope']['vnf-type'] = this.vnfParams.vnfType;
200         }
201         if (this.vnfParams && this.vnfParams.vnfcType) {
202             this.referenceDataObject['scope']['vnfc-type'] = this.vnfParams.vnfcType;
203         }
204         this.uploadedDataArray = [];
205         this.remUploadedDataArray = [];
206         this.firstArrayElement = [];
207         this.uploadFileName = '';
208         this.templateIdentifier = this.mappingEditorService.identifier
209         //this.tempAllData = [];
210     }
211     toggleIdentifier(data) {
212         if (data == 'ConfigScaleOut') {
213             this.isConfigScaleOut = true
214
215         } else {
216             this.isConfigScaleOut = false
217         }
218     }
219
220     //to retrive the data from appc and assign it to the vaiables, if no data display the message reterived from the API
221     getArtifact() {
222         try {
223             let payload = JSON.parse(sessionStorage.getItem('updateParams'));
224             payload['userID'] = localStorage['userId'];
225             payload = JSON.stringify(payload);
226             let data = {
227                 'input': {
228                     'design-request': {
229                         'request-id': localStorage['apiToken'],
230                         'action': 'getArtifact',
231                         'payload': payload
232                     }
233                 }
234             };
235             this.ngProgress.start();
236             this.httpUtils.post({
237                 url: environment.getDesigns,
238                 data: data
239             }).subscribe(resp => {
240                 if (resp.output.data.block != undefined) {
241                     this.nService.success('Status', 'data fetched ');
242                     let artifactInfo = JSON.parse(resp.output.data.block).artifactInfo[0];
243                     let reference_data = JSON.parse(artifactInfo['artifact-content'])['reference_data'][0];
244                     this.referenceDataObject = reference_data;
245                     // console.log('reference data obj==' + JSON.stringify(this.referenceDataObject));
246                     this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
247                     this.mappingEditorService.getReferenceList().push(JSON.parse(artifactInfo['artifact-content']));
248                     this.tempAllData = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
249                     this.oldAction = this.referenceDataObject.action;
250                     if (this.referenceDataObject.action === 'OpenStack Actions') {
251                         this.deviceProtocols = ['', 'OpenStack'];
252                         this.buildDesignComponent.tabs = [
253                             {
254
255                                 name: 'Reference Data',
256                                 url: 'references',
257                             }];
258                     }
259                     else {
260                         this.buildDesignComponent.tabs = [
261                             {
262                                 name: 'Reference Data',
263                                 url: 'references',
264                             }, {
265                                 name: 'Template',
266                                 url: 'templates/myTemplates',
267                             }, {
268                                 name: 'Parameter Definition',
269                                 url: 'parameterDefinitions/create'
270                             }/*, {
271                                 name: "Test",
272                                 url: 'test',
273                             }*/
274                         ];
275                     }
276                     // console.log('tempalldata===' + JSON.stringify(this.tempAllData));
277                 } else {
278                     this.nService.success('Status', 'Sorry !!! I dont have any artifact Named : ' + (JSON.parse(payload))['artifact-name']);
279                 }
280                 this.ngProgress.done();
281             });
282         }
283         catch (e) {
284             this.nService.warn('status', 'error while reteriving artifact');
285         }
286         setTimeout(() => {
287             this.ngProgress.done();
288         }, 3500);
289     }
290
291     //reinitializing the required values
292     ngOnDestroy() {
293         let referenceObject = this.prepareReferenceObject();
294         this.mappingEditorService.changeNavAppData(this.appData);
295         this.mappingEditorService.changeNavDownloadData(this.downloadData);
296         this.uploadedDataArray = [];
297         this.remUploadedDataArray = [];
298         this.firstArrayElement = [];
299         this.uploadFileName = '';
300     }
301
302     numberValidation(event: any) {
303         // // console.log(this.numberTest.test(event));
304         if (this.numberTest.test(event) && event != 0) {
305             this.numberOfVmTest = true;
306         }
307         else {
308             this.numberOfVmTest = false;
309         }
310     }
311
312     updateSessionValues(event: any, type: string) {
313         if (type === 'action') {
314             sessionStorage.setItem('action', event);
315         }
316         if (type === 'vnfType') {
317             sessionStorage.setItem('vnfType', event);
318         }
319     }
320
321     addVnfcData(vmNumber: number) {
322         var newObj = {
323             'vnfc-instance': this.referenceDataObject.vm[vmNumber].vnfc.length + 1,
324             'vnfc-type': this.vnfcTypeData,
325             'vnfc-function-code': '',
326             'ipaddress-v4-oam-vip': '',
327             'group-notation-type': '',
328             'group-notation-value': ''
329         };
330         this.referenceDataObject.vm[vmNumber].vnfc.push(newObj);
331     }
332
333     //to remove the VM's created by the user
334     removeFeature(vmNumber: any, index: any,templateId) {
335         if(this.referenceDataObject.action == "Configure"){
336             this.referenceDataObject.vm.splice(vmNumber, 1);
337             this.referenceDataObject.vm.forEach((obj,arrIndex)=>{
338                 if(arrIndex>=vmNumber){
339                     obj["vm-instance"] = obj["vm-instance"]-1
340                 }
341             })
342             console.log(this.referenceDataObject.vm)
343         } else{
344             let data = this.referenceDataObject.vm.filter(obj=>{
345                 return obj['template-id'] == templateId;
346             })
347             this.referenceDataObject.vm.splice(data[index]['vm-instance'], 1);
348             this.referenceDataObject.vm.forEach((obj,arrIndex)=>{
349                 
350                     obj["vm-instance"] = arrIndex+1
351             })
352         }
353         
354     }
355
356     //add new VM's to the configure
357     addVms() {
358         let arr = [];
359         var vnfcObj = JSON.parse(JSON.stringify(this.Sample));
360         let mberOFVm = Number(this.refernceScopeObj.from);
361         let arrlength = this.referenceDataObject.vm.length;
362         mberOFVm = arrlength + mberOFVm;
363         for (var i = (arrlength); i < mberOFVm; i++) {
364             if (this.referenceDataObject.action == 'ConfigScaleOut') {
365                 arr.push({ 'template-id': this.templateIdentifier, 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
366             } else {
367                 arr.push({ 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
368             }
369         }
370         //this.referenceDataObject.vm.splice(arrlength, 0, ...arr);
371         this.referenceDataObject.vm = this.referenceDataObject.vm.concat(arr); //splice(arrlength, 0, ...arr);
372     }
373
374     //Reference object to create reference data
375     prepareReferenceObject(isSaving?:any){
376         let scopeName = this. resetParamsOnVnfcType(); 
377         let extension =  this.decideExtension();
378         this.prepareArtifactList(scopeName,extension);
379
380         if (this.referenceDataObject.action === 'OpenStack Actions') {
381             this.referenceDataObject['template'] = 'N';
382             this.referenceDataObject['artifact-list'] = [];
383         }
384         //ditaching the object from the form and processing pfurther
385         let newObj = $.extend(true, {}, this.referenceDataObject);
386         let action = this.referenceDataObject.action;
387         //preparing Obj for save/download
388         newObj =   this.deleteVmsforNonActions(newObj,action)
389         this.pushOrReplaceTempData(newObj,action);
390         this. addAllActionObj(newObj,scopeName);
391         this.resetTempData()
392         //saving data to service
393         this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
394         this.buildDesignComponent.updateAccessUpdatePages(this.referenceDataObject.action, this.mappingEditorService.getReferenceList());
395         this.mappingEditorService.changeNav(this.tempAllData);
396         //on action change or template identifier change reset the form by restting values of Reference data object
397         this.resetVmsForScaleout(this.currentAction)
398         return { totlaRefDtaa: this.tempAllData, scopeName: scopeName };
399     }
400
401     public checkIfelementExistsInArray(element, array) {
402         //// console.log("Element==" + element)
403         var result: boolean = false;
404
405         array.forEach(function (item) {
406             // // console.log("Item==" + item)
407             if (element === item) {
408                 // console.log('Element==' + element + 'Item==' + item);
409                 result = true;
410             }
411         }
412         );
413         return result;
414     }
415
416     upload(evt: any) {
417         /*  // console.log("This uploaded array==" + JSON.stringify(this.uploadedDataArray))
418           // // console.log("This template data before==" + JSON.stringify(this.tempAllData))
419           if (this.uploadedDataArray && this.uploadedDataArray != undefined && this.uploadedDataArray.length!=0) {
420               /*  for (var i = 0; i < this.uploadedDataArray.length; i++) {
421                     var action = this.uploadedDataArray[i][0];
422                     for (var j = 0; j < this.tempAllData.length; j++) {
423                         if (action === this.tempAllData[j].action) {
424                             this.tempAllData.splice(j);
425                             // console.log("This template data===" + this.tempAllData[j]);
426                         }
427                     }
428                 }
429                if (this.tempAllData && this.tempAllData != undefined) {
430                   for (var i = 0; i < this.tempAllData.length; i++) {
431                       // alert(this.checkIfelementExistsInArray(this.tempAllData[i].action,this.actions))
432                       var result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
433                       if (this.tempAllData[i].action === "AllAction") result = true;
434                       if (!result) {
435                           // console.log("Removing VM action==" + this.tempAllData[i].action)
436                           this.tempAllData.splice(i, 1);
437                       }
438      
439                   }
440               }
441           }
442           // // console.log("This template data after==" + JSON.stringify(this.tempAllData))
443           /* wire up file reader */
444         const target: DataTransfer = <DataTransfer>(evt.target);
445         //// console.log("filename========" + evt.target.files[0].name)
446         this.uploadFileName = evt.target.files[0].name;
447         var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
448         if (target.files.length != 1) {
449             throw new Error('Cannot upload multiple files on the entry');
450         }
451         if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') {
452             const reader = new FileReader();
453             reader.onload = (e: any) => {
454                 /* read workbook */
455                 const bstr = e.target.result;
456                 //      // console.log("print 1---" + bstr);
457                 const wb = XLSX.read(bstr, { type: 'binary' });
458                 //    // console.log("print 2---" + JSON.stringify(wb));
459                 /* grab first sheet */
460                 const wsname = wb.SheetNames[0];
461                 //  // console.log("Name:---" + wsname);
462                 const ws = wb.Sheets[wsname];
463
464                 /* save data */
465
466                 let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
467                 //// console.log("row======" + (XLSX.utils.sheet_to_json(ws, { header: 1 })).toString())
468                 // // console.log("Array data---" + JSON.stringify(arrData));
469                 this.uploadedDataArray = arrData;
470                 this.firstArrayElement = arrData[0];
471                 var remUploadedDataArray = arrData;
472                 remUploadedDataArray.shift();
473                 this.remUploadedDataArray = remUploadedDataArray;
474                 if (arrData != null) {
475                     this.getExcelUploadStatus = true;
476                     this.nService.success('Success', 'Vm capabilities data uploaded successfully');
477
478                 }
479                 else {
480                     this.nService.success('Error', 'Empty Vm capabilities file uploaded');
481                 }
482             };
483             reader.readAsBinaryString(target.files[0]);
484             // console.log('TARGET files---' + JSON.stringify(evt.target));
485         }
486         else {
487             this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
488         }
489
490     }
491
492     addVmCapabilitiesData() {
493         for (var i = 0; i < this.uploadedDataArray.length; i++) {
494             var vnfcFuncCodeArray = [];
495             var data = this.uploadedDataArray[i];
496             for (var j = 1; j < data.length; j++) {
497                 // // console.log("Data " +j +" is "+ JSON.stringify(data[j]))
498                 if (data[j] != undefined) {
499                     if (data[j].toUpperCase() === 'Y') {
500                         vnfcFuncCodeArray.push(this.firstArrayElement[j]);
501                         //vnfcFuncCodeArray.push({name:this.firstArrayElement[j]});
502                     }
503                 }
504             }
505             var action = this.uploadedDataArray[i][0];
506             if (action && action != undefined) {
507                 var json = {
508                     'action': action,
509                     'action-level': 'vm',
510                     'scope': {
511                         'vnf-type': this.referenceDataObject['scope']['vnf-type'], //need to confirm what should be this value
512                         'vnfc-type': null
513                     },
514                     'vnfc-function-code-list': vnfcFuncCodeArray,
515                     'template': 'N',
516                     'device-protocol': 'OS'
517                 };
518
519                 this.tempAllData.push(json);
520             }
521
522         }
523     }
524
525     //download template
526     save(form: any, isValid: boolean) {
527         if (this.referenceDataObject.action === '') {
528             this.nService.error('Error', 'Select a valid Action');
529             return;
530         }
531         if (this.referenceDataObject['device-protocol'] === '') {
532             this.nService.error('Error', 'Select a valid Device protocol');
533             return;
534         }
535
536         if (isValid) {
537             let referenceObject = this.prepareReferenceObject();
538             let theJSON = JSON.stringify({ 'reference_data': this.tempAllData }, null, '\t');
539             let uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(theJSON);
540             this.downloadData.reference = theJSON;
541             this.validateTempAllData();
542             var blob = new Blob([theJSON], {
543                 type: 'text/plain'
544             });
545             let fileName = 'reference_AllAction_' + referenceObject.scopeName + '_' + '0.0.1V.json';
546             saveAs(blob, fileName);
547             var templateData = JSON.stringify(this.downloadData.template.templateData);
548             var nameValueData = JSON.stringify(this.downloadData.template.nameValueData);
549             var pdData = this.downloadData.pd.pdData;
550             if (templateData != '{}' && templateData != null && templateData != undefined) this.downloadTemplate();
551             if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.downloadNameValue();
552             if (pdData != '' && pdData != null && pdData != undefined) this.downloadPd();
553         }
554     }
555
556     downloadTemplate() {
557         var fileName = this.downloadData.template.templateFileName;
558         var theJSON = this.downloadData.template.templateData;
559         if (fileName != null || fileName != '') {
560             var fileExtensionArr = fileName.split('.');
561             var blob = new Blob([theJSON], {
562                 type: 'text/' + fileExtensionArr[1]
563             });
564             saveAs(blob, fileName);
565         }
566     }
567
568     downloadNameValue() {
569         var fileName = this.downloadData.template.nameValueFileName;
570         var theJSON = this.downloadData.template.nameValueData;
571         var blob = new Blob([theJSON], {
572             type: 'text/json'
573         });
574
575         saveAs(blob, fileName);
576     }
577
578     downloadPd() {
579         let fileName = this.downloadData.pd.pdFileName;
580         let theJSON = this.downloadData.pd.pdData;
581         var blob = new Blob([theJSON], {
582             type: 'text/plain'
583         });
584
585         saveAs(blob, fileName);
586     }
587
588     saveToAppc(valid, form,event) {
589         if (this.referenceDataObject.action === '') {
590             this.nService.error('Error', 'Select a valid Action');
591             return;
592         }
593         if (this.referenceDataObject['device-protocol'] === '') {
594             this.nService.error('Error', 'Select a valid Device protocol');
595             return;
596         }
597
598         try {
599             form._submitted = true;
600             if (valid) {
601
602                 let referenceObject = this.prepareReferenceObject(true);
603                 this.validateTempAllData();
604                 let theJSON = JSON.stringify(this.tempAllData, null, '\t');
605                 let fileName = 'reference_AllAction_' + referenceObject.scopeName + '_' + '0.0.1V.json';
606                 this.uploadArtifact(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
607                 var templateData = JSON.stringify(this.appData.template.templateData);
608                 var nameValueData = JSON.stringify(this.appData.template.nameValueData);
609                 var pdData = JSON.stringify(this.appData.pd);
610                 if (templateData != '{}' && templateData != null && templateData != undefined) this.saveTemp();
611                 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.saveNameValue();
612                 if (pdData != '{}' && pdData != null && pdData != undefined) this.savePd();
613                 if (this.actionChanged) {
614                     this.referenceDataObject.action = this.currentAction;
615                     this.populateExistinAction(this.referenceDataObject.action);
616                     this.actionChanged = false;
617                 }
618             }
619         }
620         catch (e) {
621             this.nService.warn('status', 'unable to save the artifact');
622         }
623     }
624
625     validateTempAllData() {
626         if (this.tempAllData) {
627             var updatedData = [];
628             this.tempAllData.forEach(data => {
629                 if (data.action) {
630                     updatedData.push(data);
631                 }
632             });
633             this.tempAllData = updatedData;
634         }
635     }
636
637     appendSlashes(artifactData) {
638         return artifactData.replace(/"/g, '\\"');
639     }
640
641     uploadArtifact(artifactData, dataJson, fileName) {
642         let data = [];
643         let slashedPayload = this.appendSlashes(artifactData);
644         let newPyaload = '{"userID": "' + localStorage['userId'] + '","vnf-type" : "' + dataJson['scope']['vnf-type'] + '","action" : "AllAction","artifact-name" : "' + fileName + '","artifact-type" : "APPC-CONFIG","artifact-version" : "0.1","artifact-contents" :" ' + slashedPayload + '"}';
645         let payload = {
646             'input': {
647                 'design-request': {
648                     'request-id': localStorage['apiToken'],
649                     'action': 'uploadArtifact',
650                     'payload': newPyaload,
651                 }
652             }
653         };
654         this.ngProgress.start();
655         this.httpUtils.post({
656             url: environment.getDesigns,
657             data: payload
658         }).subscribe((resp) => {
659             if (resp != null && resp.output.status.code == '400') {
660                 window.scrollTo(0, 0);
661                 this.nService.success('Status', 'successfully uploaded the Reference Data');
662             } else {
663                 this.nService.warn('Status', 'Error while saving Reference Data');
664             }
665             this.uploadStatusError = false;
666             this.getRefStatus = false;
667             this.ngProgress.done();
668         }, (err) => {
669             this.nService.error('Status', 'Error Connecting to the APPC Network');
670             window.scrollTo(0, 0);
671         });
672         this.appData.reference = payload;
673         setTimeout(() => {
674             this.ngProgress.done();
675         }, 3500);
676     }
677
678     retriveFromAppc() {
679         if (sessionStorage.getItem('updateParams') != 'undefined') {
680             this.getArtifact();
681             this.noCacheData = false;
682         } else {
683             this.noCacheData = true;
684         }
685     }
686
687     cloneMessage(servermessage) {
688         var clone = {};
689         for (var key in servermessage) {
690             if (servermessage.hasOwnProperty(key)) //ensure not adding inherited props
691                 clone[key] = servermessage[key];
692         }
693         return clone;
694     }
695
696     public showUpload() {
697         this.selectedUploadType = this.uploadTypes[0].value;
698     };
699
700     public fileChange(input) {
701         this.fileName = input.target.files[0].name.replace(/C:\\fakepath\\/i, '');
702         this.fileUploaded = true;
703         this.disableRetrieve = true;
704         if (input.target.files && input.target.files[0]) {
705             // Create the file reader
706             let reader = new FileReader();
707             this.readFile(input.target.files[0], reader, (result) => {
708                 // After the callback fires do:
709                 if ('Reference Data' === this.selectedUploadType) {
710                     try {
711                         let obj: any;
712                         let jsonObject = (JSON.parse(result))['reference_data'];
713                         this.uploadedData = JSON.parse(JSON.stringify(jsonObject));
714                         this.tempAllData = JSON.parse(JSON.stringify(jsonObject));
715                         this.notificationService.notifySuccessMessage('Reference Data file successfully uploaded..');
716                         if (jsonObject instanceof Array) {
717                             this.referenceDataObject = jsonObject[0];
718                             jsonObject.forEach(obj => {
719                                 this.selectedActions.push(obj.action);
720                             });
721                         } else {
722                             this.referenceDataObject = jsonObject;
723                             this.selectedActions.push(jsonObject.action);
724                         }
725                         if (this.referenceDataObject.action === 'OpenStack Actions') {
726                             this.deviceProtocols = ['', 'OpenStack'];
727                             this.buildDesignComponent.tabs = [
728                                 {
729                                     type: 'dropdown',
730                                     name: 'Reference Data',
731                                     url: 'references',
732                                 }];
733                         }
734                         else {
735                             this.buildDesignComponent.tabs = [
736                                 {
737                                     name: 'Reference Data',
738                                     url: 'references',
739                                 }, {
740                                     name: 'Template',
741                                     url: 'templates/myTemplates',
742                                 }, {
743                                     name: 'Parameter Definition',
744                                     url: 'parameterDefinitions/create'
745                                 } /*, {
746         name: "Test",
747         url: 'test',
748       }*/
749                             ];
750                         }
751                         if (this.referenceDataObject.template == null) {
752                             this.referenceDataObject.template = 'Y';
753                         }
754                         if (this.referenceDataObject['action-level'] == null) {
755                             this.referenceDataObject['action-level'] = 'VNF';
756                         }
757                     } catch (e) {
758                         this.nService.error('Error', 'Incorrect file format');
759                     }
760                 }
761                 this.hideModal = true;
762             });
763         } else {
764             this.notificationService.notifyErrorMessage('Failed to read file..');
765         }
766
767     }
768
769     public readFile(file, reader, callback) {
770         // Set a callback funtion to fire after the file is fully loaded
771         reader.onload = () => {
772             // callback with the results
773             callback(reader.result);
774         };
775         this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size);
776         // Read the file
777         reader.readAsText(file, 'UTF-8');
778     }
779
780     fileChangeEvent(fileInput: any) {
781         let obj: any = fileInput.target.files;
782     }
783
784     clearVnfcData() {
785         this.Sample = {
786             'vnfc-instance': '1',
787             'vnfc-function-code': '',
788             'ipaddress-v4-oam-vip': '',
789             'group-notation-type': '',
790             'group-notation-value': ''
791         };
792     }
793
794     setVmInstance(index) {
795         this.referenceDataObject.vm[index]['vm-instance'] = index + 1;
796     }
797
798     setVnfcType(str: String) {
799         this.Sample['vnfc-type'] = str;
800     }
801
802     getChange(value: String) {
803         if (value === 'vnfType') {
804             this.referenceDataObject.scope['vnfc-type'] = '';
805         }
806     }
807
808     resetForm() {
809         this.referenceDataObject['action-level'] = 'vnf';
810         this.referenceDataObject.template = 'Y';
811         this.referenceDataObject['device-protocol'] = '';
812         this.referenceDataObject['user-name'] = '';
813         this.referenceDataObject['port-number'] = '';
814         this.refernceScopeObj.sourceType = '';
815         this.Sample['vnfc-type'] = '';
816     }
817
818     populateExistinAction(data) {
819         let existAction = this.tempAllData.findIndex(obj => {
820             return obj.action == data;
821         });
822         if (existAction > -1) {
823             let obj = $.extend(true, {}, this.tempAllData[existAction]);
824             this.referenceDataObject = obj;
825             this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type'];
826             this.referenceDataObject.scope['vnfc-type'] = obj['scope']['vnfc-type'];
827             this.referenceDataObject['device-protocol'] = obj['device-protocol'];
828             this.refernceScopeObj['sourceType'] = obj['scopeType'];
829         } else {
830             this.resetForm();
831             this.referenceDataObject.action = data;
832         }
833         //# iof healthCeck change deviceprotocol drp vaues
834         if (data == 'HealthCheck') {
835             this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST'];
836             this.actionHealthCheck = true;
837         } else if (data == 'UpgradeBackout' || data == 'ResumeTraffic' || data == 'QuiesceTraffic' || data == 'UpgradeBackup' || data == 'UpgradePostCheck' || data == 'UpgradePreCheck' || data == 'UpgradeSoftware' || data == 'ConfigBackup' || data == 'ConfigRestore' || data == 'StartApplication' || data == 'StopApplication' || data == 'GetRunningConfig') {
838             this.deviceProtocols = ['', 'CHEF', 'ANSIBLE'];
839         } else if (data == 'OpenStack Actions') {
840             this.deviceProtocols = ['', 'OpenStack'];
841         } else if (data == 'ConfigScaleOut') {
842             this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML','RESTCONF'];
843         }
844         else {
845             this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
846             this.actionHealthCheck = false;
847         }
848     }
849
850     //Modal pop up for action change with values entered.
851     actionChange(data, content, userForm) {
852         // this.actionChanged = true;
853         this.disableGrpNotationValue = false
854         if (data == null) {
855             return;
856         }
857         if ((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
858             this.actionChanged = true;
859             this.modalService.open(content).result.then(res => {
860                 if (res == 'yes') {
861                     this.currentAction = this.referenceDataObject.action;
862                     this.referenceDataObject.action = this.oldAction;
863                     $('#saveToAppc').click();//make sure the save all is done before the tempall obj is saved form the API
864                     this.toggleIdentifier(data)
865                     this.oldAction = this.currentAction;// this.referenceDataObject.action + '';
866                     this.referenceDataObject.action = this.currentAction
867
868                     this.populateExistinAction(data);
869                     if (this.oldAction === 'OpenStack Actions') {
870
871                         this.uploadedDataArray = [];
872                         this.remUploadedDataArray = [];
873                         this.firstArrayElement = [];
874                         this.uploadFileName = '';
875                         //this.tempAllData = [];
876                     }
877                     this.clearCache();
878                 } else {
879                     this.toggleIdentifier(data)
880                     this.currentAction = this.referenceDataObject.action;
881                     this.populateExistinAction(data);
882                     this.oldAction = this.referenceDataObject.action + '';
883                     this.clearCache();
884                 }
885             });
886         } else {
887             this.actionChanged = true;
888             this.oldAction = this.referenceDataObject.action + '';
889             this.populateExistinAction(data);
890             this.resetVmsForScaleout(data);
891             this.toggleIdentifier(data)
892         }
893
894         if (data == 'ConfigScaleOut') {
895             this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
896         }
897
898         if (data == 'OpenStack Actions') {
899             this.buildDesignComponent.tabs = [
900                 {
901                     type: 'dropdown',
902                     name: 'Reference Data',
903                     url: 'references',
904                 }];
905         }
906         else {
907             this.buildDesignComponent.tabs = [
908                 {
909                     name: 'Reference Data',
910                     url: 'references',
911                 }, {
912                     name: 'Template',
913                     url: 'templates/myTemplates',
914                 }, {
915                     name: 'Parameter Definition',
916                     url: 'parameterDefinitions/create'
917                 }/*, {
918                     name: "Test",
919                     url: 'test',
920                 }*/
921             ];
922         }
923         if (data == 'Configure' || data == 'ConfigModify') {
924             this.nonConfigureAction = false;
925         } else {
926             this.nonConfigureAction = true;
927         }
928     }
929     // For the issue with multiple template changes
930     // idChange(data, content, userForm) {
931     //     if (data == null) {
932     //     return;
933     //     }
934     //     if ((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
935     //     let referenceObject = this.prepareReferenceObject();
936     //     this.actionChanged = true;
937     //     if(this.templateIdentifier)
938     //     {
939     //     this.modalService.open(content).result.then(res => {
940     //     if (res == 'yes') {
941     //     this.validateTempAllData();
942     //     let theJSON = JSON.stringify(this.tempAllData, null, '\t');
943     //     let fileName = 'reference_AllAction_' + referenceObject.scopeName + '_' + '0.0.1V.json';
944     //     this.uploadArtifact(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
945     //     var templateData = JSON.stringify(this.appData.template.templateData);
946     //     var nameValueData = JSON.stringify(this.appData.template.nameValueData);
947     //     var pdData = JSON.stringify(this.appData.pd);
948     //     if (templateData != '{}' && templateData != null && templateData != undefined) this.saveTemp();
949     //     if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.saveNameValue();
950     //     if (pdData != '{}' && pdData != null && pdData != undefined) this.savePd();
951     //     this.clearTemplateCache();
952     //     this.clearPdCache();
953     //     }
954     //     else{
955     //     this.clearTemplateCache();
956     //     this.clearPdCache();
957     //     }
958     //     });
959     //     }
960     //     }
961     //     }
962
963     clearCache() 
964     {
965         // get the value and save the userid and persist it. 
966         this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
967         localStorage['paramsContent'] = '{}';
968         this.mappingEditorService.setParamContent(undefined);
969         this.paramShareService.setSessionParamData(undefined);
970         this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
971         this.downloadData = {
972             reference: {},
973             template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
974             pd: { pdData: '', pdFileName: '' }
975         };
976     }
977
978     // needed for the the clearing template cache.
979     //{
980     //     // get the value and save the userid and persist it.
981     //     this.clearTemplateCache();
982     //     this.clearPdCache();
983     //     this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
984     //     this.downloadData = {
985     //     reference: {},
986     //     template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
987     //     pd: { pdData: '', pdFileName: '' }
988     //     };
989     //     }
990         
991     //     clearTemplateCache()
992     //     {
993     //     this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
994     //     localStorage['paramsContent'] = '{}';
995     //     }
996     //     clearPdCache()
997     //     {
998     //     this.mappingEditorService.setParamContent(undefined);
999     //     this.paramShareService.setSessionParamData(undefined);
1000     //     }
1001
1002     saveTemp() {
1003         this
1004             .httpUtils
1005             .post(
1006                 { url: environment.getDesigns, data: this.appData.template.templateData })
1007             .subscribe(resp => {
1008                 if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
1009                     this.nService.success('Status', 'Successfully uploaded the Template Data');
1010                 }
1011                 if (resp.output.status.code === '401') {
1012                     this.nService.warn('Status', 'Error in saving the Template to Appc');
1013
1014                 }
1015             },
1016                 (err) => this.nService.error('Status', 'Error Connecting to the APPC Network'));
1017     }
1018
1019     saveNameValue() {
1020         this
1021             .httpUtils
1022             .post(
1023                 {
1024                     url: environment.getDesigns, data: this.appData.template.nameValueData
1025                 })
1026             .subscribe(resp => {
1027                 if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
1028                     this.nService.success('Status', 'Successfully uploaded the Name Value Pairs');
1029                 }
1030                 if (resp.output.status.code === '401') {
1031                     this.nService.warn('Status', 'Error in saving the Name value pairs to Appc');
1032                 }
1033             },
1034                 error => {
1035                     this.nService.error('Status', 'Error Connecting to the APPC Network');
1036                     return false;
1037                 });
1038     }
1039
1040     savePd() {
1041         this
1042             .httpUtils
1043             .post(
1044                 {
1045                     url: environment.getDesigns, data: this.appData.pd
1046                 })
1047             .subscribe(resp => {
1048                 if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
1049                     this.nService.success('Status', 'Successfully uploaded PD file');
1050                 }
1051                 if (resp.output.status.code === '401') {
1052                     this.nService.warn('Status', 'Error in saving the PD to Appc');
1053                 }
1054             },
1055                 error => {
1056                     this.nService.error('Status', 'Error Connecting to the APPC Network');
1057                     return false;
1058                 });
1059     }
1060
1061     openModel(toShow: any, message: any, title: any) {
1062         this.modalComponent.isShow = toShow;
1063         this.modalComponent.message = message;
1064         this.modalComponent.title = title;
1065     }
1066
1067     browseOption() {
1068         $('#inputFile').trigger('click');
1069     }
1070
1071     excelBrowseOption() {
1072         $('#excelInputFile').trigger('click');
1073     }
1074
1075     showIdentifier() {
1076         $('#identifierModal').modal();
1077     }
1078
1079     addToIdentDrp() {
1080         if (!(this.referenceDataObject['template-id-list'])) {
1081             this.referenceDataObject['template-id-list'] = [];
1082         }
1083         if(!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim())>-1)){
1084             this.referenceDataObject['template-id-list'].push(this.templateId.trim());
1085         }
1086     }
1087
1088     resetVms() {
1089         this.referenceDataObject.vm = [];
1090     }
1091
1092     dataModified() {
1093       //  this.referenceDataObject.vm = this.referenceDataObject.vm;
1094     }
1095
1096     resetGroupNotation() {
1097         if (this.Sample['group-notation-type'] == "existing-group-name") {
1098             this.Sample['group-notation-value'] = ""
1099
1100             this.disableGrpNotationValue = true
1101         } else {
1102             this.disableGrpNotationValue = false
1103         }
1104     }
1105
1106     resetVmsForScaleout(action){
1107          //reset currentform vms based on action
1108          if (action == "ConfigScaleOut") {
1109             let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
1110                 return obj['action'] ==action
1111             });
1112             if (ConfigScaleOutIndex > -1) {
1113                 this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
1114             } else {
1115                if(this.actionChanged ){
1116                this.referenceDataObject.vm = []
1117                }
1118               //  
1119             }
1120         }
1121     }
1122
1123      resetParamsOnVnfcType(){
1124     let scopeName = '';
1125         //if only vnf is there
1126         if (this.referenceDataObject.scope['vnfc-type'] == '' || this.referenceDataObject.scope['vnfc-type'] == null || this.referenceDataObject.scope['vnfc-type'] == 'null') {
1127             scopeName = this.referenceDataObject.scope['vnf-type'];
1128             this.referenceDataObject.scope['vnfc-type'] = '';
1129             this.referenceDataObject['action-level'] = 'vnf';
1130             this.referenceDataObject['scopeType'] = 'vnf-type';
1131         }
1132         //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  
1133         else {
1134             scopeName = this.referenceDataObject.scope['vnfc-type'];
1135             if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify') {
1136                 this.referenceDataObject['action-level'] = 'vnfc';
1137                 this.referenceDataObject['scopeType'] = 'vnfc-type';
1138             } else {
1139                 this.referenceDataObject['action-level'] = 'vnf';
1140                 this.referenceDataObject['scopeType'] = 'vnf-type';
1141             }
1142         }
1143           //replacing / with _ and removing spaces in the scopeName
1144          if (scopeName) {
1145             scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1146         }
1147         return scopeName
1148      }
1149     decideExtension(){
1150         //marking the extension based on the device-protocol selected by the user 
1151         let extension = 'json';
1152         if (this.referenceDataObject['device-protocol'] == 'ANSIBLE' || this.referenceDataObject['device-protocol'] == 'CHEF' || this.referenceDataObject['device-protocol'] == 'CLI') {
1153             extension = 'json';
1154         } else if (this.referenceDataObject['device-protocol'] == 'NETCONF-XML' || this.referenceDataObject['device-protocol'] == 'REST') {
1155             extension = 'xml';
1156         }
1157         return extension
1158     }
1159     prepareArtifactList(scopeName,extension){
1160     this.referenceDataObject['artifact-list'] = [];
1161
1162  //preparing the artifact list array file names along with extension
1163         let config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.' + extension;
1164         let pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
1165         let reference_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
1166
1167         let configTemplate = {
1168             'artifact-name': 'template_' + config_template_fileName,
1169             'artifact-type': 'config_template'
1170         };
1171
1172         let pdTemplate = {
1173             'artifact-name': 'pd_' + pd_fileName,
1174             'artifact-type': 'parameter_definitions'
1175         };
1176         if (this.referenceDataObject.action != 'ConfigScaleOut') {
1177
1178             this.referenceDataObject['artifact-list'].push(configTemplate,
1179                 pdTemplate
1180             );
1181
1182         } else {
1183             let identifiers = this.referenceDataObject['template-id-list'];
1184             if (identifiers) {
1185                 for (var x = 0; x < identifiers.length; x++) {
1186                     //for replacing spaces and "/" with "_"
1187                     identifiers[x]=identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1188                     pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V_' + identifiers[x] + '.yaml';
1189                     config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V_' + identifiers[x] + '.' + extension;
1190
1191                     configTemplate = {
1192                         'artifact-name': 'template_' + config_template_fileName,
1193                         'artifact-type': 'config_template'
1194                     };
1195                     pdTemplate = {
1196                         'artifact-name': 'pd_' + pd_fileName,
1197                         'artifact-type': 'parameter_definitions'
1198                     };
1199                     this.referenceDataObject['artifact-list'].push(configTemplate,
1200                         pdTemplate
1201                     );
1202                 }
1203             }
1204
1205         }
1206     }
1207     deleteVmsforNonActions(newObj,action){
1208  let configureObject = (action == 'Configure');
1209         let ConfigScaleOut = (action == 'ConfigScaleOut');
1210         //delete VM's if selected action is not configure.
1211         if (!ConfigScaleOut && !configureObject && this.tempAllData.length != 0) {
1212             //  delete newObj.vm
1213
1214             if (ConfigScaleOut) {
1215                 // 
1216             } else {
1217                 newObj.vm = [];
1218             }
1219             //this.tempAllData.push(newObj);
1220         } else {
1221             if (ConfigScaleOut) {
1222             } else {
1223                 delete newObj['template-id-list'];
1224             }
1225         }
1226         return newObj
1227     }
1228     pushOrReplaceTempData(newObj,action){
1229
1230         let actionObjIndex = this.tempAllData.findIndex(obj => {
1231             return obj['action'] == action;
1232         });
1233         if (newObj.action != 'HealthCheck') {
1234             delete newObj['url'];
1235         }
1236         
1237         if (actionObjIndex > -1) {
1238             this.tempAllData[actionObjIndex] = newObj;
1239             this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
1240             this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1241         } else {
1242             if (newObj.action != '') {
1243                 this.tempAllData.push(newObj);
1244                 this.mappingEditorService.saveLatestAction(newObj);
1245                 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1246             }
1247         }
1248         
1249     }
1250
1251     addAllActionObj(newObj,scopeName){
1252         
1253         //Creating all action block to allow mulitple actions at once
1254         let allAction = {
1255             action: 'AllAction',
1256             'action-level': 'vnf',
1257             scope: newObj.scope,
1258             'artifact-list': [{
1259                 'artifact-name': 'reference_AllAction' + '_' + scopeName + '_' + '0.0.1V.json',
1260                 'artifact-type': 'reference_template'
1261             }]
1262         };
1263         let allActionIndex = this.tempAllData.findIndex(obj => {
1264             return obj['action'] == 'AllAction';
1265         });
1266         if (allActionIndex > -1) {
1267             this.tempAllData[allActionIndex] = allAction;
1268         } else {
1269             this.tempAllData.push(allAction);
1270         }
1271     }
1272
1273     resetTempData(){
1274  if (this.uploadedDataArray && this.uploadedDataArray != undefined && this.uploadedDataArray.length != 0) {
1275            
1276             if (this.tempAllData && this.tempAllData != undefined) {
1277                 for (var i = 0; i < this.tempAllData.length; i++) {
1278                     // alert(this.checkIfelementExistsInArray(this.tempAllData[i].action,this.actions))
1279                     var result = false;
1280
1281                     if (this.tempAllData[i].action === 'AllAction') {
1282                         result = true;
1283                     }
1284                     else {
1285                         result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
1286                     }
1287                     if (!result) {
1288                         // console.log('Removing VM action==' + this.tempAllData[i].action);
1289                         this.tempAllData.splice(i, 1);
1290                         i = i - 1;
1291                     }
1292
1293                 }
1294             }
1295             this.addVmCapabilitiesData();
1296         }
1297     }
1298 }