mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-12 06:55:19 +00:00
feat(logs): enhance container status display in logs
- Added support for displaying "ready" state in badge color logic. - Updated logs display to include container status and current state in the dashboard components. - Modified Docker command outputs to include status and current state for better visibility of container health.
This commit is contained in:
@@ -34,6 +34,7 @@ export const DockerLogs = dynamic(
|
|||||||
export const badgeStateColor = (state: string) => {
|
export const badgeStateColor = (state: string) => {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "running":
|
case "running":
|
||||||
|
case "ready":
|
||||||
return "green";
|
return "green";
|
||||||
case "exited":
|
case "exited":
|
||||||
case "shutdown":
|
case "shutdown":
|
||||||
@@ -142,6 +143,7 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
|
|||||||
<Badge variant={badgeStateColor(container.state)}>
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
{container.state}
|
{container.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{container.status ? ` ${container.status}` : ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -157,6 +159,9 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
|
|||||||
<Badge variant={badgeStateColor(container.state)}>
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
{container.state}
|
{container.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{container.currentState
|
||||||
|
? ` ${container.currentState}`
|
||||||
|
: ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
|||||||
<Badge variant={badgeStateColor(container.state)}>
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
{container.state}
|
{container.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{container.status ? ` ${container.status}` : ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -143,6 +144,9 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
|||||||
<Badge variant={badgeStateColor(container.state)}>
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
{container.state}
|
{container.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{container.currentState
|
||||||
|
? ` ${container.currentState}`
|
||||||
|
: ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Loader2 } from "lucide-react";
|
import { Loader2 } from "lucide-react";
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
|
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -93,6 +93,7 @@ export const ShowDockerLogsCompose = ({
|
|||||||
<Badge variant={badgeStateColor(container.state)}>
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
{container.state}
|
{container.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{container.status ? ` ${container.status}` : ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
<SelectLabel>Containers ({data?.length})</SelectLabel>
|
<SelectLabel>Containers ({data?.length})</SelectLabel>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export const getContainersByAppNameMatch = async (
|
|||||||
try {
|
try {
|
||||||
let result: string[] = [];
|
let result: string[] = [];
|
||||||
const cmd =
|
const cmd =
|
||||||
"docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}}'";
|
"docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}} | Status: {{.Status}}'";
|
||||||
|
|
||||||
const command =
|
const command =
|
||||||
appType === "docker-compose"
|
appType === "docker-compose"
|
||||||
@@ -148,10 +148,14 @@ export const getContainersByAppNameMatch = async (
|
|||||||
const state = parts[2]
|
const state = parts[2]
|
||||||
? parts[2].replace("State: ", "").trim()
|
? parts[2].replace("State: ", "").trim()
|
||||||
: "No state";
|
: "No state";
|
||||||
|
|
||||||
|
const status = parts[3] ? parts[3].replace("Status: ", "").trim() : "";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
containerId,
|
containerId,
|
||||||
name,
|
name,
|
||||||
state,
|
state,
|
||||||
|
status,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -168,7 +172,7 @@ export const getStackContainersByAppName = async (
|
|||||||
try {
|
try {
|
||||||
let result: string[] = [];
|
let result: string[] = [];
|
||||||
|
|
||||||
const command = `docker stack ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}}'`;
|
const command = `docker stack ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
|
||||||
if (serverId) {
|
if (serverId) {
|
||||||
const { stdout, stderr } = await execAsyncRemote(serverId, command);
|
const { stdout, stderr } = await execAsyncRemote(serverId, command);
|
||||||
|
|
||||||
@@ -205,11 +209,15 @@ export const getStackContainersByAppName = async (
|
|||||||
const node = parts[3]
|
const node = parts[3]
|
||||||
? parts[3].replace("Node: ", "").trim()
|
? parts[3].replace("Node: ", "").trim()
|
||||||
: "No specific node";
|
: "No specific node";
|
||||||
|
const currentState = parts[4]
|
||||||
|
? parts[4].replace("CurrentState: ", "").trim()
|
||||||
|
: "";
|
||||||
return {
|
return {
|
||||||
containerId,
|
containerId,
|
||||||
name,
|
name,
|
||||||
state,
|
state,
|
||||||
node,
|
node,
|
||||||
|
currentState,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -226,8 +234,7 @@ export const getServiceContainersByAppName = async (
|
|||||||
try {
|
try {
|
||||||
let result: string[] = [];
|
let result: string[] = [];
|
||||||
|
|
||||||
const command = `docker service ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}}'`;
|
const command = `docker service ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
|
||||||
|
|
||||||
if (serverId) {
|
if (serverId) {
|
||||||
const { stdout, stderr } = await execAsyncRemote(serverId, command);
|
const { stdout, stderr } = await execAsyncRemote(serverId, command);
|
||||||
|
|
||||||
@@ -265,10 +272,15 @@ export const getServiceContainersByAppName = async (
|
|||||||
const node = parts[3]
|
const node = parts[3]
|
||||||
? parts[3].replace("Node: ", "").trim()
|
? parts[3].replace("Node: ", "").trim()
|
||||||
: "No specific node";
|
: "No specific node";
|
||||||
|
|
||||||
|
const currentState = parts[4]
|
||||||
|
? parts[4].replace("CurrentState: ", "").trim()
|
||||||
|
: "";
|
||||||
return {
|
return {
|
||||||
containerId,
|
containerId,
|
||||||
name,
|
name,
|
||||||
state,
|
state,
|
||||||
|
currentState,
|
||||||
node,
|
node,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user