From 20e5d13525b59266da6558f22e0853533c488d44 Mon Sep 17 00:00:00 2001 From: zhangab Date: Tue, 25 Dec 2018 14:54:50 +0800 Subject: Fix VNF Alarm Query Bugs Change-Id: I8fb88ed5845d0edbad6a7e70958557cd9cffe866 Issue-ID: USECASEUI-164 Signed-off-by: zhangab --- usecaseui-portal/src/app/alarm/alarm.component.ts | 4 +- usecaseui-portal/src/app/app.module.ts | 2 + .../app/components/details/details.component.ts | 4 +- .../graphiclist/graphiclist.component.ts | 4 +- .../performance-details.component.ts | 4 +- usecaseui-portal/src/app/home/home.component.ts | 4 +- usecaseui-portal/src/app/homes.service.spec.ts | 15 +++ usecaseui-portal/src/app/homes.service.ts | 103 +++++++++++++++++++++ usecaseui-portal/src/app/myhttp.service.ts | 95 ------------------- .../performance-vnf/performance-vnf.component.ts | 4 +- 10 files changed, 132 insertions(+), 107 deletions(-) create mode 100644 usecaseui-portal/src/app/homes.service.spec.ts create mode 100644 usecaseui-portal/src/app/homes.service.ts (limited to 'usecaseui-portal') diff --git a/usecaseui-portal/src/app/alarm/alarm.component.ts b/usecaseui-portal/src/app/alarm/alarm.component.ts index 9b454b02..be8aae01 100644 --- a/usecaseui-portal/src/app/alarm/alarm.component.ts +++ b/usecaseui-portal/src/app/alarm/alarm.component.ts @@ -14,7 +14,7 @@ limitations under the License. */ import { Component, OnInit, Input, Output, EventEmitter, HostBinding, Pipe, PipeTransform } from '@angular/core'; -import { MyhttpService } from '../myhttp.service'; +import { HomesService } from '../homes.service'; import { showHideAnimate, slideToRight } from '../animates'; import { DatePipe } from "@angular/common" @Component({ @@ -41,7 +41,7 @@ export class AlarmComponent implements OnInit { sourcenames: any; constructor( private datePipe: DatePipe, - private myhttp: MyhttpService) { } + private myhttp: HomesService) { } ngOnInit() { this.getAlarmFormData(); this.getSourceNames(); diff --git a/usecaseui-portal/src/app/app.module.ts b/usecaseui-portal/src/app/app.module.ts index 3b562649..8926badf 100644 --- a/usecaseui-portal/src/app/app.module.ts +++ b/usecaseui-portal/src/app/app.module.ts @@ -46,6 +46,7 @@ import { PieComponent } from './components/charts/pie/pie.component'; import {PathLocationStrategy, LocationStrategy, HashLocationStrategy} from '@angular/common'; // 自定义服务 import { MyhttpService } from './myhttp.service'; +import { HomesService } from './homes.service'; import { onboardService } from './onboard.service'; import { networkHttpservice } from './networkHttpservice.service'; import { PerformanceDetailsComponent } from './components/performance-details/performance-details.component'; @@ -55,6 +56,7 @@ import { PerformanceDetailsComponent } from './components/performance-details/pe { provide: LocationStrategy, useClass: HashLocationStrategy }, { provide: NZ_I18N, useValue: en_US }, MyhttpService, + HomesService, onboardService, networkHttpservice ], diff --git a/usecaseui-portal/src/app/components/details/details.component.ts b/usecaseui-portal/src/app/components/details/details.component.ts index 19da9e66..bc6b3246 100644 --- a/usecaseui-portal/src/app/components/details/details.component.ts +++ b/usecaseui-portal/src/app/components/details/details.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Input } from '@angular/core'; import { slideUpDown } from '../../animates'; -import { MyhttpService } from '../../myhttp.service'; +import { HomesService } from '../../homes.service'; @Component({ selector: 'app-details', @@ -10,7 +10,7 @@ import { MyhttpService } from '../../myhttp.service'; }) export class DetailsComponent implements OnInit { - constructor(private myhttp:MyhttpService) { } + constructor(private myhttp:HomesService) { } ngOnInit() { } diff --git a/usecaseui-portal/src/app/components/graphiclist/graphiclist.component.ts b/usecaseui-portal/src/app/components/graphiclist/graphiclist.component.ts index 01e716db..712f2f9e 100644 --- a/usecaseui-portal/src/app/components/graphiclist/graphiclist.component.ts +++ b/usecaseui-portal/src/app/components/graphiclist/graphiclist.component.ts @@ -14,7 +14,7 @@ limitations under the License. */ import { Component, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core'; -import { MyhttpService } from '../../myhttp.service'; +import { HomesService } from '../../homes.service'; import * as addDays from 'date-fns/add_days'; import { DatePipe } from "@angular/common" @@ -31,7 +31,7 @@ export class GraphiclistComponent implements OnInit { public pageSize: number = 10; list: any; constructor( private datePipe: DatePipe, - private myhttp: MyhttpService) { } + private myhttp: HomesService) { } isVisibleMiddle = false; showModalMiddle(): void { diff --git a/usecaseui-portal/src/app/components/performance-details/performance-details.component.ts b/usecaseui-portal/src/app/components/performance-details/performance-details.component.ts index 83467172..2b5cded5 100644 --- a/usecaseui-portal/src/app/components/performance-details/performance-details.component.ts +++ b/usecaseui-portal/src/app/components/performance-details/performance-details.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Input } from '@angular/core'; import { slideUpDown } from '../../animates'; -import { MyhttpService } from '../../myhttp.service'; +import { HomesService } from '../../homes.service'; @Component({ selector: 'app-performance-details', @@ -11,7 +11,7 @@ import { MyhttpService } from '../../myhttp.service'; export class PerformanceDetailsComponent implements OnInit { - constructor(private myhttp:MyhttpService) { } + constructor(private myhttp:HomesService) { } ngOnInit() { diff --git a/usecaseui-portal/src/app/home/home.component.ts b/usecaseui-portal/src/app/home/home.component.ts index 5d91e357..093d67ae 100644 --- a/usecaseui-portal/src/app/home/home.component.ts +++ b/usecaseui-portal/src/app/home/home.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core'; -import { MyhttpService } from '../myhttp.service'; +import { HomesService } from '../homes.service'; import { slideToRight } from '../animates'; @Component({ @@ -11,7 +11,7 @@ import { slideToRight } from '../animates'; export class HomeComponent implements OnInit { @HostBinding('@routerAnimate') routerAnimateState; - constructor(private myhttp: MyhttpService) { } + constructor(private myhttp: HomesService) { } ngOnInit() { this.getSourceNames(); diff --git a/usecaseui-portal/src/app/homes.service.spec.ts b/usecaseui-portal/src/app/homes.service.spec.ts new file mode 100644 index 00000000..9c03dcb2 --- /dev/null +++ b/usecaseui-portal/src/app/homes.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { HomesService } from './homes.service'; + +describe('HomesService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [HomesService] + }); + }); + + it('should be created', inject([HomesService], (service: HomesService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/usecaseui-portal/src/app/homes.service.ts b/usecaseui-portal/src/app/homes.service.ts new file mode 100644 index 00000000..6f104771 --- /dev/null +++ b/usecaseui-portal/src/app/homes.service.ts @@ -0,0 +1,103 @@ +/* + Copyright (C) 2018 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 } from './dataInterface'; + +@Injectable() +export class HomesService { + + constructor(private http: HttpClient) { } + // baseUrl = 'http://172.19.44.223/api/usecaseui-server/v1'; + baseUrl = '/api/usecaseui-server/v1'; + url = { + home_serviceData: this.baseUrl + "/uui-lcm/serviceNumByCustomer", + home_performanceData: this.baseUrl + "/performance/queryAllSourceNames", + home_alarmData: this.baseUrl + "/alarm/statusCount", + home_alarmChartData: this.baseUrl + "/alarm/diagram", + sourceNames: this.baseUrl + "/alarm/getSourceNames", + } + + // 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() { + return this.http.get(this.url.home_serviceData); + } + getHomePerformanceData() { + return this.http.get(this.url.home_performanceData); + } + getHomeAlarmData() { + return this.http.get(this.url.home_alarmData); + } + getHomeAlarmChartData(paramsObj) { + let params = new HttpParams({ fromObject: paramsObj }); + return this.http.get(this.url.home_alarmChartData, { params }); + } + + // alarm data + getAlarmFormData(currentPage: number, pageSize: number, sourceName?: string, priority?: string, startTime?: string, endTime?: string, vfStatus?: string) { + return this.http.get('/api/usecaseui-server/v1/alarm/' + '/' + currentPage + '/' + pageSize + '?sourceName=' + sourceName + '&priority=' + priority + '&startTime=' + startTime + '&endTime=' + endTime + '&vfStatus=' + vfStatus); + } + + getSourceNames() { + return this.http.get('/api/usecaseui-server/v1/alarm/getSourceNames/'); + } + + getstatuscount() { + let httpurl = '/api/usecaseui-server/v1/alarm/statusCount'; + return this.http.get(httpurl); + } + getAlarmDetailData(id) { + let httpurl = '/api/usecaseui-server/v1/alarm/getAlarmsHeaderDetail/' + id; + return this.http.get(httpurl); + } + + // performance data + getqueryAllSourceNames() { + let httpurl = this.baseUrl + "/api/usecaseui-server/v1/performance/queryAllSourceNames"; + return this.http.get(httpurl); + } + getperformanceSourceNames(currentPage: number, pageSize: number, sourceName: string) { + let httpurl = this.baseUrl + "/api/usecaseui-server/v1/performanceSsourceNames" + "/" + currentPage + "/" + pageSize + "?sourceName=" + sourceName; + return this.http.get(httpurl); + } + getPerformanceFormData(currentPage: number, pageSize: number, sourceName?: string, startTime?: string, endTime?: string) { + return this.http.get('/api/usecaseui-server/v1/performance' + '/' + currentPage + '/' + pageSize + '?sourceName=' + sourceName + '&startTime=' + startTime + '&endTime=' + endTime); + } + getPerformanceHeaderDetail(id) { + let httpurl = '/api/usecaseui-server/v1/performance/getPerformanceHeaderDetail/' + id; + return this.http.get(httpurl); + } + +} diff --git a/usecaseui-portal/src/app/myhttp.service.ts b/usecaseui-portal/src/app/myhttp.service.ts index 4d28d220..032471f5 100644 --- a/usecaseui-portal/src/app/myhttp.service.ts +++ b/usecaseui-portal/src/app/myhttp.service.ts @@ -24,53 +24,9 @@ import { homeData, homeVmLineData, servicesSelectData, servicesTableData, create export class MyhttpService { constructor(private http: HttpClient) { } - - // baseUrl = "./assets/json"; - // url={ - // home_serviceData:this.baseUrl + "/home_serviceData.json", - // home_performanceData:this.baseUrl + "/home_performanceData.json", - // home_alarmData:this.baseUrl + "/home_alarmData.json", - // home_alarmChartData:this.baseUrl + "/home_alarmChartData.json", - // sourceNames:this.baseUrl + "/SourceName.json", - - // customers:this.baseUrl + "/customers.json?", - // serviceType:this.baseUrl + "/serviceTypes.json?*_*", - // servicesTableData:this.baseUrl + "/servicesTableData.json", - // serviceTemplates:this.baseUrl + "/serviceTemplates2.json?", - // templateParameters:this.baseUrl + "/*_*" + "ServiceTemplateParameters.json?", - // vimInfo:this.baseUrl + "/vimInfo.json?", - // sdnControllers:this.baseUrl + "/sdnControllers.json?", - // addressData: this.baseUrl + "/siteAddressData.json?", - // createService:this.baseUrl + "/createService.json", - // ns_createService: this.baseUrl + "/createNsService.json?", - // ns_createService2: this.baseUrl + "/createNsService2.json", - // inputNamesTransform: this.baseUrl + "/configuration_files/inputNamesTranslate.json?", - // deleteService: this.baseUrl + "/deleteService.json?", - // ns_deleteService: this.baseUrl + "/deleteNsService.json?", - // ns_stopService: this.baseUrl + "/stopNsService.json?", - // ns_healService: this.baseUrl + "/healNsService.json?", - // vnfInfo: this.baseUrl + "/vnfInfo.json?", - // progress:this.baseUrl + "/progress.json?", - // nsProgress:this.baseUrl + "nsProgress.json?", - // e2eScale:this.baseUrl + "/e2eScale.json?", - // e2e_nsdata:this.baseUrl + "/e2e_nsdata.json?", - - // allottedResource:this.baseUrl + "/allotted-resources2.json?", - // pnfDetail:this.baseUrl + "/pnfdetail-domain.json?", - // connectivity:this.baseUrl + "/sotn-connectivity2.json?", - // vpnBinding:this.baseUrl + "/vpnbinding.json?", - // alarmFormData:this.baseUrl + "/alarmFormData.json?", - // } - // baseUrl = 'http://172.19.44.223/api/usecaseui-server/v1'; baseUrl = '/api/usecaseui-server/v1'; url = { - home_serviceData: this.baseUrl + "/uui-lcm/serviceNumByCustomer", - home_performanceData: this.baseUrl + "/performance/queryAllSourceNames", - home_alarmData: this.baseUrl + "/alarm/statusCount", - home_alarmChartData: this.baseUrl + "/alarm/diagram", - sourceNames: this.baseUrl + "/alarm/getSourceNames", - customers: this.baseUrl + "/uui-lcm/customers", serviceType: this.baseUrl + "/uui-lcm/customers/" + "*_*" + "/service-subscriptions", servicesTableData: this.baseUrl + '/uui-lcm/service-instances', @@ -100,21 +56,6 @@ export class MyhttpService { vpnBinding: this.baseUrl + "/uui-sotn/getPinterfaceByVpnId/", } - // home - getHomeServiceData() { - return this.http.get(this.url.home_serviceData); - } - getHomePerformanceData() { - return this.http.get(this.url.home_performanceData); - } - getHomeAlarmData() { - return this.http.get(this.url.home_alarmData); - } - getHomeAlarmChartData(paramsObj) { - let params = new HttpParams({ fromObject: paramsObj }); - return this.http.get(this.url.home_alarmChartData, { params }); - } - // serviceTable list getServicesTableData(paramsObj): Observable> { let params = new HttpParams({ fromObject: paramsObj }); @@ -280,40 +221,4 @@ export class MyhttpService { let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds; return formattime; } - - - // alarm data - getAlarmFormData(currentPage: number, pageSize: number, sourceName?: string, priority?: string, startTime?: string, endTime?: string, vfStatus?: string) { - return this.http.get('/api/usecaseui-server/v1/alarm/' + '/' + currentPage + '/' + pageSize + '?sourceName=' + sourceName + '&priority=' + priority + '&startTime=' + startTime + '&endTime=' + endTime + '&vfStatus=' + vfStatus); - } - - getSourceNames() { - return this.http.get('/api/usecaseui-server/v1/alarm/getSourceNames/'); - } - - getstatuscount() { - let httpurl = '/api/usecaseui-server/v1/alarm/statusCount'; - return this.http.get(httpurl); - } - getAlarmDetailData(id) { - let httpurl = '/api/usecaseui-server/v1/alarm/getAlarmsHeaderDetail/' + id; - return this.http.get(httpurl); - } - - // performance data - getqueryAllSourceNames() { - let httpurl = this.baseUrl + "/api/usecaseui-server/v1/performance/queryAllSourceNames"; - return this.http.get(httpurl); - } - getperformanceSourceNames(currentPage: number, pageSize: number, sourceName: string) { - let httpurl = this.baseUrl + "/api/usecaseui-server/v1/performanceSsourceNames" + "/" + currentPage + "/" + pageSize + "?sourceName=" + sourceName; - return this.http.get(httpurl); - } - getPerformanceFormData(currentPage: number, pageSize: number, sourceName?: string, startTime?: string, endTime?: string) { - return this.http.get('/api/usecaseui-server/v1/performance' + '/' + currentPage + '/' + pageSize + '?sourceName=' + sourceName + '&startTime=' + startTime + '&endTime=' + endTime); - } - getPerformanceHeaderDetail(id) { - let httpurl = '/api/usecaseui-server/v1/performance/getPerformanceHeaderDetail/' + id; - return this.http.get(httpurl); - } } diff --git a/usecaseui-portal/src/app/performance/performance-vnf/performance-vnf.component.ts b/usecaseui-portal/src/app/performance/performance-vnf/performance-vnf.component.ts index 934cfd16..e52e19d2 100644 --- a/usecaseui-portal/src/app/performance/performance-vnf/performance-vnf.component.ts +++ b/usecaseui-portal/src/app/performance/performance-vnf/performance-vnf.component.ts @@ -15,7 +15,7 @@ */ import { Component, OnInit, HostBinding } from '@angular/core'; import { slideToRight, showHideAnimate } from '../../animates'; -import { MyhttpService } from '../../myhttp.service'; +import { HomesService } from '../../homes.service'; @Component({ selector: 'app-performance-vnf', @@ -35,7 +35,7 @@ export class PerformanceVnfComponent implements OnInit { list: any; constructor( - private myhttp: MyhttpService) { } + private myhttp: HomesService) { } ngOnInit() { this.getqueryAllSourceNames(); -- cgit 1.2.3-korg