Skip to content

Commit

Permalink
Added displaying of imported environment variables per container.
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Vlasov <[email protected]>
  • Loading branch information
vlasov-y committed Jan 18, 2025
1 parent e67e512 commit 9d52c69
Show file tree
Hide file tree
Showing 15 changed files with 645 additions and 100 deletions.
20 changes: 11 additions & 9 deletions frontend/src/components/cluster/Charts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import { KubeMetrics } from '../../lib/k8s/cluster';
import Node from '../../lib/k8s/node';
import Pod from '../../lib/k8s/pod';
import { parseCpu, parseRam, TO_GB, TO_ONE_CPU } from '../../lib/units';
import { formatMetricValueUnit, parseCpu, parseRam } from '../../lib/units';
import ResourceCircularChart, {
CircularChartProps as ResourceCircularChartProps,
} from '../common/Resource/CircularChart';
Expand All @@ -15,24 +15,25 @@ export function MemoryCircularChart(props: ResourceCircularChartProps) {
const { t } = useTranslation(['translation', 'glossary']);

function memoryUsedGetter(item: KubeMetrics) {
return parseRam(item.usage.memory) / TO_GB;
return parseRam(item.usage.memory);
}

function memoryAvailableGetter(item: Node | Pod) {
return parseRam(item.status?.capacity?.memory) / TO_GB;
return parseRam(item.status?.capacity?.memory);
}

function getLegend(used: number, available: number) {
if (available === 0 || available === -1) {
return '';
}

const availableLabel = `${available.toFixed(2)} GB`;
const availableLabel = formatMetricValueUnit(available, '', 'binary');
if (noMetrics) {
return availableLabel;
}
const usedLabel = formatMetricValueUnit(used, '', 'binary');

return `${used.toFixed(2)} / ${availableLabel}`;
return `${usedLabel} / ${availableLabel}`;
}

return (
Expand All @@ -51,24 +52,25 @@ export function CpuCircularChart(props: ResourceCircularChartProps) {
const { t } = useTranslation(['translation', 'glossary']);

function cpuUsedGetter(item: KubeMetrics) {
return parseCpu(item.usage.cpu) / TO_ONE_CPU;
return parseCpu(item.usage.cpu);
}

function cpuAvailableGetter(item: Node | Pod) {
return parseCpu(item.status?.capacity?.cpu) / TO_ONE_CPU;
return parseCpu(item.status?.capacity?.cpu);
}

function getLegend(used: number, available: number) {
if (available === 0 || available === -1) {
return '';
}

const availableLabel = t('translation|{{ available }} units', { available });
const availableLabel = `${formatMetricValueUnit(available, '', '')} ${t('cores')}`;
if (noMetrics) {
return availableLabel;
}
const usedLabel = formatMetricValueUnit(used, '', 'cpu');

return `${used.toFixed(2)} / ${availableLabel}`;
return `${usedLabel} / ${availableLabel}`;
}

return (
Expand Down
Loading

0 comments on commit 9d52c69

Please sign in to comment.