- Fix the suburl prefix via extending existing HttpAdorment

- Add the rest of content panel UI layouts
- Update the card value with onChange
This commit is contained in:
Shemy Gan committed 2024-12-10 16:07:42 -05:00
1 parent 1ab4bd7275
commit 9370db62cc
5 files changed
+55 -10

No files matched your search

@@ -2,7 +2,7 @@ import TextInput from "../../../../Inputs/TextInput";
import { ServerStartAdornment, ServerEndAdornment } from "../../../../Inputs/TextInput/Adornments";
const Server = ({ id, removeItem, value }) => {
const Server = ({ id, removeItem, value, onChange }) => {
return (
<TextInput
type="text"
@@ -15,6 +15,7 @@ const Server = ({ id, removeItem, value }) => {
}
id={id}
value= {value}
onChange ={ onChange }
></TextInput>
);
};
@@ -14,13 +14,14 @@ const CustomCard = React.forwardRef((props, ref) => (
id={props.id}
removeItem={props.removeCard}
value={props.value}
onChange={props.onChange}
/>
</CardContent>
</CardActionArea>
</Card>
));
const MyCard = ({ id, index, moveCard, removeCard, value }) => {
const MyCard = ({ id, index, moveCard, removeCard, value, onChange }) => {
const ref = useRef(null);
const [, drop] = useDrop({
accept: ItemTypes.CARD,
@@ -81,6 +82,7 @@ const MyCard = ({ id, index, moveCard, removeCard, value }) => {
id={id}
removeCard={removeCard}
value={value}
onChange={onChange}
/>
);
};
@@ -8,6 +8,7 @@ import { buildErrors } from "../../../Validation/error";
import { hasValidationErrors } from "../../../Validation/error";
import Card from "./Card";
import update from "immutability-helper";
import Checkbox from "../../Inputs/Checkbox";
const ContentPanel = () => {
const theme = useTheme();
@@ -15,6 +16,9 @@ const ContentPanel = () => {
// Local state for form data, errors, and file handling
const [localData, setLocalData] = useState({
monitors: [],
showUptimePercentage: false,
showBarcode: false
});
const [cards, setCards] = useState(localData.monitors);
@@ -52,6 +56,17 @@ const ContentPanel = () => {
}));
};
const handleCardChange = (event) => {
event.preventDefault();
const { value, id } = event.target;
let idx = cards.findIndex((a) => a.id == id);
if (idx >= 0) {
let x = JSON.parse(JSON.stringify(cards[idx]));
x.url = value;
setCards(update(cards, { $splice: [[idx, 1, x]] }));
} else setCards(update(cards, { $push: [{ id: id, url: value }] }));
}
const handleSubmit = () => {
if (hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)) {
return;
@@ -154,7 +169,8 @@ const ContentPanel = () => {
text={"" + idx}
moveCard={moveCard}
removeCard={removeCard}
value={card?.url ?? card?.id}
value={card?.url}
onChange = {handleCardChange}
/>
))}
</Stack>
@@ -162,6 +178,33 @@ const ContentPanel = () => {
</Box>
</Box>
</ConfigBox>
<ConfigBox>
<Box>
<Stack gap={theme.spacing(6)}>
<Typography component="h2">Features</Typography>
<Typography component="p">Show more details on the status page</Typography>
</Stack>
</Box>
<Stack
>
<Checkbox
id="show-barcode"
label={`Show Barcode`}
isChecked={localData.showBarcode}
value={"localData.showBarcode"}
onChange={handleChange}
onBlur={handleBlur}
/>
<Checkbox
id="show-uptime-percentage"
label={`Show Uptime Percentage`}
isChecked={localData.showUptimePercentage}
value={"localData.showUptimePercentage"}
onChange={handleChange}
onBlur={handleBlur}
/>
</Stack>
</ConfigBox>
<Stack
direction="row"
@@ -194,8 +194,7 @@ const GeneralSettingsPanel = () => {
type="url"
label="SubURL"
value={localData.url}
startAdornment={<HttpAdornment https={true} />}
//prefix={"http://uptimegenie.com/"}
startAdornment={<HttpAdornment prefix = {"http://uptimegenie.com/"} https={false} />}
onChange={handleChange}
onBlur={handleBlur}
helperText={errors["url"]}