This commit is contained in:
@@ -567,6 +567,13 @@ body.ppt-preview-open {
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.ppt-panel-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--momo-space-2, 8px);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.ppt-panel-body {
|
||||
padding: var(--momo-space-4, 16px);
|
||||
}
|
||||
@@ -901,6 +908,7 @@ body.ppt-preview-open {
|
||||
}
|
||||
|
||||
.ppt-panel-head,
|
||||
.ppt-panel-actions,
|
||||
.ppt-table-title,
|
||||
.ppt-workbench-head,
|
||||
.ppt-workbench-actions,
|
||||
|
||||
@@ -604,6 +604,7 @@
|
||||
const previewDownload = previewModal ? previewModal.querySelector('[data-ppt-preview-download]') : null;
|
||||
const previewLoading = previewModal ? previewModal.querySelector('[data-ppt-preview-loading]') : null;
|
||||
const previewFrameWrap = previewModal ? previewModal.querySelector('.ppt-preview-frame-wrap') : null;
|
||||
const visionAuditFilenames = readJson('obs-ppt-audit-filenames', []);
|
||||
|
||||
function closePreviewModal() {
|
||||
if (!previewModal) return;
|
||||
@@ -668,6 +669,62 @@
|
||||
window.triggerAiderHeal(button.dataset.pptFilename || '', button.dataset.pptError || '');
|
||||
});
|
||||
});
|
||||
|
||||
async function triggerVisionAudit(button) {
|
||||
const filenames = Array.isArray(visionAuditFilenames) ? visionAuditFilenames.filter(Boolean) : [];
|
||||
if (!filenames.length) {
|
||||
if (pageStatus) pageStatus.textContent = '目前沒有可送進視覺 QA 的 PPTX 檔案。';
|
||||
return;
|
||||
}
|
||||
const buttons = Array.from(document.querySelectorAll('[data-ppt-run-vision]'));
|
||||
const originalHtml = button ? button.innerHTML : '';
|
||||
buttons.forEach(item => {
|
||||
item.disabled = true;
|
||||
item.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>QA 排入中';
|
||||
});
|
||||
if (pageStatus) {
|
||||
pageStatus.classList.add('is-working');
|
||||
pageStatus.textContent = `已準備送出 ${filenames.length} 份簡報進行視覺 QA,完成後會寫入資料庫。`;
|
||||
}
|
||||
try {
|
||||
const response = await postJson('/observability/ppt_audit/run_vision', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filenames, max_files: filenames.length })
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.ok) {
|
||||
throw new Error(data.error || data.message || '視覺 QA 送出失敗');
|
||||
}
|
||||
buttons.forEach(item => {
|
||||
item.innerHTML = data.status === 'already_running'
|
||||
? '<i class="fas fa-clock me-1"></i>QA 執行中'
|
||||
: '<i class="fas fa-check me-1"></i>QA 已排入';
|
||||
});
|
||||
if (pageStatus) {
|
||||
pageStatus.textContent = data.status === 'already_running'
|
||||
? '視覺 QA 已在執行中,請稍後重新整理查看資料庫結果。'
|
||||
: `視覺 QA 已排入 ${filenames.length} 份簡報;審核結果會寫入 ppt_audit_results。`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('ppt_vision_audit_queue_failed', error);
|
||||
buttons.forEach(item => {
|
||||
item.disabled = false;
|
||||
item.innerHTML = item === button && originalHtml ? originalHtml : '<i class="fas fa-eye me-1"></i>立即視覺 QA';
|
||||
});
|
||||
if (pageStatus) {
|
||||
pageStatus.classList.remove('is-working');
|
||||
pageStatus.textContent = '視覺 QA 送出失敗,請稍後再試或查看系統日誌。';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-ppt-run-vision]').forEach(button => {
|
||||
if (button.dataset.bound === '1') return;
|
||||
button.dataset.bound = '1';
|
||||
button.addEventListener('click', () => triggerVisionAudit(button));
|
||||
});
|
||||
|
||||
function markPreviewCacheReady(filename) {
|
||||
document.querySelectorAll('[data-ppt-preview-state]').forEach(node => {
|
||||
if (node.dataset.pptPreviewState !== filename) return;
|
||||
|
||||
Reference in New Issue
Block a user