Add advacned settings page
This commit is contained in:
1 parent
179e95eefe
commit
488ba717ac
6 files changed
+194
-45
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import { Box, Stack, Typography, Button } from "@mui/material";
|
||||
import Field from "../../Components/Inputs/Field";
|
||||
import Link from "../../Components/Link";
|
||||
import Select from "../../Components/Inputs/Select";
|
||||
@@ -13,15 +13,15 @@ import {
|
||||
deleteAllMonitors,
|
||||
} from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||
import { update } from "../../Features/Auth/authSlice";
|
||||
import { getAppSettings } from "../../Features/Settings/settingsSlice";
|
||||
import PropTypes from "prop-types";
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import { setTimezone } from "../../Features/UI/uiSlice";
|
||||
import timezones from "../../Utils/timezones.json";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { ConfigBox } from "./styled";
|
||||
import { networkService } from "../../main";
|
||||
import { settingsValidation } from "../../Validation/validation";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
const SECONDS_PER_DAY = 86400;
|
||||
|
||||
@@ -36,24 +36,9 @@ const Settings = ({ isAdmin }) => {
|
||||
const [form, setForm] = useState({
|
||||
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
|
||||
});
|
||||
const [settings, setSettings] = useState({
|
||||
apiBaseUrl: "",
|
||||
});
|
||||
const [errors, setErrors] = useState({});
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSettings = async () => {
|
||||
const action = await dispatch(getAppSettings({ authToken }));
|
||||
if (getAppSettings.fulfilled.match(action)) {
|
||||
const settings = action.payload.data;
|
||||
setSettings(settings);
|
||||
} else if (getAppSettings.rejected.match(action)) {
|
||||
throw new Error(action.error.message);
|
||||
}
|
||||
};
|
||||
fetchSettings();
|
||||
}, [dispatch, authToken]);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleChange = (event) => {
|
||||
const { value, id } = event.target;
|
||||
@@ -268,19 +253,22 @@ const Settings = ({ isAdmin }) => {
|
||||
)}
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography component="h1">Client Settings</Typography>
|
||||
<Typography component="h1">Advanced Settings</Typography>
|
||||
<Typography sx={{ mt: theme.spacing(2) }}>
|
||||
Here you can modify settings for the client.
|
||||
Click here to modify advanced settings
|
||||
</Typography>
|
||||
</Box>
|
||||
<Stack gap={theme.spacing(20)}>
|
||||
<Field
|
||||
id="apiBaseUrl"
|
||||
label="Base URL for backend API"
|
||||
value={settings.apiBaseUrl}
|
||||
onChange={handleChange}
|
||||
error={errors["settings-client-base-url"]}
|
||||
/>
|
||||
<Box>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
navigate("/advanced-settings");
|
||||
}}
|
||||
>
|
||||
Advanced Settings
|
||||
</Button>
|
||||
</Box>
|
||||
</Stack>
|
||||
</ConfigBox>
|
||||
<ConfigBox>
|
||||
|
||||
Reference in new issue
Block a user