From b651369dc538e2d7d4ed87ff3aaddf42e70ef0a0 Mon Sep 17 00:00:00 2001 From: Shemy Gan Date: Thu, 5 Dec 2024 10:34:41 -0500 Subject: [PATCH] - WIP Server list tab --- .../Inputs/TextInput/Adornments/index.jsx | 38 +++++ .../TabPanels/Status/ContentPanel.jsx | 133 ++++++++++++++++++ .../TabPanels/Status/Server/index.jsx | 21 +++ 3 files changed, 192 insertions(+) create mode 100644 Client/src/Components/TabPanels/Status/ContentPanel.jsx create mode 100644 Client/src/Components/TabPanels/Status/Server/index.jsx diff --git a/Client/src/Components/Inputs/TextInput/Adornments/index.jsx b/Client/src/Components/Inputs/TextInput/Adornments/index.jsx index 686db183b..a89500bda 100644 --- a/Client/src/Components/Inputs/TextInput/Adornments/index.jsx +++ b/Client/src/Components/Inputs/TextInput/Adornments/index.jsx @@ -4,6 +4,9 @@ import { useState } from "react"; import PropTypes from "prop-types"; import VisibilityOff from "@mui/icons-material/VisibilityOff"; import Visibility from "@mui/icons-material/Visibility"; +import Docs from "../../../../assets/icons/docs.svg?react"; +import DeleteTwoToneIcon from '@mui/icons-material/DeleteTwoTone'; + export const HttpAdornment = ({ https }) => { const theme = useTheme(); return ( @@ -63,3 +66,38 @@ PasswordEndAdornment.propTypes = { fieldType: PropTypes.string, setFieldType: PropTypes.func, }; + +export const ServerStartAdornment = () => { + return ( + + + + ); +}; + + +export const ServerEndAdornment = ({ id, removeItem }) => { + const theme = useTheme(); + return ( + + removeItem(id)} + sx={{ + color: theme.palette.border.dark, + padding: theme.spacing(1), + "&:focus-visible": { + outline: `2px solid ${theme.palette.primary.main}`, + outlineOffset: `2px`, + }, + "& .MuiTouchRipple-root": { + pointerEvents: "none", + display: "none", + }, + }} + > + + + + ); +}; diff --git a/Client/src/Components/TabPanels/Status/ContentPanel.jsx b/Client/src/Components/TabPanels/Status/ContentPanel.jsx new file mode 100644 index 000000000..73fcc968f --- /dev/null +++ b/Client/src/Components/TabPanels/Status/ContentPanel.jsx @@ -0,0 +1,133 @@ +import { useState } from "react"; +import { Button, Box, Stack, Typography } from "@mui/material"; +import { ConfigBox } from "../../../Pages/Settings/styled"; +import { useTheme } from "@emotion/react"; +import TabPanel from "@mui/lab/TabPanel"; +import { + publicPageGeneralSettingsValidation, +} from "../../../Validation/validation"; +import { buildErrors } from "../../../Validation/error"; +import { hasValidationErrors } from "../../../Validation/error"; +import Server from "./Server" +const ContentPanel = () => { + const theme = useTheme(); + const [errors, setErrors] = useState({}); + // Local state for form data, errors, and file handling + const [localData, setLocalData] = useState({ + monitors: [] + }); + // Clears specific error from errors state + const clearError = (err) => { + setErrors((prev) => { + const updatedErrors = { ...prev }; + if (updatedErrors[err]) delete updatedErrors[err]; + return updatedErrors; + }); + }; + + const handleChange = (event) => { + event.preventDefault(); + const { value, id } = event.target; + setLocalData((prev) => ({ + ...prev, + [id]: value, + })); + }; + + const handleSubmit = () => { + if (hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)) { + return; + } + }; + + const handleBlur = (event) => { + event.preventDefault(); + const { value, id } = event.target; + const { error } = publicPageGeneralSettingsValidation.validate( + { [id]: value }, + { + abortEarly: false, + } + ); + + setErrors((prev) => { + return buildErrors(prev, id, error); + }); + }; + + return ( + + + + + + Status page servers + + You can add any number of servers that you monitor to your status page. + You can also reorder them for the best viewing experience. + + + + + + + {" "} + Servers list{" "} + + + + + + + + + + + + + ); +}; + +export default ContentPanel; diff --git a/Client/src/Components/TabPanels/Status/Server/index.jsx b/Client/src/Components/TabPanels/Status/Server/index.jsx new file mode 100644 index 000000000..2c6d6fc75 --- /dev/null +++ b/Client/src/Components/TabPanels/Status/Server/index.jsx @@ -0,0 +1,21 @@ +import TextInput from "../../../Inputs/TextInput"; +import { ServerStartAdornment, ServerEndAdornment } from "../../../Inputs/TextInput/Adornments"; + + +const Server = ({ id, removeItem }) => { + return ( + } + endAdornment={ + + } + id={id} + > + ); +}; + +export default Server; \ No newline at end of file