From aecf16ba406c4f22ef667227f0e3156baafd0730 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Mon, 11 Aug 2025 17:33:08 +0700 Subject: [PATCH] Fix: Correctly update notification status - This fix ensures that when the notification status is enabled. Resolves the issue where the status was incorrectly shown as false in PB. --- .../components/servers/EditServerDialog.tsx | 39 +++++++++++-------- application/src/types/server.types.ts | 2 + 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/application/src/components/servers/EditServerDialog.tsx b/application/src/components/servers/EditServerDialog.tsx index d7b4bcf..1bc6d4a 100644 --- a/application/src/components/servers/EditServerDialog.tsx +++ b/application/src/components/servers/EditServerDialog.tsx @@ -1,3 +1,4 @@ + import React, { useState, useEffect } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; @@ -25,7 +26,7 @@ interface EditServerDialogProps { interface ServerFormData { name: string; check_interval: number; - retry_attempts: number; + max_retries: number; docker_monitoring: boolean; notification_enabled: boolean; notification_channels: string[]; // Changed to array for multiple selections @@ -49,7 +50,7 @@ export const EditServerDialog: React.FC = ({ const [formData, setFormData] = useState({ name: "", check_interval: 60, - retry_attempts: 3, + max_retries: 3, docker_monitoring: false, notification_enabled: false, notification_channels: [], // Changed to array @@ -86,9 +87,9 @@ export const EditServerDialog: React.FC = ({ setFormData({ name: server.name || "", check_interval: server.check_interval || 60, - retry_attempts: 3, + max_retries: server.max_retries || 3, docker_monitoring: server.docker === "true", - notification_enabled: notificationChannels.length > 0, + notification_enabled: server.notification_status === true, notification_channels: notificationChannels, threshold_id: server.threshold_id || "none", template_id: server.template_id || "none", @@ -237,7 +238,9 @@ export const EditServerDialog: React.FC = ({ const updateData = { name: formData.name, check_interval: formData.check_interval, + max_retries: formData.max_retries, docker: formData.docker_monitoring ? "true" : "false", + notification_status: formData.notification_enabled, notification_id: notificationChannelsString, threshold_id: formData.notification_enabled && formData.threshold_id !== "none" ? formData.threshold_id : "", template_id: formData.notification_enabled && formData.template_id !== "none" ? formData.template_id : "", @@ -251,7 +254,7 @@ export const EditServerDialog: React.FC = ({ try { const updateThresholdData = { cpu_threshold: thresholdFormData.cpu_threshold, - ram_threshold_message: thresholdFormData.ram_threshold, // Use the correct field name + ram_threshold_message: thresholdFormData.ram_threshold, disk_threshold: thresholdFormData.disk_threshold, network_threshold: thresholdFormData.network_threshold, }; @@ -308,9 +311,9 @@ export const EditServerDialog: React.FC = ({ setFormData({ name: server.name || "", check_interval: server.check_interval || 60, - retry_attempts: 3, + max_retries: server.max_retries || 3, docker_monitoring: server.docker === "true", - notification_enabled: notificationChannels.length > 0, + notification_enabled: server.notification_status === true, notification_channels: notificationChannels, threshold_id: server.threshold_id || "none", template_id: server.template_id || "none", @@ -359,20 +362,20 @@ export const EditServerDialog: React.FC = ({
- +
@@ -668,4 +671,6 @@ export const EditServerDialog: React.FC = ({ ); -}; \ No newline at end of file +}; + +export default EditServerDialog; \ No newline at end of file diff --git a/application/src/types/server.types.ts b/application/src/types/server.types.ts index 90e0f2b..fad7360 100644 --- a/application/src/types/server.types.ts +++ b/application/src/types/server.types.ts @@ -21,6 +21,8 @@ export interface Server { template_id: string; threshold_id: string; notification_id: string; + notification_status: boolean; + max_retries: number; timestamp: string; connection: string; agent_status: string;