]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
833417904aa1dee81b38e95fa882d58c56d92712
[ceph.git] /
1 import { Component, Input, OnInit, TemplateRef, ViewChild } from '@angular/core';
2
3 import {
4   PerformanceCounterService
5 } from '../../../shared/api/performance-counter.service';
6 import { CdTableColumn } from '../../../shared/models/cd-table-column';
7
8 /**
9  * Display the specified performance counters in a datatable.
10  */
11 @Component({
12   selector: 'cd-table-performance-counter',
13   templateUrl: './table-performance-counter.component.html',
14   styleUrls: ['./table-performance-counter.component.scss']
15 })
16 export class TablePerformanceCounterComponent implements OnInit {
17
18   columns: Array<CdTableColumn> = [];
19   counters: Array<object> = [];
20
21   @ViewChild('valueTpl') public valueTpl: TemplateRef<any>;
22
23   /**
24    * The service type, e.g. 'rgw', 'mds', 'mon', 'osd', ...
25    */
26   @Input() serviceType: string;
27
28   /**
29    * The service identifier.
30    */
31   @Input() serviceId: string;
32
33   constructor(private performanceCounterService: PerformanceCounterService) { }
34
35   ngOnInit() {
36     this.columns = [
37       {
38         name: 'Name',
39         prop: 'name',
40         flexGrow: 1
41       },
42       {
43         name: 'Description',
44         prop: 'description',
45         flexGrow: 1
46       },
47       {
48         name: 'Value',
49         cellTemplate: this.valueTpl,
50         flexGrow: 1
51       }
52     ];
53   }
54
55   getCounters() {
56     this.performanceCounterService.get(this.serviceType, this.serviceId)
57       .subscribe((resp: object[]) => {
58         this.counters = resp;
59       });
60   }
61 }