DashboardDesigner 오류 해결
This commit is contained in:
parent
5d1d11869c
commit
9953014b88
|
|
@ -140,12 +140,8 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
// 대시보드 ID가 props로 전달되면 로드
|
||||
React.useEffect(() => {
|
||||
if (initialDashboardId) {
|
||||
console.log("📝 기존 대시보드 편집 모드");
|
||||
loadDashboard(initialDashboardId);
|
||||
} else {
|
||||
console.log("✨ 새 대시보드 생성 모드 - 감지된 해상도:", resolution);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [initialDashboardId]);
|
||||
|
||||
// 대시보드 데이터 로드
|
||||
|
|
@ -155,35 +151,21 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
const { dashboardApi } = await import("@/lib/api/dashboard");
|
||||
const dashboard = await dashboardApi.getDashboard(id);
|
||||
|
||||
console.log("📊 대시보드 로드:", {
|
||||
id: dashboard.id,
|
||||
title: dashboard.title,
|
||||
settings: dashboard.settings,
|
||||
settingsType: typeof dashboard.settings,
|
||||
});
|
||||
|
||||
// 대시보드 정보 설정
|
||||
setDashboardId(dashboard.id);
|
||||
setDashboardTitle(dashboard.title);
|
||||
|
||||
// 저장된 설정 복원
|
||||
const settings = (dashboard as { settings?: { resolution?: Resolution; backgroundColor?: string } }).settings;
|
||||
console.log("🎨 설정 복원:", {
|
||||
settings,
|
||||
resolution: settings?.resolution,
|
||||
backgroundColor: settings?.backgroundColor,
|
||||
});
|
||||
|
||||
// 배경색 설정
|
||||
if (settings?.backgroundColor) {
|
||||
setCanvasBackgroundColor(settings.backgroundColor);
|
||||
console.log("✅ BackgroundColor 설정됨:", settings.backgroundColor);
|
||||
}
|
||||
|
||||
// 해상도와 요소를 함께 설정 (해상도가 먼저 반영되어야 함)
|
||||
const loadedResolution = settings?.resolution || "fhd";
|
||||
setResolution(loadedResolution);
|
||||
console.log("✅ Resolution 설정됨:", loadedResolution);
|
||||
|
||||
// 요소들 설정
|
||||
if (dashboard.elements && dashboard.elements.length > 0) {
|
||||
|
|
@ -221,7 +203,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
(type: ElementType, subtype: ElementSubtype, x: number, y: number) => {
|
||||
// 좌표 유효성 검사
|
||||
if (isNaN(x) || isNaN(y)) {
|
||||
// console.error("Invalid coordinates:", { x, y });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -246,14 +227,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
|
||||
// 크기 유효성 검사
|
||||
if (isNaN(defaultWidth) || isNaN(defaultHeight) || defaultWidth <= 0 || defaultHeight <= 0) {
|
||||
// console.error("Invalid size calculated:", {
|
||||
// canvasConfig,
|
||||
// cellSize,
|
||||
// cellWithGap,
|
||||
// defaultCells,
|
||||
// defaultWidth,
|
||||
// defaultHeight,
|
||||
// });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +260,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
|
||||
// 좌표 유효성 확인
|
||||
if (isNaN(centerX) || isNaN(centerY)) {
|
||||
// console.error("Invalid canvas config:", canvasConfig);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -375,16 +347,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
setClearConfirmOpen(false);
|
||||
}, []);
|
||||
|
||||
// 리스트/야드 위젯 설정 저장 (Partial 업데이트)
|
||||
const saveWidgetConfig = useCallback(
|
||||
(updates: Partial<DashboardElement>) => {
|
||||
if (sidebarElement) {
|
||||
updateElement(sidebarElement.id, updates);
|
||||
}
|
||||
},
|
||||
[sidebarElement, updateElement],
|
||||
);
|
||||
|
||||
// 사이드바 닫기
|
||||
const handleCloseSidebar = useCallback(() => {
|
||||
setSidebarOpen(false);
|
||||
|
|
@ -436,14 +398,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
const { dashboardApi } = await import("@/lib/api/dashboard");
|
||||
|
||||
const elementsData = elements.map((el) => {
|
||||
// 야드 위젯인 경우 설정 로그 출력
|
||||
// if (el.subtype === "yard-management-3d") {
|
||||
// console.log("💾 야드 위젯 저장:", {
|
||||
// id: el.id,
|
||||
// yardConfig: el.yardConfig,
|
||||
// hasLayoutId: !!el.yardConfig?.layoutId,
|
||||
// });
|
||||
// }
|
||||
return {
|
||||
id: el.id,
|
||||
type: el.type,
|
||||
|
|
@ -487,12 +441,6 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
},
|
||||
};
|
||||
|
||||
console.log("💾 대시보드 업데이트 요청:", {
|
||||
dashboardId,
|
||||
updateData,
|
||||
elementsCount: elementsData.length,
|
||||
});
|
||||
|
||||
savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData);
|
||||
} else {
|
||||
// 새 대시보드 생성
|
||||
|
|
@ -553,18 +501,7 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
|||
// 성공 모달 표시
|
||||
setSuccessModalOpen(true);
|
||||
} catch (error) {
|
||||
console.error("❌ 대시보드 저장 실패:", error);
|
||||
const errorMessage = error instanceof Error ? error.message : "알 수 없는 오류";
|
||||
|
||||
// 상세한 에러 정보 로깅
|
||||
if (error instanceof Error) {
|
||||
console.error("Error details:", {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name,
|
||||
});
|
||||
}
|
||||
|
||||
alert(`대시보드 저장 중 오류가 발생했습니다.\n\n오류: ${errorMessage}`);
|
||||
throw error;
|
||||
}
|
||||
|
|
@ -754,13 +691,13 @@ function getElementTitle(type: ElementType, subtype: ElementSubtype): string {
|
|||
return "달력 위젯";
|
||||
case "driver-management":
|
||||
return "기사 관리 위젯";
|
||||
case "list":
|
||||
case "list-v2":
|
||||
return "리스트 위젯";
|
||||
case "map-summary":
|
||||
case "map-summary-v2":
|
||||
return "커스텀 지도 카드";
|
||||
case "status-summary":
|
||||
return "커스텀 상태 카드";
|
||||
case "risk-alert":
|
||||
case "risk-alert-v2":
|
||||
return "리스크 알림 위젯";
|
||||
case "todo":
|
||||
return "할 일 위젯";
|
||||
|
|
@ -814,7 +751,7 @@ function getElementContent(type: ElementType, subtype: ElementSubtype): string {
|
|||
return "calendar";
|
||||
case "driver-management":
|
||||
return "driver-management";
|
||||
case "list":
|
||||
case "list-v2":
|
||||
return "list-widget";
|
||||
case "yard-management-3d":
|
||||
return "yard-3d";
|
||||
|
|
|
|||
Loading…
Reference in New Issue