Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...ages/ceph-storage-plugin/src/components/block-pool/dashbaord/compression-details-card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import * as React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { compose } from 'redux'; | ||
|
||
import { getInstantVectorStats } from '@console/internal/components/graphs/utils'; | ||
|
||
import DashboardCard from '@console/shared/src/components/dashboard/dashboard-card/DashboardCard'; | ||
import DashboardCardBody from '@console/shared/src/components/dashboard/dashboard-card/DashboardCardBody'; | ||
import DashboardCardHeader from '@console/shared/src/components/dashboard/dashboard-card/DashboardCardHeader'; | ||
import DashboardCardTitle from '@console/shared/src/components/dashboard/dashboard-card/DashboardCardTitle'; | ||
import DetailItem from '@console/shared/src/components/dashboard/details-card/DetailItem'; | ||
import DetailsBody from '@console/shared/src/components/dashboard/details-card/DetailsBody'; | ||
import { usePrometheusQueries } from '@console/shared/src/components/dashboard/utilization-card/prometheus-hook'; | ||
import { | ||
humanizePercentage, | ||
humanizeBinaryBytes, | ||
humanizeNumber, | ||
} from '@console/internal/components/utils'; | ||
|
||
import { BlockPoolDashboardContext } from './block-pool-dashboard-context'; | ||
import { getPoolQuery, StorageDashboardQuery } from '../../../queries/ceph-queries'; | ||
|
||
const parser = compose((val) => val?.[0]?.y, getInstantVectorStats); | ||
|
||
export const CompressionDetailsCard: React.FC = () => { | ||
const { t } = useTranslation(); | ||
const { obj } = React.useContext(BlockPoolDashboardContext); | ||
const compressionMode = obj.spec?.compressionMode; | ||
const compressionEnabled = compressionMode !== 'none'; | ||
const { name } = obj.metadata; | ||
|
||
// Compression Metrics | ||
const queries = React.useMemo( | ||
() => [ | ||
getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_SAVINGS), | ||
getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_ELIGIBILITY), | ||
getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_RATIO), | ||
], | ||
[name], | ||
); | ||
|
||
const [values, loading] = usePrometheusQueries(queries, parser as any); | ||
const poolCompressionSavings = (values?.[0] ?? 0) as number; | ||
const poolCompressionEligibility = (values?.[1] ?? 0) as number; | ||
const poolCompressionRatio = (values?.[2] ?? 0) as number; | ||
|
||
return ( | ||
<DashboardCard data-test-id="compression-details-card"> | ||
<DashboardCardHeader> | ||
<DashboardCardTitle>{t('ceph-storage-plugin~Compression')}</DashboardCardTitle> | ||
</DashboardCardHeader> | ||
<DashboardCardBody> | ||
<DetailsBody> | ||
<DetailItem isLoading={!obj} title={t('ceph-storage-plugin~Compression status')}> | ||
{!compressionEnabled ? 'Disabled' : 'Enabled'} | ||
</DetailItem> | ||
{compressionEnabled && ( | ||
<> | ||
<DetailItem isLoading={loading} title={t('ceph-storage-plugin~Storage efficiency')}> | ||
{} | ||
</DetailItem> | ||
<DetailItem | ||
isLoading={loading} | ||
title={t('ceph-storage-plugin~Compression eligibility')} | ||
> | ||
{humanizePercentage(poolCompressionEligibility).string} | ||
</DetailItem> | ||
<DetailItem isLoading={loading} title={t('ceph-storage-plugin~Compression ratio')}> | ||
{humanizeNumber(poolCompressionRatio)} | ||
</DetailItem> | ||
<DetailItem isLoading={loading} title={t('ceph-storage-plugin~Compression savings')}> | ||
{humanizeBinaryBytes(poolCompressionSavings).string} | ||
</DetailItem> | ||
</> | ||
)} | ||
</DetailsBody> | ||
</DashboardCardBody> | ||
</DashboardCard> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters