diff options
author | wangyuerg <wangyuerg@chinamobile.com> | 2020-09-03 18:48:10 +0800 |
---|---|---|
committer | wangyuerg <wangyuerg@chinamobile.com> | 2020-09-03 19:02:32 +0800 |
commit | 0d9c465fa7053a26c3daeeb841057d571ce2b587 (patch) | |
tree | f09bfca2387b6c67efd5f696e24a6646f7d628d5 /usecaseui-portal/src/app/shared | |
parent | f40d70f5c87091c0f567e800bfb21b8a1bc79905 (diff) |
fix: change parameters of subnet, change the selection box of nexthop to an input box; method abstraction and extration; set placeholder for all input box; cancel required fields for jitter
Change-Id: If7efba49d01d870414146eea3359491b3e2cd5c0
Signed-off-by: wangyuerg <wangyuerg@chinamobile.com>
Issue-ID: USECASEUI-444
Diffstat (limited to 'usecaseui-portal/src/app/shared')
-rw-r--r-- | usecaseui-portal/src/app/shared/utils/utils.ts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts index 63d3e3b7..ad6a2f10 100644 --- a/usecaseui-portal/src/app/shared/utils/utils.ts +++ b/usecaseui-portal/src/app/shared/utils/utils.ts @@ -73,4 +73,53 @@ export class Util { 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 |