- WIP contents tab adding servers list
This commit is contained in:
1 parent
cbec5fd25c
commit
2825ff4019
3 files changed
+55
-22
No files matched your search
@@ -1,11 +1,10 @@
|
|||||||
import { Stack, Typography, InputAdornment, IconButton } from "@mui/material";
|
import { Stack, Typography, InputAdornment, IconButton } from "@mui/material";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useState } from "react";
|
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import VisibilityOff from "@mui/icons-material/VisibilityOff";
|
import VisibilityOff from "@mui/icons-material/VisibilityOff";
|
||||||
import Visibility from "@mui/icons-material/Visibility";
|
import Visibility from "@mui/icons-material/Visibility";
|
||||||
import Docs from "../../../../assets/icons/docs.svg?react";
|
import Docs from "../../../../assets/icons/docs.svg?react";
|
||||||
import DeleteTwoToneIcon from '@mui/icons-material/DeleteTwoTone';
|
import DeleteIcon from "../../../../assets/icons/trash-bin.svg?react";
|
||||||
|
|
||||||
export const HttpAdornment = ({ https }) => {
|
export const HttpAdornment = ({ https }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -96,7 +95,7 @@ export const ServerEndAdornment = ({ id, removeItem }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DeleteTwoToneIcon/>
|
<DeleteIcon/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -40,6 +40,17 @@ const ContentPanel = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAddNew = () => {
|
||||||
|
let arr = localData.monitors;
|
||||||
|
arr.push({ id: "" + Math.random() });
|
||||||
|
setLocalData({ ...localData, monitors: arr });
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeItem = (id) =>{
|
||||||
|
const currentMonitors = localData.monitors.filter(m => m.id !=id)
|
||||||
|
setLocalData({...localData, monitors: currentMonitors})
|
||||||
|
}
|
||||||
|
|
||||||
const handleBlur = (event) => {
|
const handleBlur = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
@@ -82,9 +93,9 @@ const ContentPanel = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
className="status-contents-server-list"
|
className="status-contents-server-list"
|
||||||
sx={{
|
sx={{
|
||||||
height: "fit-content",
|
height: "fit-content",
|
||||||
border: "solid",
|
border: "solid",
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
@@ -94,22 +105,44 @@ const ContentPanel = () => {
|
|||||||
"&:hover": {
|
"&:hover": {
|
||||||
borderColor: theme.palette.primary.main,
|
borderColor: theme.palette.primary.main,
|
||||||
backgroundColor: "hsl(215, 87%, 51%, 0.05)",
|
backgroundColor: "hsl(215, 87%, 51%, 0.05)",
|
||||||
}
|
},
|
||||||
}}>
|
}}
|
||||||
<Stack
|
>
|
||||||
direction="row"
|
<Box>
|
||||||
justifyContent="space-around"
|
<Stack
|
||||||
>
|
direction="row"
|
||||||
<Typography
|
justifyContent="space-around"
|
||||||
component="p"
|
|
||||||
alignSelf={"center"}
|
|
||||||
>
|
>
|
||||||
{" "}
|
<Typography
|
||||||
Servers list{" "}
|
component="p"
|
||||||
</Typography>
|
alignSelf={"center"}
|
||||||
<Button>Add New</Button>
|
>
|
||||||
</Stack>
|
{" "}
|
||||||
<Server id="id"/>
|
Servers list{" "}
|
||||||
|
</Typography>
|
||||||
|
<Button onClick={handleAddNew}>Add New</Button>
|
||||||
|
</Stack>
|
||||||
|
{localData.monitors.length > 0 && (
|
||||||
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
sx={{ml: theme.spacing(4),
|
||||||
|
mr: theme.spacing(8),
|
||||||
|
mb: theme.spacing(8)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{localData.monitors.map((m, idx) => (
|
||||||
|
<Server
|
||||||
|
key={idx}
|
||||||
|
id={m.id ?? "" + Math.random()}
|
||||||
|
removeItem={removeItem}
|
||||||
|
value={m.url}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import TextInput from "../../../Inputs/TextInput";
|
|||||||
import { ServerStartAdornment, ServerEndAdornment } from "../../../Inputs/TextInput/Adornments";
|
import { ServerStartAdornment, ServerEndAdornment } from "../../../Inputs/TextInput/Adornments";
|
||||||
|
|
||||||
|
|
||||||
const Server = ({ id, removeItem }) => {
|
const Server = ({ id, removeItem, value }) => {
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
type="text"
|
type="text"
|
||||||
@@ -14,6 +14,7 @@ const Server = ({ id, removeItem }) => {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
id={id}
|
id={id}
|
||||||
|
value= {value}
|
||||||
></TextInput>
|
></TextInput>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user