2024-08-03 09:40:08 +03:30
|
|
|
|
import { Box, Stack, Typography } from "@mui/material";
|
|
|
|
|
|
import "./index.css";
|
|
|
|
|
|
import React, { useState } from "react";
|
|
|
|
|
|
import Button from "../../../Components/Button";
|
|
|
|
|
|
import Back from "../../../assets/icons/left-arrow.svg?react";
|
|
|
|
|
|
import Select from "../../../Components/Inputs/Select";
|
|
|
|
|
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
|
|
|
|
|
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
|
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
|
|
|
|
import { MobileTimePicker } from "@mui/x-date-pickers/MobileTimePicker";
|
2024-08-05 14:17:41 +03:30
|
|
|
|
import Field from "../../../Components/Inputs/Field";
|
2024-08-03 09:40:08 +03:30
|
|
|
|
|
|
|
|
|
|
const directory = {
|
|
|
|
|
|
title: "Create a maintenance window",
|
|
|
|
|
|
description: "Your pings won’t be sent in this time frame.",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const repeatOptions = [
|
|
|
|
|
|
{ _id: 1, name: "Don't repeat" },
|
|
|
|
|
|
{ _id: 2, name: "Repeat daily" },
|
|
|
|
|
|
{ _id: 3, name: "Repeat weekly" },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const configOptionTitle = (title, description) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Stack width="40%" gap={1}>
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
style={{
|
|
|
|
|
|
fontWeight: 600,
|
|
|
|
|
|
fontSize: "var(--env-var-font-size-medium)",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{title}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
{description && (
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
style={{
|
|
|
|
|
|
fontSize: "var(--env-var-font-size-small)",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{description}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-08-05 14:17:41 +03:30
|
|
|
|
const timeFrames = [
|
2024-08-06 18:22:54 +03:30
|
|
|
|
{ _id: 1, name: "seconds" },
|
|
|
|
|
|
{ _id: 2, name: "minutes" },
|
|
|
|
|
|
{ _id: 3, name: "hours" },
|
|
|
|
|
|
{ _id: 4, name: "days" },
|
2024-08-05 14:17:41 +03:30
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const sxButtons = {
|
|
|
|
|
|
width: 110,
|
|
|
|
|
|
height: 34,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-08-03 09:40:08 +03:30
|
|
|
|
const CreateNewMaintenanceWindow = () => {
|
|
|
|
|
|
const [values, setValues] = useState({
|
|
|
|
|
|
repeat: 1,
|
2024-08-05 14:17:41 +03:30
|
|
|
|
date: dayjs(),
|
|
|
|
|
|
startTime: dayjs(),
|
|
|
|
|
|
duration: {
|
2024-08-06 18:22:54 +03:30
|
|
|
|
magnitude: "",
|
|
|
|
|
|
unit: 1,
|
2024-08-05 14:17:41 +03:30
|
|
|
|
},
|
|
|
|
|
|
friendlyName: "",
|
|
|
|
|
|
AddMonitors: "",
|
2024-08-03 09:40:08 +03:30
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const handleChange = (event, name) => {
|
|
|
|
|
|
const { value } = event.target;
|
|
|
|
|
|
setValues((prev) => ({
|
|
|
|
|
|
...prev,
|
|
|
|
|
|
[name]: value,
|
|
|
|
|
|
}));
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const configOptions = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "Repeat",
|
|
|
|
|
|
component: (
|
|
|
|
|
|
<Select
|
|
|
|
|
|
onChange={(e) => handleChange(e, "repeat")}
|
|
|
|
|
|
id="repeat-mode"
|
|
|
|
|
|
items={repeatOptions}
|
|
|
|
|
|
value={values.repeat}
|
|
|
|
|
|
/>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "Date",
|
|
|
|
|
|
component: (
|
|
|
|
|
|
<LocalizationProvider
|
|
|
|
|
|
className="date-localization-provider"
|
|
|
|
|
|
dateAdapter={AdapterDayjs}
|
|
|
|
|
|
>
|
2024-08-05 14:17:41 +03:30
|
|
|
|
<DatePicker
|
|
|
|
|
|
className="date-picker"
|
|
|
|
|
|
defaultValue={values.date}
|
|
|
|
|
|
onChange={(date) =>
|
|
|
|
|
|
handleChange({ target: { value: date } }, "date")
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2024-08-03 09:40:08 +03:30
|
|
|
|
</LocalizationProvider>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "Start time",
|
|
|
|
|
|
description: "Your pings won’t be sent in this time frame.",
|
|
|
|
|
|
component: (
|
|
|
|
|
|
<LocalizationProvider
|
|
|
|
|
|
className="time-localization-provider"
|
|
|
|
|
|
dateAdapter={AdapterDayjs}
|
|
|
|
|
|
>
|
2024-08-05 14:17:41 +03:30
|
|
|
|
<MobileTimePicker
|
|
|
|
|
|
className="time-picker"
|
|
|
|
|
|
defaultValue={values.startTime}
|
|
|
|
|
|
onChange={(time) =>
|
|
|
|
|
|
handleChange({ target: { value: time } }, "startTime")
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2024-08-03 09:40:08 +03:30
|
|
|
|
</LocalizationProvider>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
2024-08-05 14:17:41 +03:30
|
|
|
|
{
|
|
|
|
|
|
title: "Duration",
|
|
|
|
|
|
component: (
|
|
|
|
|
|
<Stack className="duration-config" gap={2} direction="row">
|
|
|
|
|
|
<Field
|
|
|
|
|
|
id="duration-value"
|
|
|
|
|
|
placeholder="60"
|
2024-08-06 18:22:54 +03:30
|
|
|
|
onChange={(e) => handleChange(e, "duration.magnitude")}
|
|
|
|
|
|
value={values["duration.unit"]}
|
2024-08-05 14:17:41 +03:30
|
|
|
|
/>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
onChange={(e) => handleChange(e, "duration.unit")}
|
|
|
|
|
|
id="duration-unit"
|
|
|
|
|
|
items={timeFrames}
|
|
|
|
|
|
value={values.duration.unit}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "Friendly name",
|
|
|
|
|
|
component: (
|
|
|
|
|
|
<Field
|
|
|
|
|
|
id="friendly-name"
|
|
|
|
|
|
placeholder="Maintanence at __ : __ for ___ minutes"
|
|
|
|
|
|
value={values.friendlyName}
|
|
|
|
|
|
onChange={(e) => handleChange(e, "friendlyName")}
|
|
|
|
|
|
/>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "Add monitors",
|
|
|
|
|
|
component: (
|
2024-08-06 18:22:54 +03:30
|
|
|
|
<Stack
|
|
|
|
|
|
className="add-monitors-fields"
|
|
|
|
|
|
sx={{ width: "60%", maxWidth: "380px" }}
|
|
|
|
|
|
gap={2}
|
|
|
|
|
|
>
|
2024-08-05 14:17:41 +03:30
|
|
|
|
<Field
|
|
|
|
|
|
id="add-monitors"
|
|
|
|
|
|
placeholder="Start typing to search for current monitors"
|
|
|
|
|
|
value={values.AddMonitors}
|
|
|
|
|
|
onChange={(e) => handleChange(e, "AddMonitors")}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
2024-08-05 21:41:28 +03:30
|
|
|
|
width: "fit-content",
|
2024-08-05 14:17:41 +03:30
|
|
|
|
fontSize: "var(--env-var-font-size-small)",
|
|
|
|
|
|
borderBottom: "1px dashed var(--env-var-color-3)",
|
2024-08-05 21:25:21 +03:30
|
|
|
|
paddingBottom: "4px",
|
2024-08-05 14:17:41 +03:30
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
Add all monitors to this maintenance window
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
2024-08-03 09:40:08 +03:30
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="create-maintenance-window">
|
|
|
|
|
|
<Stack gap={3}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
id="btn-back"
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
width: "100px",
|
|
|
|
|
|
height: "30px",
|
|
|
|
|
|
gap: "10px",
|
|
|
|
|
|
backgroundColor: "var(--env-var-color-32)",
|
|
|
|
|
|
color: "var(--env-var-color-5)",
|
|
|
|
|
|
}}
|
|
|
|
|
|
label="Back"
|
|
|
|
|
|
level="tertiary"
|
|
|
|
|
|
img={<Back />}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Box>
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
fontSize: "var(--env-var-font-size-large)",
|
|
|
|
|
|
fontWeight: "600",
|
|
|
|
|
|
color: "var(--env-var-color-5)",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{directory.title}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
|
|
|
|
<Typography sx={{ fontSize: "var(--env-var-font-size-medium)" }}>
|
|
|
|
|
|
{directory.description}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
<Stack
|
2024-08-05 14:17:41 +03:30
|
|
|
|
className="maintenance-options"
|
2024-08-03 09:40:08 +03:30
|
|
|
|
gap={5}
|
|
|
|
|
|
paddingY={4}
|
|
|
|
|
|
paddingX={8}
|
2024-08-05 14:17:41 +03:30
|
|
|
|
paddingBottom={10}
|
2024-08-03 09:40:08 +03:30
|
|
|
|
sx={{
|
|
|
|
|
|
border: "1px solid var(--env-var-color-16)",
|
|
|
|
|
|
borderRadius: "var(--env-var-radius-1)",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{configOptions.map((item, index) => (
|
|
|
|
|
|
<Stack key={index} display="-webkit-inline-box">
|
2024-08-05 14:17:41 +03:30
|
|
|
|
{item.title && configOptionTitle(item.title, item.description)}
|
2024-08-03 09:40:08 +03:30
|
|
|
|
{item.component && item.component}
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Stack>
|
2024-08-05 14:17:41 +03:30
|
|
|
|
<Stack justifyContent="end" direction="row" marginTop={3}>
|
|
|
|
|
|
<Button sx={sxButtons} level="tertiary" label="Cancel" />
|
|
|
|
|
|
<Button sx={sxButtons} level="primary" label="Create" />
|
|
|
|
|
|
</Stack>
|
2024-08-03 09:40:08 +03:30
|
|
|
|
</Stack>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default CreateNewMaintenanceWindow;
|