summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app
diff options
context:
space:
mode:
authorcyuamber <xuranyjy@chinamobile.com>2019-08-23 17:02:50 +0800
committercyuamber <xuranyjy@chinamobile.com>2019-08-23 17:33:55 +0800
commitc048639a46be107578e8ce0d8721bc7b5d4fe791 (patch)
tree3dd670c62d70897df604237bd99fc2562045fe9f /usecaseui-portal/src/app
parent1ed096510209590d1656489a74692eb5ebcdeee4 (diff)
feat:optimize public function and home page api
Change-Id: Idf849f381af9adbfae7d8a6e012d8949d170c666 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/core/services/homes.service.ts22
-rw-r--r--usecaseui-portal/src/app/myhttp.service.ts226
-rw-r--r--usecaseui-portal/src/app/shared/utils/utils.js0
-rw-r--r--usecaseui-portal/src/app/shared/utils/utils.ts18
-rw-r--r--usecaseui-portal/src/app/views/alarm/alarm.component.ts7
-rw-r--r--usecaseui-portal/src/app/views/home/home.component.ts11
6 files changed, 33 insertions, 251 deletions
diff --git a/usecaseui-portal/src/app/core/services/homes.service.ts b/usecaseui-portal/src/app/core/services/homes.service.ts
index 8d3f4684..218756d4 100644
--- a/usecaseui-portal/src/app/core/services/homes.service.ts
+++ b/usecaseui-portal/src/app/core/services/homes.service.ts
@@ -16,7 +16,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
-import { homeData, homeVmLineData, servicesSelectData, servicesTableData, creatensData, onboardTableData, onboardDataVNF, onboardDataPNF, baseUrl } from '../models/dataInterface';
+import { baseUrl } from '../models/dataInterface';
@Injectable()
export class HomesService {
@@ -36,25 +36,7 @@ export class HomesService {
sourceNames: this.baseUrl + "/alarm/getSourceNames",
listSortMasters: this.baseUrl + "/listSortMasters",
currentLanguage: "/api/portal-auxapi/languageSetting/user/",
- }
-
- // Time formatting milliseconds to normal
- dateformater(vmstime) {
- if (!vmstime) {
- return ''
- }
- let mstime = Number((vmstime + '').slice(0, 13));
- let time = new Date(mstime);
- let year = time.getFullYear();
- let month = time.getMonth() + 1;
- let day = time.getDate();
- let hours = time.getHours();
- let minutes = time.getMinutes();
- let seconds = time.getSeconds();
- let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
- return formattime;
- }
-
+ };
// home
getHomeServiceData() {
diff --git a/usecaseui-portal/src/app/myhttp.service.ts b/usecaseui-portal/src/app/myhttp.service.ts
deleted file mode 100644
index d85076fa..00000000
--- a/usecaseui-portal/src/app/myhttp.service.ts
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- 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 { Injectable } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { homeData, homeVmLineData, servicesSelectData, servicesTableData, creatensData, onboardTableData, onboardDataVNF, onboardDataPNF, baseUrl } from './core/models/dataInterface';
-
-@Injectable()
-export class MyhttpService {
-
- constructor(private http: HttpClient) { }
- baseUrl = baseUrl.baseUrl;
- url = {
- listSortMasters: this.baseUrl + "/listSortMasters",
- customers: this.baseUrl + "/uui-lcm/customers",
- orchestrators: this.baseUrl + "/uui-lcm/orchestrators",
- serviceType: this.baseUrl + "/uui-lcm/customers/" + "*_*" + "/service-subscriptions",
- servicesTableData: this.baseUrl + '/uui-lcm/service-instances',
- serviceTemplates: this.baseUrl + "/uui-lcm/service-templates",
- templateParameters: this.baseUrl + "/uui-lcm/fetchCCVPNTemplateData/*_*",
- e2etemplateParameters: this.baseUrl + "/uui-lcm/service-templates/" + "*_*" + "?toscaModelPath=",
- nstemplateParameters: this.baseUrl + "/uui-lcm/fetchNsTemplateData",
- vimInfo: this.baseUrl + "/uui-lcm/locations/",
- sdnControllers: this.baseUrl + "/uui-lcm/sdnc-controllers/",
- createService: this.baseUrl + "/uui-lcm/services",
- ns_createService: this.baseUrl + "/uui-lcm/createNetworkServiceInstance",
- ns_createService2: this.baseUrl + "/uui-lcm/instantiateNetworkServiceInstance",
- deleteService: this.baseUrl + "/uui-lcm/services/",
- ns_deleteService: this.baseUrl + "/uui-lcm/deleteNetworkServiceInstance?ns_instance_id=",
- ns_stopService: this.baseUrl + "/uui-lcm/terminateNetworkServiceInstance?ns_instance_id=",
- ns_healService: this.baseUrl + "/uui-lcm/healNetworkServiceInstance?ns_instance_id=",
- vnfInfo: this.baseUrl + "/uui-lcm/VnfInfo/",
- progress: this.baseUrl + "/uui-lcm/services/" + "*_*" + "/operations/",
- nsProgress: this.baseUrl + "/uui-lcm/jobs/getNsLcmJobStatus/" + "*_*" + "?responseId=0&serviceInstanceId=",
- e2eScale: this.baseUrl + "/services/scaleServices/",
- e2e_nsdata: this.baseUrl + "/getServiceInstanceById/customerId/",
- updateccvpn: this.baseUrl + "/uui-lcm/services/updateService/",
-
- //The following api is about ccvpn details topology
- allottedResource: this.baseUrl + "/uui-sotn/getAllottedResources",
- pnfDetail: this.baseUrl + "/uui-sotn/getPnfInfo/",
- connectivity: this.baseUrl + "/uui-sotn/getConnectivityInfo/",
- vpnBinding: this.baseUrl + "/uui-sotn/getPinterfaceByVpnId/",
- };
-
- // serviceTable list
- getServicesTableData(paramsObj): Observable<HttpResponse<servicesTableData>> {
- let params = new HttpParams({ fromObject: paramsObj });
- return this.http.get<servicesTableData>(this.url.servicesTableData, { observe: 'response', params });
- }
-
- //---------------------------------------------------------------------------------
-
- // Get all customers
- getAllCustomers() {
- return this.http.get<any>(this.url.customers);
- }
-
- // Get all Orchestrators
- getAllOrchestrators() {
- return this.http.get<any>(this.url.orchestrators);
- }
-
- // Get relevant serviceType
- getServiceTypes(customer) {
- let url = this.url.serviceType.replace("*_*", customer.id);
- return this.http.get<any>(url);
- }
-
-
- // Get all template types
- getAllServiceTemplates(type) {
- if (type == "Network Service") {
- let nsUrl = this.url.serviceTemplates.replace("service-templates", "listNsTemplates").replace("serviceTemplates2", "serviceTemplates-ns");
- console.log(nsUrl);
- return this.http.get<any>(nsUrl);
- }
- return this.http.get<any>(this.url.serviceTemplates);
- }
-
-
- //Get template input parameters
- getTemplateParameters(type, template) {
- if (type == "ns") {
- let body = {
- csarId: template.id,
- inputs: ""
- };
- return this.http.post<any>(this.url.nstemplateParameters, body);
- } else if (type == "e2e") {
- let url = this.url.e2etemplateParameters.replace("*_*", template.uuid) + template.toscaModelURL;
- return this.http.get<any>(url);
- } else {
- let body = {
- csarId: template.uuid,
- packageType: "Service",
- inputs: ""
- };
- let url = this.url.templateParameters.replace("*_*", template.uuid);
- return this.http.post<any>(url, body);
- }
- }
-
- getVimInfo() {
- return this.http.get<any>(this.url.vimInfo);
- };
- getSdnControllers() {
- return this.http.get<any>(this.url.sdnControllers);
- }
-
- // Create interface
- createInstance(requestBody, createParams) {
- // return this.http.get<any>(this.url.createService + createParams); //Local simulation
- return this.http.post<any>(this.url.createService + createParams, requestBody);
- }
- nsCreateInstance(requestBody) {
- // return this.http.get<any>(this.url.ns_createService); //Local simulation
- return this.http.post<any>(this.url.ns_createService, requestBody);
- }
- nsCreateInstance2(params, requestBody) {
- // return this.http.get<any>(this.url.ns_createService2 + params); //Local simulation
- return this.http.post<any>(this.url.ns_createService2 + params, requestBody);
- }
-
- updateccvpn(id, requestBody) {
- return this.http.put<any>(this.url.updateccvpn + id, requestBody);// online
- }
- // Delete interface
- deleteInstance(obj) {
- let httpOptions = {
- headers: new HttpHeaders({
- 'Content-Type': 'application/json',
- 'Accept': 'application/json',
- 'Authorization': 'Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=='
- }),
- body: {
- 'globalSubscriberId': obj.globalSubscriberId,
- 'serviceType': obj.serviceType.name
- }
- };
- return this.http.delete<any>(this.url.deleteService + obj.serviceInstanceId, httpOptions);
- }
- nsDeleteInstance(id) {
- return this.http.delete<any>(this.url.ns_deleteService + id);
- }
- stopNsService(id, requestBody) { //You need to terminate before deleting
- return this.http.post<any>(this.url.ns_stopService + id, requestBody);
- }
-
- getVnfInfo(id) {
- return this.http.get<any>(this.url.vnfInfo + id);
- }
- healNsService(id, requestBody) {
- return this.http.post<any>(this.url.ns_healService + id, requestBody);
- }
-
- // scale
- scaleE2eService(id, requestBody) {
- return this.http.post<any>(this.url.e2eScale + id, requestBody);
- }
- getE2e_nsData(paramsObj) {
- let params = new HttpParams({ fromObject: paramsObj });
- return this.http.get<any>(this.url.e2e_nsdata, { params });
- }
-
- // Query progress interface
- getProgress(obj) {
- let url = this.url.progress.replace("*_*", obj.serviceId) + obj.operationId + "?operationType=" + obj.operationType;
- return this.http.get<any>(url);
- }
- getNsProgress(jobid, serviceId, operationType) {
- let url = this.url.nsProgress.replace("*_*", jobid) + serviceId + "&operationType=" + operationType;
- return this.http.get<any>(url);
- }
-
- // Get allotted-resource to get tp and pnf values
- getAllottedResource(obj) {
- let params = new HttpParams({ fromObject: obj });
- let url = this.url.allottedResource;
- return this.http.get<any>(url, { params });
- }
- //Get the corresponding domain (network-resource) by pnf value
- getPnfDetail(name) {
- let url = this.url.pnfDetail + name;
- return this.http.get<any>(url);
- }
- //Get connectivity by sotn, find vpn-id
- getSotnConnectivity(id) {
- let url = this.url.connectivity + id;
- return this.http.get<any>(url);
- }
- //Find tp and pnf by vpn-id
- getVpnBinding(id) {
- let url = this.url.vpnBinding + id;
- return this.http.get<any>(url);
- }
- // Time formatting milliseconds to normal
- dateformater(vmstime) {
- if (!vmstime) {
- return ''
- }
- let mstime = Number((vmstime + '').slice(0, 13));
- let time = new Date(mstime);
- let year = time.getFullYear();
- let month = time.getMonth() + 1;
- let day = time.getDate();
- let hours = time.getHours();
- let minutes = time.getMinutes();
- let seconds = time.getSeconds();
- let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
- return formattime;
- }
-}
diff --git a/usecaseui-portal/src/app/shared/utils/utils.js b/usecaseui-portal/src/app/shared/utils/utils.js
deleted file mode 100644
index e69de29b..00000000
--- a/usecaseui-portal/src/app/shared/utils/utils.js
+++ /dev/null
diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts
new file mode 100644
index 00000000..abdb9836
--- /dev/null
+++ b/usecaseui-portal/src/app/shared/utils/utils.ts
@@ -0,0 +1,18 @@
+export class Util{
+ // Time formatting milliseconds to normal
+ dateformater(vmstime) {
+ if (!vmstime) {
+ return ''
+ }
+ let mstime = Number((vmstime + '').slice(0, 13));
+ let time = new Date(mstime);
+ let year = time.getFullYear();
+ let month = time.getMonth() + 1;
+ let day = time.getDate();
+ let hours = time.getHours();
+ let minutes = time.getMinutes();
+ let seconds = time.getSeconds();
+ let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
+ return formattime;
+ }
+} \ No newline at end of file
diff --git a/usecaseui-portal/src/app/views/alarm/alarm.component.ts b/usecaseui-portal/src/app/views/alarm/alarm.component.ts
index c2a567bd..c3223236 100644
--- a/usecaseui-portal/src/app/views/alarm/alarm.component.ts
+++ b/usecaseui-portal/src/app/views/alarm/alarm.component.ts
@@ -16,6 +16,7 @@
import { Component, OnInit, Input, Output, EventEmitter, HostBinding, Pipe, PipeTransform } from '@angular/core';
import { HomesService } from '../../core/services/homes.service';
import { showHideAnimate, slideToRight } from '../../shared/utils/animates';
+import { Util } from '../../shared/utils/utils';
import { DatePipe } from '@angular/common';
@Component({
selector: 'app-alarm',
@@ -33,7 +34,7 @@ export class AlarmComponent implements OnInit {
public pageSize: number = 10;
public sourceName: string = '';
public priority: string = '';
- public startTime: string = this.myhttp.dateformater(Date.now() - 30 * 24 * 60 * 60 * 1000);
+ public startTime: string = this.Util.dateformater(Date.now() - 30 * 24 * 60 * 60 * 1000);
public endTime: string = this.datePipe.transform(new Date(), 'yyyy-MM-dd HH:mm:ss');
public vfStatus: string = '';
public sourceNameList: Array<any> = ['---auto---'];
@@ -41,7 +42,9 @@ export class AlarmComponent implements OnInit {
sourcenames: any;
constructor(
private datePipe: DatePipe,
- private myhttp: HomesService) { }
+ private myhttp: HomesService,
+ private Util: Util
+ ) { }
ngOnInit() {
this.getAlarmFormData();
this.getSourceNames();
diff --git a/usecaseui-portal/src/app/views/home/home.component.ts b/usecaseui-portal/src/app/views/home/home.component.ts
index 681e272f..153e2219 100644
--- a/usecaseui-portal/src/app/views/home/home.component.ts
+++ b/usecaseui-portal/src/app/views/home/home.component.ts
@@ -16,6 +16,7 @@
import { Component, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core';
import { HomesService } from '../../core/services/homes.service';
import { slideToRight } from '../../shared/utils/animates';
+import { Util } from '../../shared/utils/utils';
import { TranslateService } from "@ngx-translate/core";
import { Router } from '@angular/router';
@@ -28,7 +29,11 @@ import { Router } from '@angular/router';
export class HomeComponent implements OnInit {
@HostBinding('@routerAnimate') routerAnimateState;
- constructor(private myhttp: HomesService, private router: Router) { }
+ constructor(
+ private myhttp: HomesService,
+ private router: Router,
+ private Util: Util
+ ) { }
ngOnInit() {
this.getListSortMasters();
@@ -495,8 +500,8 @@ export class HomeComponent implements OnInit {
}
}
getHomeAlarmChartData() {
- let nowTime = this.myhttp.dateformater(Date.now());
- let startTime = this.myhttp.dateformater(Date.now() - 30 * 24 * 60 * 60 * 1000);
+ let nowTime = this.Util.dateformater(Date.now());
+ let startTime = this.Util.dateformater(Date.now() - 30 * 24 * 60 * 60 * 1000);
let obj = {
sourceName: this.sourceNameSelected,
startTime: startTime,