From 2433658e01f2326606cdf6634e9d6693e185fe4f Mon Sep 17 00:00:00 2001 From: dohyeons Date: Wed, 22 Oct 2025 10:58:21 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9D=B4=EB=93=9C=EB=B0=94=EC=97=90?= =?UTF-8?q?=20=ED=83=AD=20=EB=B0=A9=EC=8B=9D=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/dashboard/ElementConfigSidebar.tsx | 240 ++++++++---------- .../dashboard/data-sources/DatabaseConfig.tsx | 12 +- 2 files changed, 114 insertions(+), 138 deletions(-) diff --git a/frontend/components/admin/dashboard/ElementConfigSidebar.tsx b/frontend/components/admin/dashboard/ElementConfigSidebar.tsx index 06d2e4e4..0523b443 100644 --- a/frontend/components/admin/dashboard/ElementConfigSidebar.tsx +++ b/frontend/components/admin/dashboard/ElementConfigSidebar.tsx @@ -5,13 +5,13 @@ import { DashboardElement, ChartDataSource, ChartConfig, QueryResult } from "./t import { QueryEditor } from "./QueryEditor"; import { ChartConfigPanel } from "./ChartConfigPanel"; import { VehicleMapConfigPanel } from "./VehicleMapConfigPanel"; -import { DataSourceSelector } from "./data-sources/DataSourceSelector"; import { DatabaseConfig } from "./data-sources/DatabaseConfig"; import { ApiConfig } from "./data-sources/ApiConfig"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; -import { X, ChevronLeft, ChevronRight } from "lucide-react"; +import { X } from "lucide-react"; import { cn } from "@/lib/utils"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; interface ElementConfigSidebarProps { element: DashboardElement | null; @@ -34,7 +34,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem }); const [chartConfig, setChartConfig] = useState({}); const [queryResult, setQueryResult] = useState(null); - const [currentStep, setCurrentStep] = useState<1 | 2>(1); const [customTitle, setCustomTitle] = useState(""); const [showHeader, setShowHeader] = useState(true); @@ -44,7 +43,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem setDataSource(element.dataSource || { type: "database", connectionType: "current", refreshInterval: 0 }); setChartConfig(element.chartConfig || {}); setQueryResult(null); - setCurrentStep(1); setCustomTitle(element.customTitle || ""); setShowHeader(element.showHeader !== false); } @@ -100,25 +98,6 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem setChartConfig({}); }, []); - // 다음 단계로 이동 - const handleNext = useCallback(() => { - if (currentStep === 1) { - setCurrentStep(2); - } - }, [currentStep]); - - // 이전 단계로 이동 - const handlePrev = useCallback(() => { - if (currentStep > 1) { - setCurrentStep((prev) => (prev - 1) as 1 | 2); - } - }, [currentStep]); - - // 취소 처리 - const handleCancel = useCallback(() => { - onClose(); - }, [onClose]); - // 적용 처리 const handleApply = useCallback(() => { if (!element) return; @@ -184,15 +163,10 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem isTitleChanged || isHeaderChanged || (isSimpleWidget - ? currentStep === 2 && queryResult && queryResult.rows.length > 0 + ? queryResult && queryResult.rows.length > 0 : isMapWidget - ? currentStep === 2 && - queryResult && - queryResult.rows.length > 0 && - chartConfig.latitudeColumn && - chartConfig.longitudeColumn - : currentStep === 2 && - queryResult && + ? queryResult && queryResult.rows.length > 0 && chartConfig.latitudeColumn && chartConfig.longitudeColumn + : queryResult && queryResult.rows.length > 0 && chartConfig.xAxis && (isPieChart || isApiSource ? (chartConfig.aggregation === "count" ? true : hasYAxis) : hasYAxis)); @@ -214,89 +188,105 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem {/* 본문: 스크롤 가능 영역 */}
- {/* 커스텀 제목 입력 */} -
- - setCustomTitle(e.target.value)} - onKeyDown={(e) => e.stopPropagation()} - placeholder="비워두면 자동 생성" - className="focus:border-primary focus:ring-primary w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-1 focus:outline-none" - /> -
- - {/* 헤더 표시 옵션 */} -
- setShowHeader(e.target.checked)} - className="text-primary focus:ring-primary h-4 w-4 rounded border-gray-300" - /> - -
- - {/* 진행 상황 표시 */} - {!isSimpleWidget && !isHeaderOnlyWidget && ( -
-
- 단계 {currentStep} / 2: {currentStep === 1 ? "데이터 소스 선택" : "데이터 설정"} -
+ {/* 기본 설정 */} +
+ {/* 커스텀 제목 입력 */} +
+ + setCustomTitle(e.target.value)} + onKeyDown={(e) => e.stopPropagation()} + placeholder="비워두면 자동 생성" + className="focus:border-primary focus:ring-primary w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-1 focus:outline-none" + />
- )} - {/* 단계별 내용 */} + {/* 헤더 표시 옵션 */} +
+ setShowHeader(e.target.checked)} + className="text-primary focus:ring-primary h-4 w-4 rounded border-gray-300" + /> + +
+
+ + {/* 헤더 전용 위젯이 아닐 때만 데이터 소스 탭 표시 */} {!isHeaderOnlyWidget && ( -
- {currentStep === 1 && ( - - )} + handleDataSourceTypeChange(value as "database" | "api")} + className="w-full" + > + + 데이터베이스 + REST API + - {currentStep === 2 && ( -
- {/* 데이터 설정 */} - {dataSource.type === "database" ? ( - <> - - + + + + {/* 차트/지도 설정 */} + {!isSimpleWidget && queryResult && queryResult.rows.length > 0 && ( +
+ {isMapWidget ? ( + - - ) : ( - - )} + ) : ( + + )} +
+ )} + - {/* 차트/지도 설정 */} - {!isSimpleWidget && queryResult && queryResult.rows.length > 0 && ( -
- {isMapWidget ? ( - - ) : ( - - )} -
- )} -
- )} -
+ + + + {/* 차트/지도 설정 */} + {!isSimpleWidget && queryResult && queryResult.rows.length > 0 && ( +
+ {isMapWidget ? ( + + ) : ( + + )} +
+ )} +
+ )} {/* 데이터 로드 상태 */} @@ -307,32 +297,14 @@ export function ElementConfigSidebar({ element, isOpen, onClose, onApply }: Elem )}
- {/* 푸터: 단계 이동 및 적용 버튼 */} -
-
- {!isSimpleWidget && !isHeaderOnlyWidget && currentStep > 1 && ( - - )} -
- -
- - {isHeaderOnlyWidget || currentStep === 1 ? ( - - ) : ( - - )} -
+ {/* 푸터: 적용 버튼 */} +
+ +
); diff --git a/frontend/components/admin/dashboard/data-sources/DatabaseConfig.tsx b/frontend/components/admin/dashboard/data-sources/DatabaseConfig.tsx index ff190184..ccd86113 100644 --- a/frontend/components/admin/dashboard/data-sources/DatabaseConfig.tsx +++ b/frontend/components/admin/dashboard/data-sources/DatabaseConfig.tsx @@ -68,8 +68,8 @@ export function DatabaseConfig({ dataSource, onChange }: DatabaseConfigProps) { >
-
현재 데이터베이스
-
애플리케이션 기본 DB
+
현재 DB
+
기본 DB
@@ -82,7 +82,7 @@ export function DatabaseConfig({ dataSource, onChange }: DatabaseConfigProps) { >
-
외부 데이터베이스
+
외부 DB
등록된 외부 커넥션
@@ -183,7 +183,11 @@ export function DatabaseConfig({ dataSource, onChange }: DatabaseConfigProps) { {(dataSource.connectionType === "current" || (dataSource.connectionType === "external" && dataSource.externalConnectionId)) && (
-
✅ 데이터베이스가 선택되었습니다. 아래에서 SQL 쿼리를 작성하세요.
+
+ 데이터베이스가 선택되었습니다. +
+ 아래에서 SQL 쿼리를 작성하세요. +
)}