mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-06 04:51:44 -07:00
feat: i18n add settings page
This commit is contained in:
parent
61fd0e7186
commit
48485fc546
11 changed files with 128 additions and 23 deletions
|
@ -56,5 +56,6 @@
|
||||||
"multicastLimit": "Multicast Recipient Limit",
|
"multicastLimit": "Multicast Recipient Limit",
|
||||||
"enaBroadcast": "Enable Broadcast",
|
"enaBroadcast": "Enable Broadcast",
|
||||||
"logInFailed": "Invalid username or password",
|
"logInFailed": "Invalid username or password",
|
||||||
"tooManyAttemps": "Too many login attempts, please try again in 15 minutes."
|
"tooManyAttemps": "Too many login attempts, please try again in 15 minutes.",
|
||||||
|
"language": "Language"
|
||||||
}
|
}
|
|
@ -56,5 +56,6 @@
|
||||||
"multicastLimit": "Límite de destinatarios multicast",
|
"multicastLimit": "Límite de destinatarios multicast",
|
||||||
"enaBroadcast": "Habilitar broadcast",
|
"enaBroadcast": "Habilitar broadcast",
|
||||||
"logInFailed": "Nombre de usuario o contraseña incorrecto",
|
"logInFailed": "Nombre de usuario o contraseña incorrecto",
|
||||||
"tooManyAttemps": "Demasiados intentos de inicio de sesión. Vuelvee a intentarlo en 15 minutos"
|
"tooManyAttemps": "Demasiados intentos de inicio de sesión. Vuelvee a intentarlo en 15 minutos",
|
||||||
|
"language": "Idioma"
|
||||||
}
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"flowRules": "Reglas de flujo",
|
|
||||||
"createNetwork": "Crear una red",
|
|
||||||
"controllerNetworks": "Controlador de redes",
|
|
||||||
"network_one": "Red",
|
|
||||||
"network_other": "Redes",
|
|
||||||
"controllerAddress": "Dirección del controlador",
|
|
||||||
"loginToContinue": "Por favor, inicia sesión para continuar",
|
|
||||||
"zerouiDesc": "ZeroUI - ZeroTier Controller Web UI - es una interfaz de usuario web para un controlador de red ZeroTier self-hosted.",
|
|
||||||
"logIn": "Iniciar sesión",
|
|
||||||
"cancel": "Cancelar",
|
|
||||||
"management": "Gestión",
|
|
||||||
"deleteNetwork": "Borrar red",
|
|
||||||
"deleteAlert": "Esta acción no puede ser revertida.",
|
|
||||||
"deleteNetworkConfirm": "¿Seguro que deseas borrar la red?",
|
|
||||||
"delete": "Borrar"
|
|
||||||
}
|
|
|
@ -8,6 +8,7 @@ import Bar from "./components/Bar";
|
||||||
import Home from "./routes/Home";
|
import Home from "./routes/Home";
|
||||||
import NotFound from "./routes/NotFound";
|
import NotFound from "./routes/NotFound";
|
||||||
import Network from "./routes/Network/Network";
|
import Network from "./routes/Network/Network";
|
||||||
|
import Settings from "./routes/Settings";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
@ -17,6 +18,7 @@ function App() {
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" component={Home} />
|
<Route exact path="/" component={Home} />
|
||||||
<Route path="/network/:nwid" component={Network} />
|
<Route path="/network/:nwid" component={Network} />
|
||||||
|
<Route path="/settings" component={Settings} />
|
||||||
<Route path="/404" component={NotFound} />
|
<Route path="/404" component={NotFound} />
|
||||||
<Redirect to="/404" />
|
<Redirect to="/404" />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
|
@ -48,7 +48,7 @@ function Bar() {
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
// TODO: add settings page
|
// TODO: add settings page
|
||||||
{
|
{
|
||||||
name: "Settings",
|
name: t("settings"),
|
||||||
to: "/settings",
|
to: "/settings",
|
||||||
},
|
},
|
||||||
...(!disabledAuth
|
...(!disabledAuth
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import {
|
||||||
|
Accordion,
|
||||||
|
AccordionSummary,
|
||||||
|
AccordionDetails,
|
||||||
|
Checkbox,
|
||||||
|
Divider,
|
||||||
|
Grid,
|
||||||
|
Typography,
|
||||||
|
TextField,
|
||||||
|
Select,
|
||||||
|
} from "@material-ui/core";
|
||||||
|
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
|
||||||
|
|
||||||
|
import API from "utils/API";
|
||||||
|
import { parseValue, replaceValue, setValue } from "utils/ChangeHelper";
|
||||||
|
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
function SettingsComponent() {
|
||||||
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
|
const handleChange = () => (event) => {
|
||||||
|
i18n.changeLanguage(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Accordion>
|
||||||
|
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
||||||
|
<Typography>{t("language")}</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails>
|
||||||
|
<Grid item>
|
||||||
|
<Select native value={i18n.language} onChange={handleChange()}>
|
||||||
|
<option value={"en"}>English</option>
|
||||||
|
<option value={"es-ES"}>Spanish</option>
|
||||||
|
</Select>
|
||||||
|
</Grid>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SettingsComponent;
|
1
frontend/src/components/SettingsComponent/index.jsx
Normal file
1
frontend/src/components/SettingsComponent/index.jsx
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default } from "./SettingsComponent";
|
|
@ -21,12 +21,12 @@ i18n
|
||||||
react: {
|
react: {
|
||||||
useSuspense: false,
|
useSuspense: false,
|
||||||
},
|
},
|
||||||
supportedLngs: ["en", "es", "es-ES"],
|
supportedLngs: ["en", "es-ES"],
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
||||||
},
|
},
|
||||||
ns: ["translation"],
|
ns: ["common"],
|
||||||
defaultNS: "translation",
|
defaultNS: "common",
|
||||||
});
|
});
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|
57
frontend/src/routes/Settings/Settings.jsx
Normal file
57
frontend/src/routes/Settings/Settings.jsx
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import { Grid, Link, Typography } from "@material-ui/core";
|
||||||
|
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
|
||||||
|
import SettingsComponent from "components/SettingsComponent";
|
||||||
|
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { Link as RouterLink, useHistory, useParams } from "react-router-dom";
|
||||||
|
import { useLocalStorage } from "react-use";
|
||||||
|
import API from "utils/API";
|
||||||
|
import useStyles from "./Settings.styles";
|
||||||
|
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
function Settings() {
|
||||||
|
const { t, i18n } = useTranslation();
|
||||||
|
const [loggedIn] = useLocalStorage("loggedIn", false);
|
||||||
|
const [network, setNetwork] = useState({});
|
||||||
|
|
||||||
|
const classes = useStyles();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
if (loggedIn) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={classes.breadcrumbs}>
|
||||||
|
<Link color="inherit" component={RouterLink} to="/" underline="none">
|
||||||
|
<ArrowBackIcon className={classes.backIcon}></ArrowBackIcon>
|
||||||
|
{t("settings")}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className={classes.container}>
|
||||||
|
<SettingsComponent />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Grid
|
||||||
|
container
|
||||||
|
spacing={0}
|
||||||
|
direction="column"
|
||||||
|
alignItems="center"
|
||||||
|
justify="center"
|
||||||
|
style={{
|
||||||
|
minHeight: "50vh",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Grid item xs={10}>
|
||||||
|
<Typography variant="h5">
|
||||||
|
You are not authorized. Please Log In
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Settings;
|
16
frontend/src/routes/Settings/Settings.styles.jsx
Normal file
16
frontend/src/routes/Settings/Settings.styles.jsx
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
backIcon: {
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
margin: "3%",
|
||||||
|
},
|
||||||
|
breadcrumbs: {
|
||||||
|
paddingTop: "2%",
|
||||||
|
paddingLeft: "2%",
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useStyles;
|
1
frontend/src/routes/Settings/index.jsx
Normal file
1
frontend/src/routes/Settings/index.jsx
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default } from "./Settings";
|
Loading…
Add table
Add a link
Reference in a new issue