diff --git a/client/src/Hooks/monitorHooks.js b/client/src/Hooks/monitorHooks.js
index eb1e7acdc..0d345324b 100644
--- a/client/src/Hooks/monitorHooks.js
+++ b/client/src/Hooks/monitorHooks.js
@@ -363,6 +363,7 @@ const useDeleteMonitor = () => {
const useUpdateMonitor = () => {
const [isLoading, setIsLoading] = useState(false);
+
const navigate = useNavigate();
const updateMonitor = async ({ monitor, redirect }) => {
try {
@@ -378,10 +379,11 @@ const useUpdateMonitor = () => {
expectedValue: monitor.expectedValue,
ignoreTlsErrors: monitor.ignoreTlsErrors,
jsonPath: monitor.jsonPath,
+ url: monitor.url,
...((monitor.type === "port" || monitor.type === "game") && {
port: monitor.port,
}),
- ...(monitor.type == "game" && {
+ ...(monitor.type === "game" && {
gameId: monitor.gameId,
}),
...(monitor.type === "hardware" && {
diff --git a/client/src/Pages/Infrastructure/Create/index.jsx b/client/src/Pages/Infrastructure/Create/index.jsx
index 28007c538..1ca025dca 100644
--- a/client/src/Pages/Infrastructure/Create/index.jsx
+++ b/client/src/Pages/Infrastructure/Create/index.jsx
@@ -76,6 +76,22 @@ const CreateInfrastructureMonitor = () => {
{ name: "Configure", path: `/infrastructure/configure/${monitorId}` },
]),
];
+ const METRICS = ["cpu", "memory", "disk", "temperature"];
+ const METRIC_PREFIX = "usage_";
+ const MS_PER_MINUTE = 60000;
+
+ const hasAlertError = (errors) => {
+ return Object.keys(errors).filter((k) => k.startsWith(METRIC_PREFIX)).length > 0;
+ };
+
+ const getAlertError = (errors) => {
+ const errorKey = Object.keys(errors).find((key) => key.startsWith(METRIC_PREFIX));
+ return errorKey ? errors[errorKey] : null;
+ };
+
+ const pageSchema = infrastructureMonitorValidation.fork(["url"], (s) =>
+ isCreate ? s.required() : s.optional()
+ );
// Populate form fields if editing
useEffect(() => {
if (isCreate) {
@@ -96,6 +112,35 @@ const CreateInfrastructureMonitor = () => {
if (error) {
return;
}
+ // Build the thresholds for the form
+ const {
+ cpu,
+ usage_cpu,
+ memory,
+ usage_memory,
+ disk,
+ usage_disk,
+ temperature,
+ usage_temperature,
+ ...rest
+ } = form;
+
+ const thresholds = {
+ ...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
+ ...(memory ? { usage_memory: usage_memory / 100 } : {}),
+ ...(disk ? { usage_disk: usage_disk / 100 } : {}),
+ ...(temperature ? { usage_temperature: usage_temperature / 100 } : {}),
+ };
+
+ form = {
+ ...(isCreate ? {} : { _id: monitorId }),
+ ...rest,
+ url: `http${https ? "s" : ""}://` + infrastructureMonitor.url,
+ description: form.name,
+ type: "hardware",
+ notifications: infrastructureMonitor.notifications,
+ thresholds,
+ };
submitInfrastructureForm(infrastructureMonitor, form, isCreate, monitorId);
};
@@ -217,31 +262,30 @@ const CreateInfrastructureMonitor = () => {
onChange={onChange}
error={errors["url"] ? true : false}
helperText={errors["url"]}
- disabled={!isCreate}
/>
- {isCreate && (
-
-
-
-
-
-
- )}
+
+
+
+
+
+
+
+