kcg-monitoring/frontend/src/services/sensorApi.ts
htlee 6c54500c70 feat: 센서 그래프 실데이터 + 선박 모달 UI 개선 + KST/UTC 라디오
- SensorChart: 백엔드 실데이터(지진/기압) + 동적 x축 시간 + 히스토리 10M/30M/1H/3H/6H
- LiveControls: KST/UTC 토글 → 라디오 버튼 그룹
- ShipLayer: 모달 고정크기(300px), 드래그 가능, S&P Global 다중사진 슬라이드
- 선박 모달 CSS 통일 (태그 스타일, 2컬럼 그리드, 긴 값 단독행)
- 센서 API: hours→min 파라미터 (기본 2880=48h), 인증 예외 처리
- useIranData/useKoreaData: 센서 10분 polling + 선박 60분 초기/6분 incremental merge

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 09:23:45 +09:00

49 lines
1.2 KiB
TypeScript

const API_BASE = '/api/kcg/sensor';
export interface SeismicDto {
usgsId: string;
magnitude: number;
depth: number | null;
lat: number;
lng: number;
place: string;
timestamp: number; // epoch ms
}
export interface PressureDto {
station: string;
lat: number;
lng: number;
pressureHpa: number;
timestamp: number; // epoch ms
}
interface SensorResponse<T> {
count: number;
data: T[];
}
/**
* 지진 이벤트 조회
* @param min 조회 범위 (분, 기본 2880=48h)
*/
export async function fetchSeismic(min?: number): Promise<SeismicDto[]> {
const params = min != null ? `?min=${min}` : '';
const res = await fetch(`${API_BASE}/seismic${params}`);
if (!res.ok) throw new Error(`seismic API ${res.status}`);
const body: SensorResponse<SeismicDto> = await res.json();
return body.data;
}
/**
* 기압 데이터 조회
* @param min 조회 범위 (분, 기본 2880=48h)
*/
export async function fetchPressure(min?: number): Promise<PressureDto[]> {
const params = min != null ? `?min=${min}` : '';
const res = await fetch(`${API_BASE}/pressure${params}`);
if (!res.ok) throw new Error(`pressure API ${res.status}`);
const body: SensorResponse<PressureDto> = await res.json();
return body.data;
}