fix: scan type

This commit is contained in:
2025-10-22 17:15:54 -04:00
committed by sbcrumb
parent 4752b424f5
commit 18ae174276
+26 -14
View File
@@ -117,6 +117,9 @@ async function loadDashboard() {
dashboardData = await apiCall('/api/dashboard');
updateDashboardStats();
updateDashboardCharts();
// Check if there's an ongoing scan when dashboard loads
await checkScanStatus();
} catch (error) {
console.error('Failed to load dashboard:', error);
}
@@ -1428,12 +1431,14 @@ async function handleManualScan(event) {
showToast('🔍 Starting manual scan...', 'info');
updateScanStatus('Starting manual scan...', true);
const result = await apiCall('/manual/scan', {
method: 'POST',
body: JSON.stringify({
// Send as query parameters instead of JSON body
const params = new URLSearchParams({
scan_type: scanType,
scan_mode: scanMode
})
});
const result = await apiCall(`/manual/scan?${params}`, {
method: 'POST'
});
showToast(`✅ Manual scan initiated: ${result.message}`, 'success');
@@ -1468,12 +1473,15 @@ async function handleCustomScan(event) {
showToast('🔍 Starting custom directory scan...', 'info');
updateScanStatus('Starting custom directory scan...', true);
const result = await apiCall('/manual/scan', {
method: 'POST',
body: JSON.stringify({
directory: customDirectory,
scan_type: customScanType
})
// Send as query parameters instead of JSON body
const params = new URLSearchParams({
path: customDirectory,
scan_type: customScanType,
scan_mode: 'smart' // Default to smart mode for custom scans
});
const result = await apiCall(`/manual/scan?${params}`, {
method: 'POST'
});
showToast(`✅ Custom scan initiated: ${result.message}`, 'success');
@@ -1547,6 +1555,11 @@ async function checkScanStatus() {
if (status.scanning) {
updateScanStatus(status.message || 'Scan in progress...', true);
// Start polling if not already polling
if (!scanStatusInterval) {
startScanStatusPolling();
}
return true; // Continue polling
} else {
updateScanStatus(status.message || 'No scan in progress', false);
@@ -1561,9 +1574,9 @@ async function checkScanStatus() {
}
function startScanStatusPolling() {
// Clear any existing interval
// Don't start if already polling
if (scanStatusInterval) {
clearInterval(scanStatusInterval);
return;
}
// Check status every 2 seconds
@@ -1581,8 +1594,7 @@ function startScanStatusPolling() {
}
}, 2000);
// Initial status check
checkScanStatus();
console.log('Started scan status polling');
}
function stopScanStatusPolling() {