Compare commits

..

3 Commits

Author SHA1 Message Date
hyungi
a820a164cb Fix: HTTPS Mixed Content 오류 수정 및 백업 시스템 구축
- Frontend: 하드코딩된 localhost API URL을 동적 URL 생성으로 변경
  - reports-daily.html: 3곳 수정 (프로젝트 로드, 미리보기, 보고서 생성)
  - issues-archive.html: 프로젝트 로드 함수 수정
  - issues-dashboard.html: 2곳 수정 (프로젝트 로드, 진행중 이슈 로드)
  - issues-inbox.html: 프로젝트 로드 함수 수정
  - daily-work.html: 프로젝트 로드 함수 수정
  - permissions.js: 2곳 수정 (권한 부여, 사용자 권한 조회)

- Backup System: 완전한 백업/복구 시스템 구축
  - backup_script.sh: 자동 백업 스크립트 (DB, 볼륨, 설정 파일)
  - restore_script.sh: 백업 복구 스크립트
  - setup_auto_backup.sh: 자동 백업 스케줄 설정 (매일 오후 9시)
  - 백업 정책: 최신 10개 버전만 유지하여 용량 절약

- Migration: 5장 사진 지원 마이그레이션 파일 업데이트

이제 Cloudflare 환경(m.hyungi.net)에서 HTTPS 프로토콜로 API 호출하여
Mixed Content 오류 없이 모든 기능이 정상 작동합니다.
2025-11-13 06:52:21 +09:00
hyungi
86a6d21a08 feat: 5장 사진 지원을 위한 데이터베이스 스키마 추가
- photo_path3, photo_path4, photo_path5 컬럼 추가
- completion_photo_path2~5 컬럼 추가
- completion_rejected_at, completion_rejected_by_id, completion_rejection_reason 컬럼 추가
- last_exported_at, export_count 컬럼 추가
- 021_add_5_photo_support.sql 마이그레이션 생성
- 백엔드 재시작으로 새로운 스키마 적용 완료
2025-11-08 15:40:35 +09:00
hyungi
1299ac261c fix: API URL 하드코딩 문제 해결 및 API 통합 개선
- API URL 생성 로직에서 localhost 환경 감지 개선
- 모든 페이지에서 하드코딩된 API URL 제거
- ManagementAPI, InboxAPI 추가로 API 호출 통합
- ProjectsAPI 사용으로 프로젝트 로드 통일
- permissions.js에서 API URL 동적 생성 적용
2025-11-08 15:34:37 +09:00
12 changed files with 638 additions and 124 deletions

View File

