60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* 로그 노드 - 디버깅 및 모니터링용
|
|
*/
|
|
|
|
import { memo } from "react";
|
|
import { Handle, Position, NodeProps } from "reactflow";
|
|
import { FileText, AlertCircle, Info, AlertTriangle } from "lucide-react";
|
|
import type { LogNodeData } from "@/types/node-editor";
|
|
|
|
const LOG_LEVEL_CONFIG = {
|
|
debug: { icon: Info, color: "text-blue-600", bg: "bg-blue-50", border: "border-blue-200" },
|
|
info: { icon: Info, color: "text-green-600", bg: "bg-green-50", border: "border-green-200" },
|
|
warn: { icon: AlertTriangle, color: "text-yellow-600", bg: "bg-yellow-50", border: "border-yellow-200" },
|
|
error: { icon: AlertCircle, color: "text-red-600", bg: "bg-red-50", border: "border-red-200" },
|
|
};
|
|
|
|
export const LogNode = memo(({ data, selected }: NodeProps<LogNodeData>) => {
|
|
const config = LOG_LEVEL_CONFIG[data.level] || LOG_LEVEL_CONFIG.info;
|
|
const Icon = config.icon;
|
|
|
|
return (
|
|
<div
|
|
className={`min-w-[200px] rounded-lg border-2 bg-white shadow-sm transition-all ${
|
|
selected ? `${config.border} shadow-md` : "border-gray-200"
|
|
}`}
|
|
>
|
|
{/* 헤더 */}
|
|
<div className={`flex items-center gap-2 rounded-t-lg ${config.bg} px-3 py-2`}>
|
|
<FileText className={`h-4 w-4 ${config.color}`} />
|
|
<div className="flex-1">
|
|
<div className={`text-sm font-semibold ${config.color}`}>로그</div>
|
|
<div className="text-xs text-gray-600">{data.level.toUpperCase()}</div>
|
|
</div>
|
|
<Icon className={`h-4 w-4 ${config.color}`} />
|
|
</div>
|
|
|
|
{/* 본문 */}
|
|
<div className="p-3">
|
|
{data.message ? (
|
|
<div className="text-sm text-gray-700">{data.message}</div>
|
|
) : (
|
|
<div className="text-sm text-gray-400">로그 메시지 없음</div>
|
|
)}
|
|
|
|
{data.includeData && (
|
|
<div className="mt-2 rounded bg-gray-50 px-2 py-1 text-xs text-gray-600">✓ 데이터 포함</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* 핸들 */}
|
|
<Handle type="target" position={Position.Left} className="!h-3 !w-3 !bg-gray-400" />
|
|
<Handle type="source" position={Position.Right} className="!h-3 !w-3 !bg-gray-400" />
|
|
</div>
|
|
);
|
|
});
|
|
|
|
LogNode.displayName = "LogNode";
|