469 lines
15 KiB
HTML
469 lines
15 KiB
HTML
<!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>
|