- Update logo handling and validation
- Update card initialization
This commit is contained in:
1 parent
1206451989
commit
8b72f8447d
4 files changed
+41
-20
No files matched your search
@@ -38,13 +38,15 @@ const ContentPanel = () => {
|
||||
}
|
||||
const fullMonitors = response.data.data.monitors ;
|
||||
setMonitors(fullMonitors);
|
||||
if (form.monitors.length > 0)
|
||||
setCards(
|
||||
form.monitors.map((mid, idx) => ({
|
||||
id: "" + idx,
|
||||
val: fullMonitors.filter((fM) => fM._id == mid)[0],
|
||||
}))
|
||||
);
|
||||
if (form.monitors.length > 0) {
|
||||
const initiCards = form.monitors.map((mid, idx) => ({
|
||||
id: "" + idx,
|
||||
val: fullMonitors.filter((fM) =>
|
||||
mid._id ? fM._id == mid._id : fM._id == mid
|
||||
)[0],
|
||||
}));
|
||||
setCards(initiCards);
|
||||
}
|
||||
} catch (error) {
|
||||
createToast({ body: "Failed to fetch monitors data" });
|
||||
logger.error("Failed to fetch monitors", error);
|
||||
@@ -92,7 +94,7 @@ const ContentPanel = () => {
|
||||
};
|
||||
const handleAddNew = () => {
|
||||
if (cards.length === monitors.length) return;
|
||||
const newCards = [...cards, { id: "" + Math.random() }];
|
||||
const newCards = [...cards, { id: "" + Math.random(),val:{} }];
|
||||
setCards(newCards);
|
||||
};
|
||||
const removeCard = (id) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useRef, useContext } from "react";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import { Box, Button, Stack, Typography } from "@mui/material";
|
||||
import ConfigBox from "../../../Components/ConfigBox";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import TabPanel from "@mui/lab/TabPanel";
|
||||
@@ -24,8 +24,9 @@ import { StatusFormContext } from "../../../Pages/Status/CreateStatusContext";
|
||||
*/
|
||||
const GeneralSettingsPanel = () => {
|
||||
const theme = useTheme();
|
||||
const [logo, setLogo] = useState();
|
||||
const { form, setForm, errors, setErrors } = useContext(StatusFormContext);
|
||||
const [logo, setLogo] = useState(form.logo);
|
||||
|
||||
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
||||
const intervalRef = useRef(null);
|
||||
|
||||
@@ -95,6 +96,12 @@ const GeneralSettingsPanel = () => {
|
||||
type: pic.type,
|
||||
size: pic.size,
|
||||
});
|
||||
setForm({...form, logo: {
|
||||
src: URL.createObjectURL(pic),
|
||||
name: pic.name,
|
||||
type: pic.type,
|
||||
size: pic.size,
|
||||
}})
|
||||
intervalRef.current = setInterval(() => {
|
||||
const buffer = 12;
|
||||
setProgress((prev) => {
|
||||
@@ -169,7 +176,12 @@ const GeneralSettingsPanel = () => {
|
||||
type="url"
|
||||
label="SubURL"
|
||||
value={form.url}
|
||||
startAdornment={<HttpAdornment prefix = {"http://uptimegenie.com/"} https={false} />}
|
||||
startAdornment={
|
||||
<HttpAdornment
|
||||
prefix={"http://uptimegenie.com/"}
|
||||
https={false}
|
||||
/>
|
||||
}
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
helperText={errors["url"]}
|
||||
@@ -212,6 +224,19 @@ const GeneralSettingsPanel = () => {
|
||||
onClick={removeLogo}
|
||||
error={errors["logo"]}
|
||||
/>
|
||||
) : logo && logo.type ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
onClick={removeLogo}
|
||||
sx={{
|
||||
width: "100%",
|
||||
maxWidth:"200px",
|
||||
alignSelf: "center"
|
||||
}}
|
||||
>
|
||||
Remove Logo
|
||||
</Button>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user