File tree Expand file tree Collapse file tree 3 files changed +39
-6
lines changed
Expand file tree Collapse file tree 3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import { Button } from "@/components/ui/button";
66import type { LogEntry } from "./show-requests" ;
77
88export 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+
2445export 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 >
Original file line number Diff line number Diff 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 } ;
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments