]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard_v2: Use datatable on Cluster/Hosts page.
authorVolker Theile <vtheile@suse.com>
Thu, 8 Feb 2018 11:41:24 +0000 (12:41 +0100)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:08 +0000 (13:07 +0000)
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/hosts/hosts.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/components/table/table.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/pipes/pipes.module.ts

index 3069a362c77ebf31b49a3c4b9fea6824bf7bf16a..c05675e74d291dd7dec748e82fc3111c0e4a3f97 100644 (file)
@@ -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 { }
index 733b0798382f0e9eae157540ba077d222e08b47d..2ad38a7c2a0897e89d3f087506f5307356ad4f75 100644 (file)
@@ -4,31 +4,9 @@
     <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>
index 476abb7fb8818a07ee98a8e2dca4d40934176aea..7a950786c7432df59757201717b3a998c56879ce 100644 (file)
@@ -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();
index e671565a920ae00b9fb5246a36db46c785e65b61..9b3d498597a71064831277167f51b159346ad968 100644 (file)
@@ -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<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) => {
index 4c2e69b3021cf2b7997e001e2b9e8ebdc348cf95..254f0b63204bbc7fdf8b42806af295f5c086237e 100644 (file)
@@ -1,6 +1,6 @@
 <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'">
index 2b4dfd5a6db5c4fdef8a0980a2a81bffb1f290cc..009d14dfb4f67b808b39e36e70561a2155d87959 100644 (file)
@@ -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();
 
index a140cf9a162101082a142028ade997f79c3282b9..02f7c0c93e137ed63d00e40ceba5970050fd5d6d 100644 (file)
@@ -24,6 +24,7 @@ import { HealthColorPipe } from './health-color.pipe';
     EllipsisPipe
   ],
   providers: [
+    CephShortVersionPipe,
     DimlessBinaryPipe,
     DimlessPipe
   ]