From 926b57b4d540c73f1930e6d2d2070e5ac6939e5d Mon Sep 17 00:00:00 2001 From: wangyuerg Date: Fri, 4 Sep 2020 18:30:46 +0800 Subject: fix: change type and key of parameters Change-Id: I51f96580758f10c9bc7bcc7d909b5d7b3bb5d7e9 Signed-off-by: wangyuerg Issue-ID: USECASEUI-444 --- .../src/app/mock/json/slicing_task_auditInfo.json | 59 +++++--------- usecaseui-portal/src/app/shared/utils/utils.ts | 12 ++- .../slicing-task-model.component.ts | 36 +++++---- .../subnet-params-model.component.html | 11 ++- .../subnet-params-model.component.ts | 94 +++++++++++----------- 5 files changed, 102 insertions(+), 110 deletions(-) (limited to 'usecaseui-portal/src/app') diff --git a/usecaseui-portal/src/app/mock/json/slicing_task_auditInfo.json b/usecaseui-portal/src/app/mock/json/slicing_task_auditInfo.json index a9640f48..0db434df 100644 --- a/usecaseui-portal/src/app/mock/json/slicing_task_auditInfo.json +++ b/usecaseui-portal/src/app/mock/json/slicing_task_auditInfo.json @@ -42,30 +42,22 @@ "suggest_nsi_name": "eMBB instance1", "an_suggest_nssi_id": "46da8cf8-0878-48ac-bea3-f2200959411a", "an_suggest_nssi_name": "eMBB ANinstance1", - "an_service_snssai": "an_1-010101", - "an_resource_sharing_level": "shared", - "an_ue_mobility_level": "stationary", + "sliceProfile_AN_sNSSAI": "an_1-010101", + "sliceProfile_AN_resourceSharingLevel": "shared", + "sliceProfile_AN_uEMobilityLevel": "stationary", "an_latency": "10", - "an_max_number_of_ues": "10000", - "an_max_number_of_pud_session":"10000", - "an_activity_factor": "60", - "an_exp_data_rate_dl": "300", - "an_exp_data_rate_ul": "300", - "an_area_traffic_cap_dl": "300", - "an_area_traffic_cap_ul": "300", - "an_overalluser_density":"test_an_overalluser_density_01", + "sliceProfile_AN_maxNumberofUEs": "10000", + "sliceProfile_AN_maxNumberofPDUSession":"10000", + "sliceProfile_AN_activityFactor": "60", + "sliceProfile_AN_expDataRateDL": "300", + "sliceProfile_AN_expDataRateUL": "300", + "sliceProfile_AN_areaTrafficCapDL": "300", + "sliceProfile_AN_areaTrafficCapUL": "300", + "sliceProfile_AN_overallUserDensity":"test_an_overalluser_density_01", "an_enableNSSISelection":false, - "an_Endpoint":[ - { - "an_ip_address":"test_an_ip_address_01" - }, - { - "an_logical_link": "test_an_logical_link_01" - }, - { - "an_nexthop_info":"test_info_01" - } - ], + "sliceProfile_AN_ipAddress":"test_an_ip_address_01", + "sliceProfile_AN_logicInterfaceId":"test_an_logical_link_01", + "sliceProfile_AN_nextHopInfo":"sliceProfile_AN_nextHopInfo", "an_script_name":"test_an_01", "an_coverage_area_ta_list": ["北京;北京市;海淀区", "北京;北京市;西城区", "北京;北京市;昌平区"], "tn_suggest_nssi_id": "46da8cf8-0878-48ac-bea3-f2200959411b", @@ -73,8 +65,8 @@ "tn_latency": "10", "tn_bandwidth": "300", "tn_script_name":"test_tn_01", - "tn_jitter":"test_tn_jitter_01", - "tn_service_snssai":"test_tn_service_snssai_01", + "sliceProfile_TN_jitte":"test_tn_jitter_01", + "sliceProfile_TN_sNSSAI":"test_tn_service_snssai_01", "tn_enableNSSISelection":false, "cn_suggest_nssi_id": "46da8cf8-0878-48ac-bea3-f2200959411c", "cn_suggest_nssi_name": "eMBB CNinstance3", @@ -89,20 +81,13 @@ "cn_area_traffic_cap_dl": "300", "cn_area_traffic_cap_ul": "300", "cn_script_name":"test_cn_01", - "cn_max_number_of_pud_session":"10000", - "cn_overalluser_density":"test_cn_overalluser_density_01", + "sliceProfile_CN_maxNumberofPDUSession":"10000", + "sliceProfile_CN_overallUserDensity":"test_cn_overalluser_density_01", "cn_enableNSSISelection":true, - "cn_Endpoint":[ - { - "cn_ip_address":"test_cn_ip_address_01" - }, - { - "cn_logical_link": "test_cn_logical_link_01" - }, - { - "cn_nexthop_info":"test_info_01" - } - ] + "sliceProfile_CN_coverageAreaTAList": "", + "sliceProfile_CN_ipAddress":"1.1.1.1", + "sliceProfile_CN_logicInterfaceId":"2222", + "sliceProfile_CN_nextHopInfo":"nexthopj" } } diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts index ad6a2f10..6864d60d 100644 --- a/usecaseui-portal/src/app/shared/utils/utils.ts +++ b/usecaseui-portal/src/app/shared/utils/utils.ts @@ -79,7 +79,7 @@ export class Util { return false; } else if (isNaN(parseInt(value))) { return false; - } else if (Number(value) >= 0 && Number(value)%1 !== 0){ + } else if (Number(value) < 0 || (Number(value)%1 !== 0)){ return false; } else { return true; @@ -90,7 +90,7 @@ export class Util { } isEmpty (a: any): boolean { const type = this.judgeType(a); - if (type === 'object Null' || type === '[object undefined]' || a === false || a === '') { + if (type === 'object Null' || type === '[object undefined]' || a === '') { return true; } else { return false; @@ -122,4 +122,12 @@ export class Util { } return true; } + pick(obj: object, arr: Array): Object { + return arr.reduce((iter, val) => { + if(val in obj) { + iter[val] = obj[val]; + } + return iter; + }, {}); + } } \ No newline at end of file diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts index c9f61215..ae5102ae 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts @@ -159,23 +159,25 @@ export class SlicingTaskModelComponent implements OnInit { // 前端模拟数据 let area = ["Beijing;Beijing;Haidian District", "Beijing;Beijing;Xicheng District", "Beijing;Beijing;Changping District"]; this.slicingSubnet[0].params = {...this.pick(nsi_nssi_info, [ - 'an_service_snssai', - 'an_resource_sharing_level', - 'an_ue_mobility_level', + 'sliceProfile_AN_sNSSAI', + 'sliceProfile_AN_resourceSharingLevel', + 'sliceProfile_AN_uEMobilityLevel', 'an_latency', - 'an_max_number_of_ues', - 'an_activity_factor', - 'an_exp_data_rate_dl', - 'an_exp_data_rate_ul', - 'an_area_traffic_cap_dl', - 'an_area_traffic_cap_ul', + 'sliceProfile_AN_maxNumberofUEs', + 'sliceProfile_AN_activityFactor', + 'sliceProfile_AN_expDataRateDL', + 'sliceProfile_AN_expDataRateUL', + 'sliceProfile_AN_areaTrafficCapDL', + 'sliceProfile_AN_areaTrafficCapUL', 'an_script_name', - 'an_overalluser_density', - 'an_Endpoint', + 'sliceProfile_AN_overallUserDensity', 'an_enableNSSISelection', - 'an_max_number_of_pud_session' + 'sliceProfile_AN_maxNumberofPDUSession', + 'sliceProfile_AN_ipAddress', + 'sliceProfile_AN_logicInterfaceId', + 'sliceProfile_AN_nextHopInfo' ]), an_coverage_area_ta_list: area}; - this.slicingSubnet[1].params = this.pick(nsi_nssi_info, ['tn_latency', 'tn_bandwidth', 'tn_script_name', 'tn_jitter', 'tn_service_snssai',"tn_enableNSSISelection"]); + this.slicingSubnet[1].params = this.pick(nsi_nssi_info, ['tn_latency', 'tn_bandwidth', 'tn_script_name', 'sliceProfile_TN_jitte', 'sliceProfile_TN_sNSSAI',"tn_enableNSSISelection"]); this.slicingSubnet[2].params = {...this.pick(nsi_nssi_info, [ 'cn_service_snssai', 'cn_resource_sharing_level', @@ -188,10 +190,12 @@ export class SlicingTaskModelComponent implements OnInit { 'cn_area_traffic_cap_dl', 'cn_area_traffic_cap_ul', 'cn_script_name', - 'cn_overalluser_density', - 'cn_Endpoint', + 'sliceProfile_CN_overallUserDensity', 'cn_enableNSSISelection', - 'cn_max_number_of_pud_session' + 'sliceProfile_CN_maxNumberofPDUSession', + 'sliceProfile_CN_logicInterfaceId', + 'sliceProfile_CN_ipAddress', + 'sliceProfile_CN_nextHopInfo' ])}; } else { this.message.error(result_message || 'Failed to get data') diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.html b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.html index 93e6f485..cde444bf 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.html +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.html @@ -47,14 +47,13 @@ -
{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}
-
{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}
-
{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}
+
{{validateEndPoint(option.title, EndpointInputs[option.key])}}
+
{{validateEndPoint(option.title, EndpointInputs[option.key])}}
+
{{validateEndPoint(option.title, EndpointInputs[option.key])}}
diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts index fb1e5b55..9d1ee34d 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts @@ -24,8 +24,9 @@ export class SubnetParamsModelComponent implements OnInit { areaList: any[] = []; // 2020.08.17 Add 3 parameters for Endpoint, Comment: The following code NexthopInfoOptions = NexthopInfo_Options; - EndpointInputs: any[] = []; + EndpointInputs: object = {}; EndpointEnable: boolean = true; // Whether to enable the three parameters of Endpoint + keyList: string[] = []; // keys of endPoint // Comment: Above code constructor( @@ -41,16 +42,13 @@ export class SubnetParamsModelComponent implements OnInit { if(this.title){ this.coreFormItems = this.title === 'An'?CORE_FORM_ITEMS.An:this.title === 'Cn'?CORE_FORM_ITEMS.Cn:[]; this.formData = JSON.parse(JSON.stringify(this.detailData)); + this.keyList = this.coreFormItems.find((item) => {return item.title === 'Endpoint'}).options.map((val) => {return val.key}); if(this.formData !==undefined && Object.keys(this.formData).length!==0){ - this.EndpointEnable = (this.formData.hasOwnProperty("an_Endpoint") && this.formData['an_Endpoint'].length!==0) || (this.formData.hasOwnProperty("cn_Endpoint") && this.formData['cn_Endpoint'].length!==0) + this.EndpointEnable = this.keyList.every((item) => {return this.formData.hasOwnProperty(item)}) } // -------> 2020.08.17 Add 3 parameters for Endpoint, Comment: The following code if(this.EndpointEnable){ - this.EndpointInputs = this.title === 'An' - ?this.formData["an_Endpoint"] - :this.title === 'Cn' - ?this.formData["cn_Endpoint"] - :[]; + this.EndpointInputs = this.Util.pick(this.formData, this.keyList)// no? }else{ this.coreFormItems.map((item,index)=>{ if(item.title === 'Endpoint'){ @@ -85,21 +83,21 @@ export class SubnetParamsModelComponent implements OnInit { } } - onInput ($event:any, title: string) { - if (!$event) { - return; - } - const target = $event.target; - if (title === 'ip_address') { - // only number and '.' can be inputted - const regexp = /[^\d^\.]+/g; - target.value = target.value.replace(regexp, ''); - } else if (title === 'logical_link') { - // only number can be inputted - const regxp = /[^\d]/g; - target.value = target.value.replace(regxp, ''); - } - } + // onInput ($event:any, title: string) { + // if (!$event) { + // return; + // } + // const target = $event.target; + // if (title === 'ip_address') { + // // only number and '.' can be inputted + // const regexp = /[^\d^\.]+/g; + // target.value = target.value.replace(regexp, ''); + // } else if (title === 'logical_link') { + // // only number can be inputted + // const regxp = /[^\d]/g; + // target.value = target.value.replace(regxp, ''); + // } + // } AreaFormatting () { let areaList = [...this.formData.an_coverage_area_ta_list]; this.areaList = areaList.map ( (item: any) => { @@ -212,35 +210,27 @@ export class SubnetParamsModelComponent implements OnInit { endCheckBeforeSubmit () : Array{ // check params of Endpoint let result: Array = [true, '']; - let formatedEndpoint = {}; - this.EndpointInputs.forEach((item) => { - formatedEndpoint[Object.keys(item)[0]] = item[Object.keys(item)[0]]; - }) - if (this.title === 'An') { - for (let prop in formatedEndpoint) { - if (prop === 'an_ip_address') { - if (!this.regxpIP.test(formatedEndpoint[prop])) { - result = [false, 'Illegal IpAddress'] - } - } else if (prop === 'an_logical_link') { - if (!this.Util.isInteger(formatedEndpoint[prop])) { - result = [false, 'LogicalID can only be an integer'] - } + const endPointList = this.coreFormItems.find((item) => {return item.title === 'Endpoint'}).options; + let ipKey = ''; + let logicalKey = ''; + for (let item of endPointList) { + if (item.title === 'ip_address') { + ipKey = item.key + } else if (item.title === 'logical_link') { + logicalKey = item.key + } + } + for (let prop in this.EndpointInputs) { + if (prop === ipKey) { + if (!this.regxpIP.test(this.EndpointInputs[prop])) { + result = [false, 'Illegal IpAddress'] } - } - } else if (this.title === 'Cn') { - for (let prop in formatedEndpoint) { - if (prop === 'cn_ip_address') { - if (!this.regxpIP.test(formatedEndpoint[prop])) { - result = [false, 'Illegal IpAddress'] - } - } else if (prop === 'cn_logical_link') { - if (!this.Util.isInteger(formatedEndpoint[prop])) { - result = [false, 'LogicalID can only be an integer'] - } + } else if (prop === logicalKey) { + if (!this.Util.isInteger(this.EndpointInputs[prop])) { + result = [false, 'LogicalID can only be an integer'] } - } - } + } + } return result; } @@ -270,6 +260,12 @@ export class SubnetParamsModelComponent implements OnInit { this.message.error(endCheckResult[1].toString()); return; } + // replace the params about endPoint + for (let prop in this.formData) { + if (typeof this.EndpointInputs[prop] !== 'undefined') { + this.formData[prop] = this.EndpointInputs[prop]; + } + } let params: object; if (this.title === 'An') { const an_coverage_area_ta_list: string[] = []; -- cgit 1.2.3-korg