Skip to content

Commit 1861e10

Browse files
authored
Merge pull request #3859 from Dokploy/3851-ui-3-issues-in-1
feat: enhance request logging display with formatted status and duration
2 parents e05f31d + 964e3c4 commit 1861e10

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

apps/dokploy/components/dashboard/requests/columns.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Button } from "@/components/ui/button";
66
import type { LogEntry } from "./show-requests";
77

88
export const getStatusColor = (status: number) => {
9+
if (status === 0) {
10+
return "secondary";
11+
}
912
if (status >= 100 && status < 200) {
1013
return "outline";
1114
}
@@ -21,6 +24,24 @@ export const getStatusColor = (status: number) => {
2124
return "destructive";
2225
};
2326

27+
const formatStatusLabel = (status: number) => {
28+
if (status === 0) {
29+
return "N/A";
30+
}
31+
return status;
32+
};
33+
34+
const formatDuration = (nanos: number) => {
35+
const ms = nanos / 1000000;
36+
if (ms < 1) {
37+
return `${(nanos / 1000).toFixed(2)} µs`;
38+
}
39+
if (ms < 1000) {
40+
return `${ms.toFixed(2)} ms`;
41+
}
42+
return `${(ms / 1000).toFixed(2)} s`;
43+
};
44+
2445
export const columns: ColumnDef<LogEntry>[] = [
2546
{
2647
accessorKey: "level",
@@ -59,10 +80,10 @@ export const columns: ColumnDef<LogEntry>[] = [
5980
</div>
6081
<div className="flex flex-row gap-3 w-full">
6182
<Badge variant={getStatusColor(log.OriginStatus)}>
62-
Status: {log.OriginStatus}
83+
Status: {formatStatusLabel(log.OriginStatus)}
6384
</Badge>
6485
<Badge variant={"secondary"}>
65-
Exec Time: {`${log.Duration / 1000000000}s`}
86+
Exec Time: {formatDuration(log.Duration)}
6687
</Badge>
6788
<Badge variant={"secondary"}>IP: {log.ClientAddr}</Badge>
6889
</div>

apps/dokploy/components/dashboard/requests/requests-table.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,15 @@ export const RequestsTable = ({ dateRange }: RequestsTableProps) => {
152152
return JSON.stringify(value, null, 2);
153153
}
154154
if (key === "Duration" || key === "OriginDuration" || key === "Overhead") {
155-
return `${value / 1000000000} s`;
155+
const nanos = Number(value);
156+
const ms = nanos / 1000000;
157+
if (ms < 1) {
158+
return `${(nanos / 1000).toFixed(2)} µs`;
159+
}
160+
if (ms < 1000) {
161+
return `${ms.toFixed(2)} ms`;
162+
}
163+
return `${(ms / 1000).toFixed(2)} s`;
156164
}
157165
if (key === "level") {
158166
return <Badge variant="secondary">{value}</Badge>;
@@ -161,7 +169,11 @@ export const RequestsTable = ({ dateRange }: RequestsTableProps) => {
161169
return <Badge variant="outline">{value}</Badge>;
162170
}
163171
if (key === "DownstreamStatus" || key === "OriginStatus") {
164-
return <Badge variant={getStatusColor(value)}>{value}</Badge>;
172+
const num = Number(value);
173+
if (num === 0) {
174+
return <Badge variant="secondary">N/A</Badge>;
175+
}
176+
return <Badge variant={getStatusColor(num)}>{value}</Badge>;
165177
}
166178
return value;
167179
};

apps/dokploy/components/ui/command.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Command = React.forwardRef<
1313
<CommandPrimitive
1414
ref={ref}
1515
className={cn(
16-
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
16+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground p-px",
1717
className,
1818
)}
1919
{...props}
@@ -44,7 +44,7 @@ const CommandInput = React.forwardRef<
4444
<CommandPrimitive.Input
4545
ref={ref}
4646
className={cn(
47-
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
47+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 focus-visible:ring-inset",
4848
className,
4949
)}
5050
{...props}

0 commit comments

Comments
 (0)