Better handling of configuration load

This commit is contained in:
Pierre HUBERT 2023-06-17 18:19:11 +02:00
parent cffa8f40c2
commit 56f8dfeb9e
2 changed files with 8 additions and 4 deletions

View File

@ -13,11 +13,10 @@ import "@fontsource/roboto/700.css";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import { ConfirmDialogProvider } from "./widgets/ConfirmDialogProvider"; import { ConfirmDialogProvider } from "./widgets/ConfirmDialogProvider";
import { AlertDialogProvider } from "./widgets/AlertDialogProvider"; import { AlertDialogProvider } from "./widgets/AlertDialogProvider";
import { AsyncWidget } from "./widgets/AsyncWidget";
async function init() { async function init() {
try { try {
await ServerApi.LoadConfig();
const root = ReactDOM.createRoot( const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement document.getElementById("root") as HTMLElement
); );
@ -28,7 +27,12 @@ async function init() {
<AlertDialogProvider> <AlertDialogProvider>
<ConfirmDialogProvider> <ConfirmDialogProvider>
<div style={{ height: "100vh" }}> <div style={{ height: "100vh" }}>
<App /> <AsyncWidget
loadKey={1}
load={async () => await ServerApi.LoadConfig()}
errMsg="Echec de la connexion au serveur pour la récupération de la configuration statique !"
build={() => <App />}
/>
</div> </div>
</ConfirmDialogProvider> </ConfirmDialogProvider>
</AlertDialogProvider> </AlertDialogProvider>

View File

@ -65,7 +65,7 @@ export function AsyncWidget(p: {
<Alert <Alert
variant="outlined" variant="outlined"
severity="error" severity="error"
style={{ marginBottom: "15px" }} style={{ margin: "0px 15px 15px 15px" }}
> >
{p.errMsg} {p.errMsg}
</Alert> </Alert>