From 4ae5d325db70282d453a27c6790433e3ff0ed2f9 Mon Sep 17 00:00:00 2001 From: guochuyicmri Date: Wed, 15 May 2019 09:45:28 +0800 Subject: Fix instance instantiation for CCVPN Change-Id: Idf597d27f6da4e24162b679773f8b3e6267563f9 Issue-ID: USECASEUI-220 Signed-off-by: guochuyicmri --- .../app/ccvpn-creation/ccvpn-creation.component.ts | 70 +++++++++++++--------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'usecaseui-portal/src/app/ccvpn-creation') diff --git a/usecaseui-portal/src/app/ccvpn-creation/ccvpn-creation.component.ts b/usecaseui-portal/src/app/ccvpn-creation/ccvpn-creation.component.ts index f2f35221..08307fa7 100644 --- a/usecaseui-portal/src/app/ccvpn-creation/ccvpn-creation.component.ts +++ b/usecaseui-portal/src/app/ccvpn-creation/ccvpn-creation.component.ts @@ -79,35 +79,49 @@ export class CcvpnCreationComponent implements OnInit { getccvpnTemParameters(data) { //Get template parameters console.log(this.createParams); - let inputs = data["inputs"]; - this.templateParameters.service = { - name: data.metadata.name, - description: data.metadata.description, - serviceInvariantUuid: data.metadata.invariantUUID, - serviceUuid: data.metadata.UUID - }; - //Screening separation sotnvpn data - inputs["vpnresourcelist"].map((item,index) => { - if(item["required"] !=undefined){ - this.templateParameters["sotnvpn"]["sdwanvpnresource_list"].push(item); - } - if (item["sitelanlist"] != undefined && item["sitelanlist"] instanceof Array === true) { - this.templateParameters["sotnvpn"]["sdwansitelan_list"] = item["sitelanlist"] - } - }); + if (typeof data["model"] == 'string') { + data = JSON.parse(data["model"]); + } + console.log(data); + let inputss = data["inputs"]; + let inputs = {}; + this.templateParameters.service = { + name: data.metadata["name"], + description: data.metadata.description, + serviceInvariantUuid: data.metadata.invariantUUID, + serviceUuid: data.metadata.UUID + }; + //Screening separation sotnvpn data + Object.keys(inputss).map((item) => { + if (item.search("vpn")) { + inputs["vpnresourcelist"] = inputss[item]; + } + if (item.search("site")) { + inputs["sitereourcelist"] = inputss[item]; + } + }); + console.log(inputs); + inputs["vpnresourcelist"].map((item, index) => { + if (item["required"] != undefined) { + this.templateParameters["sotnvpn"]["sdwanvpnresource_list"].push(item); + } + if(item["required"] == undefined && Object.keys(item).length == 1 && Object.keys(item)[0].search("sitelan") && item[Object.keys(item)[0]] instanceof Array === true){ + this.templateParameters["sotnvpn"]["sdwansitelan_list"] = item[Object.keys(item)[0]] + } + }); - //Screening separation site data - inputs["sitereourcelist"].map((item,index) => { - if(item["required"] !=undefined){ - this.templateParameters["site"]["sdwansiteresource_list"].push(item); - } - if (item["deviceList"] != undefined && item["deviceList"] instanceof Array === true) { - this.templateParameters["site"]["sdwandevice_list"] = item["deviceList"] - } - if (item["sitewanlist"] != undefined && item["sitewanlist"] instanceof Array === true) { - this.templateParameters["site"]["sdwansitewan_list"] = item["sitewanlist"] - } - }); + //Screening separation site data + inputs["sitereourcelist"].map((item, index) => { + if (item["required"] != undefined) { + this.templateParameters["site"]["sdwansiteresource_list"].push(item); + } + if(item["required"] == undefined && Object.keys(item).length == 1 && Object.keys(item)[0].search("device") && item[Object.keys(item)[0]] instanceof Array === true){ + this.templateParameters["site"]["sdwandevice_list"] = item[Object.keys(item)[0]]; + } + if(item["required"] == undefined && Object.keys(item).length == 1 && Object.keys(item)[0].search("sitewan") && item[Object.keys(item)[0]] instanceof Array === true){ + this.templateParameters["site"]["sdwansitewan_list"] = item[Object.keys(item)[0]]; + } + }); this.showTemParametersSotnVpn(); this.showTemParametersSite(); -- cgit 1.2.3-korg