implemented step 19 by Gemini

- Preview and Export
This commit is contained in:
2026-06-15 05:05:41 +02:00
parent 4135b621c4
commit c0f13495ce
5 changed files with 246 additions and 8 deletions

View File

@ -273,6 +273,24 @@ const App = {
document.getElementById('config-smtp').classList.toggle('hidden', e.target.value !== 'smtp');
});
});
// Step 7 events
document.querySelectorAll('.btn-toggle').forEach(btn => {
btn.addEventListener('click', (e) => {
document.querySelectorAll('.btn-toggle').forEach(b => b.classList.remove('active'));
e.target.classList.add('active');
const view = e.target.getAttribute('data-view');
document.getElementById('preview-container').className = 'preview-window ' + view;
});
});
// Step 8 events
document.getElementById('btn-download-zip').addEventListener('click', () => this.downloadWebsite());
document.getElementById('btn-view-live').addEventListener('click', () => {
if (this.state.project) {
window.open(`/exports/${this.state.project.project_id}/index.html`, '_blank');
}
});
},
renderCategories() {
@ -534,9 +552,48 @@ const App = {
}
this.state.currentStep = n;
// Specific step logic
if (n === 7) {
this.loadPreview();
}
this.updateUI();
},
loadPreview() {
const iframe = document.getElementById('preview-iframe');
const timestamp = new Date().getTime();
iframe.src = `/exports/${this.state.project.project_id}/index.html?t=${timestamp}`;
},
async downloadWebsite() {
const btn = document.getElementById('btn-download-zip');
const originalText = btn.textContent;
btn.disabled = true;
btn.textContent = 'Pripravujem archív...';
try {
const result = await this.apiCall('exportWebsite');
if (result.success) {
// Trigger download
const link = document.createElement('a');
link.href = '/' + result.data.download_url;
link.download = result.data.filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
} catch (error) {
console.error('Export failed:', error);
alert('Chyba pri generovaní ZIP archívu.');
} finally {
btn.disabled = false;
btn.textContent = originalText;
}
},
async nextStep() {
if (this.state.currentStep === 1) {
if (!this.state.selection.category || !this.state.selection.subcategory) {