@@ -0,0 +1,181 @@
-- 021_add_5_photo_support.sql
-- 5장 사진 지원을 위한 추가 컬럼들
-- 작성일: 2025-11-08
-- 목적: photo_path3, photo_path4, photo_path5 및 completion_photo_path2~5 컬럼 추가
BEGIN;
DO $$
DECLARE
migration_name VARCHAR(255) := '021_add_5_photo_support.sql';
migration_notes TEXT := '5장 사진 지원: photo_path3~5, completion_photo_path2~5 컬럼 추가';
current_status VARCHAR(50);
BEGIN
-- migration_log 테이블이 없으면 생성 (멱등성)
CREATE TABLE IF NOT EXISTS migration_log (
id SERIAL PRIMARY KEY,
migration_file VARCHAR(255) NOT NULL UNIQUE,
executed_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
status VARCHAR(50),
notes TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
started_at TIMESTAMP WITH TIME ZONE,
completed_at TIMESTAMP WITH TIME ZONE
);
SELECT status INTO current_status FROM migration_log WHERE migration_file = migration_name;
IF current_status IS NULL THEN
RAISE NOTICE '--- 마이그레이션 % 시작 ---', migration_name;
-- 기본 사진 경로 3~5 추가
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'photo_path3') THEN
ALTER TABLE issues ADD COLUMN photo_path3 VARCHAR(500);
RAISE NOTICE '✅ issues.photo_path3 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.photo_path3 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'photo_path4') THEN
ALTER TABLE issues ADD COLUMN photo_path4 VARCHAR(500);
RAISE NOTICE '✅ issues.photo_path4 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.photo_path4 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'photo_path5') THEN
ALTER TABLE issues ADD COLUMN photo_path5 VARCHAR(500);
RAISE NOTICE '✅ issues.photo_path5 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.photo_path5 컬럼이 이미 존재합니다.';
END IF;
-- 완료 사진 경로 2~5 추가
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_photo_path2') THEN
ALTER TABLE issues ADD COLUMN completion_photo_path2 VARCHAR(500);
RAISE NOTICE '✅ issues.completion_photo_path2 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_photo_path2 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_photo_path3') THEN
ALTER TABLE issues ADD COLUMN completion_photo_path3 VARCHAR(500);
RAISE NOTICE '✅ issues.completion_photo_path3 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_photo_path3 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_photo_path4') THEN
ALTER TABLE issues ADD COLUMN completion_photo_path4 VARCHAR(500);
RAISE NOTICE '✅ issues.completion_photo_path4 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_photo_path4 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_photo_path5') THEN
ALTER TABLE issues ADD COLUMN completion_photo_path5 VARCHAR(500);
RAISE NOTICE '✅ issues.completion_photo_path5 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_photo_path5 컬럼이 이미 존재합니다.';
END IF;
-- 추가 필드들 (최신 버전에서 필요한 것들)
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_rejected_at') THEN
ALTER TABLE issues ADD COLUMN completion_rejected_at TIMESTAMP WITH TIME ZONE;
RAISE NOTICE '✅ issues.completion_rejected_at 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_rejected_at 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_rejected_by_id') THEN
ALTER TABLE issues ADD COLUMN completion_rejected_by_id INTEGER REFERENCES users(id);
RAISE NOTICE '✅ issues.completion_rejected_by_id 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_rejected_by_id 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'completion_rejection_reason') THEN
ALTER TABLE issues ADD COLUMN completion_rejection_reason TEXT;
RAISE NOTICE '✅ issues.completion_rejection_reason 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.completion_rejection_reason 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'last_exported_at') THEN
ALTER TABLE issues ADD COLUMN last_exported_at TIMESTAMP WITH TIME ZONE;
RAISE NOTICE '✅ issues.last_exported_at 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.last_exported_at 컬럼이 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'export_count') THEN
ALTER TABLE issues ADD COLUMN export_count INTEGER DEFAULT 0;
RAISE NOTICE '✅ issues.export_count 컬럼이 추가되었습니다.';
ELSE
RAISE NOTICE ' issues.export_count 컬럼이 이미 존재합니다.';
END IF;
-- 인덱스 추가 (성능 향상)
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE tablename = 'issues' AND indexname = 'idx_issues_photo_path3') THEN
CREATE INDEX idx_issues_photo_path3 ON issues (photo_path3) WHERE photo_path3 IS NOT NULL;
RAISE NOTICE '✅ idx_issues_photo_path3 인덱스가 생성되었습니다.';
ELSE
RAISE NOTICE ' idx_issues_photo_path3 인덱스가 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE tablename = 'issues' AND indexname = 'idx_issues_photo_path4') THEN
CREATE INDEX idx_issues_photo_path4 ON issues (photo_path4) WHERE photo_path4 IS NOT NULL;
RAISE NOTICE '✅ idx_issues_photo_path4 인덱스가 생성되었습니다.';
ELSE
RAISE NOTICE ' idx_issues_photo_path4 인덱스가 이미 존재합니다.';
END IF;
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE tablename = 'issues' AND indexname = 'idx_issues_photo_path5') THEN
CREATE INDEX idx_issues_photo_path5 ON issues (photo_path5) WHERE photo_path5 IS NOT NULL;
RAISE NOTICE '✅ idx_issues_photo_path5 인덱스가 생성되었습니다.';
ELSE
RAISE NOTICE ' idx_issues_photo_path5 인덱스가 이미 존재합니다.';
END IF;
-- 마이그레이션 검증
DECLARE
col_count INTEGER;
idx_count INTEGER;
BEGIN
SELECT COUNT(*) INTO col_count FROM information_schema.columns
WHERE table_name = 'issues' AND column_name IN (
'photo_path3', 'photo_path4', 'photo_path5',
'completion_photo_path2', 'completion_photo_path3', 'completion_photo_path4', 'completion_photo_path5',
'completion_rejected_at', 'completion_rejected_by_id', 'completion_rejection_reason',
'last_exported_at', 'export_count'
);
SELECT COUNT(*) INTO idx_count FROM pg_indexes
WHERE tablename = 'issues' AND indexname IN (
'idx_issues_photo_path3', 'idx_issues_photo_path4', 'idx_issues_photo_path5'
);
RAISE NOTICE '=== 마이그레이션 검증 결과 ===';
RAISE NOTICE '추가된 컬럼: %/11개', col_count;
RAISE NOTICE '생성된 인덱스: %/3개', idx_count;
IF col_count = 11 AND idx_count = 3 THEN
RAISE NOTICE '✅ 마이그레이션이 성공적으로 완료되었습니다!';
INSERT INTO migration_log (migration_file, status, notes, completed_at) VALUES (migration_name, 'SUCCESS', migration_notes, NOW());
ELSE
RAISE EXCEPTION '❌ 마이그레이션 검증 실패!';
END IF;
END;
ELSIF current_status = 'SUCCESS' THEN
RAISE NOTICE ' 마이그레이션 %는 이미 성공적으로 실행되었습니다. 스킵합니다.', migration_name;
ELSE
RAISE NOTICE '⚠️ 마이그레이션 %는 이전에 실패했습니다. 수동 확인이 필요합니다.', migration_name;
END IF;
END $$;
COMMIT;

