summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app
diff options
context:
space:
mode:
authorcyuamber <xuranyjy@chinamobile.com>2019-09-01 22:05:42 +0800
committercyuamber <xuranyjy@chinamobile.com>2019-09-01 22:05:48 +0800
commit19abe2af19ba49073949f8254aec897afe7bb303 (patch)
treecd5c6596873748655eb492ff43fbe4942f68406e /usecaseui-portal/src/app
parente1f0160baa1f38cdb35705a39a0d42dc6d67f63d (diff)
docs: add copyright info and changelog
Change-Id: Ie2c7aa97aaf99c7a274f5ca45366f549223ba028 Issue-ID: USECASEUI-307 Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app')
-rw-r--r--usecaseui-portal/src/app/shared/utils/http.ts49
-rw-r--r--usecaseui-portal/src/app/shared/utils/utils.ts18
2 files changed, 49 insertions, 18 deletions
diff --git a/usecaseui-portal/src/app/shared/utils/http.ts b/usecaseui-portal/src/app/shared/utils/http.ts
index c0fc3f29..0d63418b 100644
--- a/usecaseui-portal/src/app/shared/utils/http.ts
+++ b/usecaseui-portal/src/app/shared/utils/http.ts
@@ -1,32 +1,47 @@
-import axios from 'axios';
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+import axios from 'axios';
-export default function http (url:string,data:object = {},method:any = 'get',query?:string | object):any {
- return new Promise((resolve,reject) => {
+export default function http(url: string, data: object = {}, method: any = 'get', query?: string | object): any {
+ return new Promise((resolve, reject) => {
method = method.trim().toLocaleLowerCase()
- let promise:any;
- if(method === 'get' || method === 'delete'){
- let options:object;
- if(JSON.stringify(data) === '{}'){
+ let promise: any;
+ if (method === 'get' || method === 'delete') {
+ let options: object;
+ if (JSON.stringify(data) === '{}') {
options = { method, url };
- }else{
- options = { method, url, params: data};
+ } else {
+ options = { method, url, params: data };
}
- if(method === 'delete'){
+ if (method === 'delete') {
}
promise = axios(options);
- }else if (method === 'post' || method === 'put') {
- if(method === 'post' && query){
- let params:string = '';
- if(<string>query){
+ } else if (method === 'post' || method === 'put') {
+ if (method === 'post' && query) {
+ let params: string = '';
+ if (<string>query) {
query = JSON.parse((<string>query));
}
Object.keys(query).forEach(item => {
- params += '&' + item + '=' + query[item];
+ params += '&' + item + '=' + query[item];
})
params = params.slice(1);
url += '?' + params;
@@ -39,9 +54,9 @@ export default function http (url:string,data:object = {},method:any = 'get',que
}
promise
.then((response) => {
- if(response.status === 200 || 304){
+ if (response.status === 200 || 304) {
resolve(response.data)
- }else{
+ } else {
reject(response)
}
})
diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts
index abdb9836..1aa9673e 100644
--- a/usecaseui-portal/src/app/shared/utils/utils.ts
+++ b/usecaseui-portal/src/app/shared/utils/utils.ts
@@ -1,4 +1,20 @@
-export class Util{
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+export class Util {
// Time formatting milliseconds to normal
dateformater(vmstime) {
if (!vmstime) {