From 356929b399ef31a4de82906267df438cf29ea59d Mon Sep 17 00:00:00 2001 From: 0-Zz-ang Date: Thu, 10 Jul 2025 15:56:13 +0900 Subject: 인터페이스 관련 파일 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/integration-log-table-columns.tsx | 238 +++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 lib/integration-log/table/integration-log-table-columns.tsx (limited to 'lib/integration-log/table/integration-log-table-columns.tsx') diff --git a/lib/integration-log/table/integration-log-table-columns.tsx b/lib/integration-log/table/integration-log-table-columns.tsx new file mode 100644 index 00000000..6a955287 --- /dev/null +++ b/lib/integration-log/table/integration-log-table-columns.tsx @@ -0,0 +1,238 @@ +"use client"; +import * as React from "react"; +import { type ColumnDef } from "@tanstack/react-table"; +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"; +import { Badge } from "@/components/ui/badge"; +import { Clock, Activity, Globe, Zap, AlertCircle } from "lucide-react"; +import { formatDateTime } from "@/lib/utils"; +import { integrationLogTable } from "@/db/schema/integration-log"; + +// 확장된 타입 정의 (JOIN 결과) +type IntegrationLogWithIntegration = typeof integrationLogTable.$inferSelect & { + code?: string; + name?: string; + type?: string; + sourceSystem?: string; + targetSystem?: string; + status?: string; +}; + +export function getColumns(): ColumnDef[] { + return [ + { + accessorKey: "name", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const name = row.getValue("name") as string; + const code = row.getValue("code") as string; + return ( +
+ +
+ {name || "-"} + {code && ( + {code} + )} +
+
+ ); + }, + enableResizing: true, + minSize: 150, + size: 200, + }, + { + accessorKey: "type", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const type = row.getValue("type") as string; + if (!type) return -; + + const typeMap: Record = { + rest_api: { label: "REST API", variant: "default" }, + soap: { label: "SOAP", variant: "secondary" }, + db_to_db: { label: "DB to DB", variant: "outline" }, + }; + + const config = typeMap[type] || { label: type, variant: "outline" }; + + return ( + + {config.label} + + ); + }, + enableResizing: true, + minSize: 100, + size: 120, + }, + { + accessorKey: "status", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const status = row.getValue("status") as string; + const statusMap: Record = { + success: { label: "성공", variant: "default" }, + failed: { label: "실패", variant: "destructive" }, + timeout: { label: "타임아웃", variant: "secondary" }, + pending: { label: "대기중", variant: "outline" }, + }; + + const config = statusMap[status] || { label: status, variant: "outline" }; + + return ( + + {config.label} + + ); + }, + enableResizing: true, + minSize: 100, + size: 120, + }, + { + accessorKey: "requestMethod", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const method = row.getValue("requestMethod") as string; + if (!method) return -; + + const methodColors: Record = { + GET: "bg-blue-100 text-blue-800", + POST: "bg-green-100 text-green-800", + PUT: "bg-yellow-100 text-yellow-800", + DELETE: "bg-red-100 text-red-800", + }; + + return ( + + {method} + + ); + }, + enableResizing: true, + minSize: 80, + size: 100, + }, + { + accessorKey: "httpStatusCode", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const statusCode = row.getValue("httpStatusCode") as number; + if (!statusCode) return -; + + const isClientError = statusCode >= 400 && statusCode < 500; + const isServerError = statusCode >= 500; + + let colorClass = "text-green-600"; + if (isClientError) colorClass = "text-yellow-600"; + if (isServerError) colorClass = "text-red-600"; + + return ( + + {statusCode} + + ); + }, + enableResizing: true, + minSize: 100, + size: 120, + }, + { + accessorKey: "responseTime", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const responseTime = row.getValue("responseTime") as number; + if (!responseTime) return -; + + let colorClass = "text-green-600"; + if (responseTime > 1000) colorClass = "text-yellow-600"; + if (responseTime > 5000) colorClass = "text-red-600"; + + return ( +
+ + + {responseTime}ms + +
+ ); + }, + enableResizing: true, + minSize: 100, + size: 120, + }, + { + accessorKey: "executionTime", + header: ({ column }) => ( + + ), + cell: ({ cell }) => { + const executionTime = cell.getValue() as Date; + return ( +
+ + {formatDateTime(executionTime)} +
+ ); + }, + enableResizing: true, + minSize: 150, + size: 180, + }, + { + accessorKey: "requestUrl", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const url = row.getValue("requestUrl") as string; + return ( +
+ +
+ {url || "-"} +
+
+ ); + }, + enableResizing: true, + minSize: 150, + size: 200, + }, + { + accessorKey: "errorMessage", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const errorMessage = row.getValue("errorMessage") as string; + if (!errorMessage) return -; + + return ( +
+ +
+ {errorMessage} +
+
+ ); + }, + enableResizing: true, + minSize: 120, + size: 150, + }, + ]; +} \ No newline at end of file -- cgit v1.2.3