mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
Merge pull request #51561 from rhcs-dashboard/hosts-no-data
mgr/dashboard: add not avaialable with unpresent host facts Reviewed-by: Pegonzal <NOT@FOUND> Reviewed-by: cloudbehl <NOT@FOUND> Reviewed-by: Ernesto Puerta <epuertat@redhat.com> Reviewed-by: Nizamudeen A <nia@redhat.com>
This commit is contained in:
commit
ac616eeefb
@ -85,10 +85,31 @@
|
||||
*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>
|
||||
|
@ -224,7 +224,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_facts orch feature is not available', () => {
|
||||
@ -251,7 +251,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', () => {
|
||||
|
@ -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 { CdTableServerSideService } from '~/app/shared/services/cd-table-server-side.service';
|
||||
@ -51,6 +50,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 })
|
||||
@ -111,7 +114,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,
|
||||
@ -236,39 +238,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
|
||||
}
|
||||
];
|
||||
@ -527,4 +534,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 !== ''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user