implemented step 12 by Gemini

- Task actions
This commit is contained in:
2026-06-14 12:42:41 +02:00
parent c01eb30632
commit 2b9b62b0aa
5 changed files with 174 additions and 3 deletions

View File

@ -50,6 +50,13 @@ const App = {
this.state.currentStep = this.state.project.current_step || 1;
console.log('Loaded existing project:', this.state.project.project_id);
this.syncSelectionWithProject();
// Resume polling if generating
const pollingStatuses = ['queued', 'generating', 'rendering'];
if (pollingStatuses.includes(this.state.project.status)) {
this.state.currentStep = 6;
this.startPolling();
}
}
} else {
await this.createProject();
@ -708,9 +715,66 @@ const App = {
if (this.state.currentStep < this.state.totalSteps) {
this.showStep(this.state.currentStep + 1);
// Trigger generation if entering step 6
if (this.state.currentStep === 6) {
this.startWebsiteGeneration();
}
}
},
async startWebsiteGeneration() {
try {
const result = await this.apiCall('generateWebsite');
if (result.success) {
console.log('Generation started:', result.data.task_id);
this.startPolling();
}
} catch (error) {
console.error('Failed to start generation:', error);
document.getElementById('generation-status').textContent = 'Chyba: ' + error.message;
}
},
startPolling() {
if (this.pollingInterval) clearInterval(this.pollingInterval);
this.pollingInterval = setInterval(async () => {
try {
const response = await this.apiCall('getProjectStatus');
if (response.success) {
const project = response.data;
this.state.project = project;
this.updateGenerationStatus(project.status);
if (project.status === 'ready' || project.status === 'failed') {
clearInterval(this.pollingInterval);
if (project.status === 'ready') {
// Move to preview step
this.showStep(7);
} else {
document.getElementById('generation-status').textContent = 'Generovanie zlyhalo. Skúste to neskôr.';
}
}
}
} catch (error) {
console.error('Polling error:', error);
}
}, 3000);
},
updateGenerationStatus(status) {
const statusEl = document.getElementById('generation-status');
const messages = {
'queued': 'Zaradené do fronty, čakám na AI...',
'generating': 'AI práve píše texty pre váš web...',
'rendering': 'Skladáme výslednú stránku...',
'ready': 'Hotovo! Pripravujem náhľad...',
'failed': 'Nastal problém pri generovaní.'
};
statusEl.textContent = messages[status] || 'Spracovávam...';
},
prevStep() {
if (this.state.currentStep > 1) {
this.showStep(this.state.currentStep - 1);
@ -749,6 +813,9 @@ const App = {
btnNext.disabled = nextDisabled;
// Hide footer in generating step
document.querySelector('.wizard-footer').classList.toggle('hidden', this.state.currentStep === 6);
if (this.state.currentStep === this.state.totalSteps) {
btnNext.textContent = 'Dokončiť';
} else {