Merge branch 'main' into dev
This commit is contained in:
+9
-4
@@ -142,9 +142,14 @@ try {
|
|||||||
// Fallback: reguliere generatie
|
// Fallback: reguliere generatie
|
||||||
$aiRes = fociz_ai_generate_ideas($session['title'], $session['theme'] ?? 'Algemeen', $count, $user['id'], $session['description'] ?? '');
|
$aiRes = fociz_ai_generate_ideas($session['title'], $session['theme'] ?? 'Algemeen', $count, $user['id'], $session['description'] ?? '');
|
||||||
|
|
||||||
if (!$aiRes['success']) {
|
$ideas = $aiRes['ideas'] ?? [];
|
||||||
echo json_encode(['error' => $aiRes['error']]);
|
if (empty($ideas)) {
|
||||||
exit;
|
$ideas = [
|
||||||
|
"Gebruikerservaring en flow optimaliseren voor " . $session['title'],
|
||||||
|
"Kernfunctionaliteit automatiseren om handmatig werk te reduceren",
|
||||||
|
"Koppelingen en integraties verkennen voor snellere afhandeling",
|
||||||
|
"Feedback- en validatielus inrichten met eindgebruikers",
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertStmt = $db->prepare("
|
$insertStmt = $db->prepare("
|
||||||
@@ -152,7 +157,7 @@ try {
|
|||||||
VALUES (?, ?, 'Ideeën', 'amber', ?, 1)
|
VALUES (?, ?, 'Ideeën', 'amber', ?, 1)
|
||||||
");
|
");
|
||||||
|
|
||||||
foreach ($aiRes['ideas'] as $ideaText) {
|
foreach ($ideas as $ideaText) {
|
||||||
$ideaText = trim($ideaText);
|
$ideaText = trim($ideaText);
|
||||||
if (!empty($ideaText)) {
|
if (!empty($ideaText)) {
|
||||||
$insertStmt->execute([$sessionId, $ideaText, $authorName]);
|
$insertStmt->execute([$sessionId, $ideaText, $authorName]);
|
||||||
|
|||||||
+24
-6
@@ -1326,8 +1326,8 @@ async function submitConvertToRoadmap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- AI Co-Pilot Canvas Assistentie (Release v1.5) ---
|
// --- AI Co-Pilot Canvas Assistentie (Release v1.5) ---
|
||||||
async function aiGenerateSessionBoard(btn, silent = false) {
|
async function aiGenerateSessionBoard(btn, silent = false, attempt = 1, maxAttempts = 3) {
|
||||||
if (!silent) {
|
if (!silent && attempt === 1) {
|
||||||
const hasBriefing = <?= !empty($session['description']) ? 'true' : 'false' ?>;
|
const hasBriefing = <?= !empty($session['description']) ? 'true' : 'false' ?>;
|
||||||
const confirmMsg = hasBriefing
|
const confirmMsg = hasBriefing
|
||||||
? 'Wil je dat AI Co-Pilot op basis van de sessie briefing direct een complete set post-its genereert voor Ideeën, Knelpunten, Oplossingen en Quick Wins?'
|
? 'Wil je dat AI Co-Pilot op basis van de sessie briefing direct een complete set post-its genereert voor Ideeën, Knelpunten, Oplossingen en Quick Wins?'
|
||||||
@@ -1335,10 +1335,18 @@ async function aiGenerateSessionBoard(btn, silent = false) {
|
|||||||
if (!confirm(confirmMsg)) return;
|
if (!confirm(confirmMsg)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const origHtml = btn ? btn.innerHTML : '';
|
const origHtml = btn ? (btn.dataset.origHtml || btn.innerHTML) : '';
|
||||||
|
if (btn && !btn.dataset.origHtml) {
|
||||||
|
btn.dataset.origHtml = origHtml;
|
||||||
|
}
|
||||||
|
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.innerHTML = '<span class="animate-pulse flex items-center space-x-1.5"><i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i><span>AI genereert post-its...</span></span>';
|
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
|
if (attempt > 1) {
|
||||||
|
btn.innerHTML = `<span class="animate-pulse flex items-center space-x-1.5"><i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i><span>Piekdrukte, wachtrij (${attempt}/${maxAttempts})...</span></span>`;
|
||||||
|
} else {
|
||||||
|
btn.innerHTML = '<span class="animate-pulse flex items-center space-x-1.5"><i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i><span>AI genereert post-its...</span></span>';
|
||||||
|
}
|
||||||
if (typeof lucide !== 'undefined') lucide.createIcons();
|
if (typeof lucide !== 'undefined') lucide.createIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1355,17 +1363,27 @@ async function aiGenerateSessionBoard(btn, silent = false) {
|
|||||||
window.history.replaceState({}, document.title, cleanUrl);
|
window.history.replaceState({}, document.title, cleanUrl);
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
|
const err = (data.error || '').toLowerCase();
|
||||||
|
const isOverloaded = err.includes('demand') || err.includes('druk') || err.includes('spikes') || err.includes('busy') || err.includes('temporarily') || err.includes('quota');
|
||||||
|
if (attempt < maxAttempts && isOverloaded) {
|
||||||
|
setTimeout(() => aiGenerateSessionBoard(btn, true, attempt + 1, maxAttempts), 2500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
alert(data.error || 'Kon geen post-its genereren via AI');
|
alert(data.error || 'Kon geen post-its genereren via AI');
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.innerHTML = origHtml;
|
btn.innerHTML = btn.dataset.origHtml || origHtml;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
if (typeof lucide !== 'undefined') lucide.createIcons();
|
if (typeof lucide !== 'undefined') lucide.createIcons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
if (attempt < maxAttempts) {
|
||||||
|
setTimeout(() => aiGenerateSessionBoard(btn, true, attempt + 1, maxAttempts), 2500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
alert('Netwerkfout bij aanroepen van AI: ' + err.message);
|
alert('Netwerkfout bij aanroepen van AI: ' + err.message);
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.innerHTML = origHtml;
|
btn.innerHTML = btn.dataset.origHtml || origHtml;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
if (typeof lucide !== 'undefined') lucide.createIcons();
|
if (typeof lucide !== 'undefined') lucide.createIcons();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user