summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/shared/utils
diff options
context:
space:
mode:
Diffstat (limited to 'usecaseui-portal/src/app/shared/utils')
-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) {