From 7097775343828eb447cd8ab431b86f8624bc9406 Mon Sep 17 00:00:00 2001 From: leeheejin Date: Thu, 16 Oct 2025 16:34:59 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=8C=EC=95=84=EC=84=9C=20=EB=B0=B0?= =?UTF-8?q?=EC=B9=98=EB=90=98=EB=8A=94=EA=B1=B0=20=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=A0=84=20=EC=84=B8=EC=9D=B4=EB=B8=8C=20=EB=94=94=EB=B2=A8?= =?UTF-8?q?=EB=A1=AD=EB=A7=8C=20=EB=90=9C=20=EC=83=81=ED=83=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-node/src/services/riskAlertService.ts | 99 +++---------------- .../(main)/dashboard/[dashboardId]/page.tsx | 10 +- .../components/dashboard/DashboardViewer.tsx | 5 +- .../dashboard/widgets/ExchangeWidget.tsx | 12 +-- 4 files changed, 29 insertions(+), 97 deletions(-) diff --git a/backend-node/src/services/riskAlertService.ts b/backend-node/src/services/riskAlertService.ts index d911de94..514d3e95 100644 --- a/backend-node/src/services/riskAlertService.ts +++ b/backend-node/src/services/riskAlertService.ts @@ -25,8 +25,8 @@ export class RiskAlertService { const apiKey = process.env.KMA_API_KEY; if (!apiKey) { - console.log('⚠️ 기상청 API 키가 없습니다. 테스트 데이터를 반환합니다.'); - return this.generateDummyWeatherAlerts(); + console.log('⚠️ 기상청 API 키가 없습니다. 빈 데이터를 반환합니다.'); + return []; } const alerts: Alert[] = []; @@ -109,7 +109,7 @@ export class RiskAlertService { console.log(`✅ 총 ${alerts.length}건의 기상특보 감지`); } catch (warningError: any) { console.error('❌ 기상청 특보 API 오류:', warningError.message); - return this.generateDummyWeatherAlerts(); + return []; } // 특보가 없으면 빈 배열 반환 (0건) @@ -120,8 +120,8 @@ export class RiskAlertService { return alerts; } catch (error: any) { console.error('❌ 기상청 특보 API 오류:', error.message); - // API 오류 시 더미 데이터 반환 - return this.generateDummyWeatherAlerts(); + // API 오류 시 빈 배열 반환 + return []; } } @@ -237,9 +237,9 @@ export class RiskAlertService { console.error('❌ 한국도로공사 API 오류:', error.message); } - // 모든 API 실패 시 더미 데이터 - console.log('ℹ️ 모든 교통사고 API 실패. 더미 데이터를 반환합니다.'); - return this.generateDummyAccidentAlerts(); + // 모든 API 실패 시 빈 배열 + console.log('ℹ️ 모든 교통사고 API 실패. 빈 배열을 반환합니다.'); + return []; } /** @@ -356,9 +356,9 @@ export class RiskAlertService { console.error('❌ 한국도로공사 API 오류:', error.message); } - // 모든 API 실패 시 더미 데이터 - console.log('ℹ️ 모든 도로공사 API 실패. 더미 데이터를 반환합니다.'); - return this.generateDummyRoadworkAlerts(); + // 모든 API 실패 시 빈 배열 + console.log('ℹ️ 모든 도로공사 API 실패. 빈 배열을 반환합니다.'); + return []; } /** @@ -467,82 +467,5 @@ export class RiskAlertService { return 'low'; } - /** - * 테스트용 날씨 특보 더미 데이터 - */ - private generateDummyWeatherAlerts(): Alert[] { - return [ - { - id: `weather-${Date.now()}-1`, - type: 'weather', - severity: 'high', - title: '대설특보', - location: '강원 영동지역', - description: '시간당 2cm 이상 폭설. 차량 운행 주의', - timestamp: new Date(Date.now() - 30 * 60000).toISOString(), - }, - { - id: `weather-${Date.now()}-2`, - type: 'weather', - severity: 'medium', - title: '강풍특보', - location: '남해안 전 지역', - description: '순간 풍속 20m/s 이상. 고속도로 주행 주의', - timestamp: new Date(Date.now() - 90 * 60000).toISOString(), - }, - ]; - } - - /** - * 테스트용 교통사고 더미 데이터 - */ - private generateDummyAccidentAlerts(): Alert[] { - return [ - { - id: `accident-${Date.now()}-1`, - type: 'accident', - severity: 'high', - title: '교통사고 발생', - location: '경부고속도로 서울방향 189km', - description: '3중 추돌사고로 2차로 통제 중. 우회 권장', - timestamp: new Date(Date.now() - 10 * 60000).toISOString(), - }, - { - id: `accident-${Date.now()}-2`, - type: 'accident', - severity: 'medium', - title: '사고 다발 지역', - location: '영동고속도로 강릉방향 160km', - description: '안개로 인한 가시거리 50m 이하. 서행 운전', - timestamp: new Date(Date.now() - 60 * 60000).toISOString(), - }, - ]; - } - - /** - * 테스트용 도로공사 더미 데이터 - */ - private generateDummyRoadworkAlerts(): Alert[] { - return [ - { - id: `construction-${Date.now()}-1`, - type: 'construction', - severity: 'medium', - title: '도로 공사', - location: '서울외곽순환 목동IC~화곡IC', - description: '야간 공사로 1차로 통제 (22:00~06:00)', - timestamp: new Date(Date.now() - 45 * 60000).toISOString(), - }, - { - id: `construction-${Date.now()}-2`, - type: 'construction', - severity: 'low', - title: '도로 통제', - location: '중부내륙고속도로 김천JC~현풍IC', - description: '도로 유지보수 작업. 차량 속도 제한 60km/h', - timestamp: new Date(Date.now() - 120 * 60000).toISOString(), - }, - ]; - } } diff --git a/frontend/app/(main)/dashboard/[dashboardId]/page.tsx b/frontend/app/(main)/dashboard/[dashboardId]/page.tsx index 0705d77b..6f5af7ba 100644 --- a/frontend/app/(main)/dashboard/[dashboardId]/page.tsx +++ b/frontend/app/(main)/dashboard/[dashboardId]/page.tsx @@ -25,6 +25,10 @@ export default function DashboardViewPage({ params }: DashboardViewPageProps) { title: string; description?: string; elements: DashboardElement[]; + settings?: { + backgroundColor?: string; + resolution?: string; + }; createdAt: string; updatedAt: string; } | null>(null); @@ -156,7 +160,11 @@ export default function DashboardViewPage({ params }: DashboardViewPageProps) { {/* 대시보드 뷰어 */}
- +
); diff --git a/frontend/components/dashboard/DashboardViewer.tsx b/frontend/components/dashboard/DashboardViewer.tsx index a363de36..1c9fd7ed 100644 --- a/frontend/components/dashboard/DashboardViewer.tsx +++ b/frontend/components/dashboard/DashboardViewer.tsx @@ -115,6 +115,7 @@ interface DashboardViewerProps { elements: DashboardElement[]; dashboardId: string; refreshInterval?: number; // 전체 대시보드 새로고침 간격 (ms) + backgroundColor?: string; // 배경색 } /** @@ -123,7 +124,7 @@ interface DashboardViewerProps { * - 실시간 데이터 업데이트 * - 반응형 레이아웃 */ -export function DashboardViewer({ elements, dashboardId, refreshInterval }: DashboardViewerProps) { +export function DashboardViewer({ elements, dashboardId, refreshInterval, backgroundColor = "#f9fafb" }: DashboardViewerProps) { const [elementData, setElementData] = useState>({}); const [loadingElements, setLoadingElements] = useState>(new Set()); const [lastRefresh, setLastRefresh] = useState(new Date()); @@ -230,7 +231,7 @@ export function DashboardViewer({ elements, dashboardId, refreshInterval }: Dash } return ( -
+
{/* 새로고침 상태 표시 */}
마지막 업데이트: {lastRefresh.toLocaleTimeString()} diff --git a/frontend/components/dashboard/widgets/ExchangeWidget.tsx b/frontend/components/dashboard/widgets/ExchangeWidget.tsx index 86743326..d7fb2128 100644 --- a/frontend/components/dashboard/widgets/ExchangeWidget.tsx +++ b/frontend/components/dashboard/widgets/ExchangeWidget.tsx @@ -135,7 +135,7 @@ export default function ExchangeWidget({ const hasError = error || !exchangeRate; return ( -
+
{/* 헤더 */}
@@ -160,10 +160,10 @@ export default function ExchangeWidget({
- {/* 통화 선택 */} -
+ {/* 통화 선택 - 반응형 (좁을 때 세로 배치) */} +
- +