87
backup_script.sh Executable file
View File

@@ -0,0 +1,87 @@
#!/bin/bash
# M 프로젝트 자동 백업 스크립트
# 사용법: ./backup_script.sh
set -e
# 백업 디렉토리 설정
BACKUP_DIR="/Users/hyungi/M-Project/backups"
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FOLDER="$BACKUP_DIR/$DATE"
echo "🚀 M 프로젝트 백업 시작: $DATE"
# 백업 폴더 생성
mkdir -p "$BACKUP_FOLDER"
# 1. 데이터베이스 백업 (가장 중요!)
echo "📊 데이터베이스 백업 중..."
docker exec m-project-db pg_dump -U mproject mproject > "$BACKUP_FOLDER/database_backup.sql"
echo "✅ 데이터베이스 백업 완료"
# 2. Docker 볼륨 백업
echo "💾 Docker 볼륨 백업 중..."
docker run --rm -v m-project_postgres_data:/data -v "$BACKUP_FOLDER":/backup alpine tar czf /backup/postgres_volume.tar.gz -C /data .
docker run --rm -v m-project_uploads:/data -v "$BACKUP_FOLDER":/backup alpine tar czf /backup/uploads_volume.tar.gz -C /data .
echo "✅ Docker 볼륨 백업 완료"
# 3. 설정 파일 백업
echo "⚙️ 설정 파일 백업 중..."
cp docker-compose.yml "$BACKUP_FOLDER/"
cp -r nginx/ "$BACKUP_FOLDER/"
cp -r backend/migrations/ "$BACKUP_FOLDER/"
echo "✅ 설정 파일 백업 완료"
# 4. 백업 정보 기록
echo "📝 백업 정보 기록 중..."
cat > "$BACKUP_FOLDER/backup_info.txt" << EOF
M 프로젝트 백업 정보
===================
백업 일시: $(date)
백업 타입: 전체 백업
백업 위치: $BACKUP_FOLDER
포함된 내용:
- database_backup.sql: PostgreSQL 데이터베이스 덤프
- postgres_volume.tar.gz: PostgreSQL 데이터 볼륨
- uploads_volume.tar.gz: 업로드 파일 볼륨
- docker-compose.yml: Docker 설정
- nginx/: Nginx 설정
- migrations/: 데이터베이스 마이그레이션 파일
복구 방법:
1. ./restore_script.sh $(pwd)
또는 수동 복구:
1. docker-compose down
2. docker volume rm m-project_postgres_data m-project_uploads
3. docker-compose up -d db
4. docker exec -i m-project-db psql -U mproject mproject < database_backup.sql
5. docker-compose up -d
백업 정책:
- 최신 10개 백업만 유지 (용량 절약)
- 매일 오후 9시 자동 백업
- 매주 일요일 오후 9시 30분 추가 백업
EOF
# 5. 백업 크기 확인
BACKUP_SIZE=$(du -sh "$BACKUP_FOLDER" | cut -f1)
echo "📏 백업 크기: $BACKUP_SIZE"
# 6. 오래된 백업 정리 (최신 10개만 유지)
echo "🧹 오래된 백업 정리 중..."
BACKUP_COUNT=$(find "$BACKUP_DIR" -type d -name "20*" | wc -l)
if [ $BACKUP_COUNT -gt 10 ]; then
REMOVE_COUNT=$((BACKUP_COUNT - 10))
echo "📊 현재 백업 개수: $BACKUP_COUNT개, 삭제할 개수: $REMOVE_COUNT개"
find "$BACKUP_DIR" -type d -name "20*" | sort | head -n $REMOVE_COUNT | xargs rm -rf
echo "✅ 오래된 백업 $REMOVE_COUNT개 삭제 완료"
else
echo "📊 현재 백업 개수: $BACKUP_COUNT개 (정리 불필요)"
fi
echo "🎉 백업 완료!"
echo "📁 백업 위치: $BACKUP_FOLDER"
echo "📏 백업 크기: $BACKUP_SIZE"

