Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
252a824d4f
|
|
@ -41,6 +41,7 @@ export class DashboardController {
|
||||||
isPublic = false,
|
isPublic = false,
|
||||||
tags,
|
tags,
|
||||||
category,
|
category,
|
||||||
|
settings,
|
||||||
}: CreateDashboardRequest = req.body;
|
}: CreateDashboardRequest = req.body;
|
||||||
|
|
||||||
// 유효성 검증
|
// 유효성 검증
|
||||||
|
|
@ -85,6 +86,7 @@ export class DashboardController {
|
||||||
elements,
|
elements,
|
||||||
tags,
|
tags,
|
||||||
category,
|
category,
|
||||||
|
settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log('대시보드 생성 시작:', { title: dashboardData.title, userId, elementsCount: elements.length });
|
// console.log('대시보드 생성 시작:', { title: dashboardData.title, userId, elementsCount: elements.length });
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,20 @@ export class DashboardService {
|
||||||
const dashboardId = uuidv4();
|
const dashboardId = uuidv4();
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
|
console.log("🔍 [createDashboard] 받은 데이터:", {
|
||||||
|
title: data.title,
|
||||||
|
settings: data.settings,
|
||||||
|
settingsType: typeof data.settings,
|
||||||
|
settingsStringified: JSON.stringify(data.settings || {}),
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 트랜잭션으로 대시보드와 요소들을 함께 생성
|
// 트랜잭션으로 대시보드와 요소들을 함께 생성
|
||||||
const result = await PostgreSQLService.transaction(async (client) => {
|
const result = await PostgreSQLService.transaction(async (client) => {
|
||||||
// 1. 대시보드 메인 정보 저장
|
// 1. 대시보드 메인 정보 저장
|
||||||
|
const settingsJson = JSON.stringify(data.settings || {});
|
||||||
|
console.log("🔍 [createDashboard] DB INSERT settings:", settingsJson);
|
||||||
|
|
||||||
await client.query(
|
await client.query(
|
||||||
`
|
`
|
||||||
INSERT INTO dashboards (
|
INSERT INTO dashboards (
|
||||||
|
|
@ -46,7 +56,7 @@ export class DashboardService {
|
||||||
JSON.stringify(data.tags || []),
|
JSON.stringify(data.tags || []),
|
||||||
data.category || null,
|
data.category || null,
|
||||||
0,
|
0,
|
||||||
JSON.stringify(data.settings || {}),
|
settingsJson,
|
||||||
companyCode || "DEFAULT",
|
companyCode || "DEFAULT",
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
@ -351,6 +361,13 @@ export class DashboardService {
|
||||||
|
|
||||||
const dashboard = dashboardResult.rows[0];
|
const dashboard = dashboardResult.rows[0];
|
||||||
|
|
||||||
|
// 🔍 디버깅: settings 원본 확인
|
||||||
|
console.log("🔍 [getDashboardById] dashboard.settings 원본:", {
|
||||||
|
type: typeof dashboard.settings,
|
||||||
|
value: dashboard.settings,
|
||||||
|
raw: JSON.stringify(dashboard.settings),
|
||||||
|
});
|
||||||
|
|
||||||
// 2. 대시보드 요소들 조회
|
// 2. 대시보드 요소들 조회
|
||||||
const elementsQuery = `
|
const elementsQuery = `
|
||||||
SELECT * FROM dashboard_elements
|
SELECT * FROM dashboard_elements
|
||||||
|
|
@ -400,7 +417,21 @@ export class DashboardService {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
// 🔍 디버깅: settings 파싱
|
||||||
|
let parsedSettings = undefined;
|
||||||
|
if (dashboard.settings) {
|
||||||
|
if (typeof dashboard.settings === 'string') {
|
||||||
|
parsedSettings = JSON.parse(dashboard.settings);
|
||||||
|
console.log("🔍 [getDashboardById] settings 문자열 파싱:", parsedSettings);
|
||||||
|
} else {
|
||||||
|
parsedSettings = dashboard.settings;
|
||||||
|
console.log("🔍 [getDashboardById] settings 이미 객체:", parsedSettings);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("🔍 [getDashboardById] settings 없음 (null/undefined)");
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = {
|
||||||
id: dashboard.id,
|
id: dashboard.id,
|
||||||
title: dashboard.title,
|
title: dashboard.title,
|
||||||
description: dashboard.description,
|
description: dashboard.description,
|
||||||
|
|
@ -412,9 +443,13 @@ export class DashboardService {
|
||||||
tags: JSON.parse(dashboard.tags || "[]"),
|
tags: JSON.parse(dashboard.tags || "[]"),
|
||||||
category: dashboard.category,
|
category: dashboard.category,
|
||||||
viewCount: parseInt(dashboard.view_count || "0"),
|
viewCount: parseInt(dashboard.view_count || "0"),
|
||||||
settings: dashboard.settings || undefined,
|
settings: parsedSettings,
|
||||||
elements,
|
elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("🔍 [getDashboardById] 최종 반환 settings:", result.settings);
|
||||||
|
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Dashboard get error:", error);
|
console.error("Dashboard get error:", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -477,8 +512,13 @@ export class DashboardService {
|
||||||
paramIndex++;
|
paramIndex++;
|
||||||
}
|
}
|
||||||
if (data.settings !== undefined) {
|
if (data.settings !== undefined) {
|
||||||
|
const settingsJson = JSON.stringify(data.settings);
|
||||||
|
console.log("🔍 [updateDashboard] DB UPDATE settings:", {
|
||||||
|
original: data.settings,
|
||||||
|
stringified: settingsJson,
|
||||||
|
});
|
||||||
updateFields.push(`settings = $${paramIndex}`);
|
updateFields.push(`settings = $${paramIndex}`);
|
||||||
updateParams.push(JSON.stringify(data.settings));
|
updateParams.push(settingsJson);
|
||||||
paramIndex++;
|
paramIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,13 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||||
const { dashboardApi } = await import("@/lib/api/dashboard");
|
const { dashboardApi } = await import("@/lib/api/dashboard");
|
||||||
const dashboard = await dashboardApi.getDashboard(id);
|
const dashboard = await dashboardApi.getDashboard(id);
|
||||||
|
|
||||||
|
console.log("🔍 [loadDashboard] 대시보드 응답:", {
|
||||||
|
id: dashboard.id,
|
||||||
|
title: dashboard.title,
|
||||||
|
settingsType: typeof (dashboard as any).settings,
|
||||||
|
settingsValue: (dashboard as any).settings,
|
||||||
|
});
|
||||||
|
|
||||||
// 대시보드 정보 설정
|
// 대시보드 정보 설정
|
||||||
setDashboardId(dashboard.id);
|
setDashboardId(dashboard.id);
|
||||||
setDashboardTitle(dashboard.title);
|
setDashboardTitle(dashboard.title);
|
||||||
|
|
@ -164,6 +171,12 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||||
// 저장된 설정 복원
|
// 저장된 설정 복원
|
||||||
const settings = (dashboard as { settings?: { resolution?: Resolution; backgroundColor?: string } }).settings;
|
const settings = (dashboard as { settings?: { resolution?: Resolution; backgroundColor?: string } }).settings;
|
||||||
|
|
||||||
|
console.log("🔍 [loadDashboard] 파싱된 settings:", {
|
||||||
|
settings,
|
||||||
|
resolution: settings?.resolution,
|
||||||
|
backgroundColor: settings?.backgroundColor,
|
||||||
|
});
|
||||||
|
|
||||||
// 배경색 설정
|
// 배경색 설정
|
||||||
if (settings?.backgroundColor) {
|
if (settings?.backgroundColor) {
|
||||||
setCanvasBackgroundColor(settings.backgroundColor);
|
setCanvasBackgroundColor(settings.backgroundColor);
|
||||||
|
|
@ -171,6 +184,7 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||||
|
|
||||||
// 해상도와 요소를 함께 설정 (해상도가 먼저 반영되어야 함)
|
// 해상도와 요소를 함께 설정 (해상도가 먼저 반영되어야 함)
|
||||||
const loadedResolution = settings?.resolution || "fhd";
|
const loadedResolution = settings?.resolution || "fhd";
|
||||||
|
console.log("🔍 [loadDashboard] 로드할 resolution:", loadedResolution);
|
||||||
setResolution(loadedResolution);
|
setResolution(loadedResolution);
|
||||||
|
|
||||||
// 요소들 설정
|
// 요소들 설정
|
||||||
|
|
@ -457,6 +471,11 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("🔍 [handleSave] 업데이트 데이터:", {
|
||||||
|
dashboardId,
|
||||||
|
settings: updateData.settings,
|
||||||
|
});
|
||||||
|
|
||||||
savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData);
|
savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData);
|
||||||
} else {
|
} else {
|
||||||
// 새 대시보드 생성
|
// 새 대시보드 생성
|
||||||
|
|
@ -471,6 +490,10 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("🔍 [handleSave] 생성 데이터:", {
|
||||||
|
settings: dashboardData.settings,
|
||||||
|
});
|
||||||
|
|
||||||
savedDashboard = await dashboardApi.createDashboard(dashboardData);
|
savedDashboard = await dashboardApi.createDashboard(dashboardData);
|
||||||
setDashboardId(savedDashboard.id);
|
setDashboardId(savedDashboard.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,3 +162,4 @@ export function getAllDescendants(
|
||||||
return descendants;
|
return descendants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,12 @@ export const dashboardApi = {
|
||||||
* 대시보드 생성
|
* 대시보드 생성
|
||||||
*/
|
*/
|
||||||
async createDashboard(data: CreateDashboardRequest): Promise<Dashboard> {
|
async createDashboard(data: CreateDashboardRequest): Promise<Dashboard> {
|
||||||
|
console.log("🔍 [API createDashboard] 요청 데이터:", {
|
||||||
|
data,
|
||||||
|
settings: data.settings,
|
||||||
|
stringified: JSON.stringify(data),
|
||||||
|
});
|
||||||
|
|
||||||
const result = await apiRequest<Dashboard>("/dashboards", {
|
const result = await apiRequest<Dashboard>("/dashboards", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
|
|
@ -140,6 +146,10 @@ export const dashboardApi = {
|
||||||
throw new Error(result.message || "대시보드 생성에 실패했습니다.");
|
throw new Error(result.message || "대시보드 생성에 실패했습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("🔍 [API createDashboard] 응답 데이터:", {
|
||||||
|
settings: result.data.settings,
|
||||||
|
});
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -226,6 +236,13 @@ export const dashboardApi = {
|
||||||
* 대시보드 수정
|
* 대시보드 수정
|
||||||
*/
|
*/
|
||||||
async updateDashboard(id: string, data: Partial<CreateDashboardRequest>): Promise<Dashboard> {
|
async updateDashboard(id: string, data: Partial<CreateDashboardRequest>): Promise<Dashboard> {
|
||||||
|
console.log("🔍 [API updateDashboard] 요청 데이터:", {
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
settings: data.settings,
|
||||||
|
stringified: JSON.stringify(data),
|
||||||
|
});
|
||||||
|
|
||||||
const result = await apiRequest<Dashboard>(`/dashboards/${id}`, {
|
const result = await apiRequest<Dashboard>(`/dashboards/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
|
|
@ -235,6 +252,10 @@ export const dashboardApi = {
|
||||||
throw new Error(result.message || "대시보드 수정에 실패했습니다.");
|
throw new Error(result.message || "대시보드 수정에 실패했습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("🔍 [API updateDashboard] 응답 데이터:", {
|
||||||
|
settings: result.data.settings,
|
||||||
|
});
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue