mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #1000 from faytranevozter/feat/simplify-node-logs
Feat: simplify node service log & add badge color on list service/container
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -30,6 +31,21 @@ export const DockerLogs = dynamic(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const badgeStateColor = (state: string) => {
|
||||||
|
switch (state) {
|
||||||
|
case "running":
|
||||||
|
return "green";
|
||||||
|
case "exited":
|
||||||
|
case "shutdown":
|
||||||
|
return "red";
|
||||||
|
case "accepted":
|
||||||
|
case "created":
|
||||||
|
return "blue";
|
||||||
|
default:
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
appName: string;
|
appName: string;
|
||||||
serverId?: string;
|
serverId?: string;
|
||||||
@@ -123,7 +139,9 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
|
|||||||
value={container.containerId}
|
value={container.containerId}
|
||||||
>
|
>
|
||||||
{container.name} ({container.containerId}){" "}
|
{container.name} ({container.containerId}){" "}
|
||||||
{container.state}
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
|
{container.state}
|
||||||
|
</Badge>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -135,7 +153,10 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
|
|||||||
value={container.containerId}
|
value={container.containerId}
|
||||||
>
|
>
|
||||||
{container.name} ({container.containerId}@{container.node}
|
{container.name} ({container.containerId}@{container.node}
|
||||||
) {container.state}
|
)
|
||||||
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
|
{container.state}
|
||||||
|
</Badge>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -35,6 +37,8 @@ interface Props {
|
|||||||
serverId?: string;
|
serverId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badgeStateColor;
|
||||||
|
|
||||||
export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
||||||
const [option, setOption] = useState<"swarm" | "native">("native");
|
const [option, setOption] = useState<"swarm" | "native">("native");
|
||||||
const [containerId, setContainerId] = useState<string | undefined>();
|
const [containerId, setContainerId] = useState<string | undefined>();
|
||||||
@@ -123,7 +127,9 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
|||||||
value={container.containerId}
|
value={container.containerId}
|
||||||
>
|
>
|
||||||
{container.name} ({container.containerId}){" "}
|
{container.name} ({container.containerId}){" "}
|
||||||
{container.state}
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
|
{container.state}
|
||||||
|
</Badge>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -135,7 +141,10 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
|
|||||||
value={container.containerId}
|
value={container.containerId}
|
||||||
>
|
>
|
||||||
{container.name} ({container.containerId}@{container.node}
|
{container.name} ({container.containerId}@{container.node}
|
||||||
) {container.state}
|
)
|
||||||
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
|
{container.state}
|
||||||
|
</Badge>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -87,7 +89,10 @@ export const ShowDockerLogsCompose = ({
|
|||||||
key={container.containerId}
|
key={container.containerId}
|
||||||
value={container.containerId}
|
value={container.containerId}
|
||||||
>
|
>
|
||||||
{container.name} ({container.containerId}) {container.state}
|
{container.name} ({container.containerId}){" "}
|
||||||
|
<Badge variant={badgeStateColor(container.state)}>
|
||||||
|
{container.state}
|
||||||
|
</Badge>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
<SelectLabel>Containers ({data?.length})</SelectLabel>
|
<SelectLabel>Containers ({data?.length})</SelectLabel>
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ export const setupDockerContainerLogsWebSocketServer = (
|
|||||||
const client = new Client();
|
const client = new Client();
|
||||||
client
|
client
|
||||||
.once("ready", () => {
|
.once("ready", () => {
|
||||||
const baseCommand = `docker ${runType === "swarm" ? "service" : "container"} logs --timestamps --tail ${tail} ${
|
const baseCommand = `docker ${runType === "swarm" ? "service" : "container"} logs --timestamps ${
|
||||||
|
runType === "swarm" ? "--raw" : ""
|
||||||
|
} --tail ${tail} ${
|
||||||
since === "all" ? "" : `--since ${since}`
|
since === "all" ? "" : `--since ${since}`
|
||||||
} --follow ${containerId}`;
|
} --follow ${containerId}`;
|
||||||
const escapedSearch = search ? search.replace(/'/g, "'\\''") : "";
|
const escapedSearch = search ? search.replace(/'/g, "'\\''") : "";
|
||||||
@@ -98,7 +100,9 @@ export const setupDockerContainerLogsWebSocketServer = (
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const shell = getShell();
|
const shell = getShell();
|
||||||
const baseCommand = `docker ${runType === "swarm" ? "service" : "container"} logs --timestamps --tail ${tail} ${
|
const baseCommand = `docker ${runType === "swarm" ? "service" : "container"} logs --timestamps ${
|
||||||
|
runType === "swarm" ? "--raw" : ""
|
||||||
|
} --tail ${tail} ${
|
||||||
since === "all" ? "" : `--since ${since}`
|
since === "all" ? "" : `--since ${since}`
|
||||||
} --follow ${containerId}`;
|
} --follow ${containerId}`;
|
||||||
const command = search
|
const command = search
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ export const getStackContainersByAppName = async (
|
|||||||
: "No container name";
|
: "No container name";
|
||||||
|
|
||||||
const state = parts[2]
|
const state = parts[2]
|
||||||
? parts[2].replace("State: ", "").trim()
|
? parts[2].replace("State: ", "").trim().toLowerCase()
|
||||||
: "No state";
|
: "No state";
|
||||||
const node = parts[3]
|
const node = parts[3]
|
||||||
? parts[3].replace("Node: ", "").trim()
|
? parts[3].replace("Node: ", "").trim()
|
||||||
@@ -255,7 +255,7 @@ export const getServiceContainersByAppName = async (
|
|||||||
: "No container name";
|
: "No container name";
|
||||||
|
|
||||||
const state = parts[2]
|
const state = parts[2]
|
||||||
? parts[2].replace("State: ", "").trim()
|
? parts[2].replace("State: ", "").trim().toLowerCase()
|
||||||
: "No state";
|
: "No state";
|
||||||
|
|
||||||
const node = parts[3]
|
const node = parts[3]
|
||||||
|
|||||||
Reference in New Issue
Block a user