fix: scan type
This commit is contained in:
@@ -117,6 +117,9 @@ async function loadDashboard() {
|
|||||||
dashboardData = await apiCall('/api/dashboard');
|
dashboardData = await apiCall('/api/dashboard');
|
||||||
updateDashboardStats();
|
updateDashboardStats();
|
||||||
updateDashboardCharts();
|
updateDashboardCharts();
|
||||||
|
|
||||||
|
// Check if there's an ongoing scan when dashboard loads
|
||||||
|
await checkScanStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load dashboard:', error);
|
console.error('Failed to load dashboard:', error);
|
||||||
}
|
}
|
||||||
@@ -1428,12 +1431,14 @@ async function handleManualScan(event) {
|
|||||||
showToast('🔍 Starting manual scan...', 'info');
|
showToast('🔍 Starting manual scan...', 'info');
|
||||||
updateScanStatus('Starting manual scan...', true);
|
updateScanStatus('Starting manual scan...', true);
|
||||||
|
|
||||||
const result = await apiCall('/manual/scan', {
|
// Send as query parameters instead of JSON body
|
||||||
method: 'POST',
|
const params = new URLSearchParams({
|
||||||
body: JSON.stringify({
|
scan_type: scanType,
|
||||||
scan_type: scanType,
|
scan_mode: scanMode
|
||||||
scan_mode: scanMode
|
});
|
||||||
})
|
|
||||||
|
const result = await apiCall(`/manual/scan?${params}`, {
|
||||||
|
method: 'POST'
|
||||||
});
|
});
|
||||||
|
|
||||||
showToast(`✅ Manual scan initiated: ${result.message}`, 'success');
|
showToast(`✅ Manual scan initiated: ${result.message}`, 'success');
|
||||||
@@ -1468,12 +1473,15 @@ async function handleCustomScan(event) {
|
|||||||
showToast('🔍 Starting custom directory scan...', 'info');
|
showToast('🔍 Starting custom directory scan...', 'info');
|
||||||
updateScanStatus('Starting custom directory scan...', true);
|
updateScanStatus('Starting custom directory scan...', true);
|
||||||
|
|
||||||
const result = await apiCall('/manual/scan', {
|
// Send as query parameters instead of JSON body
|
||||||
method: 'POST',
|
const params = new URLSearchParams({
|
||||||
body: JSON.stringify({
|
path: customDirectory,
|
||||||
directory: customDirectory,
|
scan_type: customScanType,
|
||||||
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');
|
showToast(`✅ Custom scan initiated: ${result.message}`, 'success');
|
||||||
@@ -1547,6 +1555,11 @@ async function checkScanStatus() {
|
|||||||
|
|
||||||
if (status.scanning) {
|
if (status.scanning) {
|
||||||
updateScanStatus(status.message || 'Scan in progress...', true);
|
updateScanStatus(status.message || 'Scan in progress...', true);
|
||||||
|
|
||||||
|
// Start polling if not already polling
|
||||||
|
if (!scanStatusInterval) {
|
||||||
|
startScanStatusPolling();
|
||||||
|
}
|
||||||
return true; // Continue polling
|
return true; // Continue polling
|
||||||
} else {
|
} else {
|
||||||
updateScanStatus(status.message || 'No scan in progress', false);
|
updateScanStatus(status.message || 'No scan in progress', false);
|
||||||
@@ -1561,9 +1574,9 @@ async function checkScanStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startScanStatusPolling() {
|
function startScanStatusPolling() {
|
||||||
// Clear any existing interval
|
// Don't start if already polling
|
||||||
if (scanStatusInterval) {
|
if (scanStatusInterval) {
|
||||||
clearInterval(scanStatusInterval);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check status every 2 seconds
|
// Check status every 2 seconds
|
||||||
@@ -1581,8 +1594,7 @@ function startScanStatusPolling() {
|
|||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
// Initial status check
|
console.log('Started scan status polling');
|
||||||
checkScanStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopScanStatusPolling() {
|
function stopScanStatusPolling() {
|
||||||
|
|||||||
Reference in New Issue
Block a user