--- /dev/null
+{
+ "lockfileVersion": 1
+}
"cn_area_traffic_cap_dl": "300",\r
"cn_area_traffic_cap_ul": "300",\r
"cn_script_name":"test_cn_01",\r
+ "cn_max_number_of_pud_session":"10000",\r
"cn_overalluser_density":"test_cn_overalluser_density_01",\r
"cn_enableNSSISelection":true,\r
"cn_Endpoint":[\r
validateRulesShow[index] = false;
}
}
+ isInteger (value: any) : boolean{
+ // for common string and undefined, eg '123a3'
+ if (isNaN(value)) {
+ return false;
+ } else if (isNaN(parseInt(value))) {
+ return false;
+ } else if (Number(value) >= 0 && Number(value)%1 !== 0){
+ return false;
+ } else {
+ return true;
+ }
+ }
+ judgeType (a: any) : string {
+ return Object.prototype.toString.call(a)
+ }
+ isEmpty (a: any): boolean {
+ const type = this.judgeType(a);
+ if (type === 'object Null' || type === '[object undefined]' || a === false || a === '') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ deepCheck (target: any) : boolean{
+ //used to verify that each item is not '' or undefined in a object or an array
+ let type = this.judgeType(target);
+ if (type === '[object Array]') {
+ for (let i = 0; i < target.length; i++) {
+ if (!this.deepCheck(target[i])) {
+ return false;
+ }
+ }
+ } else if (type === '[object Object]') {
+ for (const prop in target) {
+ if (target.hasOwnProperty(prop)) {
+ if (!this.deepCheck(target[prop])) {
+ return false;
+ }
+ }
+ }
+ } else {
+ if (this.isEmpty(target)) { // '', undefined, null, false
+ return false;
+ } else {
+ return true;
+ }
+ }
+ return true;
+ }
}
\ No newline at end of file
<div class="subnet_params_container">
<form nz-form *ngIf="title === 'Tn'">
<nz-form-item *ngFor="let item of transferFormItems">
- <nz-form-label [nzSpan]="7" nzRequired [nzFor]="item.key">
- {{ item.title }}
+ <nz-form-label [nzSpan]="7" [nzRequired]="item.required" [nzFor]="item.key" [ngStyle]="labelStyle(item.required)">
+ {{item.title}}
</nz-form-label>
<nz-form-control [nzSpan]="12">
<input nz-input
[id]="item.key"
[readOnly]="item.title === 'S-NSSAI'"
[disabled]="item.title === 'S-NSSAI'"
+ [placeholder]="inputHolder(item.title)"
/>
+ <div class="validation_alert" *ngIf="item.required">{{Util.isEmpty(formData[item.key])? 'can not be empty!':' '}}</div>
</nz-form-control>
</nz-form-item>
</form>
<form nz-form *ngIf="title === 'An' || title === 'Cn'">
<nz-form-item *ngFor="let item of coreFormItems">
- <nz-form-label [nzSpan]="(item.key === 'an_coverage_area_ta_list' || item.title === 'Endpoint')?7:13" nzRequired *ngIf=" item.title !== 'Endpoint' || EndpointEnable ">
+ <nz-form-label [nzSpan]="(item.key === 'an_coverage_area_ta_list' || item.title === 'Endpoint')?7:13" [nzRequired]="item.required" *ngIf=" item.title !== 'Endpoint' || EndpointEnable " [ngStyle]="labelStyle(item.required)">
{{ item.title }}
</nz-form-label>
<nz-form-control [nzSpan]="item.title === 'Endpoint'?14:8" *ngIf="item.key !== 'an_coverage_area_ta_list'">
<input nz-input [id]="item.key" [name]="item.key" [(ngModel)]="formData[item.key]"
[readOnly]="item.title === 'S-NSSAI'" [disabled]="item.title === 'S-NSSAI'"
- *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Endpoint' " />
+ *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Endpoint' " [placeholder]="inputHolder(item.title)"/>
<nz-radio-group [name]="item.key" [(ngModel)]="formData[item.key]"
*ngIf="item.title === 'Resource Sharing Level'">
<label nz-radio [nzValue]="option.key" *ngFor="let option of item.options">
<nz-option [nzValue]="option.key" [nzLabel]="option.title" *ngFor="let option of item.options">
</nz-option>
</nz-select>
- <div class="validation_alert">{{formData[item.key] === ''? 'can not be empty!':' '}}</div>
+ <div class="validation_alert" *ngIf="item.required">{{Util.isEmpty(formData[item.key])? 'can not be empty!':' '}}</div>
<!-- 2020.08.17 Add 3 parameters for Endpoint-->
<!-- Comment: The following code-->
<nz-input-group *ngIf="item.title === 'Endpoint' && EndpointEnable">
<div *ngFor="let option of item.options;let i=index">
<div class="endpoint_input">
<input nz-input
- *ngIf="option.title !== 'nexthop_info'"
[id]="option.key"
[name]="option.key"
[title]="EndpointInputs[i][option.key]"
style="width:32%;margin-right:1%" />
<div class="end_alert_ip" *ngIf="option.title === 'ip_address'">{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}</div>
<div class="end_alert_logical" *ngIf="option.title === 'logical_link'">{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}</div>
+ <div class="end_alert_nexthop" *ngIf="option.title === 'nexthop_info'">{{validateEndPoint(option.title, EndpointInputs[i][option.key])}}</div>
</div>
- <nz-select
- *ngIf="option.title === 'nexthop_info'"
- [name]="option.key"
- [title]="EndpointInputs[i][option.key]"
- [(ngModel)]="EndpointInputs[i][option.key]" style="width:34%;">
- <nz-option
- *ngFor="let infoOption of NexthopInfoOptions"
- [nzValue]="infoOption.key"
- [nzLabel]="infoOption.title"
- ></nz-option>
- </nz-select>
</div>
</nz-input-group>
<!-- Comment: Above code-->
top: 0;\r
margin: 30px 0 0 126px;\r
}\r
+ .end_alert_nexthop {\r
+ position: absolute;\r
+ color: red;\r
+ top: 0;\r
+ margin: 30px 0 0 246px;\r
+ }\r
}
\ No newline at end of file
import { Component, OnInit, Input, Output, EventEmitter, ElementRef } from '@angular/core';
import { TRANSFRER_FORM_ITEMS, CORE_FORM_ITEMS, ADDRESS , NexthopInfo_Options } from '@src/constants/constants';
import { NzMessageService } from "ng-zorro-antd";
+import { stringify } from '@angular/core/src/util';
+import { Util } from '../../../../../../shared/utils/utils';
@Component({
selector: 'app-subnet-params-model',
constructor(
private message: NzMessageService,
+ private Util: Util
) {
}
}
}
validateEndPoint (key: string, value: any): string {
- if (value === '') {
+ if (this.Util.isEmpty(value)) {
return 'can not be empty';
}
if (key === 'ip_address') {
return '';
}
} else if (key === 'logical_link') {
- if (!this.isInteger(value)){
+ if (!this.Util.isInteger(value)){
return 'integer only'
} else {
return ''
this.cancel.emit(this.showModel)
}
+ // prompt text for each item of area_list
checkArea (area: any) {
if (area.every((item) => {return item.selected === ''})) {
return 'empty';
return '';
}
- judgeType (a) {
- return Object.prototype.toString.call(a)
- }
-
- // used to verify that each item is not empty in a object
- deepCheck (target) {
- let type = this.judgeType(target);
- if (type === '[object Array]') {
- for (let i = 0; i < target.length; i++) {
- if (!this.deepCheck(target[i])) {
- return false;
- }
- }
- } else if (type === '[object Object]') {
- for (const prop in target) {
- if (target.hasOwnProperty(prop)) { // special handling for address
- if (prop === 'an_coverage_area_ta_list' || prop ==='cn_coverage_area_ta_list') {
- return target[prop].every((item) => {return this.deepCheck(item.split(';'))});
- } else if (!this.deepCheck(target[prop])) {
- return false;
- }
+ // special handling for address
+ areaCheckBeforeSubmit (target: object) : Boolean{
+ for (const prop in target) {
+ if (target.hasOwnProperty(prop)) {
+ if (prop === 'an_coverage_area_ta_list' || prop ==='cn_coverage_area_ta_list') {
+ // if the vlaue is "shanghai;shanghai;", the input is incomplete
+ return target[prop].every((item) => {return this.Util.deepCheck(item.split(';'))});
}
}
- } else {
- if (!target && target!==0) {
- return false;
- } else {
- return true;
- }
}
return true;
}
- isInteger (value: any) {
- // for common string and undefined, eg '123a3'
- if (isNaN(value)) {
- return false;
- } else if (isNaN(parseInt(value))) {
- return false;
- } else if (Number(value) >= 0 && Number(value)%1 !== 0){
- return false;
- } else {
- return true;
- }
- }
-
- endCheckBeforeSubmit () {
+ endCheckBeforeSubmit () : Array<any>{
// check params of Endpoint
- let result = [true, ''];
+ let result: Array<any> = [true, ''];
let formatedEndpoint = {};
this.EndpointInputs.forEach((item) => {
formatedEndpoint[Object.keys(item)[0]] = item[Object.keys(item)[0]];
result = [false, 'Illegal IpAddress']
}
} else if (prop === 'an_logical_link') {
- if (!this.isInteger(formatedEndpoint[prop])) {
+ if (!this.Util.isInteger(formatedEndpoint[prop])) {
result = [false, 'LogicalID can only be an integer']
}
}
result = [false, 'Illegal IpAddress']
}
} else if (prop === 'cn_logical_link') {
- if (!this.isInteger(formatedEndpoint[prop])) {
+ if (!this.Util.isInteger(formatedEndpoint[prop])) {
result = [false, 'LogicalID can only be an integer']
}
}
return result;
}
+ inputHolder (title: string): string {
+ const titleArr = title.split(' ')
+ if (titleArr.length > 1) {
+ return titleArr.slice(0, 2).join('');
+ } else {
+ return title;
+ }
+ }
+
+ labelStyle (required: boolean) : object{
+ let style;
+ if (!required) {
+ style = {'margin-left': '18px', 'margin-right': '-18px'};
+ } else {
+ style = {}
+ }
+ return style;
+ }
+
handleOk(): void {
// Verify that items of EndPoint is correct
let endCheckResult = this.endCheckBeforeSubmit()
} else {
params = {...this.formData};
}
- // Verify that each item is not empty
- if (this.deepCheck(params)) {
+ // Verify that each item is not empty, include special handeling of area_list
+ if (this.Util.deepCheck(params) && this.areaCheckBeforeSubmit(params)) {
this.paramsDataChange.emit(params);
this.handleCancel();
} else {
export const TRANSFRER_FORM_ITEMS = [\r
{\r
title: 'S-NSSAI',\r
- key: 'tn_service_snssai'\r
+ key: 'tn_service_snssai',\r
+ required: true\r
},\r
{\r
title: 'Latency (ms)',\r
- key: 'tn_latency'\r
+ key: 'tn_latency',\r
+ required: true\r
},\r
{\r
title: 'Jitter',\r
- key: 'tn_jitter'\r
+ key: 'tn_jitter',\r
+ required: false,\r
},\r
{\r
title: 'MaxBandwidth',\r
- key: 'tn_bandwidth'\r
+ key: 'tn_bandwidth',\r
+ required: true\r
},\r
- {\r
- title: 'Script Name',\r
- key: 'tn_script_name'\r
- },\r
]\r
\r
export const CORE_FORM_ITEMS = {\r
"An": [\r
{\r
title: 'S-NSSAI',\r
- key: 'an_service_snssai'\r
+ key: 'an_service_snssai',\r
+ required: true\r
},\r
{\r
title: 'Resource Sharing Level',\r
key: 'an_resource_sharing_level',\r
+ required: true,\r
options: [\r
{\r
title: 'Shared',\r
{\r
title: 'Mobility',\r
key: 'an_ue_mobility_level',\r
+ required: true,\r
options: [\r
{\r
title: 'Stationary',\r
},\r
{\r
title: 'Latency (ms)',\r
- key: 'an_latency'\r
+ key: 'an_latency',\r
+ required: true\r
+ },\r
+ {\r
+ title: 'Max Number of PUD Session',\r
+ key: 'an_max_number_of_pud_session',\r
+ required: true\r
},\r
{\r
title: 'Max Number of UEs',\r
- key: 'an_max_number_of_ues'\r
+ key: 'an_max_number_of_ues',\r
+ required: true\r
},\r
{\r
title: 'Activity Factor (%)',\r
- key: 'an_activity_factor'\r
+ key: 'an_activity_factor',\r
+ required: true\r
},\r
{\r
title: 'User Downlink Experience Rate(Mbps)',\r
- key: 'an_exp_data_rate_dl'\r
+ key: 'an_exp_data_rate_dl',\r
+ required: true\r
},\r
{\r
title: 'User Uplink Experience Rate(Mbps)',\r
- key: 'an_exp_data_rate_ul'\r
+ key: 'an_exp_data_rate_ul',\r
+ required: true\r
},\r
{\r
title: 'Downlink Regional Traffic Density(Mbps/km )',\r
- key: 'an_area_traffic_cap_dl'\r
+ key: 'an_area_traffic_cap_dl',\r
+ required: true\r
},\r
{\r
title: 'Uplink Regional Traffic Density(Mbps/km )',\r
- key: 'an_area_traffic_cap_ul'\r
+ key: 'an_area_traffic_cap_ul',\r
+ required: true\r
},\r
{\r
title: 'Script Name',\r
- key: 'an_script_name'\r
+ key: 'an_script_name',\r
+ required: true\r
},\r
{\r
- title: 'overallUserDensity',\r
- key: 'an_overalluser_density'\r
+ title: 'Overall User Density',\r
+ key: 'an_overalluser_density',\r
+ required: true\r
},\r
{\r
title:'Endpoint',\r
key:"an_Endpoint",\r
+ required: true,\r
options: [\r
{\r
title: 'ip_address',\r
},\r
{\r
title: 'nexthop_info',\r
- key: 'an_nexthop_info'\r
+ key: 'an_nexthop_info',\r
+ holder: 'NextHop'\r
}\r
]\r
},\r
{\r
title: 'Coverage Area Ta List',\r
- key: 'an_coverage_area_ta_list'\r
+ key: 'an_coverage_area_ta_list',\r
+ required: true\r
}\r
],\r
"Cn": [\r
{\r
title: 'S-NSSAI',\r
- key: 'cn_service_snssai'\r
+ key: 'cn_service_snssai',\r
+ required: true\r
},\r
{\r
title: 'Resource Sharing Level',\r
key: 'cn_resource_sharing_level',\r
+ required: true,\r
options: [\r
{\r
title: 'Shared',\r
{\r
title: 'Mobility',\r
key: 'cn_ue_mobility_level',\r
+ required: true,\r
options: [\r
{\r
title: 'Stationary',\r
},\r
{\r
title: 'Latency (ms)',\r
- key: 'cn_latency'\r
+ key: 'cn_latency',\r
+ required: true\r
},\r
{\r
title: 'Max Number of UEs',\r
- key: 'cn_max_number_of_ues'\r
+ key: 'cn_max_number_of_ues',\r
+ required: true\r
},\r
{\r
title: 'Activity Factor (%)',\r
- key: 'cn_activity_factor'\r
+ key: 'cn_activity_factor',\r
+ required: true\r
},\r
{\r
title: 'User Downlink Experience Rate(Mbps)',\r
- key: 'cn_exp_data_rate_dl'\r
+ key: 'cn_exp_data_rate_dl',\r
+ required: true\r
},\r
{\r
title: 'User Uplink Experience Rate(Mbps)',\r
- key: 'cn_exp_data_rate_ul'\r
+ key: 'cn_exp_data_rate_ul',\r
+ required: true\r
},\r
{\r
title: 'Downlink Regional Traffic Density(Mbps/km )',\r
- key: 'cn_area_traffic_cap_dl'\r
+ key: 'cn_area_traffic_cap_dl',\r
+ required: true\r
},\r
{\r
title: 'Uplink Regional Traffic Density(Mbps/km )',\r
- key: 'cn_area_traffic_cap_ul'\r
+ key: 'cn_area_traffic_cap_ul',\r
+ required: true\r
},\r
{\r
title: 'Script Name',\r
- key: 'cn_script_name'\r
+ key: 'cn_script_name',\r
+ required: true\r
+ },\r
+ {\r
+ title: 'Max Number of PUD Session',\r
+ key: 'cn_max_number_of_pud_session',\r
+ required: true\r
},\r
{\r
- title: 'overallUserDensity',\r
- key: 'cn_overalluser_density'\r
+ title: 'OverAll User Density',\r
+ key: 'cn_overalluser_density',\r
+ required: true\r
},\r
{\r
title:'Endpoint',\r
key:"cn_Endpoint",\r
+ required: true,\r
options: [\r
{\r
title: 'ip_address',\r