Merge commit '397efb86dc84197b74d9a3b16a11b1d0d534ad9e' as 'integrations/document-ai'
This commit is contained in:
585
integrations/document-ai/templates/dashboard.html
Normal file
585
integrations/document-ai/templates/dashboard.html
Normal file
@@ -0,0 +1,585 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI 모델 대시보드 - NLLB 번역 시스템</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #2563eb;
|
||||
--success-color: #059669;
|
||||
--warning-color: #d97706;
|
||||
--error-color: #dc2626;
|
||||
--background-color: #f8fafc;
|
||||
--text-color: #1e293b;
|
||||
--border-color: #e2e8f0;
|
||||
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
|
||||
line-height: 1.6;
|
||||
color: var(--text-color);
|
||||
background: var(--background-color);
|
||||
}
|
||||
|
||||
.dashboard-container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
margin-bottom: 24px;
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.header .subtitle {
|
||||
color: #64748b;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
||||
gap: 24px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.card-header h3 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.card-icon {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.model-status {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.model-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
background: #f8fafc;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.model-info h4 {
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.model-details {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 6px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.status-ready {
|
||||
background: #dcfce7;
|
||||
color: var(--success-color);
|
||||
}
|
||||
|
||||
.status-loading {
|
||||
background: #fef3c7;
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
.status-error {
|
||||
background: #fee2e2;
|
||||
color: var(--error-color);
|
||||
}
|
||||
|
||||
.status-unloaded {
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
background: #f8fafc;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
background: #e2e8f0;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: var(--primary-color);
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.control-buttons {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #64748b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #475569;
|
||||
}
|
||||
|
||||
.job-list {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.job-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.job-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.job-id {
|
||||
font-family: monospace;
|
||||
font-size: 0.75rem;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.auto-refresh {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background: white;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.refresh-indicator {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--success-color);
|
||||
margin-right: 8px;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
height: 200px;
|
||||
position: relative;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.dashboard-container {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="auto-refresh">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div class="refresh-indicator"></div>
|
||||
<span style="font-size: 0.875rem;">실시간 업데이트</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-container">
|
||||
<div class="header">
|
||||
<h1>🤖 AI 모델 대시보드</h1>
|
||||
<p class="subtitle">NLLB 번역 시스템 - 실시간 모니터링</p>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<!-- 모델 상태 카드 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-icon">🧠</span>
|
||||
<h3>AI 모델 상태</h3>
|
||||
</div>
|
||||
<div class="model-status" id="modelStatus">
|
||||
<!-- 동적으로 채워짐 -->
|
||||
</div>
|
||||
|
||||
<div class="control-buttons">
|
||||
<button class="btn btn-primary" onclick="restartModels()">
|
||||
🔄 모델 재시작
|
||||
</button>
|
||||
<button class="btn btn-secondary" onclick="clearCache()">
|
||||
🗑️ 캐시 정리
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 시스템 성능 카드 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-icon">📊</span>
|
||||
<h3>시스템 성능</h3>
|
||||
</div>
|
||||
<div class="metrics-grid" id="systemMetrics">
|
||||
<!-- 동적으로 채워짐 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 작업 통계 카드 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-icon">📈</span>
|
||||
<h3>작업 통계</h3>
|
||||
</div>
|
||||
<div class="metrics-grid" id="jobStats">
|
||||
<!-- 동적으로 채워짐 -->
|
||||
</div>
|
||||
|
||||
<div class="chart-container">
|
||||
<canvas id="performanceChart" width="400" height="200"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 활성 작업 카드 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-icon">⚡</span>
|
||||
<h3>활성 작업</h3>
|
||||
</div>
|
||||
<div class="job-list" id="activeJobs">
|
||||
<!-- 동적으로 채워짐 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 대시보드 데이터 관리
|
||||
let dashboardData = {};
|
||||
let performanceChart = null;
|
||||
|
||||
// 페이지 로드 시 초기화
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initializeChart();
|
||||
loadDashboardData();
|
||||
|
||||
// 5초마다 자동 새로고침
|
||||
setInterval(loadDashboardData, 5000);
|
||||
});
|
||||
|
||||
// 대시보드 데이터 로드
|
||||
async function loadDashboardData() {
|
||||
try {
|
||||
const response = await fetch('/api/dashboard');
|
||||
dashboardData = await response.json();
|
||||
|
||||
updateModelStatus();
|
||||
updateSystemMetrics();
|
||||
updateJobStats();
|
||||
updateActiveJobs();
|
||||
updatePerformanceChart();
|
||||
|
||||
} catch (error) {
|
||||
console.error('대시보드 데이터 로드 실패:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 모델 상태 업데이트
|
||||
function updateModelStatus() {
|
||||
const container = document.getElementById('modelStatus');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (dashboardData.models_status) {
|
||||
Object.values(dashboardData.models_status).forEach(model => {
|
||||
const modelItem = document.createElement('div');
|
||||
modelItem.className = 'model-item';
|
||||
|
||||
const memoryUsage = model.memory_usage_mb ? `${model.memory_usage_mb.toFixed(0)}MB` : 'N/A';
|
||||
const totalProcessed = model.total_processed || 0;
|
||||
const lastUsed = model.last_used ? new Date(model.last_used).toLocaleTimeString() : 'N/A';
|
||||
|
||||
modelItem.innerHTML = `
|
||||
<div class="model-info">
|
||||
<h4>${model.name}</h4>
|
||||
<div class="model-details">
|
||||
메모리: ${memoryUsage} | 처리 완료: ${totalProcessed}개 | 마지막 사용: ${lastUsed}
|
||||
</div>
|
||||
</div>
|
||||
<span class="status-badge status-${model.status}">${getStatusText(model.status)}</span>
|
||||
`;
|
||||
|
||||
container.appendChild(modelItem);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 시스템 메트릭 업데이트
|
||||
function updateSystemMetrics() {
|
||||
const container = document.getElementById('systemMetrics');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (dashboardData.current_metrics) {
|
||||
const metrics = dashboardData.current_metrics;
|
||||
|
||||
const metricItems = [
|
||||
{ value: `${metrics.total_memory_usage_mb.toFixed(0)}MB`, label: '메모리 사용량' },
|
||||
{ value: `${metrics.cpu_usage_percent.toFixed(1)}%`, label: 'CPU 사용률' },
|
||||
{ value: formatUptime(metrics.uptime_seconds), label: '서비스 가동시간' },
|
||||
{ value: `${metrics.average_processing_time.toFixed(1)}초`, label: '평균 처리시간' }
|
||||
];
|
||||
|
||||
metricItems.forEach(item => {
|
||||
const metricDiv = document.createElement('div');
|
||||
metricDiv.className = 'metric-item';
|
||||
metricDiv.innerHTML = `
|
||||
<div class="metric-value">${item.value}</div>
|
||||
<div class="metric-label">${item.label}</div>
|
||||
`;
|
||||
container.appendChild(metricDiv);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 작업 통계 업데이트
|
||||
function updateJobStats() {
|
||||
const container = document.getElementById('jobStats');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (dashboardData.current_metrics) {
|
||||
const metrics = dashboardData.current_metrics;
|
||||
|
||||
const jobItems = [
|
||||
{ value: metrics.active_jobs, label: '진행 중인 작업' },
|
||||
{ value: metrics.queued_jobs, label: '대기 중인 작업' },
|
||||
{ value: metrics.completed_jobs_today, label: '오늘 완료된 작업' },
|
||||
{ value: dashboardData.completed_today || 0, label: '총 완료 작업' }
|
||||
];
|
||||
|
||||
jobItems.forEach(item => {
|
||||
const jobDiv = document.createElement('div');
|
||||
jobDiv.className = 'metric-item';
|
||||
jobDiv.innerHTML = `
|
||||
<div class="metric-value">${item.value}</div>
|
||||
<div class="metric-label">${item.label}</div>
|
||||
`;
|
||||
container.appendChild(jobDiv);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 활성 작업 업데이트
|
||||
function updateActiveJobs() {
|
||||
const container = document.getElementById('activeJobs');
|
||||
|
||||
if (dashboardData.active_jobs === 0) {
|
||||
container.innerHTML = '<div style="text-align: center; color: #64748b; padding: 20px;">현재 진행 중인 작업이 없습니다.</div>';
|
||||
} else {
|
||||
container.innerHTML = `<div style="text-align: center; color: #2563eb; padding: 20px;">현재 ${dashboardData.active_jobs}개의 작업이 진행 중입니다.</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
// 성능 차트 초기화
|
||||
function initializeChart() {
|
||||
const canvas = document.getElementById('performanceChart');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// 간단한 차트 구현 (실제로는 Chart.js 등 사용 권장)
|
||||
performanceChart = {
|
||||
canvas: canvas,
|
||||
ctx: ctx,
|
||||
data: []
|
||||
};
|
||||
}
|
||||
|
||||
// 성능 차트 업데이트
|
||||
function updatePerformanceChart() {
|
||||
if (!performanceChart || !dashboardData.recent_metrics) return;
|
||||
|
||||
const ctx = performanceChart.ctx;
|
||||
const canvas = performanceChart.canvas;
|
||||
|
||||
// 캔버스 지우기
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// 간단한 메모리 사용량 그래프 그리기
|
||||
const metrics = dashboardData.recent_metrics.slice(-20); // 최근 20개
|
||||
if (metrics.length === 0) return;
|
||||
|
||||
const maxMemory = Math.max(...metrics.map(m => m.metrics.total_memory_usage_mb));
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
|
||||
ctx.strokeStyle = '#2563eb';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
|
||||
metrics.forEach((metric, index) => {
|
||||
const x = (index / (metrics.length - 1)) * width;
|
||||
const y = height - (metric.metrics.total_memory_usage_mb / maxMemory) * height;
|
||||
|
||||
if (index === 0) {
|
||||
ctx.moveTo(x, y);
|
||||
} else {
|
||||
ctx.lineTo(x, y);
|
||||
}
|
||||
});
|
||||
|
||||
ctx.stroke();
|
||||
|
||||
// 레이블 추가
|
||||
ctx.fillStyle = '#64748b';
|
||||
ctx.font = '12px Arial';
|
||||
ctx.fillText('메모리 사용량 추이', 10, 20);
|
||||
ctx.fillText(`현재: ${metrics[metrics.length - 1]?.metrics.total_memory_usage_mb.toFixed(0)}MB`, 10, height - 10);
|
||||
}
|
||||
|
||||
// 헬퍼 함수들
|
||||
function getStatusText(status) {
|
||||
const statusMap = {
|
||||
'ready': '준비완료',
|
||||
'loading': '로딩중',
|
||||
'error': '오류',
|
||||
'unloaded': '로드안됨'
|
||||
};
|
||||
return statusMap[status] || status;
|
||||
}
|
||||
|
||||
function formatUptime(seconds) {
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
return `${hours}시간 ${minutes}분`;
|
||||
}
|
||||
|
||||
// 제어 함수들
|
||||
async function restartModels() {
|
||||
if (confirm('AI 모델을 재시작하시겠습니까? 진행 중인 작업이 중단될 수 있습니다.')) {
|
||||
try {
|
||||
await fetch('/api/restart-models', { method: 'POST' });
|
||||
alert('모델 재시작을 시작했습니다. 잠시 후 상태가 업데이트됩니다.');
|
||||
} catch (error) {
|
||||
alert('모델 재시작 실패: ' + error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function clearCache() {
|
||||
if (confirm('시스템 캐시를 정리하시겠습니까?')) {
|
||||
try {
|
||||
await fetch('/api/clear-cache', { method: 'POST' });
|
||||
alert('캐시 정리가 완료되었습니다.');
|
||||
} catch (error) {
|
||||
alert('캐시 정리 실패: ' + error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
468
integrations/document-ai/templates/index.html
Normal file
468
integrations/document-ai/templates/index.html
Normal file
@@ -0,0 +1,468 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI 번역 시스템</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #2563eb, #3b82f6);
|
||||
color: white;
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
background: #f8fafc;
|
||||
padding: 20px 40px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: #374151;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.nav-link.active {
|
||||
color: #2563eb;
|
||||
border-bottom: 2px solid #2563eb;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
background: #f0f9ff;
|
||||
padding: 15px 40px;
|
||||
border-bottom: 1px solid #bae6fd;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.status-good { color: #065f46; }
|
||||
.status-bad { color: #dc2626; }
|
||||
.status-warning { color: #d97706; }
|
||||
|
||||
.main-content {
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.upload-section {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.file-drop-zone {
|
||||
border: 3px dashed #e5e7eb;
|
||||
border-radius: 16px;
|
||||
padding: 60px 20px;
|
||||
margin: 20px 0;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.file-drop-zone:hover {
|
||||
border-color: #2563eb;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.file-drop-zone.drag-over {
|
||||
border-color: #2563eb;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.upload-icon {
|
||||
font-size: 4rem;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 1.2rem;
|
||||
color: #374151;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
color: #6b7280;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.upload-btn {
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
margin-top: 20px;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.upload-btn:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
.upload-btn:disabled {
|
||||
background: #9ca3af;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.progress-section {
|
||||
display: none;
|
||||
background: #f8fafc;
|
||||
border-radius: 12px;
|
||||
padding: 30px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.progress-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
width: 100%;
|
||||
height: 12px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2563eb, #3b82f6);
|
||||
width: 0%;
|
||||
transition: width 0.5s ease;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
font-size: 0.9rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.result-section {
|
||||
display: none;
|
||||
background: #f0f9ff;
|
||||
border: 1px solid #0ea5e9;
|
||||
border-radius: 12px;
|
||||
padding: 30px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.result-title {
|
||||
color: #0369a1;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.result-actions {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #f8fafc;
|
||||
color: #374151;
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
.error-section {
|
||||
display: none;
|
||||
background: #fef2f2;
|
||||
border: 1px solid #fecaca;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
color: #dc2626;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>🤖 AI 번역 시스템</h1>
|
||||
<p>PDF/문서를 다국어 HTML로 자동 변환</p>
|
||||
</div>
|
||||
|
||||
<div class="nav-menu">
|
||||
<div class="nav-links">
|
||||
<a href="/" class="nav-link active">📤 업로드</a>
|
||||
<a href="/library" class="nav-link">📚 라이브러리</a>
|
||||
<a href="/system-status" class="nav-link">📊 시스템</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-bar">
|
||||
<div>
|
||||
{% if nas_status.status == "connected" %}
|
||||
<span class="status-good">✅ NAS 연결됨 (DS1525+)</span>
|
||||
{% else %}
|
||||
<span class="status-bad">❌ NAS 연결 실패: {{ nas_status.error }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<span class="status-good">🚀 Mac Mini Ready</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
{% if nas_status.status != "connected" %}
|
||||
<div class="error-section" style="display: block;">
|
||||
<h3>NAS 연결 필요</h3>
|
||||
<p>{{ nas_status.error }}</p>
|
||||
<p><strong>해결 방법:</strong></p>
|
||||
<ul style="margin-left: 20px; margin-top: 10px;">
|
||||
<li>Finder → 이동 → 서버에 연결</li>
|
||||
<li>smb://192.168.1.227 입력</li>
|
||||
<li>DS1525+ 연결 후 페이지 새로고침</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="upload-section">
|
||||
<div class="file-drop-zone" id="dropZone">
|
||||
<div class="upload-icon">📁</div>
|
||||
<div class="upload-text">파일을 드래그하거나 클릭하여 업로드</div>
|
||||
<div class="upload-hint">PDF, TXT, DOCX 파일 지원 (최대 100MB)</div>
|
||||
<input type="file" id="fileInput" class="file-input" accept=".pdf,.txt,.docx,.doc">
|
||||
<button type="button" class="upload-btn" id="uploadBtn"
|
||||
{% if nas_status.status != "connected" %}disabled{% endif %}
|
||||
onclick="document.getElementById('fileInput').click()">
|
||||
{% if nas_status.status == "connected" %}
|
||||
파일 선택
|
||||
{% else %}
|
||||
NAS 연결 필요
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress-section" id="progressSection">
|
||||
<div class="progress-title">처리 진행 상황</div>
|
||||
<div class="progress-bar">
|
||||
<div class="progress-fill" id="progressFill"></div>
|
||||
</div>
|
||||
<div class="progress-text" id="progressText">준비 중...</div>
|
||||
</div>
|
||||
|
||||
<div class="result-section" id="resultSection">
|
||||
<div class="result-title">🎉 변환 완료!</div>
|
||||
<div class="result-actions">
|
||||
<a href="#" id="downloadBtn" class="btn btn-primary">📥 HTML 다운로드</a>
|
||||
<a href="#" id="previewBtn" class="btn btn-secondary" target="_blank">👁️ 미리보기</a>
|
||||
<a href="/library" class="btn btn-secondary">📚 라이브러리 보기</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentJobId = null;
|
||||
const nasConnected = {{ 'true' if nas_status.status == 'connected' else 'false' }};
|
||||
|
||||
// 파일 드래그 앤 드롭
|
||||
const dropZone = document.getElementById('dropZone');
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const uploadBtn = document.getElementById('uploadBtn');
|
||||
|
||||
if (nasConnected) {
|
||||
dropZone.addEventListener('dragover', (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.add('drag-over');
|
||||
});
|
||||
|
||||
dropZone.addEventListener('dragleave', () => {
|
||||
dropZone.classList.remove('drag-over');
|
||||
});
|
||||
|
||||
dropZone.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove('drag-over');
|
||||
|
||||
const files = e.dataTransfer.files;
|
||||
if (files.length > 0) {
|
||||
handleFileUpload(files[0]);
|
||||
}
|
||||
});
|
||||
|
||||
dropZone.addEventListener('click', () => {
|
||||
if (!uploadBtn.disabled) {
|
||||
fileInput.click();
|
||||
}
|
||||
});
|
||||
|
||||
fileInput.addEventListener('change', (e) => {
|
||||
if (e.target.files.length > 0) {
|
||||
handleFileUpload(e.target.files[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function handleFileUpload(file) {
|
||||
if (!nasConnected) {
|
||||
alert('NAS 연결이 필요합니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 파일 크기 검증 (100MB)
|
||||
if (file.size > 100 * 1024 * 1024) {
|
||||
alert('파일 크기는 100MB를 초과할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 파일 형식 검증
|
||||
const allowedTypes = ['.pdf', '.txt', '.docx', '.doc'];
|
||||
const fileExt = '.' + file.name.split('.').pop().toLowerCase();
|
||||
|
||||
if (!allowedTypes.includes(fileExt)) {
|
||||
alert('지원되지 않는 파일 형식입니다. PDF, TXT, DOCX 파일만 업로드 가능합니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
// UI 업데이트
|
||||
document.getElementById('progressSection').style.display = 'block';
|
||||
document.getElementById('resultSection').style.display = 'none';
|
||||
uploadBtn.disabled = true;
|
||||
|
||||
// 파일 업로드
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
try {
|
||||
const response = await fetch('/upload', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || '업로드 실패');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
currentJobId = result.job_id;
|
||||
|
||||
// 진행 상황 모니터링 시작
|
||||
monitorProgress();
|
||||
|
||||
} catch (error) {
|
||||
alert('업로드 실패: ' + error.message);
|
||||
document.getElementById('progressSection').style.display = 'none';
|
||||
uploadBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function monitorProgress() {
|
||||
if (!currentJobId) return;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/status/${currentJobId}`);
|
||||
const status = await response.json();
|
||||
|
||||
// 진행률 업데이트
|
||||
document.getElementById('progressFill').style.width = status.progress + '%';
|
||||
document.getElementById('progressText').textContent = status.message;
|
||||
|
||||
if (status.status === 'completed') {
|
||||
// 완료 처리
|
||||
document.getElementById('progressSection').style.display = 'none';
|
||||
document.getElementById('resultSection').style.display = 'block';
|
||||
|
||||
// 다운로드 링크 설정
|
||||
document.getElementById('downloadBtn').href = `/download/${currentJobId}`;
|
||||
|
||||
uploadBtn.disabled = false;
|
||||
|
||||
} else if (status.status === 'error') {
|
||||
alert('처리 실패: ' + status.message);
|
||||
document.getElementById('progressSection').style.display = 'none';
|
||||
uploadBtn.disabled = false;
|
||||
|
||||
} else {
|
||||
// 계속 모니터링
|
||||
setTimeout(monitorProgress, 2000); // 2초마다 확인
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('상태 확인 오류:', error);
|
||||
setTimeout(monitorProgress, 5000); // 오류시 5초 후 재시도
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
373
integrations/document-ai/templates/library_organized.html
Normal file
373
integrations/document-ai/templates/library_organized.html
Normal file
@@ -0,0 +1,373 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>문서 라이브러리 - AI 번역 시스템</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #2563eb, #3b82f6);
|
||||
color: white;
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 { font-size: 2.5rem; margin-bottom: 10px; }
|
||||
.header p { font-size: 1.1rem; opacity: 0.9; }
|
||||
|
||||
.nav-menu {
|
||||
background: #f8fafc;
|
||||
padding: 20px 40px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-links { display: flex; gap: 30px; }
|
||||
.nav-link {
|
||||
color: #374151;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
.nav-link:hover { color: #2563eb; }
|
||||
.nav-link.active {
|
||||
color: #2563eb;
|
||||
border-bottom: 2px solid #2563eb;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.stats-bar {
|
||||
background: #f0f9ff;
|
||||
padding: 15px 40px;
|
||||
border-bottom: 1px solid #bae6fd;
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
font-size: 0.9rem;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
.stat-item { display: flex; align-items: center; gap: 8px; }
|
||||
|
||||
.main-content { padding: 40px; }
|
||||
|
||||
.search-section {
|
||||
margin-bottom: 30px;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
flex: 1;
|
||||
padding: 15px;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.filter-select {
|
||||
padding: 15px;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
background: white;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.category-section {
|
||||
margin-bottom: 40px;
|
||||
background: #f8fafc;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
background: linear-gradient(135deg, #1e40af, #2563eb);
|
||||
color: white;
|
||||
padding: 20px 30px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.category-title { font-size: 1.3rem; font-weight: 600; }
|
||||
.category-count {
|
||||
background: rgba(255,255,255,0.2);
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.documents-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
|
||||
gap: 20px;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.document-card {
|
||||
background: white;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.document-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 12px 24px rgba(0,0,0,0.1);
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
.document-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.document-meta {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 0.85rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.language-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
border-radius: 6px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.document-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 16px;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
}
|
||||
.btn-primary:hover { background: #1d4ed8; }
|
||||
|
||||
.btn-secondary {
|
||||
background: #f8fafc;
|
||||
color: #374151;
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
.btn-secondary:hover { background: #f1f5f9; }
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 80px 20px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.empty-icon { font-size: 4rem; margin-bottom: 20px; }
|
||||
.empty-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.documents-grid { grid-template-columns: 1fr; }
|
||||
.nav-menu { flex-direction: column; gap: 20px; }
|
||||
.stats-bar { flex-wrap: wrap; }
|
||||
.search-section { flex-direction: column; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>📚 문서 라이브러리</h1>
|
||||
<p>체계적으로 분류된 다국어 번역 문서</p>
|
||||
</div>
|
||||
|
||||
<div class="nav-menu">
|
||||
<div class="nav-links">
|
||||
<a href="/" class="nav-link">📤 업로드</a>
|
||||
<a href="/library" class="nav-link active">📚 라이브러리</a>
|
||||
<a href="/system-status" class="nav-link">📊 시스템</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-bar">
|
||||
<div class="stat-item">
|
||||
<span>📄</span>
|
||||
<span>총 {{ total_documents }}개 문서</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span>🗂️</span>
|
||||
<span>{{ categories|length }}개 카테고리</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span>🌍</span>
|
||||
<span>다국어 지원</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="search-section">
|
||||
<input type="text" class="search-box" placeholder="🔍 문서 제목으로 검색..." id="searchInput">
|
||||
<select class="filter-select" id="categoryFilter">
|
||||
<option value="">모든 카테고리</option>
|
||||
{% for category_name in categories.keys() %}
|
||||
<option value="{{ category_name }}">{{ category_name|replace("_", " ")|title }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% if categories %}
|
||||
{% for category_name, documents in categories.items() %}
|
||||
<div class="category-section" data-category="{{ category_name }}">
|
||||
<div class="category-header">
|
||||
<div class="category-title">
|
||||
{% if category_name == "English To Korean" %}
|
||||
🇺🇸→🇰🇷 English to Korean
|
||||
{% elif category_name == "Japanese To Korean" %}
|
||||
🇯🇵→🇰🇷 Japanese to Korean
|
||||
{% elif category_name == "Korean Only" %}
|
||||
🇰🇷 Korean Documents
|
||||
{% else %}
|
||||
{{ category_name }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="category-count">{{ documents|length }}개</div>
|
||||
</div>
|
||||
|
||||
<div class="documents-grid">
|
||||
{% for doc in documents %}
|
||||
<div class="document-card" data-title="{{ doc.name.lower() }}" data-category="{{ category_name }}">
|
||||
<div class="language-badge">{{ doc.language_display }}</div>
|
||||
<div class="document-title">{{ doc.name }}</div>
|
||||
<div class="document-meta">
|
||||
<div class="meta-item">
|
||||
<span>📅</span>
|
||||
<span>{{ doc.created }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<span>📊</span>
|
||||
<span>{{ doc.size }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<span>📁</span>
|
||||
<span>{{ doc.month }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<span>🌐</span>
|
||||
<span>{{ doc.language_type.replace("-", " ")|title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="document-actions">
|
||||
<a href="{{ doc.url }}" class="btn btn-primary" target="_blank">👁️ 보기</a>
|
||||
<a href="{{ doc.url }}" class="btn btn-secondary" download="{{ doc.filename }}">📥 다운로드</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">📚</div>
|
||||
<div class="empty-title">아직 변환된 문서가 없습니다</div>
|
||||
<div class="empty-text">PDF나 텍스트 파일을 업로드하여 다국어 문서를 만들어보세요!</div>
|
||||
<a href="/" class="btn btn-primary">📤 첫 번째 문서 업로드</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 검색 및 필터링
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const categoryFilter = document.getElementById('categoryFilter');
|
||||
|
||||
function filterDocuments() {
|
||||
const query = searchInput.value.toLowerCase();
|
||||
const selectedCategory = categoryFilter.value;
|
||||
|
||||
// 모든 카테고리 섹션 처리
|
||||
document.querySelectorAll('.category-section').forEach(section => {
|
||||
const categoryName = section.dataset.category;
|
||||
let hasVisibleCards = false;
|
||||
|
||||
// 카테고리 필터 확인
|
||||
if (selectedCategory && categoryName !== selectedCategory) {
|
||||
section.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
// 카드 필터링
|
||||
section.querySelectorAll('.document-card').forEach(card => {
|
||||
const title = card.dataset.title;
|
||||
const matchesSearch = !query || title.includes(query);
|
||||
|
||||
if (matchesSearch) {
|
||||
card.style.display = 'block';
|
||||
hasVisibleCards = true;
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// 카테고리 섹션 표시/숨김
|
||||
section.style.display = hasVisibleCards ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
searchInput.addEventListener('input', filterDocuments);
|
||||
categoryFilter.addEventListener('change', filterDocuments);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user