From: Volker Theile Date: Thu, 8 Feb 2018 11:41:24 +0000 (+0100) Subject: mgr/dashboard_v2: Use datatable on Cluster/Hosts page. X-Git-Tag: v13.0.2~84^2~77 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d307fb18764f1d7203dad250bf556b3d3a7e6747;p=ceph.git mgr/dashboard_v2: Use datatable on Cluster/Hosts page. Signed-off-by: Volker Theile --- diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts index 3069a362c77e..c05675e74d29 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts @@ -1,6 +1,7 @@ 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'; @@ -8,8 +9,15 @@ import { ServiceListPipe } from './service-list.pipe'; @NgModule({ imports: [ CommonModule, + ComponentsModule, SharedModule ], - declarations: [HostsComponent, ServiceListPipe], + declarations: [ + HostsComponent, + ServiceListPipe + ], + providers: [ + ServiceListPipe + ] }) export class ClusterModule { } diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.html b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.html index 733b0798382f..2ad38a7c2a08 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.html +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.html @@ -4,31 +4,9 @@ - - - - - - - - - - - - - - - -
- Hostname - - Services - - Version -
- {{ host.hostname }} - - {{ host.services | serviceList }} - - {{ host.ceph_version | cephShortVersion }} -
+ + diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts index 476abb7fb881..7a950786c743 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts @@ -1,6 +1,7 @@ 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'; @@ -13,11 +14,15 @@ describe('HostsComponent', () => { TestBed.configureTestingModule({ imports: [ SharedModule, - HttpClientTestingModule + HttpClientTestingModule, + ComponentsModule ], declarations: [ HostsComponent, ServiceListPipe + ], + providers: [ + ServiceListPipe ] }) .compileComponents(); diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index e671565a920a..9b3d498597a7 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -1,5 +1,8 @@ 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({ @@ -9,9 +12,32 @@ import { HostService } from '../../../shared/services/host.service'; }) export class HostsComponent implements OnInit { - hosts: any = []; + columns: Array = []; + hosts: Array = []; - 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) => { diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.html b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.html index 4c2e69b3021c..254f0b63204b 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.html +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.html @@ -1,6 +1,6 @@
+ *ngIf="toolHeader">
@@ -54,9 +54,10 @@ [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'"> diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.ts index 2b4dfd5a6db5..009d14dfb4f6 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.ts @@ -25,12 +25,18 @@ export class TableComponent implements OnInit, OnChanges { // 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(); diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/pipes/pipes.module.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/pipes/pipes.module.ts index a140cf9a1621..02f7c0c93e13 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/pipes/pipes.module.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/pipes/pipes.module.ts @@ -24,6 +24,7 @@ import { HealthColorPipe } from './health-color.pipe'; EllipsisPipe ], providers: [ + CephShortVersionPipe, DimlessBinaryPipe, DimlessPipe ]