import { BsDropdownModule } from 'ngx-bootstrap';
import {
- TablePerformanceCounterService
-} from '../../../shared/api/table-performance-counter.service';
+ PerformanceCounterService
+} from '../../../shared/api/performance-counter.service';
import { PerformanceCounterModule } from '../performance-counter.module';
import { PerformanceCounterComponent } from './performance-counter.component';
async(() => {
TestBed.configureTestingModule({
imports: [PerformanceCounterModule, BsDropdownModule.forRoot(), RouterTestingModule],
- providers: [{ provide: TablePerformanceCounterService, useValue: fakeService }]
+ providers: [{ provide: PerformanceCounterService, useValue: fakeService }]
}).compileComponents();
})
);
import { Component, Input, OnInit, TemplateRef, ViewChild } from '@angular/core';
import {
- TablePerformanceCounterService
-} from '../../../shared/api/table-performance-counter.service';
+ PerformanceCounterService
+} from '../../../shared/api/performance-counter.service';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
/**
*/
@Input() serviceId: string;
- constructor(private performanceCounterService: TablePerformanceCounterService) { }
+ constructor(private performanceCounterService: PerformanceCounterService) { }
ngOnInit() {
this.columns = [
getCounters() {
this.performanceCounterService.get(this.serviceType, this.serviceId)
- .then((resp) => {
+ .subscribe((resp: object[]) => {
this.counters = resp;
});
}
import { HostService } from './host.service';
import { MonitorService } from './monitor.service';
import { OsdService } from './osd.service';
+import { PerformanceCounterService } from './performance-counter.service';
import { PoolService } from './pool.service';
import { RbdMirroringService } from './rbd-mirroring.service';
import { RbdService } from './rbd.service';
import { RgwBucketService } from './rgw-bucket.service';
import { RgwDaemonService } from './rgw-daemon.service';
import { RgwUserService } from './rgw-user.service';
-import { TablePerformanceCounterService } from './table-performance-counter.service';
import { TcmuIscsiService } from './tcmu-iscsi.service';
@NgModule({
RgwBucketService,
RgwDaemonService,
RgwUserService,
- TablePerformanceCounterService,
+ PerformanceCounterService,
TcmuIscsiService
]
})
--- /dev/null
+import { HttpClientModule } from '@angular/common/http';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { inject, TestBed } from '@angular/core/testing';
+
+import { BsDropdownModule } from 'ngx-bootstrap';
+
+import { PerformanceCounterService } from './performance-counter.service';
+
+describe('PerformanceCounterService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [PerformanceCounterService],
+ imports: [
+ HttpClientTestingModule,
+ BsDropdownModule.forRoot(),
+ HttpClientModule
+ ]
+ });
+ });
+
+ it(
+ 'should be created',
+ inject([PerformanceCounterService], (service: PerformanceCounterService) => {
+ expect(service).toBeTruthy();
+ })
+ );
+});
--- /dev/null
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+
+@Injectable()
+export class PerformanceCounterService {
+
+ private url = 'api/perf_counters';
+
+ constructor(private http: HttpClient) {}
+
+ list() {
+ return this.http.get(this.url);
+ }
+
+ get(service_type: string, service_id: string) {
+ const serviceType = service_type.replace('-', '_');
+ return this.http.get(`${this.url}/${serviceType}/${service_id}`)
+ .flatMap((resp) => {
+ return Observable.of(resp['counters']);
+ });
+ }
+}
+++ /dev/null
-import { HttpClientModule } from '@angular/common/http';
-import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { inject, TestBed } from '@angular/core/testing';
-
-import { BsDropdownModule } from 'ngx-bootstrap';
-
-import { TablePerformanceCounterService } from './table-performance-counter.service';
-
-describe('TablePerformanceCounterService', () => {
- beforeEach(() => {
- TestBed.configureTestingModule({
- providers: [TablePerformanceCounterService],
- imports: [
- HttpClientTestingModule,
- BsDropdownModule.forRoot(),
- HttpClientModule
- ]
- });
- });
-
- it(
- 'should be created',
- inject([TablePerformanceCounterService], (service: TablePerformanceCounterService) => {
- expect(service).toBeTruthy();
- })
- );
-});
+++ /dev/null
-import { HttpClient } from '@angular/common/http';
-import { Injectable } from '@angular/core';
-
-@Injectable()
-export class TablePerformanceCounterService {
-
- private url = 'api/perf_counters';
-
- constructor(private http: HttpClient) { }
-
- list() {
- return this.http.get(this.url)
- .toPromise()
- .then((resp: object): object => {
- return resp;
- });
- }
-
- get(service_type: string, service_id: string) {
- const serviceType = service_type.replace('-', '_');
-
- return this.http.get(`${this.url}/${serviceType}/${service_id}`)
- .toPromise()
- .then((resp: object): Array<object> => {
- return resp['counters'];
- });
- }
-}