Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/Dashboard.jsx
Browse files
frontend/src/pages/Dashboard.jsx
CHANGED
|
@@ -88,12 +88,13 @@ export const Dashboard = () => {
|
|
| 88 |
const MAX_ERRORS = 20; // tolerate up to 20 failures (covers token refresh + brief outages)
|
| 89 |
|
| 90 |
const pollLogs = async () => {
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
let activeToken = getToken();
|
| 94 |
|
| 95 |
try {
|
| 96 |
-
let res = await fetch(`/api/scans/${
|
| 97 |
headers: { 'Authorization': `Bearer ${activeToken}` }
|
| 98 |
});
|
| 99 |
|
|
@@ -102,7 +103,7 @@ export const Dashboard = () => {
|
|
| 102 |
const newToken = await refreshAccessToken();
|
| 103 |
if (newToken) {
|
| 104 |
activeToken = newToken;
|
| 105 |
-
res = await fetch(`/api/scans/${
|
| 106 |
headers: { 'Authorization': `Bearer ${newToken}` }
|
| 107 |
});
|
| 108 |
}
|
|
@@ -116,7 +117,7 @@ export const Dashboard = () => {
|
|
| 116 |
|
| 117 |
consecutiveErrors = 0;
|
| 118 |
const data = await res.json();
|
| 119 |
-
if (data.logs
|
| 120 |
setLiveLogs(data.logs);
|
| 121 |
}
|
| 122 |
|
|
@@ -125,7 +126,7 @@ export const Dashboard = () => {
|
|
| 125 |
setActiveScan(null);
|
| 126 |
activeScanRef.current = null;
|
| 127 |
persistActiveScan(null); // clear localStorage
|
| 128 |
-
markScanAsCompleted(
|
| 129 |
fetchDashboard();
|
| 130 |
}
|
| 131 |
} catch (err) {
|
|
|
|
| 88 |
const MAX_ERRORS = 20; // tolerate up to 20 failures (covers token refresh + brief outages)
|
| 89 |
|
| 90 |
const pollLogs = async () => {
|
| 91 |
+
const currentScan = activeScanRef.current || scan;
|
| 92 |
+
if (!currentScan) { stopLogPolling(); return; }
|
| 93 |
|
| 94 |
let activeToken = getToken();
|
| 95 |
|
| 96 |
try {
|
| 97 |
+
let res = await fetch(`/api/scans/${currentScan.id}/logs`, {
|
| 98 |
headers: { 'Authorization': `Bearer ${activeToken}` }
|
| 99 |
});
|
| 100 |
|
|
|
|
| 103 |
const newToken = await refreshAccessToken();
|
| 104 |
if (newToken) {
|
| 105 |
activeToken = newToken;
|
| 106 |
+
res = await fetch(`/api/scans/${currentScan.id}/logs`, {
|
| 107 |
headers: { 'Authorization': `Bearer ${newToken}` }
|
| 108 |
});
|
| 109 |
}
|
|
|
|
| 117 |
|
| 118 |
consecutiveErrors = 0;
|
| 119 |
const data = await res.json();
|
| 120 |
+
if (data.logs) {
|
| 121 |
setLiveLogs(data.logs);
|
| 122 |
}
|
| 123 |
|
|
|
|
| 126 |
setActiveScan(null);
|
| 127 |
activeScanRef.current = null;
|
| 128 |
persistActiveScan(null); // clear localStorage
|
| 129 |
+
markScanAsCompleted(currentScan.id);
|
| 130 |
fetchDashboard();
|
| 131 |
}
|
| 132 |
} catch (err) {
|