diff --git a/gui/src/components/card/ErrorCard.tsx b/gui/src/components/card/ErrorCard.tsx index 030e9e0a..c822004d 100644 --- a/gui/src/components/card/ErrorCard.tsx +++ b/gui/src/components/card/ErrorCard.tsx @@ -83,17 +83,18 @@ export function selectActions(state: OnnxState) { }; } -export const IMAGE_ERROR = 'error.image.'; +export const ANY_ERROR = 'error.'; +export const IMAGE_ERROR = `${ANY_ERROR}image.`; export const UNKNOWN_ERROR = `${IMAGE_ERROR}unknown`; export function getImageErrorReason(image: FailedJobResponse | UnknownJobResponse) { if (image.status === JobStatus.FAILED) { const error = image.error; - if (doesExist(error) && error.startsWith(IMAGE_ERROR)) { + if (doesExist(error) && error.startsWith(ANY_ERROR)) { return error; } - return `${IMAGE_ERROR}.${error}`; + return `${IMAGE_ERROR}${error}`; } return UNKNOWN_ERROR; diff --git a/gui/src/components/card/LoadingCard.tsx b/gui/src/components/card/LoadingCard.tsx index a9508acd..18921dbc 100644 --- a/gui/src/components/card/LoadingCard.tsx +++ b/gui/src/components/card/LoadingCard.tsx @@ -3,7 +3,7 @@ import { Box, Button, Card, CardContent, CircularProgress, Typography } from '@m import { Stack } from '@mui/system'; import { useMutation, useQuery } from '@tanstack/react-query'; import * as React from 'react'; -import { useContext, useEffect } from 'react'; +import { useContext, useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useStore } from 'zustand'; import { shallow } from 'zustand/shallow'; @@ -58,6 +58,8 @@ export function LoadingCard(props: LoadingCardProps) { } }, [ready.status, getStatus(ready.data), getProgress(ready.data)]); + const status = useMemo(() => getStatus(ready.data), [ready.data]); + return {renderProgress()} - {t('loading.progress', selectStatus(ready.data, image))} + { + status === JobStatus.PENDING ? + {t('loading.queue', getQueue(ready.data))} : + {t('loading.progress', selectStatus(ready.data, image))} + } @@ -138,3 +144,14 @@ function getStatus(data: Maybe>) { return JobStatus.PENDING; } + +function getQueue(data: Maybe>) { + if (doesExist(data) && data[0].status === JobStatus.PENDING) { + return data[0].queue; + } + + return { + current: 0, + total: 0, + }; +} diff --git a/gui/src/strings/de.ts b/gui/src/strings/de.ts index f3727477..5e4ae8de 100644 --- a/gui/src/strings/de.ts +++ b/gui/src/strings/de.ts @@ -80,6 +80,7 @@ export const I18N_STRINGS_DE = { loading: { cancel: 'Stornieren', progress: '{{current}} von {{total}} Schritten', + queue: '', server: 'Verbindung zum Server...', unknown: 'vielen', }, diff --git a/gui/src/strings/en.ts b/gui/src/strings/en.ts index de691a79..eaaa4928 100644 --- a/gui/src/strings/en.ts +++ b/gui/src/strings/en.ts @@ -72,6 +72,7 @@ export const I18N_STRINGS_EN = { loading: { cancel: 'Cancel', progress: '{{steps.current}} of {{steps.total}} steps, {{tiles.current}} of {{tiles.total}} tiles, {{stages.current}} of {{stages.total}} stages', + queue: '{{current}} of {{total}} in queue', server: 'Connecting to server...', unknown: 'many', }, diff --git a/gui/src/strings/es.ts b/gui/src/strings/es.ts index 5ecf4eba..44925135 100644 --- a/gui/src/strings/es.ts +++ b/gui/src/strings/es.ts @@ -80,6 +80,7 @@ export const I18N_STRINGS_ES = { loading: { cancel: 'Cancelar', progress: '{{current}} de {{total}} pasos', + queue: '', server: 'Conectando al servidor...', unknown: 'muchos', }, diff --git a/gui/src/strings/fr.ts b/gui/src/strings/fr.ts index edbe267b..a3b453df 100644 --- a/gui/src/strings/fr.ts +++ b/gui/src/strings/fr.ts @@ -80,6 +80,7 @@ export const I18N_STRINGS_FR = { loading: { cancel: 'Annuler', progress: '{{current}} des {{total}} étapes', + queue: '', server: 'Connexion au serveur...', unknown: 'nombreuses', }, diff --git a/gui/src/types/api-v2.ts b/gui/src/types/api-v2.ts index 9d25f920..093847de 100644 --- a/gui/src/types/api-v2.ts +++ b/gui/src/types/api-v2.ts @@ -75,7 +75,8 @@ export interface CancelledJobResponse extends BaseJobResponse { */ export interface FailedJobResponse extends BaseJobResponse { status: JobStatus.FAILED; - error: string; + + error?: string; } /** @@ -83,6 +84,7 @@ export interface FailedJobResponse extends BaseJobResponse { */ export interface PendingJobResponse extends BaseJobResponse { status: JobStatus.PENDING; + queue: Progress; }