diff options
author | 2021-01-28 10:34:35 +0800 | |
---|---|---|
committer | 2021-01-28 10:41:55 +0800 | |
commit | 186b679ba02d7729801b4d560697d87034b9c8f6 (patch) | |
tree | a3dfa487da10a0f5adbc7bad55224595aa9c6547 /usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts | |
parent | 14e5467cf340f32afc38cd88be39ee4cba26def9 (diff) |
feat: TN change modification
Signed-off-by: wangyuerg <wangyuerg@chinamobile.com>
Change-Id: I7bed0f4b43e0f978b5e109bfd198c4cad2205463
Issue-ID: USECASEUI-527
Diffstat (limited to 'usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/subnet-params-model/subnet-params-model.component.ts | 263 |
1 files changed, 193 insertions, 70 deletions
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 119f87d4..862e2a1f 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 @@ -16,17 +16,25 @@ export class SubnetParamsModelComponent implements OnInit { @Input() title: string; @Output() cancel = new EventEmitter<boolean>(); @Output() paramsDataChange = new EventEmitter<any>(); + @Output() noPassParaChange = new EventEmitter<any>(); - transferFormItems = TRANSFRER_FORM_ITEMS; + transferFormItems: any[] = TRANSFRER_FORM_ITEMS; regxpIP = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/; // check for correct ip address formData: any; coreFormItems : any = []; areaList: any[] = []; // 2020.08.17 Add 3 parameters for Endpoint, Comment: The following code NexthopInfoOptions = NexthopInfo_Options; - EndpointInputs: object = {}; + EndpointInputs: object = {}; + ANEndpointInputs: object = {}; + CNEndpointInputs: object = {}; + ANkeyList: string[] = []; + CNkeyList: string[] = []; EndpointEnable: boolean = true; // Whether to enable the three parameters of Endpoint keyList: string[] = []; // keys of endPoint + specialParaTN: string[] = ['Resource Sharing Level', 'Connection Links', 'AN Endpoint', 'CN Endpoint']; + // Parameters not passed to the back end + notPassPara: string[] = ['tn_connection_links']; // Comment: Above code constructor( @@ -39,44 +47,119 @@ export class SubnetParamsModelComponent implements OnInit { } ngOnChanges() { - if(this.title){ + if (this.title) { this.formData = JSON.parse(JSON.stringify(this.detailData)); if (this.title === 'An' || this.title === 'Cn') { this.coreFormItems = this.title === 'An'?CORE_FORM_ITEMS.An:this.title === 'Cn'?CORE_FORM_ITEMS.Cn:[]; 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.keyList.every((item) => {return this.formData.hasOwnProperty(item)}) - } - if(this.EndpointEnable){ - this.EndpointInputs = this.Util.pick(this.formData, this.keyList)// no? - }else{ - this.coreFormItems.map((item,index)=>{ - if(item.title === 'Endpoint'){ - this.coreFormItems.splice(index,1) } + else if (this.title === 'Tn') { + this.ANkeyList = this.transferFormItems.find((item) => {return item.title === 'AN Endpoint'}).options.map((val) => {return val.key}) + this.CNkeyList = this.transferFormItems.find((item) => {return item.title === 'CN Endpoint'}).options.map((val) => {return val.key}) + this.keyList = this.ANkeyList.concat(this.CNkeyList) + this.formData['tn_connection_links_option'].forEach((item) => { // add init selection status + if (this.formData['tn_connection_links']!== null && this.formData['tn_connection_links'].indexOf(item.id) !== -1) { + item.checked = true + } else { + item.checked = false + } }) + this.judgeTn() // init judge + } + // If the endpoint related parameters from the back end are incomplete, delete the endpoint item + if(this.formData !==undefined && Object.keys(this.formData).length!==0) { + this.EndpointEnable = this.keyList.every((item) => {return this.formData.hasOwnProperty(item)}) + } + if(this.EndpointEnable){ + if (this.title === 'An' || this.title === 'Cn') { + this.EndpointInputs = this.Util.pick(this.formData, this.keyList) + } else if (this.title === 'Tn') { + this.ANEndpointInputs = this.Util.pick(this.formData, this.ANkeyList) + this.CNEndpointInputs = this.Util.pick(this.formData, this.CNkeyList) + } else { + if (this.title === 'An' || this.title === 'Cn') { + this.coreFormItems.map((item,index)=>{ + if (item.title === 'Endpoint') { + this.coreFormItems.splice(index,1) + } + }) + } else if (this.title === 'Tn') { + this.transferFormItems.map((item,index)=>{ + if (item.title === 'AN Endpoint' || item.title === 'CN Endpoint') { + this.coreFormItems.splice(index,1) + } + }) } } - + //-------> Comment: Above code + if (this.title === 'An') { + this.AreaFormatting(); + } + } } - //-------> Comment: Above code - if (this.title === 'An') { - this.AreaFormatting(); + } + changeResourceShare () { + this.judgeTn() + } + + judgeTn (): void { + if (this.formData['sliceProfile_TN_resourceSharingLevel'] === 'non-shared') { + this.formData['tn_connection_links_option'].forEach ((item) => { + item.checked = false + }) + this.formData['tn_connection_links'] = null + this.transferFormItems.forEach((item) => { + if (item.title === 'Connection Links') { + item.disable = true + this.notPassPara = ['tn_connection_links', 'tn_connection_links_option'] + } else if (item.title === 'AN Endpoint' || item.title === 'CN Endpoint') { + item.required = true + item.disable = false + } + }) + } else if (this.formData['sliceProfile_TN_resourceSharingLevel'] === 'shared') { + this.transferFormItems.forEach((item) => { + if (item.title === 'Connection Links') { + item.disable = false + } else if (item.title === 'AN Endpoint' || item.title === 'CN Endpoint') { + if (this.formData['tn_connection_links']!==null && this.formData['tn_connection_links'].length !== 0) { + item.disable = true + item.required = false + this.notPassPara = ['tn_connection_links_option'] + this.notPassPara = this.notPassPara.concat(this.ANkeyList, this.CNkeyList) + console.log('not', this.notPassPara) + } else if (this.formData['tn_connection_links']!==null && this.formData['tn_connection_links'].length === 0) { + item.disable = false + item.required = true + } + } + }) } } - validateEndPoint (key: string, value: any): string { - if (this.Util.isEmpty(value)) { - return 'can not be empty'; + + validateEndPoint (key: string, value: any, required: boolean): string { + if (required) { + if (this.Util.isEmpty(value)) { + return 'can not be empty'; + } } if (key === 'ip_address') { if (!this.regxpIP.test(value)) { - return 'xxx.xxx.xxx.xxx'; + if (value !== '') { + return 'xxx.xxx.xxx.xxx'; + } else { + return '' + } } else { return ''; } } else if (key === 'logical_link') { if (!this.Util.isInteger(value)){ - return 'integer only' + if (value !== ''){ + return 'integer only' + } else { + return '' + } } else { return '' } @@ -85,21 +168,15 @@ 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, ''); - // } - // } + changeLinkCheck (id: string, e: boolean) : void{ // update the selection state + this.formData['tn_connection_links_option'].find((item) => { + return item.id === id + }).checked = e + const checkedList = this.formData['tn_connection_links_option'].filter((item) => {return item.checked === true}) + this.formData['tn_connection_links'] = checkedList.map((item) => {return item.id}) // get the selected id + this.judgeTn() + } + AreaFormatting () { let areaList = [...this.formData.an_coverage_area_ta_list]; this.areaList = areaList.map ( (item: any) => { @@ -180,13 +257,13 @@ export class SubnetParamsModelComponent implements OnInit { } } - handleCancel() { + handleCancel() : void{ this.showModel = false this.cancel.emit(this.showModel) } // prompt text for each item of area_list - checkArea (area: any) { + checkArea (area: any) : string{ if (area.every((item) => {return item.selected === ''})) { return 'empty'; } @@ -209,31 +286,56 @@ export class SubnetParamsModelComponent implements OnInit { return true; } - endCheckBeforeSubmit () : Array<any>{ + endCheckBeforeSubmit (endpoint, required) : Array<any>{ // check params of Endpoint - let result: Array<any> = [true, '']; - const endPointList = this.coreFormItems&&this.coreFormItems.length!==0?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 + console.log('end', endpoint) + let result: Array<any> = [true, '']; + let endPointList; + if (this.title === 'An' || this.title === 'Cn') { + endPointList = this.coreFormItems.find((item) => {return item.title === 'Endpoint'}).options + } else { + endPointList = this.transferFormItems.find((item) => {return item.title === 'AN Endpoint'}).options } - } - for (let prop in this.EndpointInputs) { - if (prop === ipKey) { - if (!this.regxpIP.test(this.EndpointInputs[prop])) { - result = [false, 'Illegal IpAddress'] - } - } else if (prop === logicalKey) { - if (!this.Util.isInteger(this.EndpointInputs[prop])) { - result = [false, 'LogicalID can only be an integer'] + let ipKey = ''; + let logicalKey = ''; + let nextKey = '' + for (let item of endPointList) { + if (item.title === 'ip_address') { + ipKey = item.key + } else if (item.title === 'logical_link') { + logicalKey = item.key + } else if (item.title === 'nexthop_info') { + nextKey = item.key } } - } - return result; + for (let prop in endpoint) { + if (prop === ipKey) { + if (required) { + if (endpoint[prop] === '') { + result = [false, 'Endpoint can not be empty'] + } else if (!this.regxpIP.test(endpoint[prop])) { + result = [false, 'Illegal IpAddress'] + } + } else if (!this.regxpIP.test(endpoint[prop]) && endpoint[prop] !== '') { + result = [false, 'Illegal IpAddress'] + } + } else if (prop === logicalKey) { + if (required) { + if (endpoint[prop] === '') { + result = [false, 'logical can not be empty'] + } else if (!this.Util.isInteger(endpoint[prop])) { + result = [false, 'LogicalID can only be an integer'] + } + } else if (!this.Util.isInteger(endpoint[prop]) && endpoint[prop] !== '') { + result = [false, 'LogicalID can only be an integer'] + } + } else if (prop === nextKey) { + if (required && endpoint[prop] === '') { + result = [false, 'Endpoint can not be empty'] + } + } + } + return result; } inputHolder (title: string): string { @@ -257,15 +359,36 @@ export class SubnetParamsModelComponent implements OnInit { handleOk(): void { // Verify that items of EndPoint is correct - let endCheckResult = this.endCheckBeforeSubmit() - if (!endCheckResult[0]) { - 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]; + if (this.EndpointEnable) { + let endCheckResult = [] + if (this.title === 'An' || this.title === 'Cn') { + endCheckResult = this.endCheckBeforeSubmit(this.EndpointInputs, this.coreFormItems.find((item) => {return item.title === 'Endpoint'}).required) + } else if (this.title === 'Tn') { + const ANendCheckResult = this.endCheckBeforeSubmit(this.ANEndpointInputs, this.transferFormItems.find((item) => {return item.title === 'AN Endpoint'}).required) + const CNendCheckResult = this.endCheckBeforeSubmit(this.CNEndpointInputs, this.transferFormItems.find((item) => {return item.title === 'CN Endpoint'}).required) + if (ANendCheckResult[0] && CNendCheckResult[0]) { + endCheckResult[0] = true + } else { + if (ANendCheckResult[0] === false) { + endCheckResult = ANendCheckResult + } else { + endCheckResult = CNendCheckResult + } + } + } + if (!endCheckResult[0]) { + this.message.error(endCheckResult[1].toString()); + return; + } + // replace the params about endPoint + for (let prop in this.formData) { + if ((this.title === 'An' || this.title === 'Cn') && typeof this.EndpointInputs[prop] !== 'undefined') { + this.formData[prop] = this.EndpointInputs[prop]; + } else if (this.title === 'Tn' && typeof this.ANEndpointInputs[prop] !== 'undefined') { + this.formData[prop] = this.ANEndpointInputs[prop]; + } else if (this.title === 'Tn' && typeof this.CNEndpointInputs[prop] !== 'undefined') { + this.formData[prop] = this.CNEndpointInputs[prop]; + } } } let params: object; @@ -282,8 +405,7 @@ export class SubnetParamsModelComponent implements OnInit { } else { params = {...this.formData}; } - // Verify that each item is not empty, include special handeling of area_list - console.log(params) + // Verify that each item exclude endpoint is not empty, include special handeling of area_list let checkParams = params if (this.title === 'An' || this.title === 'Cn') { checkParams = this.coreFormItems.filter((item) => { @@ -296,6 +418,7 @@ export class SubnetParamsModelComponent implements OnInit { } if (this.Util.deepCheck(checkParams) && this.areaCheckBeforeSubmit(params)) { this.paramsDataChange.emit(params); + this.noPassParaChange.emit(this.notPassPara) this.handleCancel(); } else { this.message.error('Please complete the form'); |