대시보드 관리 오류 수정
This commit is contained in:
@@ -72,7 +72,7 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||
|
||||
// 화면 해상도 자동 감지
|
||||
const [screenResolution] = useState<Resolution>(() => detectScreenResolution());
|
||||
const [resolution, setResolution] = useState<Resolution>(screenResolution);
|
||||
const [resolution, setResolution] = useState<Resolution>("fhd"); // 초기값은 FHD, 로드 시 덮어씀
|
||||
|
||||
// resolution 변경 감지 및 요소 자동 조정
|
||||
const handleResolutionChange = useCallback(
|
||||
@@ -171,23 +171,19 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||
settings,
|
||||
resolution: settings?.resolution,
|
||||
backgroundColor: settings?.backgroundColor,
|
||||
currentResolution: resolution,
|
||||
});
|
||||
|
||||
if (settings?.resolution) {
|
||||
setResolution(settings.resolution);
|
||||
console.log("✅ Resolution 설정됨:", settings.resolution);
|
||||
} else {
|
||||
console.log("⚠️ Resolution 없음, 기본값 유지:", resolution);
|
||||
}
|
||||
|
||||
// 배경색 설정
|
||||
if (settings?.backgroundColor) {
|
||||
setCanvasBackgroundColor(settings.backgroundColor);
|
||||
console.log("✅ BackgroundColor 설정됨:", settings.backgroundColor);
|
||||
} else {
|
||||
console.log("⚠️ BackgroundColor 없음, 기본값 유지:", canvasBackgroundColor);
|
||||
}
|
||||
|
||||
// 해상도와 요소를 함께 설정 (해상도가 먼저 반영되어야 함)
|
||||
const loadedResolution = settings?.resolution || "fhd";
|
||||
setResolution(loadedResolution);
|
||||
console.log("✅ Resolution 설정됨:", loadedResolution);
|
||||
|
||||
// 요소들 설정
|
||||
if (dashboard.elements && dashboard.elements.length > 0) {
|
||||
setElements(dashboard.elements);
|
||||
@@ -432,8 +428,15 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||
id: el.id,
|
||||
type: el.type,
|
||||
subtype: el.subtype,
|
||||
position: el.position,
|
||||
size: el.size,
|
||||
// 위치와 크기는 정수로 반올림 (DB integer 타입)
|
||||
position: {
|
||||
x: Math.round(el.position.x),
|
||||
y: Math.round(el.position.y),
|
||||
},
|
||||
size: {
|
||||
width: Math.round(el.size.width),
|
||||
height: Math.round(el.size.height),
|
||||
},
|
||||
title: el.title,
|
||||
customTitle: el.customTitle,
|
||||
showHeader: el.showHeader,
|
||||
@@ -459,6 +462,12 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||
},
|
||||
};
|
||||
|
||||
console.log("💾 대시보드 업데이트 요청:", {
|
||||
dashboardId,
|
||||
updateData,
|
||||
elementsCount: elementsData.length,
|
||||
});
|
||||
|
||||
savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData);
|
||||
} else {
|
||||
// 새 대시보드 생성
|
||||
@@ -519,7 +528,18 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user