]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard_v2: Datatable related code improvements
authorVolker Theile <vtheile@suse.com>
Thu, 15 Feb 2018 10:16:11 +0000 (11:16 +0100)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:11 +0000 (13:07 +0000)
Signed-off-by: Volker Theile <vtheile@suse.com>
13 files changed:
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.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.scss
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts

index 93e1a8ffd9a7319a88373418145890a68b7be518..29f74fab55b0dd2ca39448aa50c31263f63c29e2 100644 (file)
@@ -9,7 +9,8 @@
           columnMode="flex"
           [toolHeader]="false"
           [footer]="false"
-          [limit]="0">
+          [limit]="0"
+          (fetchData)="getHosts()">
   <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 ? ", " : "" }}
index 2c6f1b1cadc3d6a0d67f22cb6395bf1631a0efd8..dfc7b62e050a989fe293a744a4aa40eda6daca91 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
 
+import { CdTableColumn } from '../../../shared/models/cd-table-column';
 import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
 import { HostService } from '../../../shared/services/host.service';
 
@@ -10,7 +11,7 @@ import { HostService } from '../../../shared/services/host.service';
 })
 export class HostsComponent implements OnInit {
 
-  columns: Array<object> = [];
+  columns: Array<CdTableColumn> = [];
   hosts: Array<object> = [];
 
   @ViewChild('servicesTpl') public servicesTpl: TemplateRef<any>;
@@ -38,6 +39,9 @@ export class HostsComponent implements OnInit {
         pipe: this.cephShortVersionPipe
       }
     ];
