diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/common.json similarity index 98% rename from frontend/public/locales/en/translation.json rename to frontend/public/locales/en/common.json index 7208646..a6e25f2 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/common.json @@ -56,5 +56,6 @@ "multicastLimit": "Multicast Recipient Limit", "enaBroadcast": "Enable Broadcast", "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" } diff --git a/frontend/public/locales/es/translation.json b/frontend/public/locales/es-ES/common.json similarity index 97% rename from frontend/public/locales/es/translation.json rename to frontend/public/locales/es-ES/common.json index a636135..eb70d23 100644 --- a/frontend/public/locales/es/translation.json +++ b/frontend/public/locales/es-ES/common.json @@ -56,5 +56,6 @@ "multicastLimit": "Límite de destinatarios multicast", "enaBroadcast": "Habilitar broadcast", "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" } diff --git a/frontend/public/locales/es-ES/translation.json b/frontend/public/locales/es-ES/translation.json deleted file mode 100644 index 8d16e37..0000000 --- a/frontend/public/locales/es-ES/translation.json +++ /dev/null @@ -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" -} diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 04c9dc1..9142994 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -8,6 +8,7 @@ import Bar from "./components/Bar"; import Home from "./routes/Home"; import NotFound from "./routes/NotFound"; import Network from "./routes/Network/Network"; +import Settings from "./routes/Settings"; function App() { return ( @@ -17,6 +18,7 @@ function App() { + diff --git a/frontend/src/components/Bar/Bar.jsx b/frontend/src/components/Bar/Bar.jsx index 3de2252..e27b56c 100644 --- a/frontend/src/components/Bar/Bar.jsx +++ b/frontend/src/components/Bar/Bar.jsx @@ -48,7 +48,7 @@ function Bar() { const menuItems = [ // TODO: add settings page { - name: "Settings", + name: t("settings"), to: "/settings", }, ...(!disabledAuth diff --git a/frontend/src/components/SettingsComponent/SettingsComponent.jsx b/frontend/src/components/SettingsComponent/SettingsComponent.jsx new file mode 100644 index 0000000..12aabe4 --- /dev/null +++ b/frontend/src/components/SettingsComponent/SettingsComponent.jsx @@ -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 ( + + }> + {t("language")} + + + + + + + + ); +} + +export default SettingsComponent; diff --git a/frontend/src/components/SettingsComponent/index.jsx b/frontend/src/components/SettingsComponent/index.jsx new file mode 100644 index 0000000..88ef994 --- /dev/null +++ b/frontend/src/components/SettingsComponent/index.jsx @@ -0,0 +1 @@ +export { default } from "./SettingsComponent"; diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 89e0dee..1cf038f 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -21,12 +21,12 @@ i18n react: { useSuspense: false, }, - supportedLngs: ["en", "es", "es-ES"], + supportedLngs: ["en", "es-ES"], backend: { loadPath: "/locales/{{lng}}/{{ns}}.json", }, - ns: ["translation"], - defaultNS: "translation", + ns: ["common"], + defaultNS: "common", }); export default i18n; diff --git a/frontend/src/routes/Settings/Settings.jsx b/frontend/src/routes/Settings/Settings.jsx new file mode 100644 index 0000000..b97e5bf --- /dev/null +++ b/frontend/src/routes/Settings/Settings.jsx @@ -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 ( + <> +
+ + + {t("settings")} + +
+
+ +
+ + ); + } else { + return ( + + + + You are not authorized. Please Log In + + + + ); + } +} + +export default Settings; diff --git a/frontend/src/routes/Settings/Settings.styles.jsx b/frontend/src/routes/Settings/Settings.styles.jsx new file mode 100644 index 0000000..ac884a7 --- /dev/null +++ b/frontend/src/routes/Settings/Settings.styles.jsx @@ -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; diff --git a/frontend/src/routes/Settings/index.jsx b/frontend/src/routes/Settings/index.jsx new file mode 100644 index 0000000..41d6622 --- /dev/null +++ b/frontend/src/routes/Settings/index.jsx @@ -0,0 +1 @@ +export { default } from "./Settings";