Files
Todo-Project/frontend/calendar.html
Hyungi Ahn 4c7d2d8290 feat: 다중 이미지 업로드 및 표시 기능 완전 구현
 주요 기능 추가:
- 다중 이미지 업로드 지원 (최대 5개)
- 체크리스트 완료 시 자동 사라짐 기능
- 캘린더 상세 모달에서 다중 이미지 표시
- Todo 변환 시 기존 이미지 보존 및 새 이미지 추가

🔧 백엔드 수정:
- Todo 모델: image_url → image_urls (JSON 배열)
- API 엔드포인트: 다중 이미지 직렬화/역직렬화
- 새 엔드포인트: POST /todos/{id}/add-image (이미지 추가)
- 데이터베이스 마이그레이션 스크립트 추가

🎨 프론트엔드 개선:
- 대시보드: 실제 API 데이터 연동, 다중 이미지 표시
- 업로드 모달: 다중 파일 선택, 실시간 미리보기, 5개 제한
- 체크리스트: 완료 시 1.5초 후 자동 제거, 토스트 메시지
- 캘린더 모달: 2x2 그리드 이미지 표시, 클릭 확대
- Todo 변환: 기존 이미지 + 새 이미지 합치기

🐛 버그 수정:
- currentPhoto 변수 오류 해결
- 이미지 표시 문제 (단일 → 다중 지원)
- 완료 처리 로컬/백엔드 동기화
- 새로고침 시 완료 항목 재출현 문제
2025-09-23 08:47:45 +09:00

