diff --git a/frontend/components/admin/dashboard/ElementConfigSidebar.tsx b/frontend/components/admin/dashboard/ElementConfigSidebar.tsx index 32a45a49..f5f83c50 100644 --- a/frontend/components/admin/dashboard/ElementConfigSidebar.tsx +++ b/frontend/components/admin/dashboard/ElementConfigSidebar.tsx @@ -16,6 +16,10 @@ import { X } from "lucide-react"; import { cn } from "@/lib/utils"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import CustomMetricConfigSidebar from "./widgets/custom-metric/CustomMetricConfigSidebar"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Checkbox } from "@/components/ui/checkbox"; +import { Label } from "@/components/ui/label"; interface ElementConfigSidebarProps { element: DashboardElement | null; @@ -50,16 +54,11 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem // 사이드바가 열릴 때 초기화 useEffect(() => { if (isOpen && element) { - console.log("🔄 ElementConfigSidebar 초기화 - element.id:", element.id); - console.log("🔄 element.dataSources:", element.dataSources); - console.log("🔄 element.chartConfig?.dataSources:", element.chartConfig?.dataSources); - setDataSource(element.dataSource || { type: "database", connectionType: "current", refreshInterval: 0 }); // dataSources는 element.dataSources 또는 chartConfig.dataSources에서 로드 // ⚠️ 중요: 없으면 반드시 빈 배열로 초기화 const initialDataSources = element.dataSources || element.chartConfig?.dataSources || []; - console.log("🔄 초기화된 dataSources:", initialDataSources); setDataSources(initialDataSources); setChartConfig(element.chartConfig || {}); @@ -69,7 +68,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem setShowHeader(element.showHeader !== false); } else if (!isOpen) { // 사이드바가 닫힐 때 모든 상태 초기화 - console.log("🧹 ElementConfigSidebar 닫힘 - 상태 초기화"); setDataSource({ type: "database", connectionType: "current", refreshInterval: 0 }); setDataSources([]); setChartConfig({}); @@ -124,8 +122,8 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem (newConfig: ChartConfig) => { setChartConfig(newConfig); - // 🎯 실시간 미리보기: 즉시 부모에게 전달 (map-test 위젯용) - if (element && element.subtype === "map-test" && newConfig.tileMapUrl) { + // 🎯 실시간 미리보기: 즉시 부모에게 전달 (map-summary-v2 위젯용) + if (element && element.subtype === "map-summary-v2" && newConfig.tileMapUrl) { onApply({ ...element, chartConfig: newConfig, @@ -148,10 +146,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem const handleApply = useCallback(() => { if (!element) return; - console.log("🔧 적용 버튼 클릭 - dataSource:", dataSource); - console.log("🔧 적용 버튼 클릭 - dataSources:", dataSources); - console.log("🔧 적용 버튼 클릭 - chartConfig:", chartConfig); - // 다중 데이터 소스 위젯 체크 const isMultiDS = element.subtype === "map-summary-v2" || @@ -170,7 +164,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem showHeader, }; - console.log("🔧 적용할 요소:", updatedElement); onApply(updatedElement); // 사이드바는 열린 채로 유지 (연속 수정 가능) }, [element, dataSource, dataSources, chartConfig, customTitle, showHeader, onApply]); @@ -179,7 +172,7 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem if (!element) return null; // 리스트 위젯은 별도 사이드바로 처리 - if (element.subtype === "list") { + if (element.subtype === "list-v2") { return ( 0 : isMapWidget - ? element.subtype === "map-test" - ? chartConfig.tileMapUrl || (queryResult && queryResult.rows.length > 0) // 🧪 지도 테스트 위젯: 타일맵 URL 또는 API 데이터 + ? element.subtype === "map-summary-v2" + ? chartConfig.tileMapUrl || (queryResult && queryResult.rows.length > 0) // 지도 위젯: 타일맵 URL 또는 API 데이터 : queryResult && queryResult.rows.length > 0 && chartConfig.latitudeColumn && chartConfig.longitudeColumn : queryResult && queryResult.rows.length > 0 && @@ -291,62 +281,58 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem return (
{/* 헤더 */} -
+
- {element.title} + {element.title}
- +
{/* 본문: 스크롤 가능 영역 */}
{/* 기본 설정 카드 */} -
-
기본 설정
+
+
기본 설정
{/* 커스텀 제목 입력 */}
- setCustomTitle(e.target.value)} onKeyDown={(e) => e.stopPropagation()} placeholder="위젯 제목" - className="focus:border-primary focus:ring-primary/20 h-8 w-full rounded border border-border bg-muted px-2 text-xs placeholder:text-muted-foreground focus:bg-background focus:ring-1 focus:outline-none" + className="bg-muted focus:bg-background h-8 text-xs" />
{/* 헤더 표시 옵션 */} - + +
{/* 다중 데이터 소스 위젯 */} {isMultiDataSourceWidget && ( <> -
+
{ const updated = new Map(prev); updated.set(dataSourceId, result); - console.log("📊 테스트 결과 저장:", dataSourceId, result); return updated; }); }} @@ -372,11 +356,11 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem {/* 지도 위젯: 타일맵 URL 설정 */} {element.subtype === "map-summary-v2" && ( -
+
- +
-
+
타일맵 설정 (선택사항)
기본 VWorld 타일맵 사용 중
@@ -403,11 +387,13 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem {/* 차트 위젯: 차트 설정 */} {element.subtype === "chart" && ( -
+
- +
-
차트 설정
+
+ 차트 설정 +
{testResults.size > 0 ? `${testResults.size}개 데이터 소스 • X축, Y축, 차트 타입 설정` @@ -439,24 +425,26 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem {/* 헤더 전용 위젯이 아닐 때만 데이터 소스 표시 */} {!isHeaderOnlyWidget && !isMultiDataSourceWidget && ( -
-
데이터 소스
+
+
+ 데이터 소스 +
handleDataSourceTypeChange(value as "database" | "api")} className="w-full" > - + 데이터베이스 REST API @@ -472,10 +460,10 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem {/* 차트/지도 설정 */} {!isSimpleWidget && - (element.subtype === "map-test" || (queryResult && queryResult.rows.length > 0)) && ( + (element.subtype === "map-summary-v2" || (queryResult && queryResult.rows.length > 0)) && (
{isMapWidget ? ( - element.subtype === "map-test" ? ( + element.subtype === "map-summary-v2" ? ( 0)) && ( + (element.subtype === "map-summary-v2" || (queryResult && queryResult.rows.length > 0)) && (
{isMapWidget ? ( - element.subtype === "map-test" ? ( + element.subtype === "map-summary-v2" ? ( -
- - {queryResult.rows.length}개 데이터 로드됨 - +
+
+ {queryResult.rows.length}개 데이터 로드됨
)}
@@ -564,20 +550,13 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem
{/* 푸터: 적용 버튼 */} -
- - + +
);