+  }
+
+  getHosts() {
     this.hostService.list().then((resp) => {
       resp.map((host) => {
         host.services.map((service) => {
@@ -49,5 +53,4 @@ export class HostsComponent implements OnInit {
       this.hosts = resp;
     });
   }
-
 }
index dd954792d8382dc51bd3cb1524c9e226434fb0e2..516c66f429b8fbf969c987d1ff2ed319cf75c416 100644 (file)
@@ -3,7 +3,8 @@
           columnMode="flex"
           [toolHeader]="false"
           [footer]="false"
-          [limit]="0">
+          [limit]="0"
+          (fetchData)="getCounters()">
   <ng-template #valueTpl let-row="row">
     {{ row.value | dimless }} {{ row.unit }}
   </ng-template>
index 83fd492a7b2f2354565b673fd7e5444bf38358cc..de2295a970948c9d313bd22fe44b156c47b4f58e 100644 (file)
@@ -1,6 +1,7 @@
 <tabset>
   <tab heading="Details">
-    <cd-table-key-value [data]="metadata">
+    <cd-table-key-value [data]="metadata"
+                        (fetchData)="getMetaData()">
     </cd-table-key-value>
   </tab>
   <tab heading="Performance Counters">
index f5cef494366341adb1df25d312736aae0f13e48f..418f46c707c7bea4f748e521061f890431ea532b 100644 (file)
@@ -19,17 +19,17 @@ export class RgwDaemonDetailsComponent implements OnInit {
   constructor(private rgwDaemonService: RgwDaemonService) { }
 
   ngOnInit() {
-    this.getMetaData();
+    // Get the service id of the first selected row.
+    if (this.selected.length > 0) {
+      this.serviceId = this.selected[0].id;
+    }
   }
 
-  private getMetaData() {
-    if (this.selected.length < 1) {
+  getMetaData() {
+    if (_.isEmpty(this.serviceId)) {
       return;
     }
 
-    // Get the service id of the first selected row.
-    this.serviceId = this.selected[0].id;
-
     this.rgwDaemonService.get(this.serviceId)
       .then((resp) => {
         const metadata = [];
index 77814b73ebbf9be4b30cf871273369138570c33b..22fe789373d0e351604fa9f04ed06e3ff60b7e0c 100644 (file)
@@ -5,6 +5,7 @@
 </nav>
 <cd-table [data]="daemons"
           [columns]="columns"
+          columnMode="flex"
           [detailsComponent]="detailsComponent"
           (fetchData)="getDaemonList()"
           [beforeShowDetails]="beforeShowDetails">
index c9d02510abd915ba27d5deadf5d7fc253e0dcd79..f4be3192364708e9c979eea61b2192db930410ee 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
 
 import { CdTableColumn } from '../../../shared/models/cd-table-column';
 import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
@@ -9,38 +9,35 @@ import { RgwDaemonService } from '../services/rgw-daemon.service';
   templateUrl: './rgw-daemon-list.component.html',
   styleUrls: ['./rgw-daemon-list.component.scss']
 })
-export class RgwDaemonListComponent implements OnInit {
+export class RgwDaemonListComponent {
 
   columns: Array<CdTableColumn> = [];
   daemons: Array<object> = [];
 
   detailsComponent = 'RgwDaemonDetailsComponent';
 
-  constructor(private rgwDaemonService: RgwDaemonService) {
+  constructor(private rgwDaemonService: RgwDaemonService,
+              cephShortVersionPipe: CephShortVersionPipe) {
     this.columns = [
       {
         name: 'ID',
         prop: 'id',
-        width: 100
+        flexGrow: 2
       },
       {
         name: 'Hostname',
         prop: 'server_hostname',
-        width: 100
+        flexGrow: 2
       },
       {
         name: 'Version',
         prop: 'version',
-        width: 50,
-        pipe: new CephShortVersionPipe()
+        flexGrow: 1,
+        pipe: cephShortVersionPipe
       }
     ];
   }
 
-  ngOnInit() {
-    this.getDaemonList();
-  }
-
   getDaemonList() {
     this.rgwDaemonService.list()
       .then((resp) => {
index ad5346f18ef8bc3cf0600dc476091031e3a49160..b09e5e9e1ba3dc22aa352143616a15daab59e077 100644 (file)
@@ -4,5 +4,6 @@
           [toolHeader]="false"
           [header]="false"
           [footer]="false"
-          [limit]="0">
+          [limit]="0"
+          (fetchData)="reloadData()">
 </cd-table>
index b8af65a120c51c18f0c03e536baa953c18184e08..46e4f71f90ec6768d75f41f9375b24eed11db292 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
 
 import { CellTemplate } from '../../enum/cell-template.enum';
 import { CdTableColumn } from '../../models/cd-table-column';
@@ -39,6 +39,11 @@ export class TableKeyValueComponent implements OnInit {
    */
   @Input() value = 'value';
 
+  /**
+   * The function that will be called to update the input data.
+   */
+  @Output() fetchData = new EventEmitter();
+
   constructor() { }
 
   ngOnInit() {
@@ -54,4 +59,9 @@ export class TableKeyValueComponent implements OnInit {
       }
     ];
   }
+
+  reloadData() {
+    // Forward event triggered by the 'cd-table' datatable.
+    this.fetchData.emit();
+  }
 }
index 043362f73933b1a05f0a1c352de68f936b3b3623..a3c66b861acecff7fcde0d3701bc184fe62ba2aa 100644 (file)
@@ -60,7 +60,7 @@
                  [headerHeight]="header ? 'auto' : 0"
                  [footerHeight]="footer ? 'auto' : 0"
                  [limit]="limit > 0 ? limit : undefined"
-                 [loadingIndicator]="true"
+                 [loadingIndicator]="loadingIndicator"
                  [rowHeight]="'auto'">
     <!-- Row Detail Template -->
     <ngx-datatable-row-detail (toggle)="updateDetailView()">
@@ -71,7 +71,6 @@
 
 <!-- cell templates that can be accessed from outside -->
 <ng-template #tableCellBoldTpl
-             let-row="row"
              let-value="value">
   <strong>{{ value }}</strong>
 </ng-template>
index 2d19806633ebfeb89292c5d8c28f1c8cef0d9697..80136b63edd8f515451f84cf495a779240c2b267 100644 (file)
@@ -76,6 +76,7 @@
   }
   .input-group.dataTables_paginate {
     width: 8%;
+    min-width: 85px;
   }
 }
 
   border: $border-color;
   margin-bottom: 0;
   max-width: none!important;
+  .progress-linear {
+    display: block;
+    position: relative;
+    width: 100%;
+    height: 5px;
+    padding: 0;
+    margin: 0;
+    .container {
+      background-color: $oa-color-light-blue;
+      .bar {
+        left: 0;
+        height: 100%;
+        width: 100%;
+        position: absolute;
+        overflow: hidden;
+        background-color: $oa-color-light-blue;
+      }
+      .bar:before{
+        display: block;
+        position: absolute;
+        content: "";
+        left: -200px;
+        width: 200px;
+        height: 100%;
+        background-color: $oa-color-blue;
+        animation: progress-loading 3s linear infinite;
+      }
+    }
+  }
   .datatable-header {
     background-clip: padding-box;
     background-color: #f9f9f9;
     }
   }
 }
+
+@keyframes progress-loading {
+    from {
+      left: -200px;
+      width: 15%;
+    }
+    50% {
+      width: 30%;
+    }
+    70% {
+      width: 70%;
+    }
+    80% {
+      left: 50%;
+    }
+    95% {
+      left: 120%;
+    }
+    to {
+      left: 100%;
+    }
+}
index db158649453e53922f330066ac8a1c8f51d3c593..cefecdc0468069e0d45a44f26264094b9f9198d5 100644 (file)
@@ -31,7 +31,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
   @ViewChild('routerLinkTpl') routerLinkTpl: TemplateRef<any>;
 
   // This is the array with the items to be shown.
-  @Input() data: any[];
+  @Input() data: any[] = [];
   // Each item -> { prop: 'attribute name', name: 'display name' }
   @Input() columns: CdTableColumn[];
   // Method used for setting column widths.
@@ -50,6 +50,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
   // The current selection is passed as function argument. To do not display
   // the details page, return false.
   @Input() beforeShowDetails: Function;
+
   // Should be the function that will update the input data.
   @Output() fetchData = new EventEmitter();
 
@@ -60,6 +61,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
   search = '';
   rows = [];
   selected = [];
+  loadingIndicator = false;
   paginationClasses = {
     pagerLeftArrow: 'i fa fa-angle-double-left',
     pagerRightArrow: 'i fa fa-angle-double-right',
@@ -118,11 +120,13 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
   }
 
   reloadData() {
+    this.loadingIndicator = true;
     this.fetchData.emit();
   }
 
   useData() {
     this.rows = [...this.data];
+    this.loadingIndicator = false;
   }
 
   toggleExpandRow() {