Skip to content

Commit

Permalink
feat(gui): add loading spinner while fetching server params
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 5, 2023
1 parent d5a3b0f commit aed5e1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gui/src/components/LoadingScreen.tsx
Original file line number Diff line number Diff line change
@@ -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>;
}
4 changes: 4 additions & 0 deletions gui/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mustDefault, mustExist, timeout, TimeoutError } from '@apextoaster/js-utils';
import { Box, CircularProgress } from '@mui/material';
import { createLogger, Logger } from 'browser-bunyan';
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
Expand All @@ -14,6 +15,7 @@ import { ApiClient, makeClient } from './client/api.js';
import { LOCAL_CLIENT } from './client/local.js';
import { ParamsVersionError } from './components/error/ParamsVersion.js';
import { ServerParamsError } from './components/error/ServerParams.js';
import { LoadingScreen } from './components/LoadingScreen.js';
import { OnnxError } from './components/OnnxError.js';
import { OnnxWeb } from './components/OnnxWeb.js';
import {
Expand Down Expand Up @@ -163,6 +165,8 @@ export async function main() {

try {
logger.info('getting image parameters from server');
app.render(<LoadingScreen />);

// load full params from the API server and merge with the initial client config
const params = await timeout(INITIAL_LOAD_TIMEOUT, client.params());
const version = mustDefault(params.version, '0.0.0');
Expand Down

0 comments on commit aed5e1b

Please sign in to comment.