CheckingServerHealth component
parent
735bba1e4d
commit
25a2ff95e4
|
@ -92,6 +92,7 @@
|
||||||
"ServerAvailability": {
|
"ServerAvailability": {
|
||||||
"Unavailable": "Oops. Looks like the server is currently unavailable.",
|
"Unavailable": "Oops. Looks like the server is currently unavailable.",
|
||||||
"TryAgain": "Try again in a few seconds",
|
"TryAgain": "Try again in a few seconds",
|
||||||
"Retry": "Retry"
|
"Retry": "Retry",
|
||||||
|
"CheckingServerHealth": "Checking server health..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
"ServerAvailability": {
|
"ServerAvailability": {
|
||||||
"Unavailable": "Hopa! Se pare că serverul nu este disponibil momentan.",
|
"Unavailable": "Hopa! Se pare că serverul nu este disponibil momentan.",
|
||||||
"TryAgain": "Încercați din nou în câteva secunde",
|
"TryAgain": "Încercați din nou în câteva secunde",
|
||||||
"Retry": "Reîncercați"
|
"Retry": "Reîncercați",
|
||||||
|
"CheckingServerHealth": "Se verifică starea serverului..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ export default function App() {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter basename={process.env.PUBLIC_URL || ""}>
|
<BrowserRouter basename={process.env.PUBLIC_URL || ""}>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
<Route exact path="/" render={() => <Redirect to="/dashboard" />} />
|
||||||
<PrivateRoute
|
<PrivateRoute
|
||||||
path="/server-not-available"
|
path="/server-not-available"
|
||||||
component={ServerNotAvailable}
|
component={ServerNotAvailable}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import React from "react";
|
||||||
|
import useStyles from "../styles";
|
||||||
|
import { Grid, Typography } from "@material-ui/core";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import classnames from "classnames";
|
||||||
|
|
||||||
|
const CheckingServerHealth = () => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Grid container className={classnames(classes.container, classes.success)}>
|
||||||
|
<Typography
|
||||||
|
variant="h1"
|
||||||
|
className={classnames(classes.textRow, classes.singleText)}
|
||||||
|
>
|
||||||
|
{t("ServerAvailability.CheckingServerHealth")}
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CheckingServerHealth;
|
|
@ -11,7 +11,7 @@ const ServerNotAvailable = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container className={classes.container}>
|
<Grid container className={classnames(classes.container, classes.error)}>
|
||||||
<Paper classes={{ root: classes.paperRoot }}>
|
<Paper classes={{ root: classes.paperRoot }}>
|
||||||
<div className={classes.imageFrame}>
|
<div className={classes.imageFrame}>
|
||||||
<img
|
<img
|
||||||
|
|
|
@ -8,11 +8,16 @@ export default makeStyles((theme) => ({
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
backgroundColor: theme.palette.error.dark,
|
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0
|
left: 0
|
||||||
},
|
},
|
||||||
|
error: {
|
||||||
|
backgroundColor: theme.palette.error.dark
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
backgroundColor: theme.palette.success.light
|
||||||
|
},
|
||||||
imageFrame: {
|
imageFrame: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
@ -41,6 +46,10 @@ export default makeStyles((theme) => ({
|
||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
color: theme.palette.text.hint
|
color: theme.palette.text.hint
|
||||||
},
|
},
|
||||||
|
singleText: {
|
||||||
|
fontWeight: 300,
|
||||||
|
color: theme.palette.info.main
|
||||||
|
},
|
||||||
button: {
|
button: {
|
||||||
backgroundColor: theme.palette.error.dark,
|
backgroundColor: theme.palette.error.dark,
|
||||||
textTransform: "none",
|
textTransform: "none",
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { Redirect } from "react-router-dom";
|
import { Redirect } from "react-router-dom";
|
||||||
import { useServerApi } from "../api";
|
import { useServerApi } from "../api";
|
||||||
|
import CheckingServerHealth from "../availability/components/CheckingServerHealth";
|
||||||
|
|
||||||
const ServerAvailabilityProvider = ({ children }) => {
|
const ServerAvailabilityProvider = ({ children }) => {
|
||||||
const [ok, setOk] = useState(null);
|
const [ok, setOk] = useState(null);
|
||||||
|
@ -14,7 +15,7 @@ const ServerAvailabilityProvider = ({ children }) => {
|
||||||
});
|
});
|
||||||
}, [checkHealth]);
|
}, [checkHealth]);
|
||||||
|
|
||||||
if (ok === null) return <span>Checking server health...</span>;
|
if (ok === null) return <CheckingServerHealth />;
|
||||||
if (ok === false) return <Redirect to="/server-not-available" />;
|
if (ok === false) return <Redirect to="/server-not-available" />;
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue