From 0b5c8497e0d706fca68601276a44e4bab033e945 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 23 Jul 2018 16:12:26 +0530 Subject: refactord payload creatn for template & param save refactored payload creation for saving template and param artifacts to APPC using createPayloadForSave method in utility.service.ts Issue-ID: APPC-1105 Change-Id: I2dd446aebdbcbc1ffc070993ee53d09e25eeae6b Signed-off-by: Sandeep J --- .../template-configuration.component.ts | 49 +++------------------- 1 file changed, 5 insertions(+), 44 deletions(-) (limited to 'src/app/vnfs') diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts index dc40704..a3d55ba 100644 --- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts @@ -40,7 +40,8 @@ import { NgProgress } from 'ngx-progressbar'; import { NgxSpinnerService } from 'ngx-spinner'; import { UtilityService } from '../../../../shared/services/utilityService/utility.service'; declare var $: any - +const PARAM_DATA:string="param_data"; +const TEMPLATE_DATA:string="template_data"; @Component({ selector: 'app-golden-configuration', templateUrl: './template-configuration.component.html', styleUrls: ['./template-configuration.component.css'] }) export class GoldenConfigurationComponent implements OnInit { @ViewChild('templateeditor') templateeditor; @@ -99,6 +100,7 @@ export class GoldenConfigurationComponent implements OnInit { } public replaceWord; public enableDownloadButtons: boolean = false; + constructor( private buildDesignComponent: BuildDesignComponent, private paramShareService: ParamShareService, @@ -354,27 +356,7 @@ export class GoldenConfigurationComponent implements OnInit { let vnfType = this.vnfType; let Json = [paramsKeyValueFromEditor]; let slashedPayload = this.appendSlashes(JSON.stringify(Json)); - let newPayload = - { - "userID": this.userId, - "vnf-type": this.vnfType, - "action": action, - "artifact-name": fileName, - "artifact-type": "APPC-CONFIG", - "artifact-version": this.templateVersionNo, - "artifact-contents": slashedPayload - } - let data = - { - "input": { - "design-request": { - "request-id": this.apiToken, - "action": "uploadArtifact", - "payload": JSON.stringify(newPayload) - - } - } - } + let data = this.utilityService.createPayLoadForSave(PARAM_DATA, this.vnfType, action, fileName, this.templateVersionNo, slashedPayload); this.appDataObject.template.nameValueData = data; } if (this.configMappingEditorContent) { @@ -398,28 +380,7 @@ export class GoldenConfigurationComponent implements OnInit { fileName = this.artifactName; } let vnfType = this.vnfType; - let newPayload = - { - "userID": this.userId, - "vnf-type": this.vnfType, - "action": action, - "artifact-name": fileName, - "artifact-type": "APPC-CONFIG", - "artifact-version": this.templateVersionNo, - "artifact-contents": this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}') - - } - let data = - { - "input": { - "design-request": { - "request-id": this.apiToken, - "action": "uploadArtifact", - "payload": JSON.stringify(newPayload) - - } - } - } + let data = this.utilityService.createPayLoadForSave(TEMPLATE_DATA, this.vnfType, action, fileName, this.templateVersionNo, this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}')); this.appDataObject.template.templateData = data; this.mappingEditorService.initialise(this.templateeditor.getEditor(), actualContent, this.modal); } -- cgit 1.2.3-korg