diff --git a/Client/src/Pages/AdvancedSettings/index.css b/Client/src/Pages/AdvancedSettings/index.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/Client/src/Pages/AdvancedSettings/index.jsx b/Client/src/Pages/AdvancedSettings/index.jsx deleted file mode 100644 index 433829f28..000000000 --- a/Client/src/Pages/AdvancedSettings/index.jsx +++ /dev/null @@ -1,361 +0,0 @@ -import { useTheme } from "@emotion/react"; -import { Box, Stack, Typography } from "@mui/material"; -import TextInput from "../../Components/Inputs/TextInput"; -import Link from "../../Components/Link"; -import "./index.css"; -import { useDispatch, useSelector } from "react-redux"; -import { createToast } from "../../Utils/toastUtils"; -import PropTypes from "prop-types"; -import LoadingButton from "@mui/lab/LoadingButton"; -import { ConfigBox } from "../Settings/styled"; -import { useNavigate } from "react-router"; -import { getAppSettings, updateAppSettings } from "../../Features/Settings/settingsSlice"; -import { useState, useEffect } from "react"; -import Select from "../../Components/Inputs/Select"; -import { advancedSettingsValidation } from "../../Validation/validation"; -import { buildErrors, hasValidationErrors } from "../../Validation/error"; -import { useIsAdmin } from "../../Hooks/useIsAdmin"; - -const AdvancedSettings = () => { - const navigate = useNavigate(); - const isAdmin = useIsAdmin(); - useEffect(() => { - if (!isAdmin) { - navigate("/"); - } - }, [navigate, isAdmin]); - const [errors, setErrors] = useState({}); - const theme = useTheme(); - const { authToken } = useSelector((state) => state.auth); - const dispatch = useDispatch(); - const settings = useSelector((state) => state.settings); - const [localSettings, setLocalSettings] = useState({ - apiBaseUrl: "", - logLevel: "debug", - systemEmailHost: "", - systemEmailPort: "", - systemEmailAddress: "", - systemEmailPassword: "", - jwtTTLNum: 99, - jwtTTLUnits: "days", - jwtTTL: "99d", - dbType: "", - redisHost: "", - redisPort: "", - pagespeedApiKey: "", - }); - - const parseJWTTTL = (data) => { - if (data.jwtTTL) { - const len = data.jwtTTL.length; - data.jwtTTLNum = data.jwtTTL.substring(0, len - 1); - data.jwtTTLUnits = unitItems.filter( - (itm) => itm._id == data.jwtTTL.substring(len - 1) - )[0].name; - } - }; - - useEffect(() => { - const getSettings = async () => { - const action = await dispatch(getAppSettings({ authToken })); - if (action.payload.success) { - parseJWTTTL(action.payload.data); - setLocalSettings(action.payload.data); - } else { - createToast({ body: "Failed to get settings" }); - } - }; - getSettings(); - }, [authToken, dispatch]); - - const logItems = [ - { _id: 1, name: "none" }, - { _id: 2, name: "debug" }, - { _id: 3, name: "error" }, - { _id: 4, name: "warn" }, - ]; - - const logItemLookup = { - none: 1, - debug: 2, - error: 3, - warn: 4, - }; - - const unitItemLookup = { - days: "d", - hours: "h", - }; - const unitItems = Object.keys(unitItemLookup).map((key) => ({ - _id: unitItemLookup[key], - name: key, - })); - - const handleLogLevel = (e) => { - const id = e.target.value; - const newLogLevel = logItems.find((item) => item._id === id).name; - setLocalSettings({ ...localSettings, logLevel: newLogLevel }); - }; - - const handleJWTTTLUnits = (e) => { - const id = e.target.value; - const newUnits = unitItems.find((item) => item._id === id).name; - setLocalSettings({ ...localSettings, jwtTTLUnits: newUnits }); - }; - - const handleBlur = (event) => { - const { value, id } = event.target; - const { error } = advancedSettingsValidation.validate( - { [id]: value }, - { - abortEarly: false, - } - ); - setErrors((prev) => { - return buildErrors(prev, id, error); - }); - }; - const handleChange = (event) => { - const { value, id } = event.target; - setLocalSettings({ ...localSettings, [id]: value }); - }; - - const handleSave = async () => { - localSettings.jwtTTL = - localSettings.jwtTTLNum + unitItemLookup[localSettings.jwtTTLUnits]; - if (hasValidationErrors(localSettings, advancedSettingsValidation, setErrors)) { - return; - } - const action = await dispatch( - updateAppSettings({ settings: localSettings, authToken }) - ); - let body = ""; - if (action.payload.success) { - parseJWTTTL(action.payload.data); - setLocalSettings(action.payload.data); - body = "Settings saved successfully"; - } else { - body = "Failed to save settings"; - } - createToast({ body }); - }; - - return ( - - - - - Client settings - - Modify client settings here. - - - - - - - - - - - - - - - About - - - BlueWave Uptime v1.0.0 - - Developed by Bluewave Labs. - - - - - - - Save - - - - - ); -}; - -AdvancedSettings.propTypes = { - isAdmin: PropTypes.bool, -}; -export default AdvancedSettings; diff --git a/Client/src/Pages/Settings/index.jsx b/Client/src/Pages/Settings/index.jsx index aab9fa537..f3fcb8376 100644 --- a/Client/src/Pages/Settings/index.jsx +++ b/Client/src/Pages/Settings/index.jsx @@ -324,28 +324,7 @@ const Settings = () => { /> )} - {isAdmin && ( - - - Advanced settings - - Click here to modify advanced settings - - - - - - - - - )} + About diff --git a/Client/src/Routes/index.jsx b/Client/src/Routes/index.jsx index 784b44609..7d444f2ab 100644 --- a/Client/src/Routes/index.jsx +++ b/Client/src/Routes/index.jsx @@ -19,7 +19,6 @@ import SetNewPassword from "../Pages/Auth/SetNewPassword"; import NewPasswordConfirmed from "../Pages/Auth/NewPasswordConfirmed"; import ProtectedRoute from "../Components/ProtectedRoute"; import Details from "../Pages/Uptime/Details"; -import AdvancedSettings from "../Pages/AdvancedSettings"; import Maintenance from "../Pages/Maintenance"; import Configure from "../Pages/Uptime/Configure"; import PageSpeed from "../Pages/PageSpeed"; @@ -114,10 +113,6 @@ const Routes = () => { path="settings" element={} /> - } - /> }