]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: add not avaialable with unpresent host facts
authorPere Diaz Bou <pere-altea@hotmail.com>
Wed, 17 May 2023 13:35:17 +0000 (15:35 +0200)
committerPere Diaz Bou <pere-altea@hotmail.com>
Mon, 17 Jul 2023 08:32:45 +0000 (10:32 +0200)
Some of the facts that are retrieved from hosts might be empty, so
instead of displayed empty cells we display a "-" with a hover
explaining that it wasn't retrievable from the orchestrator.

Fixes: https://tracker.ceph.com/issues/61221
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts

index 1aeaef1f95fb3758fbc47dbae7614e6043ff692a..92e4309b27770dcb43e603a36177874e48044adf 100644 (file)
                 *ngIf="showSubmit">Are you sure you want to continue?</ng-container>
 </ng-template>
 
+
+<ng-template #hostMetricTmpl
+             let-value="value">
+  <div *ngIf="validValue(value)">
+    <span>{{ value }}</span>
+  </div>
+  <div *ngIf="!validValue(value)">
+    <span ngbTooltip="Not available. Data could not be fetched from Ceph">-</span>
+  </div>
+</ng-template>
+
+<ng-template #hostDimlessTmpl
+             let-value="value">
+  <div *ngIf="!validValue(value)">
+    <span ngbTooltip="Not available. Data could not be fetched from Ceph">-</span>
+  </div>
+  <div *ngIf="validValue(value)">
+    <span>{{ value | dimlessBinary }}</span>
+  </div>
+</ng-template>
+
 <ng-template #orchTmpl>
   <span i18n
         i18n-ngbTooltip
-        ngbTooltip="Data will be available only if Orchestrator is available.">N/A</span>
+        ngbTooltip="Data will be available only if Orchestrator is available.">-</span>
 </ng-template>
 
 <ng-template #flashTmpl>
index 2e76d1f43ed63645d9e1497d9883b76690ac9bd1..1678316ba05f29400c1b77460c99224975567da0 100644 (file)
@@ -213,7 +213,7 @@ describe('HostsComponent', () => {
     const spans = fixture.debugElement.nativeElement.querySelectorAll(
       '.datatable-body-cell-label span'
     );
-    expect(spans[7].textContent).toBe('N/A');
+    expect(spans[7].textContent).toBe('-');
   });
 
   it('should test if host facts are unavailable if get_fatcs orch feature is not available', () => {
@@ -238,7 +238,7 @@ describe('HostsComponent', () => {
     const spans = fixture.debugElement.nativeElement.querySelectorAll(
       '.datatable-body-cell-label span'
     );
-    expect(spans[7].textContent).toBe('N/A');
+    expect(spans[7].textContent).toBe('-');
   });
 
   it('should test if memory/raw capacity columns shows N/A if facts are available but in fetching state', () => {
index 3bdda8aca3ef4d79ddfd2e35ed241969f105977a..d69dc59a11714c98f49c3b93cbfa7bd64edf8ed0 100644 (file)
@@ -26,7 +26,6 @@ import { FinishedTask } from '~/app/shared/models/finished-task';
 import { OrchestratorFeature } from '~/app/shared/models/orchestrator.enum';
 import { OrchestratorStatus } from '~/app/shared/models/orchestrator.interface';
 import { Permissions } from '~/app/shared/models/permissions';
-import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe';
 import { EmptyPipe } from '~/app/shared/pipes/empty.pipe';
 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
 import { ModalService } from '~/app/shared/services/modal.service';
@@ -50,6 +49,10 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
   table: TableComponent;
   @ViewChild('servicesTpl', { static: true })
   public servicesTpl: TemplateRef<any>;
+  @ViewChild('hostMetricTmpl', { static: true })
+  public hostMetricTmpl: TemplateRef<any>;
+  @ViewChild('hostDimlessTmpl', { static: true })
+  public hostDimlessTmpl: TemplateRef<any>;
   @ViewChild('maintenanceConfirmTpl', { static: true })
   maintenanceConfirmTpl: TemplateRef<any>;
   @ViewChild('orchTmpl', { static: true })
@@ -108,7 +111,6 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
 
   constructor(
     private authStorageService: AuthStorageService,
-    private dimlessBinary: DimlessBinaryPipe,
     private emptyPipe: EmptyPipe,
     private hostService: HostService,
     private actionLabels: ActionLabelsI18n,
@@ -233,39 +235,44 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
       {
         name: $localize`CPUs`,
         prop: 'cpu_count',
+        cellTemplate: this.hostMetricTmpl,
         flexGrow: 0.3
       },
       {
         name: $localize`Cores`,
         prop: 'cpu_cores',
+        cellTemplate: this.hostMetricTmpl,
         flexGrow: 0.3
       },
       {
         name: $localize`Total Memory`,
         prop: 'memory_total_bytes',
-        pipe: this.dimlessBinary,
+        cellTemplate: this.hostDimlessTmpl,
         flexGrow: 0.4
       },
       {
         name: $localize`Raw Capacity`,
         prop: 'raw_capacity',
-        pipe: this.dimlessBinary,
+        cellTemplate: this.hostDimlessTmpl,
         flexGrow: 0.5
       },
       {
         name: $localize`HDDs`,
         prop: 'hdd_count',
+        cellTemplate: this.hostMetricTmpl,
         flexGrow: 0.3
       },
       {
         name: $localize`Flash`,
         prop: 'flash_count',
         headerTemplate: this.flashTmpl,
+        cellTemplate: this.hostMetricTmpl,
         flexGrow: 0.3
       },
       {
         name: $localize`NICs`,
         prop: 'nic_count',
+        cellTemplate: this.hostMetricTmpl,
         flexGrow: 0.3
       }
     ];
@@ -513,4 +520,15 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
         }
       );
   }
+
+  validValue(value: any) {
+    // Check if value is a number(int or float) and that it isn't null
+    return (
+      Number(value) == value &&
+      value % 1 == 0 &&
+      value !== undefined &&
+      value !== null &&
+      value !== ''
+    );
+  }
 }