Merge pull request #3933 from bluewave-labs/feat/docker-state-palette
feat: docker state palette
This commit is contained in:
2 files changed
+11
No files matched your search
@@ -10,6 +10,7 @@ import type { DockerContainerInfo } from "@/Types/Check";
|
|||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { formatDuration } from "@/Utils/TimeUtils";
|
import { formatDuration } from "@/Utils/TimeUtils";
|
||||||
|
import { getDockerPalette } from "@/Utils/MonitorUtils";
|
||||||
|
|
||||||
export const DockerContainerStatusBoxes = ({
|
export const DockerContainerStatusBoxes = ({
|
||||||
container,
|
container,
|
||||||
@@ -24,6 +25,7 @@ export const DockerContainerStatusBoxes = ({
|
|||||||
const { state, restartCount, health } = container;
|
const { state, restartCount, health } = container;
|
||||||
const startedAt = container.startedAt ?? "0";
|
const startedAt = container.startedAt ?? "0";
|
||||||
const runningFor = Date.now() - new Date(startedAt).getTime();
|
const runningFor = Date.now() - new Date(startedAt).getTime();
|
||||||
|
const palette = getDockerPalette(state);
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -33,6 +35,7 @@ export const DockerContainerStatusBoxes = ({
|
|||||||
<StatBox
|
<StatBox
|
||||||
title={t("common.labels.state")}
|
title={t("common.labels.state")}
|
||||||
subtitle={state}
|
subtitle={state}
|
||||||
|
palette={palette}
|
||||||
/>
|
/>
|
||||||
<StatBox
|
<StatBox
|
||||||
title={t("common.labels.uptime")}
|
title={t("common.labels.uptime")}
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ export const getStatusPalette = (status: MonitorStatus): PaletteKey => {
|
|||||||
return "warning";
|
return "warning";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDockerPalette = (dockerState: DockerContainerState): PaletteKey => {
|
||||||
|
if (dockerState === "created") return "success";
|
||||||
|
if (dockerState === "running") return "success";
|
||||||
|
if (dockerState === "dead") return "error";
|
||||||
|
if (dockerState === "exited") return "error";
|
||||||
|
return "warning";
|
||||||
|
};
|
||||||
|
|
||||||
export const getValuePalette = (value: ValueType): PaletteKey => {
|
export const getValuePalette = (value: ValueType): PaletteKey => {
|
||||||
const paletteMap: Record<ValueType, PaletteKey> = {
|
const paletteMap: Record<ValueType, PaletteKey> = {
|
||||||
positive: "success",
|
positive: "success",
|
||||||
|
|||||||
Reference in new issue
Block a user