import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+import { ComponentsModule } from '../../shared/components/components.module';
import { SharedModule } from '../../shared/shared.module';
import { HostsComponent } from './hosts/hosts.component';
import { ServiceListPipe } from './service-list.pipe';
@NgModule({
imports: [
CommonModule,
+ ComponentsModule,
SharedModule
],
- declarations: [HostsComponent, ServiceListPipe],
+ declarations: [
+ HostsComponent,
+ ServiceListPipe
+ ],
+ providers: [
+ ServiceListPipe
+ ]
})
export class ClusterModule { }
<li class="breadcrumb-item active">Hosts</li>
</ol>
</nav>
-<table class="table table-bordered">
- <thead>
- <tr>
- <th>
- Hostname
- </th>
- <th>
- Services
- </th>
- <th>
- Version
- </th>
- </tr>
- </thead>
- <tbody>
- <tr *ngFor="let host of hosts">
- <td>
- {{ host.hostname }}
- </td>
- <td>
- {{ host.services | serviceList }}
- </td>
- <td>
- {{ host.ceph_version | cephShortVersion }}
- </td>
- </tr>
- </tbody>
-</table>
+<cd-table [data]="hosts"
+ [columns]="columns"
+ columnMode="flex"
+ [toolHeader]="false"
+ [footer]="false">
+</cd-table>
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/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';
TestBed.configureTestingModule({
imports: [
SharedModule,
- HttpClientTestingModule
+ HttpClientTestingModule,
+ ComponentsModule
],
declarations: [
HostsComponent,
ServiceListPipe
+ ],
+ providers: [
+ ServiceListPipe
]
})
.compileComponents();
import { Component, OnInit } from '@angular/core';
+import { ServiceListPipe } from '../service-list.pipe';
+
+import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
import { HostService } from '../../../shared/services/host.service';
@Component({
})
export class HostsComponent implements OnInit {
- hosts: any = [];
+ columns: Array<object> = [];
+ hosts: Array<object> = [];
- constructor(private hostService: HostService) { }
+ constructor(private hostService: HostService,
+ cephShortVersionPipe: CephShortVersionPipe,
+ serviceListPipe: ServiceListPipe) {
+ this.columns = [
+ {
+ name: 'Hostname',
+ prop: 'hostname',
+ flexGrow: 1
+ },
+ {
+ name: 'Services',
+ prop: 'services',
+ flexGrow: 3,
+ pipe: serviceListPipe
+ },
+ {
+ name: 'Version',
+ prop: 'ceph_version',
+ flexGrow: 1,
+ pipe: cephShortVersionPipe
+ }
+ ];
+ }
ngOnInit() {
this.hostService.list().then((resp) => {
<div class="dataTables_wrapper">
<div class="dataTables_header clearfix"
- *ngIf="header">
+ *ngIf="toolHeader">
<!-- actions -->
<div class="oadatatableactions">
<ng-content select="table-actions"></ng-content>
[selected]="selected"
(select)="toggleExpandRow($event)"
[columns]="columns"
- [columnMode]="'force'"
+ [columnMode]="columnMode"
[rows]="rows"
- [footerHeight]="'auto'"
+ [headerHeight]="header ? 'auto' : 0"
+ [footerHeight]="footer ? 'auto' : 0"
[limit]="limit"
[loadingIndicator]="true"
[rowHeight]="'auto'">
// This is the array with the items to be shown
@Input() data: any[];
- // each item -> { prop: 'attribute name', name: 'display name' }
+ // Each item -> { prop: 'attribute name', name: 'display name' }
@Input() columns: TableColumn[];
- // name of the component fe 'TableDetailsComponent'
+ // Method used for setting column widths.
+ @Input() columnMode ?= 'force';
+ // Name of the component fe 'TableDetailsComponent'
@Input() detailsComponent?: string;
+ // Display the tool header, including reload button, pagination and search fields?
+ @Input() toolHeader ?= true;
+ // Display the table header?
@Input() header ?= true;
-
+ // Display the table footer?
+ @Input() footer ?= true;
// Should be the function that will update the input data
@Output() fetchData = new EventEmitter();
EllipsisPipe
],
providers: [
+ CephShortVersionPipe,
DimlessBinaryPipe,
DimlessPipe
]