1
0
Fork 0

feat(gui): add loading spinner while fetching server params

This commit is contained in:
Sean Sube 2023-03-05 16:41:31 -06:00
parent d5a3b0fed8
commit aed5e1bf12
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { Box, CircularProgress, Stack } from '@mui/material';
import * as React from 'react';
export function LoadingScreen() {
return <Box sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minHeight: 512,
}}>
<Stack
direction='column'
spacing={2}
sx={{ alignItems: 'center' }}
>
<CircularProgress />
</Stack>
</Box>;
}

View File

@ -1,4 +1,5 @@
import { mustDefault, mustExist, timeout, TimeoutError } from '@apextoaster/js-utils'; import { mustDefault, mustExist, timeout, TimeoutError } from '@apextoaster/js-utils';
import { Box, CircularProgress } from '@mui/material';
import { createLogger, Logger } from 'browser-bunyan'; import { createLogger, Logger } from 'browser-bunyan';
import i18n from 'i18next'; import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector'; import LanguageDetector from 'i18next-browser-languagedetector';
@ -14,6 +15,7 @@ import { ApiClient, makeClient } from './client/api.js';
import { LOCAL_CLIENT } from './client/local.js'; import { LOCAL_CLIENT } from './client/local.js';
import { ParamsVersionError } from './components/error/ParamsVersion.js'; import { ParamsVersionError } from './components/error/ParamsVersion.js';
import { ServerParamsError } from './components/error/ServerParams.js'; import { ServerParamsError } from './components/error/ServerParams.js';
import { LoadingScreen } from './components/LoadingScreen.js';
import { OnnxError } from './components/OnnxError.js'; import { OnnxError } from './components/OnnxError.js';
import { OnnxWeb } from './components/OnnxWeb.js'; import { OnnxWeb } from './components/OnnxWeb.js';
import { import {
@ -163,6 +165,8 @@ export async function main() {
try { try {
logger.info('getting image parameters from server'); logger.info('getting image parameters from server');
app.render(<LoadingScreen />);
// load full params from the API server and merge with the initial client config // load full params from the API server and merge with the initial client config
const params = await timeout(INITIAL_LOAD_TIMEOUT, client.params()); const params = await timeout(INITIAL_LOAD_TIMEOUT, client.params());
const version = mustDefault(params.version, '0.0.0'); const version = mustDefault(params.version, '0.0.0');