@AuthRequired()
class PerfCounters(RESTController):
def __init__(self):
+ self.mds = PerfCounter('mds', self.mgr)
self.mon = PerfCounter('mon', self.mgr)
self.osd = PerfCounter('osd', self.mgr)
self.rgw = PerfCounter('rgw', self.mgr)
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
import { ComponentsModule } from '../../shared/components/components.module';
import { SharedModule } from '../../shared/shared.module';
import { HostsComponent } from './hosts/hosts.component';
import { MonitorService } from './monitor.service';
import { MonitorComponent } from './monitor/monitor.component';
-import { ServiceListPipe } from './service-list.pipe';
@NgModule({
imports: [
CommonModule,
ComponentsModule,
- SharedModule
+ SharedModule,
+ RouterModule
],
declarations: [
HostsComponent,
- ServiceListPipe,
MonitorComponent,
],
providers: [
- ServiceListPipe,
MonitorService
]
})
[toolHeader]="false"
[footer]="false"
[limit]="0">
+ <ng-template #servicesTpl let-value="value">
+ <span *ngFor="let service of value; last as isLast">
+ <a [routerLink]="[service.cdLink]">{{ service.type }}.{{ service.id }}</a>{{ !isLast ? ", " : "" }}
+ </span>
+ </ng-template>
</cd-table>
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { RouterTestingModule } from '@angular/router/testing';
import { ComponentsModule } from '../../../shared/components/components.module';
import { SharedModule } from '../../../shared/shared.module';
-import { ServiceListPipe } from '../service-list.pipe';
import { HostsComponent } from './hosts.component';
describe('HostsComponent', () => {
imports: [
SharedModule,
HttpClientTestingModule,
- ComponentsModule
+ ComponentsModule,
+ RouterTestingModule
],
declarations: [
- HostsComponent,
- ServiceListPipe
- ],
- providers: [
- ServiceListPipe
+ HostsComponent
]
})
.compileComponents();
-import { Component, OnInit } from '@angular/core';
-
-import { ServiceListPipe } from '../service-list.pipe';
+import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
import { HostService } from '../../../shared/services/host.service';
columns: Array<object> = [];
hosts: Array<object> = [];
+ @ViewChild('servicesTpl') public servicesTpl: TemplateRef<any>;
+
constructor(private hostService: HostService,
- cephShortVersionPipe: CephShortVersionPipe,
- serviceListPipe: ServiceListPipe) {
+ private cephShortVersionPipe: CephShortVersionPipe) { }
+
+ ngOnInit() {
this.columns = [
{
name: 'Hostname',
name: 'Services',
prop: 'services',
flexGrow: 3,
- pipe: serviceListPipe
+ cellTemplate: this.servicesTpl
},
{
name: 'Version',
prop: 'ceph_version',
flexGrow: 1,
- pipe: cephShortVersionPipe
+ pipe: this.cephShortVersionPipe
}
];
- }
-
- ngOnInit() {
this.hostService.list().then((resp) => {
+ resp.map((host) => {
+ host.services.map((service) => {
+ service.cdLink = `/perf_counters/${service.type}/${service.id}`;
+ return service;
+ });
+ return host;
+ });
this.hosts = resp;
});
}
+++ /dev/null
-import { ServiceListPipe } from './service-list.pipe';
-
-describe('ServiceListPipe', () => {
- it('create an instance', () => {
- const pipe = new ServiceListPipe();
- expect(pipe).toBeTruthy();
- });
-});
+++ /dev/null
-import { Pipe, PipeTransform } from '@angular/core';
-
-@Pipe({
- name: 'serviceList'
-})
-export class ServiceListPipe implements PipeTransform {
- transform(value: any, args?: any): any {
- const strings = [];
- value.forEach((server) => {
- strings.push(server.type + '.' + server.id);
- });
- return strings.join(', ');
- }
-}
-<nav aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item">Cluster</li>
- <li class="breadcrumb-item active">
- <a [routerLink]="['/monitor']">Monitors</a>
- </li>
- <li class="breadcrumb-item active">{{ serviceType }}.{{ serviceId }} </li>
- </ol>
-</nav>
-
<fieldset>
<legend>Performance Counters</legend>
-
+ <h3>{{ serviceType }}.{{ serviceId }}</h3>
<cd-table-performance-counter [serviceType]="serviceType"
[serviceId]="serviceId">
</cd-table-performance-counter>
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { TablePerformanceCounterService } from '../services/table-performance-counter.service';
-
@Component({
selector: 'cd-performance-counter',
templateUrl: './performance-counter.component.html',
serviceType: string;
routeParamsSubscribe: any;
- constructor(
- private route: ActivatedRoute,
- private performanceCounterService: TablePerformanceCounterService
- ) {}
+ constructor(private route: ActivatedRoute) { }
ngOnInit() {
this.routeParamsSubscribe = this.route.params.subscribe(