show spinner while running backgroun task
This commit is contained in:
parent
5a9a837b27
commit
e05b4788e0
3 changed files with 8 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ import { getUser } from '@/auth/authService';
|
|||
import type { User } from 'oidc-client-ts';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import AlertError from './AlertError';
|
||||
import { Spinner } from './Spinner';
|
||||
import { HoverCard, HoverCardContent, HoverCardTrigger } from './ui/hover-card';
|
||||
import { Progress } from './ui/progress';
|
||||
|
||||
|
|
@ -101,11 +102,11 @@ const ActiveQuery: React.FC<ModalProps> = ({
|
|||
setLastUpdateTime(new Date());
|
||||
// const taskStatus = getTaskStatus(data.status);
|
||||
const taskStatus = data.status;
|
||||
if (taskStatus === "FAILURE") {
|
||||
clearInterval(interval);
|
||||
throw new Error('Task failed');
|
||||
}
|
||||
setTaskStatus(taskStatus);
|
||||
if (taskStatus === "FAILURE" || taskStatus === "REVOKED") {
|
||||
clearInterval(interval);
|
||||
throw new Error('Task failed. status: ' + taskStatus);
|
||||
}
|
||||
// const progress = taskStatusToProgress(taskStatus);
|
||||
const parsedResult = JSON.parse(data.result)
|
||||
setProgressPercentage(parsedResult.progress * 100);
|
||||
|
|
@ -134,6 +135,7 @@ const ActiveQuery: React.FC<ModalProps> = ({
|
|||
<HoverCardTrigger>
|
||||
{taskStatus && <>Task status: {taskStatus} </>}
|
||||
<Progress value={progressPercentage} />
|
||||
{taskStatus && taskStatus !== 'SUCCESS' && taskStatus !== 'FAILURE' && taskStatus !== 'REVOKED' && <Spinner />}
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent>
|
||||
Task ID: {taskID}
|
||||
|
|
|
|||
1
crawler/frontend/tsconfig.app.tsbuildinfo
Normal file
1
crawler/frontend/tsconfig.app.tsbuildinfo
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"root":["./src/App.tsx","./src/AppSidebar.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/auth/authService.ts","./src/auth/config.ts","./src/components/ActiveQuery.tsx","./src/components/AlertError.tsx","./src/components/LoginModal.tsx","./src/components/Map.tsx","./src/components/Parameters.tsx","./src/components/ui/alert-dialog.tsx","./src/components/ui/alert.tsx","./src/components/ui/badge.tsx","./src/components/ui/breadcrumb.tsx","./src/components/ui/button.tsx","./src/components/ui/dialog.tsx","./src/components/ui/form.tsx","./src/components/ui/hover-card.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/progress.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/select.tsx","./src/components/ui/separator.tsx","./src/components/ui/sheet.tsx","./src/components/ui/sidebar.tsx","./src/components/ui/skeleton.tsx","./src/components/ui/tooltip.tsx","./src/hooks/use-mobile.ts","./src/lib/utils.ts"],"version":"5.8.3"}
|
||||
1
crawler/frontend/tsconfig.node.tsbuildinfo
Normal file
1
crawler/frontend/tsconfig.node.tsbuildinfo
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"root":["./vite.config.ts"],"version":"5.8.3"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue