summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usecaseui-portal/src/app/shared/utils/utils.ts42
-rw-r--r--usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html14
-rw-r--r--usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts89
3 files changed, 66 insertions, 79 deletions
diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts
index 1aa9673e..63d3e3b7 100644
--- a/usecaseui-portal/src/app/shared/utils/utils.ts
+++ b/usecaseui-portal/src/app/shared/utils/utils.ts
@@ -31,4 +31,46 @@ export class Util {
let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
return formattime;
}
+
+ getRulesText(words: string, title: string, index: number, rulesText: any[]){
+ return rulesText[index] = words + title
+ };
+ validator(title: string, key: string, val: any, index: number, rulesText: any[], validateRulesShow: any[]) {
+ let maxNumberReg = /^([1-9]\d{0,4}|100000)$/, // Check integer between 1 ~ 100000
+ expDataRateReg = /^([1-9]\d{2}|[1-3]\d{3}|3000)$/, // Check integer between 100 ~ 3000
+ latencyReg = /^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/; // Check integers between 10 and 200
+ if (val === null || val.replace(/\s*/g, '').length <= 0) {
+ validateRulesShow[index] = true;
+ this.getRulesText('Please enter ', title, index,rulesText);
+ return false
+ } else {
+ validateRulesShow[index] = false;
+ }
+ if (isNaN(val) && (key === 'maxNumberofUEs' || key === 'expDataRateDL' || key === 'expDataRateUL' || key === 'latency')) {
+ validateRulesShow[index] = true;
+ this.getRulesText('Only numbers can be entered', '', index,rulesText);
+ return false
+ }
+ if (!isNaN(val) && key === 'maxNumberofUEs' && !maxNumberReg.test(val)) {
+ validateRulesShow[index] = true;
+ this.getRulesText('Scope: 1-100000', '', index,rulesText);
+ return false
+ } else {
+ validateRulesShow[index] = false;
+ }
+ if ( !isNaN(val) && (key === 'expDataRateDL' || key === 'expDataRateUL') && !expDataRateReg.test(val)) {
+ validateRulesShow[index] = true;
+ this.getRulesText('Scope: 100-3000', '', index,rulesText);
+ return false
+ } else {
+ validateRulesShow[index] = false;
+ }
+ if (!isNaN(val) && key === 'latency' && !latencyReg.test(val)) {
+ validateRulesShow[index] = true;
+ this.getRulesText('Scope: 10-200', '', index,rulesText);
+ return false
+ } else {
+ validateRulesShow[index] = false;
+ }
+ }
} \ No newline at end of file
diff --git a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html
index 3b6debb9..be199b5e 100644
--- a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html
+++ b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html
@@ -10,15 +10,15 @@
<nz-form-control [nzSpan]="15">
<input nz-input nz-tooltip [id]="item.key" [name]="item.key"
[(ngModel)]="slicing_order_info[item.key]"
- [ngClass]="{'error-input-border':validateRules[i] === true}"
- *ngIf=" item.title === 'Slicing Business Name' "
- (blur)="validator(item,slicing_order_info[item.key],i)"/>
+ [ngClass]="{'error-input-border':validateRulesShow[i] === true}"
+ *ngIf=" item.title === 'Communication Service Name' "
+ (blur)="this.Util.validator(item.title,item.key,slicing_order_info[item.key],i,rulesText,validateRulesShow)"/>
<nz-tooltip [nzTitle]="tooltipText" [nzPlacement]="'right'" [nzTrigger]="'focus'">
<input nz-input nz-tooltip [id]="item.key" [name]="item.key"
[(ngModel)]="slicing_order_info[item.key]"
- [ngClass]="{'error-input-border':validateRules[i] === true}"
- *ngIf=" item.title !== 'Slicing Business Name' && item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' "
- (blur)="validator(item,slicing_order_info[item.key],i)"
+ [ngClass]="{'error-input-border':validateRulesShow[i] === true}"
+ *ngIf=" item.title !== 'Communication Service Name' && item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' "
+ (blur)="this.Util.validator(item.title,item.key,slicing_order_info[item.key],i,rulesText,validateRulesShow)"
(focus)="changeTooltipText(item.title)"/>
</nz-tooltip>
<nz-radio-group [name]="item.key" [(ngModel)]="slicing_order_info[item.key]"
@@ -34,7 +34,7 @@
</nz-option>
</nz-select>
<nz-form-explain
- *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' && validateRules[i]"
+ *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' && validateRulesShow[i]"
class="validateRules">{{rulesText[i]}}
</nz-form-explain>
</nz-form-control>
diff --git a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts
index a07edce2..5320a064 100644
--- a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts
+++ b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts
@@ -1,5 +1,6 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "../../../../../../constants/constants";
+import { Util } from '../../../../../shared/utils/utils';
import {SlicingTaskServices} from "../../../../../core/services/slicingTaskServices";
import {NzMessageService} from "ng-zorro-antd";
@@ -12,7 +13,8 @@ export class BusinessOrderComponent implements OnInit {
constructor(
private myhttp: SlicingTaskServices,
- private message: NzMessageService
+ private message: NzMessageService,
+ private Util: Util
) {
}
@@ -38,11 +40,11 @@ export class BusinessOrderComponent implements OnInit {
};
areaList: any[] = [];
isSpinning: boolean = false;
- validateRules: any[] = [];
+ validateRulesShow: any[] = [];
rulesText: any[] = [];
tooltipText: string = 'Scope: 1-100000';
- AreaFormatting() {
+ AreaFormatting(): void {
let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street'];
this.areaList = areaList.map((item: any) => {
let arr = item.split(';');
@@ -129,26 +131,17 @@ export class BusinessOrderComponent implements OnInit {
}
}
- handleChangeSelected(area: any[], areaItem: any) {
- if (areaItem.key === 'province') {
- area[1].selected = ''
- area[1].options = [];
- area[2].selected = '';
- area[2].options = [];
- area[3].selected = '';
- area[3].options = [];
- } else if (areaItem.key === 'city') {
- area[2].selected = '';
- area[2].options = [];
- area[3].selected = '';
- area[3].options = [];
- } else if (areaItem.key === 'district') {
- area[3].selected = '';
- area[3].options = [];
- }
+ handleChangeSelected(area: any[], areaItem: any): void {
+ let areaItemIndex = area.indexOf(areaItem);
+ area.map((item,index)=>{
+ if(index > areaItemIndex){
+ item.selected = '';
+ item.options = [];
+ }
+ })
}
- handleCancel() {
+ handleCancel(): void {
this.showModel = false;
this.cancel.emit(this.showModel);
this.slicing_order_info = {
@@ -163,7 +156,7 @@ export class BusinessOrderComponent implements OnInit {
};
}
- changeTooltipText(title) {
+ changeTooltipText(title): void {
if (title === 'Max Number of UEs') {
this.tooltipText = 'Scope: 1-100000'
} else if (title === 'Data Rate Downlink (Mbps)' || title === 'Data Rate Uplink (Mbps)') {
@@ -175,61 +168,13 @@ export class BusinessOrderComponent implements OnInit {
}
}
- getRulesText = (words, title, val, index) => {
- return this.rulesText[index] = words + title
- };
-
- validator(item, val, i) {
- if (val === null || val.replace(/\s*/g, '').length <= 0) {
- this.validateRules[i] = true;
- this.getRulesText('Please enter ', item.title, val, i,);
- return false
- } else {
- this.validateRules[i] = false;
- }
- if (item.key === 'maxNumberofUEs' && !/^([1-9]\d{0,4}|100000)$/.test(val) && isNaN(val)) {
- this.validateRules[i] = true;
- this.getRulesText('Only numbers can be entered', '', '', i);
- return false
- } else if (item.key === 'maxNumberofUEs' && !/^([1-9]\d{0,4}|100000)$/.test(val) && !isNaN(val)) {
- console.log("-----maxNumberofUEs")
- this.validateRules[i] = true;
- this.getRulesText('Scope: 1-100000', '', '', i);
- return false
- } else {
- this.validateRules[i] = false;
- }
- if ((item.key === 'expDataRateDL' || item.key === 'expDataRateUL') && !/^([1-9]\d{2}|[1-3]\d{3}|3000)$/.test(val) && isNaN(val)) {
- this.validateRules[i] = true;
- this.getRulesText('Only numbers can be entered', '', '', i);
- return false
- } else if ((item.key === 'expDataRateDL' || item.key === 'expDataRateUL') && !/^([1-9]\d{2}|[1-3]\d{3}|3000)$/.test(val) && !isNaN(val)) {
- this.validateRules[i] = true;
- this.getRulesText('Scope: 100-3000', '', '', i);
- return false
- } else {
- this.validateRules[i] = false;
- }
- if (item.key === 'latency' && !/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/.test(val) && isNaN(val)) {
- this.validateRules[i] = true;
- this.getRulesText('Only numbers can be entered', '', '', i);
- return false
- } else if (item.key === 'latency' && !/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/.test(val) && !isNaN(val)) {
- this.validateRules[i] = true;
- this.getRulesText('Scope: 10-200', '', '', i);
- return false
- } else {
- this.validateRules[i] = false;
- }
- }
-
handleOk(): void {
COMMUNICATION_FORM_ITEMS.forEach((item, index) => {
if (item.key !== 'resourceSharingLevel' && item.key !== 'uEMobilityLevel' && item.key !== 'coverageArea') {
- this.validator(item, this.slicing_order_info[item.key], index)
+ this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow)
}
});
- if (this.validateRules.indexOf(true) > -1) {
+ if (this.validateRulesShow.indexOf(true) > -1) {
return
}
const coverage_list: string[] = [];