A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat: Calculate and display total CPU and memory usage (#5911)
Bergashad9cbd5427d0e
diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.jsonindex e59c38dae..319820774 100644--- a/packages/translation/src/lang/en.json+++ b/packages/translation/src/lang/en.json@@ -4954,7 +4954,9 @@"updated": "Updated {when}","search": "Seach {count} containers","selected": "{selectCount} of {totalCount} containers selected",- "footer": "Total {count} containers"+ "footer": "Total {count} containers",+ "totalCpu": "Total CPU: {cpu}%",+ "totalMemory": "Total Mem: {memory}"},"field": {"name": {diff --git a/packages/widgets/src/docker/component.tsx b/packages/widgets/src/docker/component.tsxindex d8dd77bdf..b50139361 100644--- a/packages/widgets/src/docker/component.tsx+++ b/packages/widgets/src/docker/component.tsx@@ -200,6 +200,17 @@ export default function DockerWidget({ options, width, isEditMode }: WidgetCompoconst totalContainers = containers.length;+ const totals = useMemo(() => {+ return containers.reduce(+ (acc, container) => {+ acc.cpu += safeValue(container.cpuUsage);+ acc.memory += safeValue(container.memoryUsage);+ return acc;+ },+ { cpu: 0, memory: 0 }+ );+ }, [containers]);+const columns = useMemo(() => createColumns(t), [t]);const table = useTranslatedMantineReactTable({@@ -261,12 +272,26 @@ export default function DockerWidget({ options, width, isEditMode }: WidgetCompo}}p={4}>- <Group gap={4}>- <IconBrandDocker size={20} />- <Text size="sm">{t("table.footer", { count: totalContainers.toString() })}</Text>+ <Group gap={4} wrap="nowrap">+ <IconBrandDocker size={20} style={{ flexShrink: 0 }} />+ <Text size="sm" truncate="end">+ {t("table.footer", { count: totalContainers.toString() })}+ </Text></Group>- <Text size="sm">{t("table.updated", { when: relativeTime })}</Text>+ <Group gap="sm" wrap="wrap" justify="flex-end" style={{ flex: 1, minWidth: 0 }}>+ <Text size="sm" style={{ whiteSpace: "nowrap" }}>+ {t("table.totalCpu", { cpu: totals.cpu.toFixed(2) })}+ </Text>++ <Text size="sm" style={{ whiteSpace: "nowrap" }}>+ {t("table.totalMemory", { memory: humanFileSize(totals.memory) })}+ </Text>++ <Text size="sm" style={{ whiteSpace: "nowrap" }}>+ {t("table.updated", { when: relativeTime })}+ </Text>+ </Group></Group>)}</Stack>