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 { Component, Input, OnInit, ViewChild } from '@angular/core';
24 import { HttpUtilService } from '../../../../shared/services/httpUtil/http-util.service';
25 import { MappingEditorService } from '../../../../shared/services/mapping-editor.service';
26 import { ArtifactRequest } from '../../../../shared/models/index';
27 import { ActivatedRoute, Router } from '@angular/router';
28 import { saveAs } from 'file-saver';
29 import { NotificationService } from '../../../../shared/services/notification.service';
30 import { NotificationsService } from 'angular2-notifications';
31 import { ParamShareService } from '../../../../shared/services/paramShare.service';
32 import { DialogService } from 'ng2-bootstrap-modal';
33 import { ConfirmComponent } from '../../../../shared/confirmModal/confirm.component';
34 import { BuildDesignComponent } from '../../build-artifacts.component';
35 import { environment } from '../../../../../environments/environment';
36 import { ModalComponent } from 'ng2-bs3-modal/ng2-bs3-modal';
37 import { NgProgress } from 'ngx-progressbar';
38 import { UtilityService } from '../../../../shared/services/utilityService/utility.service';
39 import { APIService } from "../../../../shared/services/cdt.apicall";
40 import { ProcOnSrvSideSvc } from "../../../../shared/services/procOnSrvSide.service";
43 @Component({ selector: 'app-golden-configuration', templateUrl: './template-configuration.component.html', styleUrls: ['./template-configuration.component.css'] })
44 export class GoldenConfigurationComponent implements OnInit {
45 clName= "TemplateConfComp";
46 @ViewChild('templateeditor') templateeditor;
47 @Input() configMappingEditorContent: string;
48 @Input() isMappingComp: boolean;
49 @ViewChild('myInput') myInputVariable: any;
50 // @ViewChild(ModalComponent) modalComponent: ModalComponent;
51 @ViewChild('myModal') modal: ModalComponent;
54 showTemplateVersionDiv: any;
55 downloadedTemplateFileName: any;
56 downloadedParamFileName: any;
57 templateVersionNo: any = require('../../../../../cdt.application.properties.json').versionNoForApiCall;
58 saveToGuiCacheFlag = 'false';
60 public referenceData: Array<Object> = [];
61 public scopeName: any;
62 public subscription: any;
63 public item: any = {};
64 public goldenActions: Array<string> = [];
65 public refNameObj = {};
67 public artifactName = '';
69 public showError: boolean = false;
70 public tempretrieveFlag: boolean = false;
71 public fileNameForTempSave;
73 showDownloadDiv: boolean = false;
75 enableBrowse: boolean = true;
76 enableMerge: boolean = false;
77 uploadValidationSuccess: boolean = false;
78 apiToken = localStorage['apiToken'];
79 public appDataObject: any;
80 public downloadDataObject: any;
81 public checkNameEntered: boolean = true;
82 public selectedWord: any = this.mappingEditorService.getSelectedWord();
84 { action: "ConfigBackup", value: "ConfigBackup" },
85 { action: "ConfigModify", value: "ConfigModify" },
86 { action: "ConfigRestore", value: "ConfigRestore" },
87 { action: "Configure", value: "Configure" },
88 { action: "GetRunningConfig", value: "GetRunningConfig" },
89 { action: "HealthCheck", value: "HealthCheck" },
90 { action: "StartApplication", value: "StartApplication" },
91 { action: "StopApplication", value: "StopApplication" },
92 { action: "DistributeTraffic", value: "DistributeTraffic" }
97 showProgressBar: true,
103 public enableDownloadButtons: boolean = false;
106 private buildDesignComponent: BuildDesignComponent,
107 private apiService: APIService,
108 private utilityService: UtilityService,
109 private paramShareService: ParamShareService,
110 private dialogService: DialogService,
111 private notificationService: NotificationService,
112 private httpUtil: HttpUtilService,
113 private mappingEditorService: MappingEditorService,
114 private activeRoutes: ActivatedRoute,
115 private router: Router,
116 private nService: NotificationsService,
117 private procOnSrvSideSvc: ProcOnSrvSideSvc,
118 private ngProgress: NgProgress)
120 if( this.utilityService.getTracelvl() > 0 )
121 console.log( this.clName+": new: start.");
122 this.artifactRequest.action = '';
123 this.artifactRequest.version = '';
124 this.artifactRequest.paramsContent = '{}';
125 this.artifactRequest.paramKeysContent = '';
128 public templateEditor: any;
129 public fileType: any = '';
130 public actionType: any;
131 public myfileName: any;
132 userId = localStorage['userId'];
133 public artifactRequest: ArtifactRequest = new ArtifactRequest();
134 public showUploadStatus: boolean = false;
135 public uploadStatus: boolean = false;
136 public uploadTypes = [
138 value: 'Generated Template',
139 display: 'Sample Json Param File'
142 value: 'Mapping Data',
143 display: 'Sample Json Param File'
153 paramArtifactName: any;
154 enableValidateTemplate: boolean = false;;
155 public selectedUploadType: string = this.uploadTypes[0].value;
156 checkSpace: boolean = true;
158 public tempRetrievalResponse: any;
159 public mergeStatus: boolean = false;
160 //====================================================
162 var methName= "ngOnInit";
163 if( this.utilityService.getTracelvl() > 0 )
164 console.log( this.clName+": "+methName+": start.");
165 var refObj = this.refObj = this.prepareFileName();
166 // console.log("Ref object: " + JSON.stringify(refObj))
167 if (refObj && refObj != undefined) {
170 this.vnfType = this.item.vnf;
171 this.vnfcType = this.item.vnfc;
172 this.protocol = this.item.protocol;
173 this.action = this.item.action;
174 if( this.utilityService.getTracelvl() > 0 )
175 console.log( this.clName+": "+methName+": vnfType:["+this.vnfType+
176 "] vnfcType:["+this.vnfcType+"] protocol:["+this.protocol+"] action:["+
178 this.artifactName = this.item["template_artifact"]
179 this.paramArtifactName = this.item["param_artifact"]
180 this.artifactRequest.action = this.item.action;
181 this.artifactRequest.vnfType = this.vnfType;
182 if (this.vnfcType != undefined && this.vnfcType.length != 0) {
183 this.scopeName = this.vnfcType;
186 this.scopeName = this.vnfType;
190 if( this.utilityService.getTracelvl() > 0 )
191 console.log( this.clName+": "+methName+": refObj is not defined.");
192 this.item = { "action": "", "scope": { "vnf-type": "", "vnfc-type": "" }, "vm": [], "protocol": "", "download-dg-reference": "", "user-name": "", "port-number": "", "artifact-list": [], "deviceTemplate": "", "scopeType": "" };
194 this.initialAction = this.item.action;
195 this.activeRoutes.url.subscribe(UrlSegment => {
196 this.actionType = UrlSegment[0].path
198 this.mappingEditorService.fromScreen = 'MappingScreen';
201 //========================== End of ngOnInit() Method============================================
203 if( this.utilityService.getTracelvl() > 0 )
204 console.log( this.clName+": ngOnDestroy: start.");
205 if (this.refObj && this.refObj != undefined) {
206 if (this.configMappingEditorContent && this.configMappingEditorContent != undefined) {
208 this.prepareAppData();
209 this.prepareDownloadData();
210 this.mappingEditorService.changeNavAppData(this.appDataObject);
211 this.mappingEditorService.changeNavDownloadData(this.downloadDataObject);
214 if( this.utilityService.getTracelvl() > 0 )
215 console.log( this.clName+": ngOnDestroy: finish.");
217 //========================== End of ngOnDestroy() Method============================================
219 var methName= "ngAfterViewInit";
220 if( this.utilityService.getTracelvl() > 0 )
221 console.log( this.clName+": "+methName+": start.");
222 if (this.mappingEditorService.latestAction) {
223 this.refNameObj = this.mappingEditorService.latestAction;
224 if (this.vnfcType !== 'null') {
225 this.type = this.vnfcType;
228 this.type = this.vnfType;
232 this.templateEditor = self.templateeditor.getEditor();
233 this.templateeditor.getEditor().commands.addCommand({
234 name: 'annotateCommand',
235 bindKey: { win: 'ctrl-z', mac: 'Command-z' },
236 exec: (editor: any) => {
237 this.handleUndo(this.modal);
240 this.templateeditor.getEditor().commands.addCommand({
241 name: 'annotateCommandAlternate',
242 bindKey: { win: 'CTRL-4', mac: 'Command-4' },
243 exec: (editor: any) => {
244 this.checkNameEntered = true;
245 this.checkSpace = true;
246 this.handleAnnotation(this.modal);
249 if (this.mappingEditorService.fromScreen === 'MappingScreen') {
250 this.configMappingEditorContent = this.mappingEditorService.getTemplateMappingDataFromStore();
251 this.fileType = sessionStorage.getItem('fileType');
253 if (this.configMappingEditorContent) {
254 this.artifactRequest.templateContent = this.configMappingEditorContent;
255 this.mappingEditorService.initialise(this.templateeditor.getEditor(), this.artifactRequest.templateContent);
258 if (this.mappingEditorService.getTemplateMappingDataFromStore() &&
259 this.mappingEditorService.getTemplateMappingDataFromStore() != undefined) {
260 this.configMappingEditorContent = this.mappingEditorService.getTemplateMappingDataFromStore();
263 if (this.artifactName) this.retrieveTemplateFromAppc();
268 this.enableBrowse = false;
269 this.nService.error("Error",
270 "Please enter Action and VNF type in Reference Data screen", this.options);
274 //========================== End of ngAfterViewInit() Method============================================
276 $("#inputFile").trigger('click');
278 //========================== End of browseOption() Method============================================
279 public saveTemplate() {
280 var methName= "saveTemplate";
281 if( this.utilityService.getTracelvl() > 0 )
282 console.log( this.clName+": "+methName+": start.");
283 this.mappingEditorService.paramData = [];
284 if (this.configMappingEditorContent) {
285 if( this.utilityService.getTracelvl() > 0 )
286 console.log( methName+": do refreshEditor ...");
287 this.mappingEditorService.refreshEditor();
288 let paramArr: any = []
289 if (this.mappingEditorService.paramData && this.mappingEditorService.paramData != undefined) {
290 if (this.mappingEditorService.paramData.length === 0 && this.mappingEditorService.hasErrorCode === true) {
291 this.nService.error("Error", 'Special characters error', this.options);
295 this.showError = false;
298 this.mappingEditorService.setTemplateMappingDataFromStore(this.configMappingEditorContent);
301 //========================== End of saveTemplate() Method============================================
302 retrieveTemplateFromAppc() {
303 var methName= "retrieveTemplateFromAppc";
304 if( this.utilityService.getTracelvl() > 0 )
305 console.log( methName+": start ...");
306 let refObj = this.refObj;
307 if (refObj && refObj != undefined) {
308 let fileName = this.artifactName;
309 let input = this.utilityService.createPayloadForRetrieve(false, this.item.action, this.vnfType, fileName);
310 // console.log("Retrieve artifact payload=="+ payload);
311 let artifactContent: any;
312 this.ngProgress.start();
313 this.apiService.callGetArtifactsApi(input).subscribe(resp => {
314 if (resp.output.status.code === '400' && resp.output.status.message === "success") {
315 this.nService.success("Success","Template retrieved successfully from APPC", this.options);
316 this.tempRetrievalResponse = resp;
317 let result = JSON.parse(resp.output.data.block).artifactInfo[0];
318 result = result['artifact-content'];
319 this.configMappingEditorContent = result
320 this.mappingEditorService.initialise(this.templateeditor.getEditor(), this.artifactRequest.templateContent);
321 this.tempretrieveFlag = true;
322 this.fileNameForTempSave = fileName;
326 this.nService.info("Information","There is no template saved in APPC for the selected action!", this.options);
328 this.ngProgress.done();
330 error => this.nService.error("Error", "Error in connecting to APPC Server", this.options));
332 this.ngProgress.done();
336 //========================== End of retrieveTemplateFromAppc() Method============================================
338 var methName= "prepareAppData";
339 if( this.utilityService.getTracelvl() > 0 )
340 console.log( this.clName+": "+methName+": start.");
341 let refObj = this.refObj;
342 if (refObj && refObj != undefined) {
343 if( this.utilityService.getTracelvl() > 0 )
344 console.log( this.clName+": "+methName+": parse locStor.paramsContent");
345 let paramsKeyValueFromEditor: JSON;
347 paramsKeyValueFromEditor = JSON.parse(localStorage["paramsContent"]);
350 console.log(methName+": Could not parse name value pairs:" + error);
352 if (paramsKeyValueFromEditor) {
353 if( this.utilityService.getTracelvl() > 0 )
354 console.log( this.clName+": "+methName+
355 ": have paramsKeyValueFromEditor");
356 let action = this.item.action;
358 this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
360 fileName = this.paramArtifactName;
361 let Json = [paramsKeyValueFromEditor];
362 let slashedPayload = this.appendSlashes(JSON.stringify(Json));
364 this.utilityService.createPayLoadForSave("param_data", this.vnfType, action, fileName, this.templateVersionNo, slashedPayload);
365 this.appDataObject.template.nameValueData = data;
367 if (this.configMappingEditorContent) {
368 if( this.utilityService.getTracelvl() > 0 )
369 console.log( this.clName+": "+methName+
370 ": have configMappingEditorContent");
371 let actualContent = this.configMappingEditorContent;
372 this.mappingEditorService.generateTemplate(this.templateEditor);
373 let action = this.item.action;
374 let versionandFileType: any;
375 if (this.fileType === "text/xml") {
376 versionandFileType = this.templateVersionNo + 'V.xml'
378 versionandFileType = this.templateVersionNo + 'V.json'
381 if (this.tempretrieveFlag) {
382 fileName = this.fileNameForTempSave;
385 fileName = this.artifactName;
387 let vnfType = this.vnfType;
389 if( this.utilityService.getTracelvl() > 0 )
390 console.log( this.clName+": "+methName+
391 ": start replace: content length="+
392 this.configMappingEditorContent.length );
394 this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}');
395 if( this.utilityService.getTracelvl() > 0 )
396 console.log( this.clName+": "+methName+" replace done");
398 let data = this.utilityService.createPayLoadForSave("template_data", this.vnfType, action, fileName, this.templateVersionNo, replContent );
400 this.appDataObject.template.templateData = data;
401 if( this.utilityService.getTracelvl() > 0 )
402 console.log( this.clName+": "+methName+": initialise editor ...");
403 this.mappingEditorService.initialise(this.templateeditor.getEditor(), actualContent);
405 if( this.utilityService.getTracelvl() > 0 )
406 console.log( this.clName+": "+methName+": finish.");
409 //========================== End of prepareAppData() Method============================================
410 prepareFileName(): any {
411 let fileNameObject: any = this.mappingEditorService.newObject;
412 this.appDataObject = this.mappingEditorService.appDataObject;
413 this.downloadDataObject = this.mappingEditorService.downloadDataObject;
414 this.referenceData = fileNameObject;
415 return fileNameObject;
417 //========================== End of prepareFileName() Method============================================
418 onDownloadParameter() {
419 let refObj = this.refObj;
421 let paramsKeyValueFromEditor: JSON;
423 paramsKeyValueFromEditor = JSON.parse(localStorage["paramsContent"]);
426 console.log("Could not parse name value pairs==" + error);
428 let theJSON = JSON.stringify(paramsKeyValueFromEditor, null, "\t")
429 var blob = new Blob([theJSON], {
433 var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
434 fileName = this.paramArtifactName;
435 this.downloadDataObject.template.nameValueData = theJSON;
436 this.downloadDataObject.template.nameValueFileName = fileName;
439 this.nService.error("Error", "Please enter Action and VNF type in Reference Data screen", this.options);
443 //========================== End of onDownloadParameter() Method============================================
444 public onDownloadTemplate(artifact: string) {
445 var methName= "onDownloadTemplate";
446 if( this.utilityService.getTracelvl() > 0 )
447 console.log( methName+": start: artifact:["+artifact+"] fileType:["+
449 let actualContent = this.configMappingEditorContent;
450 var textToSaveAsBlob: any;
451 var config_template_fileName: any
452 let refObj = this.refObj;
453 let versionandFileType: string;
454 if (artifact == 'Template' && this.artifactRequest && this.configMappingEditorContent && refObj) {
455 if (this.fileType === "text/xml") {
456 textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
459 versionandFileType = this.templateVersionNo + 'V.xml'
461 if (this.fileType === "text/plain") {
462 textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
465 versionandFileType = this.templateVersionNo + 'V.txt'
467 if (this.fileType === "text/json") {
468 textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
471 versionandFileType = this.templateVersionNo + 'V.json'
473 if (this.tempretrieveFlag) {
474 config_template_fileName = this.fileNameForTempSave;
475 var filextension = config_template_fileName.substring(config_template_fileName.indexOf("V") + 2, config_template_fileName.length);
476 textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
477 type: "text/" + filextension
481 config_template_fileName = this.artifactName;
483 if( this.utilityService.getTracelvl() > 0 )
484 console.log( methName+": config_template_fileName:["+
485 config_template_fileName+"]");
486 this.mappingEditorService.initialise(this.templateeditor.getEditor(), actualContent);
487 if( this.utilityService.getTracelvl() > 0 )
488 console.log( methName+": start replacements in content");
489 this.downloadDataObject.template.templateData = this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}');
490 this.downloadDataObject.template.templateFileName = config_template_fileName;
491 if( this.utilityService.getTracelvl() > 0 )
492 console.log( methName+": finish.");
495 //========================== End of onDownloadTemplate() Method============================================
499 let refObj = this.refObj;
500 this.enableValidateTemplate = true;
502 if (refObj && refObj != undefined) {
503 // refObj = refObj[refObj.length - 1];
504 if (input.files && input.files[0]) {
505 //console.log("input files0" + JSON.stringify(input.files[0]))
506 this.myfileName = input.files[0].name;
507 this.fileName = input.files[0].name;
508 this.fileType = input.files[0].type;
509 // var fileExtension = this.myfileName.substr(this.myfileName.lastIndexOf('.') + 1);
511 let reader = new FileReader();
512 // if(this.validateUploadedFile(fileExtension))
514 this.readFile( input.files[0], reader, (result) => {
515 if (this.fileType === 'text/xml') {
516 sessionStorage.setItem('fileType', 'text/xml');
518 if (this.fileName.endsWith(".json")) {
519 this.fileType = "text/json";
520 sessionStorage.setItem('fileType', 'text/json');
522 if (this.fileType === '') {
523 sessionStorage.setItem('fileType', '');
526 if ('Generated Template' === this.selectedUploadType) {
527 this.configMappingEditorContent = result
528 this.artifactRequest.templateContent = this.configMappingEditorContent;
529 // console.log("editor content==" + JSON.stringify(this.configMappingEditorContent))
530 this.notificationService.notifySuccessMessage('Configuration Template file successfully uploaded..');
531 if (this.artifactRequest.templateContent) {
532 this.mappingEditorService.initialise(this.templateeditor.getEditor(), this.artifactRequest.templateContent);
535 this.enableDownloadButtons = true;
536 this.initialData = result;
538 this.templateeditor.getEditor().$enableBlockSelect = false;
539 this.templateeditor.getEditor().$enableMultiselect = false;
544 // this.nService.error("Error", "Incorrect File Format")
545 //this.configMappingEditorContent=''
549 this.nService.error("Error", "Failed to read file", this.options);
551 this.myInputVariable.nativeElement.value = "";
554 this.nService.error("Error", "Please enter Action and VNF type in Reference Data screen", this.options);
558 //========================== End of fileChange() Method============================================
559 public readFile(file, reader, callback) {
560 // Set a callback funtion to fire after the file is fully loaded
561 reader.onload = () => {
562 // callback with the results
563 callback(reader.result);
566 reader.readAsText(file, "UTF-8");
568 //========================== End of readFile() Method============================================
569 validateUploadedFile(fileExtension) {
571 if (fileExtension.toUpperCase() === 'json'.toUpperCase() || fileExtension.toUpperCase() === 'xml'.toUpperCase()) {
579 //========================== End of validateUploadedFile() Method============================================
580 appendSlashes(artifactData) {
581 let x = artifactData.replace(new RegExp(',"', "g"), ',\"');
582 let y = x.replace(new RegExp('":', 'g'), '\":');
583 let z = y.replace(new RegExp('{"', 'g'), '{\"')
584 let t = z.replace(new RegExp(':"', 'g'), ':\"')
585 let m = t.replace(new RegExp('",', 'g'), '\",');
586 let n = y.replace(new RegExp('"}', 'g'), '\"}')
587 let nw = n.replace(new RegExp('{"', 'g'), '{\"');
588 let nw1 = nw.replace(new RegExp(':"', 'g'), ':\"');
589 let nw2 = nw1.replace(new RegExp('",', 'g'), '\",');
592 //========================== End of appendSlashes() Method============================================
593 prepareDownloadData() {
594 if( this.utilityService.getTracelvl() > 0 )
595 console.log( this.clName+": prepareDownloadData: start.");
596 this.onDownloadParameter();
597 this.onDownloadTemplate('Template');
599 //========================== End of prepareDownloadData() Method============================================
600 syncTemplate( callOrig: string ) {
601 var methName= "syncTemplate";
602 if( this.utilityService.getTracelvl() > 0 )
603 console.log( methName+": start. callOrig:["+callOrig+"]");
604 if( callOrig == '0' ) {
605 if( this.utilityService.getTracelvl() > 0 )
606 console.log( methName+": this call is from HTML -start 1-st step.");
607 var ediContent= this.mappingEditorService.editor.session.getValue();
608 if( this.utilityService.getTracelvl() > 0 )
609 console.log( methName+": ediContent length="+ediContent.length );
610 if( this.utilityService.getTracelvl() > 1 )
611 console.log( methName+": ediContent(begin):["+
612 ediContent.substr(0,200)+"...]");
613 this.procOnSrvSideSvc.sendToSrv(
614 ediContent, this.mappingEditorService, this );
617 if( callOrig == '1' ) {
618 if( this.utilityService.getTracelvl() > 0 )
619 console.log( methName+": this call is from ProcOnSrvSideSvc -continue.");
620 // console.log( methName+": start replaceNamesWithBlankValues.");
621 // this.mappingEditorService.replaceNamesWithBlankValues();
622 if( this.utilityService.getTracelvl() > 0 )
623 console.log( methName+": start saveTemplate ...");
625 var templateData = this.mappingEditorService.paramData; //template data array
626 var pdData = this.paramShareService.getSessionParamData(); //PD data array
627 var paramsContent = localStorage["paramsContent"];
628 if( this.utilityService.getTracelvl() > 0 )
629 console.log( methName+": paramsContent length="+paramsContent.length );
632 var resultParamObj = {};
633 let checkNamesOnlyCondition: boolean = true;
635 if (templateData && templateData != undefined) {
636 if( this.utilityService.getTracelvl() > 0 )
637 console.log( methName+": templateData (params) are not empty.");
638 templateData.forEach(function (item) {
639 if (item.paramValue !== "" && item.paramValue != undefined && item.paramValue != null) {
640 checkNamesOnlyCondition = false;
642 resultParamObj[item.paramName] = item.paramValue;
644 templateData = Array.from(new Set(templateData.map((itemInArray) => itemInArray.paramName)))
645 if( paramsContent && paramsContent != undefined) {
646 if( this.utilityService.getTracelvl() > 0 )
647 console.log( methName+": parse paramsContent ...");
649 var paramTabData = JSON.parse(paramsContent);
652 console.log( methName+": paramsContent parse error:" + error);
654 if( this.utilityService.getTracelvl() > 0 )
655 console.log( methName+": templateData length="+templateData.length );
656 templateData.forEach(function (item) {
657 for (var index in paramTabData) {
658 if (item.paramName === index) {
659 if (checkNamesOnlyCondition) {
660 resultParamObj[index] = paramTabData[index];
663 if (item.paramValue === "") {
664 resultParamObj[index] = paramTabData[index];
667 resultParamObj[index] = item.paramValue;
707 "ruleTypeValues": [null]
711 localStorage["paramsContent"] = JSON.stringify(resultParamObj);
712 if (pdData && pdData != undefined) {
713 if( this.utilityService.getTracelvl() > 0 )
714 console.log( methName+
715 ": have pdData, resultArr.length="+resultArr.length );
716 for (var i = 0; i < resultArr.length; i++) {
717 pdData.forEach(function (arr2item) {
718 if (resultArr[i].name === arr2item.name) {
720 "name": arr2item.name,
721 "type": arr2item.type,
722 "description": arr2item.description,
723 "required": arr2item.required,
724 "default": arr2item.default,
725 "source": arr2item.source,
726 "rule-type": arr2item["rule-type"],
727 "request-keys": arr2item["request-keys"],
728 "response-keys": arr2item["response-keys"],
729 "ruleTypeValues": arr2item.ruleTypeValues
731 resultArr.splice(i, 1, json)
736 this.paramShareService.setSessionParamData(resultArr);
737 this.mappingEditorService.paramData = [];
738 //navigate to PD page after sync
739 if( this.utilityService.getTracelvl() > 0 )
740 console.log( methName+": navigate to PD page after sync ...");
743 .navigate(['../../../vnfs/design/parameterDefinitions/create']);
748 //========================== End of syncTemplate() Method============================================
750 this.mergeStatus = this.mappingEditorService.autoAnnotateDataForParams();
751 if (this.mergeStatus) {
752 this.nService.success("Success", "Merge Successful", this.options);
755 this.nService.error("Error", "Merge Unsuccessful", this.options);
759 //========================== End of mergeParams() Method============================================
760 public handleAnnotation(modal) {
762 this.selectedWord = this.templateeditor.getEditor().session.getTextRange(this.templateeditor.getEditor().selectionRange);
763 if (this.selectedWord && this.selectedWord != undefined) modal.open();
765 //========================== End of handleAnnotations() Method============================================
766 public handleUndo(modal) {
767 let markersList = this.templateeditor.getEditor().session.getMarkers();
769 let filteredObj = {};
770 let lastMarker = Object.keys(markersList).filter(function (key) {
771 if (markersList[key]['clazz'] != 'undoMarker') {
772 filteredObj[key] = markersList[key]
776 this.templateeditor.getEditor().session.getUndoManager().undo();
777 this.templateeditor.getEditor().getSelection().clearSelection();
779 this.templateeditor.getEditor().session.removeMarker(this.templateeditor.getEditor().getSelection().session.$markerId);
780 this.templateeditor.getEditor().session.addMarker(markersList[parseInt(lastMarker[lastMarker.length - 1])].range, 'undoMarker', 'text')
782 //========================== End of handleUndo() Method============================================
783 public submitNameValues() {
784 this.checkNameEntered = true;
785 this.checkSpace = true;
787 if (this.tempName.startsWith(' ') || this.tempName.endsWith(' ')) {
788 this.checkSpace = false
791 this.checkNameEntered = true;
793 if (this.selectedWord) {
794 if (this.selectedWord.startsWith('${(')) {
795 var replaceWord: any = this.replaceWord = this.selectedWord.substring(3, this.selectedWord.indexOf(')=(')) + this.tempName;
796 this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
799 let mappingKey = this.mappingEditorService.getKeysForValues(this.selectedWord);
800 var replaceWord: any = this.replaceWord = '${(' + this.selectedWord + ')=(' + this.tempName + ')}';
801 this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
805 this.mappingEditorService.refreshEditor();
811 this.checkNameEntered = false;
814 //========================== End of submitNameValues() Method============================================