修改前端显示逻辑
This commit is contained in:
@@ -111,9 +111,11 @@ function setRunningState(running) {
|
||||
if (running) {
|
||||
statusDot.className = 'dot running';
|
||||
statusText.innerText = 'Analysis in Progress';
|
||||
if (document.getElementById('followUpSection')) document.getElementById('followUpSection').style.display = 'none';
|
||||
} else {
|
||||
statusDot.className = 'dot done';
|
||||
statusText.innerText = 'Completed';
|
||||
if (currentSessionId && document.getElementById('followUpSection')) document.getElementById('followUpSection').style.display = 'flex';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +217,7 @@ async function loadGallery() {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Export Report ---
|
||||
// --- Export Report ---
|
||||
window.triggerExport = async function () {
|
||||
if (!currentSessionId) {
|
||||
@@ -228,17 +231,29 @@ window.triggerExport = async function () {
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
// Trigger download
|
||||
// We can't use fetch for file download easily if we want browser to handle save dialog
|
||||
// So we create a link approach or check status first
|
||||
|
||||
// Check if download is possible
|
||||
const url = `/api/export?session_id=${currentSessionId}`;
|
||||
const res = await fetch(url, { method: 'HEAD' });
|
||||
const res = await fetch(url); // Default GET
|
||||
|
||||
if (res.ok) {
|
||||
window.location.href = url;
|
||||
const blob = await res.blob();
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = downloadUrl;
|
||||
a.download = `analysis_export_${currentSessionId}.zip`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
} else {
|
||||
alert("Export failed: No data available.");
|
||||
// Try to parse error
|
||||
let errMsg = "Unknown error";
|
||||
try {
|
||||
const err = await res.json();
|
||||
errMsg = err.detail || errMsg;
|
||||
} catch (jsonErr) {
|
||||
errMsg = res.statusText;
|
||||
}
|
||||
alert("Export failed: " + errMsg);
|
||||
}
|
||||
} catch (e) {
|
||||
alert("Export failed: " + e.message);
|
||||
@@ -248,6 +263,45 @@ window.triggerExport = async function () {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Follow-up Chat ---
|
||||
window.sendFollowUp = async function () {
|
||||
if (!currentSessionId || isRunning) return;
|
||||
|
||||
const input = document.getElementById('followUpInput');
|
||||
const message = input.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
// UI Loading state
|
||||
const btn = document.getElementById('sendFollowUpBtn');
|
||||
btn.disabled = true;
|
||||
input.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ session_id: currentSessionId, message: message })
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
input.value = '';
|
||||
setRunningState(true);
|
||||
startPolling();
|
||||
switchTab('logs');
|
||||
} else {
|
||||
const err = await res.json();
|
||||
alert('Error: ' + err.detail);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Failed to send request');
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
input.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Tabs (Inner) ---
|
||||
window.switchTab = function (tabName) {
|
||||
|
||||
Reference in New Issue
Block a user