*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>
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', () => {
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', () => {
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';
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 })
constructor(
private authStorageService: AuthStorageService,
- private dimlessBinary: DimlessBinaryPipe,
private emptyPipe: EmptyPipe,
private hostService: HostService,
private actionLabels: ActionLabelsI18n,
{
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
}
];
}
);
}
+
+ 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 !== ''
+ );
+ }
}