399 lines
17 KiB
HTML

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>캘린더 - 마감 기한이 있는 일들</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary: #3b82f6; /* 하늘색 */
--primary-dark: #2563eb; /* 진한 하늘색 */
--success: #10b981; /* 초록색 */
--warning: #f59e0b; /* 주황색 */
--danger: #ef4444; /* 빨간색 */
--gray-50: #f9fafb; /* 연한 회색 */
--gray-100: #f3f4f6; /* 회색 */
--gray-200: #e5e7eb; /* 중간 회색 */
--gray-300: #d1d5db; /* 진한 회색 */
}
body {
background-color: var(--gray-50);
}
.btn-primary {
background-color: var(--primary);
color: white;
transition: all 0.2s;
}
.btn-primary:hover {
background-color: var(--primary-dark);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-warning {
background-color: var(--warning);
color: white;
transition: all 0.2s;
}
.btn-warning:hover {
background-color: #d97706;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.calendar-item {
background: white;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
transition: all 0.2s;
}
.calendar-item:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.deadline-urgent {
border-left: 4px solid #ef4444;
}
.deadline-warning {
border-left: 4px solid #f59e0b;
}
.deadline-normal {
border-left: 4px solid #3b82f6;
}
</style>
</head>
<body>
<div class="min-h-screen">
<!-- 헤더 -->
<header class="bg-white shadow-sm border-b">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16">
<div class="flex items-center">
<button onclick="goBack()" class="mr-4 text-gray-500 hover:text-gray-700">
<i class="fas fa-arrow-left text-xl"></i>
</button>
<i class="fas fa-calendar-times text-2xl text-orange-500 mr-3"></i>
<h1 class="text-xl font-semibold text-gray-800">캘린더</h1>
<span class="ml-3 text-sm text-gray-500">마감 기한이 있는 일들</span>
</div>
<div class="flex items-center space-x-4">
<button onclick="goToDashboard()" class="text-blue-600 hover:text-blue-800 font-medium">
<i class="fas fa-chart-line mr-1"></i>대시보드
</button>
<span class="text-sm text-gray-600" id="currentUser"></span>
<button onclick="logout()" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-sign-out-alt"></i>
</button>
</div>
</div>
</div>
</header>
<!-- 메인 컨텐츠 -->
<main class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- 페이지 설명 -->
<div class="bg-orange-50 rounded-xl p-6 mb-8">
<div class="flex items-center mb-4">
<i class="fas fa-calendar-times text-2xl text-orange-600 mr-3"></i>
<h2 class="text-xl font-semibold text-orange-900">캘린더 관리</h2>
</div>
<p class="text-orange-800 mb-4">
마감 기한이 있는 일들을 관리합니다. 우선순위에 따라 계획적으로 진행해보세요.
</p>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
<div class="bg-white rounded-lg p-3">
<div class="font-medium text-red-900 mb-1">🚨 긴급</div>
<div class="text-red-700">3일 이내 마감</div>
</div>
<div class="bg-white rounded-lg p-3">
<div class="font-medium text-orange-900 mb-1">⚠️ 주의</div>
<div class="text-orange-700">1주일 이내 마감</div>
</div>
<div class="bg-white rounded-lg p-3">
<div class="font-medium text-blue-900 mb-1">📅 여유</div>
<div class="text-blue-700">1주일 이상 남음</div>
</div>
</div>
</div>
<!-- 필터 및 정렬 -->
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
<div class="flex space-x-1 bg-gray-100 rounded-lg p-1">
<button onclick="filterCalendar('all')" class="filter-tab active px-4 py-2 rounded text-sm font-medium">전체</button>
<button onclick="filterCalendar('urgent')" class="filter-tab px-4 py-2 rounded text-sm font-medium">긴급</button>
<button onclick="filterCalendar('warning')" class="filter-tab px-4 py-2 rounded text-sm font-medium">주의</button>
<button onclick="filterCalendar('normal')" class="filter-tab px-4 py-2 rounded text-sm font-medium">여유</button>
<button onclick="filterCalendar('completed')" class="filter-tab px-4 py-2 rounded text-sm font-medium">완료</button>
</div>
<div class="flex items-center space-x-3">
<label class="text-sm text-gray-600">정렬:</label>
<select id="sortBy" class="border border-gray-300 rounded-lg px-3 py-1 text-sm">
<option value="due_date">마감일 순</option>
<option value="priority">우선순위 순</option>
<option value="created_at">등록일 순</option>
</select>
</div>
</div>
</div>
<!-- 캘린더 목록 -->
<div class="bg-white rounded-xl shadow-sm">
<div class="p-6 border-b">
<h3 class="text-lg font-semibold text-gray-800">
<i class="fas fa-list text-orange-500 mr-2"></i>마감 기한별 목록
</h3>
</div>
<div id="calendarList" class="divide-y divide-gray-100">
<!-- 캘린더 항목들이 여기에 동적으로 추가됩니다 -->
</div>
<div id="emptyState" class="p-12 text-center text-gray-500">
<i class="fas fa-calendar-times text-4xl mb-4 opacity-50"></i>
<p>아직 마감 기한이 설정된 일이 없습니다.</p>
<p class="text-sm">메인 페이지에서 항목을 등록하고 마감 기한을 설정해보세요!</p>
<button onclick="goBack()" class="mt-4 btn-warning px-6 py-2 rounded-lg">
<i class="fas fa-arrow-left mr-2"></i>메인으로 돌아가기
</button>
</div>
</div>
</main>
</div>
<!-- JavaScript -->
<script src="static/js/auth.js"></script>
<script>
// 페이지 초기화
document.addEventListener('DOMContentLoaded', () => {
checkAuthStatus();
loadCalendarItems();
});
// 뒤로 가기
function goBack() {
window.location.href = 'index.html';
}
// 캘린더 항목 로드
async function loadCalendarItems() {
try {
// API에서 캘린더 카테고리 항목들만 가져오기
const items = await TodoAPI.getTodos(null, 'calendar');
renderCalendarItems(items);
} catch (error) {
console.error('캘린더 항목 로드 실패:', error);
renderCalendarItems([]);
}
}
// 캘린더 항목 렌더링
function renderCalendarItems(items) {
const calendarList = document.getElementById('calendarList');
const emptyState = document.getElementById('emptyState');
if (items.length === 0) {
calendarList.innerHTML = '';
emptyState.classList.remove('hidden');
return;
}
emptyState.classList.add('hidden');
calendarList.innerHTML = items.map(item => `
<div class="calendar-item p-6 ${getDeadlineClass(item.priority)}">
<div class="flex items-start space-x-4">
<!-- 우선순위 아이콘 -->
<div class="flex-shrink-0 mt-1">
<div class="w-8 h-8 rounded-full flex items-center justify-center ${getPriorityColor(item.priority)}">
<i class="fas ${getPriorityIcon(item.priority)} text-sm"></i>
</div>
</div>
<!-- 사진 (있는 경우) -->
${item.image_urls && item.image_urls.length > 0 ? `
<div class="flex-shrink-0">
<div class="flex space-x-2">
${item.image_urls.slice(0, 3).map(url => `
<img src="${url}" class="w-16 h-16 object-cover rounded-lg" alt="첨부 사진">
`).join('')}
${item.image_urls.length > 3 ? `
<div class="w-16 h-16 bg-gray-100 rounded-lg flex items-center justify-center">
<span class="text-xs text-gray-500">+${item.image_urls.length - 3}</span>
</div>
` : ''}
</div>
</div>
` : ''}
<!-- 내용 -->
<div class="flex-1 min-w-0">
<h4 class="text-gray-900 font-medium mb-2">${item.title}</h4>
<div class="flex items-center space-x-4 text-sm text-gray-500 mb-2">
<span class="${getDueDateColor(item.due_date)}">
<i class="fas fa-calendar-times mr-1"></i>마감: ${formatDate(item.due_date)}
</span>
<span>
<i class="fas fa-clock mr-1"></i>등록: ${formatDate(item.created_at)}
</span>
</div>
<div class="text-sm">
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${getPriorityBadgeColor(item.priority)}">
${getPriorityText(item.priority)}
</span>
<span class="ml-2 text-gray-500">
${getDaysRemaining(item.due_date)}
</span>
</div>
</div>
<!-- 액션 버튼 -->
<div class="flex-shrink-0 flex space-x-2">
${item.status !== 'completed' ? `
<button onclick="completeCalendar('${item.id}')" class="text-green-500 hover:text-green-700" title="완료하기">
<i class="fas fa-check"></i>
</button>
<button onclick="extendDeadline('${item.id}')" class="text-orange-500 hover:text-orange-700" title="기한 연장">
<i class="fas fa-calendar-plus"></i>
</button>
` : ''}
<button onclick="editCalendar('${item.id}')" class="text-gray-400 hover:text-blue-500" title="수정하기">
<i class="fas fa-edit"></i>
</button>
</div>
</div>
</div>
`).join('');
}
// 마감 기한별 클래스
function getDeadlineClass(priority) {
const classes = {
urgent: 'deadline-urgent',
warning: 'deadline-warning',
normal: 'deadline-normal'
};
return classes[priority] || 'deadline-normal';
}
// 우선순위별 색상
function getPriorityColor(priority) {
const colors = {
urgent: 'bg-red-100 text-red-600',
warning: 'bg-orange-100 text-orange-600',
normal: 'bg-blue-100 text-blue-600'
};
return colors[priority] || 'bg-gray-100 text-gray-600';
}
// 우선순위별 아이콘
function getPriorityIcon(priority) {
const icons = {
urgent: 'fa-exclamation-triangle',
warning: 'fa-exclamation',
normal: 'fa-calendar'
};
return icons[priority] || 'fa-circle';
}
// 우선순위별 배지 색상
function getPriorityBadgeColor(priority) {
const colors = {
urgent: 'bg-red-100 text-red-800',
warning: 'bg-orange-100 text-orange-800',
normal: 'bg-blue-100 text-blue-800'
};
return colors[priority] || 'bg-gray-100 text-gray-800';
}
// 우선순위 텍스트
function getPriorityText(priority) {
const texts = {
urgent: '긴급',
warning: '주의',
normal: '여유'
};
return texts[priority] || '일반';
}
// 마감일 색상
function getDueDateColor(dueDate) {
const days = getDaysUntilDeadline(dueDate);
if (days <= 3) return 'text-red-600 font-medium';
if (days <= 7) return 'text-orange-600 font-medium';
return 'text-gray-600';
}
// 남은 일수 계산
function getDaysUntilDeadline(dueDate) {
const today = new Date();
const deadline = new Date(dueDate);
const diffTime = deadline - today;
return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
}
// 남은 일수 텍스트
function getDaysRemaining(dueDate) {
const days = getDaysUntilDeadline(dueDate);
if (days < 0) return '기한 초과';
if (days === 0) return '오늘 마감';
if (days === 1) return '내일 마감';
return `${days}일 남음`;
}
// 날짜 포맷팅
function formatDate(dateString) {
if (!dateString) return '날짜 없음';
const date = new Date(dateString);
if (isNaN(date.getTime())) return '날짜 없음';
return date.toLocaleDateString('ko-KR');
}
// 캘린더 완료
function completeCalendar(id) {
console.log('캘린더 완료:', id);
// TODO: API 호출하여 상태를 'completed'로 변경
}
// 기한 연장
function extendDeadline(id) {
console.log('기한 연장:', id);
// TODO: 기한 연장 모달 표시
}
// 캘린더 편집
function editCalendar(id) {
console.log('캘린더 편집:', id);
// TODO: 편집 모달 또는 페이지로 이동
}
// 필터링
function filterCalendar(filter) {
console.log('필터:', filter);
// TODO: 필터에 따라 목록 재로드
}
// 대시보드로 이동
function goToDashboard() {
window.location.href = 'dashboard.html';
}
// 전역 함수 등록
window.goToDashboard = goToDashboard;
</script>
<script src="static/js/api.js?v=20250921110800"></script>
<script src="static/js/auth.js?v=20250921110800"></script>
</body>
</html>