View File

@@ -339,30 +339,26 @@
async function loadProjects() {
try {
// API에서 최신 프로젝트 데이터 가져오기
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
}
});
if (response.ok) {
projects = await response.json();
console.log('프로젝트 로드 완료:', projects.length, '개');
console.log('활성 프로젝트:', projects.filter(p => p.is_active).length, '개');
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
// localStorage에도 캐시 저장
localStorage.setItem('work-report-projects', JSON.stringify(projects));
} else {
console.error('프로젝트 로드 실패:', response.status);
// 실패 시 localStorage에서 로드
const saved = localStorage.getItem('work-report-projects');
if (saved) {
projects = JSON.parse(saved);
console.log('캐시에서 프로젝트 로드:', projects.length, '개');
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
// ProjectsAPI 사용 (모든 프로젝트 로드)
projects = await ProjectsAPI.getAll(false);
console.log('프로젝트 로드 완료:', projects.length, '개');
console.log('활성 프로젝트:', projects.filter(p => p.is_active).length, '개');
// localStorage에도 캐시 저장
localStorage.setItem('work-report-projects', JSON.stringify(projects));
} catch (error) {
console.error('프로젝트 로드 오류:', error);
// 오류 시 localStorage에서 로드

View File

@@ -287,7 +287,19 @@
// 프로젝트 로드
async function loadProjects() {
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,

View File

@@ -323,20 +323,22 @@
// 데이터 로드 함수들
async function loadProjects() {
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
});
if (response.ok) {
projects = await response.json();
updateProjectFilter();
} else {
throw new Error('프로젝트 목록을 불러올 수 없습니다.');
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
// ProjectsAPI 사용
projects = await ProjectsAPI.getAll(false);
updateProjectFilter();
} catch (error) {
console.error('프로젝트 로드 실패:', error);
}
@@ -344,21 +346,24 @@
async function loadInProgressIssues() {
try {
const response = await fetch('/api/issues/admin/all', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
});
if (response.ok) {
const allData = await response.json();
// 진행 중 상태만 필터링
allIssues = allData.filter(issue => issue.review_status === 'in_progress');
filteredIssues = [...allIssues];
} else {
throw new Error('부적합 목록을 불러올 수 없습니다.');
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
// ManagementAPI 사용하여 관리함 이슈 로드
const managementData = await ManagementAPI.getAll();
// 진행 중 상태만 필터링
allIssues = managementData.filter(issue => issue.review_status === 'in_progress');
filteredIssues = [...allIssues];
} catch (error) {
console.error('부적합 로드 실패:', error);
}

View File

@@ -668,24 +668,24 @@
async function loadProjects() {
console.log('🔄 프로젝트 로드 시작');
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
});
console.log('📡 프로젝트 API 응답 상태:', response.status);
if (response.ok) {
projects = await response.json();
console.log('✅ 프로젝트 로드 성공:', projects.length, '개');
console.log('📋 프로젝트 목록:', projects);
updateProjectFilter();
} else {
console.error('❌ 프로젝트 API 응답 실패:', response.status, response.statusText);
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
// ProjectsAPI 사용 (모든 프로젝트 로드)
projects = await ProjectsAPI.getAll(false);
console.log(' 프로젝트 로드 성공:', projects.length, '개');
console.log('📋 프로젝트 목록:', projects);
updateProjectFilter();
} catch (error) {
console.error('❌ 프로젝트 로드 실패:', error);
}

View File

@@ -472,66 +472,41 @@
// 프로젝트 로드
async function loadProjects() {
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
}
});
if (response.ok) {
projects = await response.json();
updateProjectFilter();
}
// ProjectsAPI 사용 (모든 프로젝트 로드)
projects = await ProjectsAPI.getAll(false);
updateProjectFilter();
} catch (error) {
console.error('프로젝트 로드 실패:', error);
}
}
// 부적합 목록 로드 (관리자는 모든 부적합 조회)
// 부적합 목록 로드 (관리함 API 사용)
async function loadIssues() {
try {
let endpoint = '/api/issues/admin/all';
// ManagementAPI 사용
const managementIssues = await ManagementAPI.getAll();
const response = await fetch(endpoint, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
'Content-Type': 'application/json'
// 수신함에서 넘어온 순서대로 No. 재할당 (reviewed_at 기준)
managementIssues.sort((a, b) => new Date(a.reviewed_at) - new Date(b.reviewed_at));
// 프로젝트별로 그룹화하여 No. 재할당
const projectGroups = {};
managementIssues.forEach(issue => {
if (!projectGroups[issue.project_id]) {
projectGroups[issue.project_id] = [];
}
projectGroups[issue.project_id].push(issue);
});
if (response.ok) {
const allIssues = await response.json();
// 관리함에서는 진행 중(in_progress)과 완료됨(completed) 상태만 표시
let filteredIssues = allIssues.filter(issue =>
issue.review_status === 'in_progress' || issue.review_status === 'completed'
);
// 수신함에서 넘어온 순서대로 No. 재할당 (reviewed_at 기준)
filteredIssues.sort((a, b) => new Date(a.reviewed_at) - new Date(b.reviewed_at));
// 프로젝트별로 그룹화하여 No. 재할당
const projectGroups = {};
filteredIssues.forEach(issue => {
if (!projectGroups[issue.project_id]) {
projectGroups[issue.project_id] = [];
}
projectGroups[issue.project_id].push(issue);
// 각 프로젝트별로 순번 재할당
Object.keys(projectGroups).forEach(projectId => {
projectGroups[projectId].forEach((issue, index) => {
issue.project_sequence_no = index + 1;
});
// 각 프로젝트별로 순번 재할당
Object.keys(projectGroups).forEach(projectId => {
projectGroups[projectId].forEach((issue, index) => {
issue.project_sequence_no = index + 1;
});
});
issues = filteredIssues;
filterIssues();
} else {
throw new Error('부적합 목록을 불러올 수 없습니다.');
}
});
issues = managementIssues;
filterIssues();
} catch (error) {
console.error('부적합 로드 실패:', error);
alert('부적합 목록을 불러오는데 실패했습니다.');

View File

@@ -234,7 +234,19 @@
// 프로젝트 목록 로드
async function loadProjects() {
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/projects/`, {
headers: {
@@ -302,7 +314,19 @@
}
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/reports/daily-preview?project_id=${selectedProjectId}`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
@@ -427,7 +451,19 @@
button.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i>생성 중...';
button.disabled = true;
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/reports/daily-export`, {
method: 'POST',
headers: {

View File

@@ -6,8 +6,8 @@ const API_BASE_URL = (() => {
console.log('🔧 API URL 생성 - hostname:', hostname, 'protocol:', protocol, 'port:', port);
// 로컬 환경 (포트 있음)
if (port === '16080') {
// 로컬 환경 (localhost 또는 127.0.0.1이고 포트 있음)
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
const url = `${protocol}//${hostname}:${port}/api`;
console.log('🏠 로컬 환경 URL:', url);
return url;
@@ -256,6 +256,41 @@ const DailyWorkAPI = {
}
};
// Management API
const ManagementAPI = {
getAll: () => apiRequest('/management/'),
update: (issueId, updateData) => apiRequest(`/management/${issueId}`, {
method: 'PUT',
body: JSON.stringify(updateData)
}),
updateAdditionalInfo: (issueId, additionalInfo) => apiRequest(`/management/${issueId}/additional-info`, {
method: 'PUT',
body: JSON.stringify(additionalInfo)
})
};
// Inbox API
const InboxAPI = {
getAll: () => apiRequest('/inbox/'),
review: (issueId, reviewData) => apiRequest(`/inbox/${issueId}/review`, {
method: 'PUT',
body: JSON.stringify(reviewData)
}),
dispose: (issueId, disposeData) => apiRequest(`/inbox/${issueId}/dispose`, {
method: 'PUT',
body: JSON.stringify(disposeData)
}),
updateAdditionalInfo: (issueId, additionalInfo) => apiRequest(`/inbox/${issueId}/additional-info`, {
method: 'PUT',
body: JSON.stringify(additionalInfo)
})
};
// Reports API
const ReportsAPI = {
getSummary: (startDate, endDate) => apiRequest('/reports/summary', {

View File

@@ -46,7 +46,13 @@ class PagePermissionManager {
try {
// API에서 사용자별 페이지 권한 가져오기
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/users/${this.currentUser.id}/page-permissions`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
@@ -199,7 +205,19 @@ class PagePermissionManager {
}
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/page-permissions/grant`, {
method: 'POST',
headers: {
@@ -232,7 +250,19 @@ class PagePermissionManager {
*/
async getUserPagePermissions(userId) {
try {
const apiUrl = window.API_BASE_URL || 'http://localhost:16080/api';
const apiUrl = window.API_BASE_URL || (() => {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;
if ((hostname === 'localhost' || hostname === '127.0.0.1') && port) {
return `${protocol}//${hostname}:${port}/api`;
}
if (hostname === 'm.hyungi.net') {
return 'https://m-api.hyungi.net/api';
}
return '/api';
})();
const response = await fetch(`${apiUrl}/users/${userId}/page-permissions`, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`

105
restore_script.sh Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/bash
# M 프로젝트 복구 스크립트
# 사용법: ./restore_script.sh /path/to/backup/folder
set -e
if [ -z "$1" ]; then
echo "❌ 사용법: $0 <백업폴더경로>"
echo "예시: $0 /Users/hyungi/M-Project/backups/20251108_152538"
exit 1
fi
BACKUP_FOLDER="$1"
if [ ! -d "$BACKUP_FOLDER" ]; then
echo "❌ 백업 폴더가 존재하지 않습니다: $BACKUP_FOLDER"
exit 1
fi
echo "🔄 M 프로젝트 복구 시작"
echo "📁 백업 폴더: $BACKUP_FOLDER"
# 백업 정보 확인
if [ -f "$BACKUP_FOLDER/backup_info.txt" ]; then
echo "📋 백업 정보:"
cat "$BACKUP_FOLDER/backup_info.txt"
echo ""
fi
read -p "⚠️ 기존 데이터가 모두 삭제됩니다. 계속하시겠습니까? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ 복구가 취소되었습니다."
exit 1
fi
# 1. 서비스 중지
echo "🛑 서비스 중지 중..."
cd /Users/hyungi/M-Project
docker-compose down
# 2. 기존 볼륨 삭제
echo "🗑️ 기존 볼륨 삭제 중..."
docker volume rm m-project_postgres_data m-project_uploads 2>/dev/null || true
# 3. 데이터베이스 컨테이너만 시작
echo "🚀 데이터베이스 컨테이너 시작 중..."
docker-compose up -d db
# 데이터베이스 준비 대기
echo "⏳ 데이터베이스 준비 대기 중..."
sleep 10
# 4. 데이터베이스 복구
if [ -f "$BACKUP_FOLDER/database_backup.sql" ]; then
echo "📊 데이터베이스 복구 중..."
docker exec -i m-project-db psql -U mproject mproject < "$BACKUP_FOLDER/database_backup.sql"
echo "✅ 데이터베이스 복구 완료"
else
echo "❌ 데이터베이스 백업 파일을 찾을 수 없습니다."
fi
# 5. Docker 볼륨 복구
if [ -f "$BACKUP_FOLDER/postgres_volume.tar.gz" ]; then
echo "💾 PostgreSQL 볼륨 복구 중..."
docker run --rm -v m-project_postgres_data:/data -v "$BACKUP_FOLDER":/backup alpine tar xzf /backup/postgres_volume.tar.gz -C /data
echo "✅ PostgreSQL 볼륨 복구 완료"
fi
if [ -f "$BACKUP_FOLDER/uploads_volume.tar.gz" ]; then
echo "📁 업로드 볼륨 복구 중..."
docker run --rm -v m-project_uploads:/data -v "$BACKUP_FOLDER":/backup alpine tar xzf /backup/uploads_volume.tar.gz -C /data
echo "✅ 업로드 볼륨 복구 완료"
fi
# 6. 설정 파일 복구
if [ -f "$BACKUP_FOLDER/docker-compose.yml" ]; then
echo "⚙️ 설정 파일 복구 중..."
cp "$BACKUP_FOLDER/docker-compose.yml" ./
if [ -d "$BACKUP_FOLDER/nginx" ]; then
cp -r "$BACKUP_FOLDER/nginx/" ./
fi
if [ -d "$BACKUP_FOLDER/migrations" ]; then
cp -r "$BACKUP_FOLDER/migrations/" ./backend/
fi
echo "✅ 설정 파일 복구 완료"
fi
# 7. 전체 서비스 시작
echo "🚀 전체 서비스 시작 중..."
docker-compose up -d
# 8. 서비스 상태 확인
echo "⏳ 서비스 시작 대기 중..."
sleep 15
echo "🔍 서비스 상태 확인 중..."
docker-compose ps
echo "🎉 복구 완료!"
echo "🌐 프론트엔드: http://localhost:16080"
echo "🔗 백엔드 API: http://localhost:16000"
echo "📊 데이터베이스: localhost:16432"

52
setup_auto_backup.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
# M 프로젝트 자동 백업 설정 스크립트
echo "🔧 M 프로젝트 자동 백업 설정"
# 현재 crontab 백업
crontab -l > /tmp/current_crontab 2>/dev/null || touch /tmp/current_crontab
# M 프로젝트 백업 작업이 이미 있는지 확인
if grep -q "M-Project backup" /tmp/current_crontab; then
echo "⚠️ M 프로젝트 백업 작업이 이미 설정되어 있습니다."
echo "기존 설정:"
grep "M-Project backup" /tmp/current_crontab
read -p "기존 설정을 덮어쓰시겠습니까? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ 설정이 취소되었습니다."
exit 1
fi
# 기존 M 프로젝트 백업 작업 제거
grep -v "M-Project backup" /tmp/current_crontab > /tmp/new_crontab
mv /tmp/new_crontab /tmp/current_crontab
fi
# 새로운 백업 작업 추가
cat >> /tmp/current_crontab << 'EOF'
# M-Project backup - 매일 오후 9시에 실행
0 21 * * * /Users/hyungi/M-Project/backup_script.sh >> /Users/hyungi/M-Project/backup.log 2>&1
# M-Project backup - 매주 일요일 오후 9시 30분에 전체 백업 (추가 보안)
30 21 * * 0 /Users/hyungi/M-Project/backup_script.sh >> /Users/hyungi/M-Project/backup.log 2>&1
EOF
# 새로운 crontab 적용
crontab /tmp/current_crontab
# 정리
rm /tmp/current_crontab
echo "✅ 자동 백업 설정 완료!"
echo ""
echo "📅 백업 스케줄:"
echo " - 매일 오후 9시: 자동 백업"
echo " - 매주 일요일 오후 9시 30분: 추가 백업"
echo ""
echo "📋 현재 crontab 설정:"
crontab -l | grep -A2 -B2 "M-Project"
echo ""
echo "📄 백업 로그 위치: /Users/hyungi/M-Project/backup.log"
echo "📁 백업 저장 위치: /Users/hyungi/M-Project/backups/"