mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(logs): replaced the log type component with the new
This commit is contained in:
parent
7577e40b25
commit
b03011a94f
@ -9,18 +9,50 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { Download as DownloadIcon, Loader2 } from "lucide-react";
|
import {
|
||||||
|
CheckCircle2Icon,
|
||||||
|
Download as DownloadIcon,
|
||||||
|
Loader2,
|
||||||
|
Bug,
|
||||||
|
InfoIcon,
|
||||||
|
CircleX,
|
||||||
|
TriangleAlert,
|
||||||
|
} from "lucide-react";
|
||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect, useRef } from "react";
|
||||||
import { TerminalLine } from "./terminal-line";
|
import { TerminalLine } from "./terminal-line";
|
||||||
import { type LogLine, getLogType, parseLogs } from "./utils";
|
import { type LogLine, getLogType, parseLogs } from "./utils";
|
||||||
|
import { StatusLogsFilter } from "./status-logs-filter";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
containerId: string;
|
containerId: string;
|
||||||
serverId?: string | null;
|
serverId?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type TimeFilter = "all" | "1h" | "6h" | "24h" | "168h" | "720h";
|
type TimeFilter = "all" | "1h" | "6h" | "24h" | "168h" | "720h";
|
||||||
type TypeFilter = "all" | "error" | "warning" | "success" | "info" | "debug";
|
|
||||||
|
export const priorities = [
|
||||||
|
{
|
||||||
|
label: "Info",
|
||||||
|
value: "info",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Success",
|
||||||
|
value: "success",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Warning",
|
||||||
|
value: "warning",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Debug",
|
||||||
|
value: "debug",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Error",
|
||||||
|
value: "error",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
||||||
const { data } = api.docker.getConfig.useQuery(
|
const { data } = api.docker.getConfig.useQuery(
|
||||||
@ -40,7 +72,7 @@ export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
|||||||
const [search, setSearch] = React.useState<string>("");
|
const [search, setSearch] = React.useState<string>("");
|
||||||
|
|
||||||
const [since, setSince] = React.useState<TimeFilter>("all");
|
const [since, setSince] = React.useState<TimeFilter>("all");
|
||||||
const [typeFilter, setTypeFilter] = React.useState<TypeFilter>("all");
|
const [typeFilter, setTypeFilter] = React.useState<string[]>([]);
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
const [isLoading, setIsLoading] = React.useState(false);
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
||||||
@ -74,10 +106,6 @@ export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
|||||||
setSince(value);
|
setSince(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTypeFilter = (value: TypeFilter) => {
|
|
||||||
setTypeFilter(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!containerId) return;
|
if (!containerId) return;
|
||||||
|
|
||||||
@ -179,11 +207,13 @@ export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
|||||||
const handleFilter = (logs: LogLine[]) => {
|
const handleFilter = (logs: LogLine[]) => {
|
||||||
return logs.filter((log) => {
|
return logs.filter((log) => {
|
||||||
const logType = getLogType(log.message).type;
|
const logType = getLogType(log.message).type;
|
||||||
|
|
||||||
|
if (typeFilter.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const matchesType = typeFilter === "all" || logType === typeFilter;
|
return typeFilter.includes(logType);
|
||||||
|
});
|
||||||
return matchesType;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -232,32 +262,13 @@ export const DockerLogsId: React.FC<Props> = ({ containerId, serverId }) => {
|
|||||||
<SelectItem value="all">All time</SelectItem>
|
<SelectItem value="all">All time</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<Select value={typeFilter} onValueChange={handleTypeFilter}>
|
<StatusLogsFilter
|
||||||
<SelectTrigger className="sm:w-[180px] w-full h-9">
|
value={typeFilter}
|
||||||
<SelectValue placeholder="Type filter" />
|
setValue={setTypeFilter}
|
||||||
</SelectTrigger>
|
title="Log type"
|
||||||
<SelectContent>
|
options={priorities}
|
||||||
<SelectItem value="all">
|
/>
|
||||||
<Badge variant="blank">All</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="error">
|
|
||||||
<Badge variant="red">Error</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="warning">
|
|
||||||
<Badge variant="orange">Warning</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="debug">
|
|
||||||
<Badge variant="yellow">Debug</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="success">
|
|
||||||
<Badge variant="green">Success</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="info">
|
|
||||||
<Badge variant="blue">Info</Badge>
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
type="search"
|
type="search"
|
||||||
|
Loading…
Reference in New Issue
Block a user