Fix initial errors in calculate metrics and get progress working in frontend
This commit is contained in:
@@ -254,8 +254,8 @@ export function Settings() {
|
||||
}
|
||||
|
||||
// Handle completion
|
||||
if (progressData.status === 'complete') {
|
||||
console.log(`Operation ${type} completed`);
|
||||
if (progressData.status === 'complete' || progressData.status === 'cancelled') {
|
||||
console.log(`Operation ${type} completed or cancelled`);
|
||||
|
||||
// For import, only close connection when both operations are complete
|
||||
if (type === 'import') {
|
||||
@@ -433,11 +433,14 @@ export function Settings() {
|
||||
}, [eventSource]);
|
||||
|
||||
const handleCancel = async () => {
|
||||
// Determine which operation is running first
|
||||
const operation = isImporting ? 'Import' : isUpdating ? 'Update' : 'Reset';
|
||||
// Determine which operation is running
|
||||
const operation = isImporting ? 'import' :
|
||||
isUpdating ? 'update' :
|
||||
isResetting ? 'reset' :
|
||||
isCalculatingMetrics ? 'calculate-metrics' : 'reset';
|
||||
|
||||
// Show cancellation toast immediately
|
||||
toast.warning(`${operation} cancelled`);
|
||||
toast.warning(`${operation.charAt(0).toUpperCase() + operation.slice(1)} cancelled`);
|
||||
|
||||
// Clean up everything immediately
|
||||
if (eventSource) {
|
||||
@@ -447,13 +450,15 @@ export function Settings() {
|
||||
setIsUpdating(false);
|
||||
setIsImporting(false);
|
||||
setIsResetting(false);
|
||||
setIsCalculatingMetrics(false);
|
||||
setUpdateProgress(null);
|
||||
setImportProgress(null);
|
||||
setResetProgress(null);
|
||||
setMetricsProgress(null);
|
||||
|
||||
// Fire and forget the cancel request with the operation type
|
||||
try {
|
||||
await fetch(`${config.apiUrl}/csv/cancel?operation=${operation.toLowerCase()}`, {
|
||||
await fetch(`${config.apiUrl}/csv/cancel?operation=${operation}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user