Merge branch 'main' of http://39.117.244.52:3000/kjs/ERP-node into feature/dashboard

This commit is contained in:
dohyeons
2025-10-16 18:10:22 +09:00
9 changed files with 105 additions and 26 deletions

View File

@@ -233,6 +233,14 @@ app.listen(PORT, HOST, async () => {
logger.info(`🔗 Health check: http://${HOST}:${PORT}/health`);
logger.info(`🌐 External access: http://39.117.244.52:${PORT}/health`);
// 대시보드 마이그레이션 실행
try {
const { runDashboardMigration } = await import('./database/runMigration');
await runDashboardMigration();
} catch (error) {
logger.error(`❌ 대시보드 마이그레이션 실패:`, error);
}
// 배치 스케줄러 초기화
try {
await BatchSchedulerService.initialize();

View File

@@ -0,0 +1,42 @@
import { PostgreSQLService } from './PostgreSQLService';
/**
* 데이터베이스 마이그레이션 실행
* dashboard_elements 테이블에 custom_title, show_header 컬럼 추가
*/
export async function runDashboardMigration() {
try {
console.log('🔄 대시보드 마이그레이션 시작...');
// custom_title 컬럼 추가
await PostgreSQLService.query(`
ALTER TABLE dashboard_elements
ADD COLUMN IF NOT EXISTS custom_title VARCHAR(255)
`);
console.log('✅ custom_title 컬럼 추가 완료');
// show_header 컬럼 추가
await PostgreSQLService.query(`
ALTER TABLE dashboard_elements
ADD COLUMN IF NOT EXISTS show_header BOOLEAN DEFAULT true
`);
console.log('✅ show_header 컬럼 추가 완료');
// 기존 데이터 업데이트
await PostgreSQLService.query(`
UPDATE dashboard_elements
SET show_header = true
WHERE show_header IS NULL
`);
console.log('✅ 기존 데이터 업데이트 완료');
console.log('✅ 대시보드 마이그레이션 완료!');
} catch (error) {
console.error('❌ 대시보드 마이그레이션 실패:', error);
// 이미 컬럼이 있는 경우는 무시
if (error instanceof Error && error.message.includes('already exists')) {
console.log(' 컬럼이 이미 존재합니다.');
}
}
}

View File

@@ -60,9 +60,9 @@ export class DashboardService {
INSERT INTO dashboard_elements (
id, dashboard_id, element_type, element_subtype,
position_x, position_y, width, height,
title, content, data_source_config, chart_config,
title, custom_title, show_header, content, data_source_config, chart_config,
display_order, created_at, updated_at
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
`,
[
elementId,
@@ -74,6 +74,8 @@ export class DashboardService {
element.size.width,
element.size.height,
element.title,
element.customTitle || null,
element.showHeader !== false, // 기본값 true
element.content || null,
JSON.stringify(element.dataSource || {}),
JSON.stringify(element.chartConfig || {}),
@@ -335,6 +337,8 @@ export class DashboardService {
height: row.height,
},
title: row.title,
customTitle: row.custom_title || undefined,
showHeader: row.show_header !== false, // 기본값 true
content: row.content,
dataSource: JSON.parse(row.data_source_config || "{}"),
chartConfig: JSON.parse(row.chart_config || "{}"),
@@ -460,9 +464,9 @@ export class DashboardService {
INSERT INTO dashboard_elements (
id, dashboard_id, element_type, element_subtype,
position_x, position_y, width, height,
title, content, data_source_config, chart_config,
title, custom_title, show_header, content, data_source_config, chart_config,
display_order, created_at, updated_at
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
`,
[
elementId,
@@ -474,6 +478,8 @@ export class DashboardService {
element.size.width,
element.size.height,
element.title,
element.customTitle || null,
element.showHeader !== false, // 기본값 true
element.content || null,
JSON.stringify(element.dataSource || {}),
JSON.stringify(element.chartConfig || {}),

View File

@@ -15,6 +15,8 @@ export interface DashboardElement {
height: number;
};
title: string;
customTitle?: string; // 사용자 정의 제목 (옵션)
showHeader?: boolean; // 헤더 표시 여부 (기본값: true)
content?: string;
dataSource?: {
type: "api" | "database" | "static";