summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/shared/utils/utils.ts
diff options
context:
space:
mode:
authorcyuamber <xuranyjy@chinamobile.com>2020-02-24 17:15:28 +0800
committercyuamber <xuranyjy@chinamobile.com>2020-02-24 19:40:58 +0800
commit832bf90a245a5b164e2ed4363e58c7ddd34710a1 (patch)
tree020871c185f4002e6ff92e35f0ce3ec6e3a6d345 /usecaseui-portal/src/app/shared/utils/utils.ts
parent2f3a4ddaee7bf578f83fa9af7bd18e54c84b54d3 (diff)
feat:Public method extraction and optimization of CSMF slicing page
Change-Id: Iac04b79b18d324b16c791e58ae40d3c93165a381 Issue-ID: USECASEUI-368 Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/shared/utils/utils.ts')
-rw-r--r--usecaseui-portal/src/app/shared/utils/utils.ts42
1 files changed, 42 insertions, 0 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