From 2d2bd790b0ba022262bac2bb00f3556985902cbc Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Thu, 10 Jul 2025 22:14:17 +0700 Subject: [PATCH] Disable the debug console logs for production --- application/src/api/index.ts | 10 +-- application/src/api/settings/index.ts | 4 +- .../src/components/dashboard/Header.tsx | 4 +- .../ScheduleIncidentContent.tsx | 8 +-- .../hooks/useIncidentData.ts | 20 +++--- .../MaintenanceNotificationSettingsField.tsx | 40 ++++++------ .../form/config/AssignedUsersField.tsx | 20 +++--- .../hooks/useRealTimeUpdates.tsx | 12 ++-- .../hooks/useServiceData.tsx | 36 +++++------ .../services/ServiceMonitoringButton.tsx | 8 +-- .../src/components/services/UptimeBar.tsx | 6 +- .../hooks/useConsolidatedUptimeData.ts | 64 +++++++++---------- .../services/hooks/useServiceActions.ts | 8 +-- .../incident-history/LatestChecksTable.tsx | 6 +- .../services/incident-history/utils.tsx | 2 +- .../alerts-templates/TemplateDialog.tsx | 4 +- .../ssl-domain/AddSSLCertificateForm.tsx | 6 +- .../ssl-domain/EditSSLCertificateForm.tsx | 4 +- .../ssl-domain/SSLDomainContent.tsx | 24 +++---- application/src/hooks/useSystemSettings.tsx | 16 ++--- application/src/pages/Dashboard.tsx | 4 +- application/src/pages/SslDomain.tsx | 8 +-- .../src/services/alertConfigService.ts | 24 +++---- application/src/services/authService.ts | 14 ++-- .../src/services/incident/incidentCache.ts | 4 +- .../src/services/incident/incidentFetch.ts | 20 +++--- .../maintenanceNotificationService.ts | 30 ++++----- .../service-status/startAllServices.ts | 4 +- .../service-status/startMonitoring.ts | 14 ++-- application/src/services/serviceService.ts | 2 +- .../src/services/ssl/sslFetchService.ts | 14 ++-- application/src/services/uptimeService.ts | 40 ++++++------ application/src/services/userService.ts | 60 ++++++++--------- 33 files changed, 270 insertions(+), 270 deletions(-) diff --git a/application/src/api/index.ts b/application/src/api/index.ts index c4f7f62..1fa86b7 100644 --- a/application/src/api/index.ts +++ b/application/src/api/index.ts @@ -11,19 +11,19 @@ const api = { * Handle API requests */ async handleRequest(path, method, body) { - console.log(`API request: ${method} ${path}`, body); + // console.log(`API request: ${method} ${path}`, body); // Route to the appropriate handler if (path === '/api/realtime') { - console.log("Routing to realtime handler"); + // console.log("Routing to realtime handler"); return await realtime(body); } else if (path === '/api/settings' || path.startsWith('/api/settings/')) { - console.log("Routing to settings handler"); + // console.log("Routing to settings handler"); return await settingsApi(body, path); } // Return 404 for unknown routes - console.error(`Endpoint not found: ${path}`); + // console.error(`Endpoint not found: ${path}`); return { status: 404, json: { @@ -40,7 +40,7 @@ const originalFetch = window.fetch; window.fetch = async (url, options = {}) => { // Check if this is an API request to our mock endpoints if (typeof url === 'string' && url.startsWith('/api/')) { - console.log('Intercepting API request:', url, options); + // console.log('Intercepting API request:', url, options); try { let body = {}; diff --git a/application/src/api/settings/index.ts b/application/src/api/settings/index.ts index 1be26bc..50d2b7d 100644 --- a/application/src/api/settings/index.ts +++ b/application/src/api/settings/index.ts @@ -8,7 +8,7 @@ import { testEmail } from './actions/testEmail'; * Settings API handler */ const settingsApi = async (body: any, path?: string) => { - console.log('Settings API called with path:', path, 'body:', body); + // console.log('Settings API called with path:', path, 'body:', body); // Handle test email endpoint specifically if (path === '/api/settings/test/email') { @@ -18,7 +18,7 @@ const settingsApi = async (body: any, path?: string) => { // Handle regular settings API with action-based routing const action = body?.action; - console.log('Settings API called with action:', action, 'data:', body?.data); + // console.log('Settings API called with action:', action, 'data:', body?.data); switch (action) { case 'getSettings': diff --git a/application/src/components/dashboard/Header.tsx b/application/src/components/dashboard/Header.tsx index bc98045..0e0815d 100644 --- a/application/src/components/dashboard/Header.tsx +++ b/application/src/components/dashboard/Header.tsx @@ -53,7 +53,7 @@ export const Header = ({ // Log avatar data for debugging useEffect(() => { if (currentUser) { - console.log("Avatar URL in Header:", currentUser.avatar); + // console.log("Avatar URL in Header:", currentUser.avatar); } }, [currentUser]); @@ -66,7 +66,7 @@ export const Header = ({ } else { avatarUrl = currentUser.avatar; } - console.log("Final avatar URL:", avatarUrl); + // console.log("Final avatar URL:", avatarUrl); } return ( diff --git a/application/src/components/schedule-incident/ScheduleIncidentContent.tsx b/application/src/components/schedule-incident/ScheduleIncidentContent.tsx index a3b8422..05ee42a 100644 --- a/application/src/components/schedule-incident/ScheduleIncidentContent.tsx +++ b/application/src/components/schedule-incident/ScheduleIncidentContent.tsx @@ -22,12 +22,12 @@ export const ScheduleIncidentContent = () => { // Initialize maintenance notifications when the component mounts useEffect(() => { - console.log("Initializing maintenance notifications"); + // console.log("Initializing maintenance notifications"); initMaintenanceNotifications(); // Clean up when the component unmounts return () => { - console.log("Cleaning up maintenance notifications"); + // console.log("Cleaning up maintenance notifications"); stopMaintenanceNotifications(); }; }, []); @@ -43,7 +43,7 @@ export const ScheduleIncidentContent = () => { const handleMaintenanceCreated = () => { // Refresh data by incrementing the refresh trigger const newTriggerValue = refreshTrigger + 1; - console.log("Maintenance created, refreshing data with new trigger value:", newTriggerValue); + // console.log("Maintenance created, refreshing data with new trigger value:", newTriggerValue); setRefreshTrigger(newTriggerValue); // Show success toast @@ -56,7 +56,7 @@ export const ScheduleIncidentContent = () => { const handleIncidentCreated = () => { // Refresh data by incrementing the refresh trigger const newTriggerValue = incidentRefreshTrigger + 1; - console.log("Incident created, refreshing data with new trigger value:", newTriggerValue); + // console.log("Incident created, refreshing data with new trigger value:", newTriggerValue); setIncidentRefreshTrigger(newTriggerValue); // Show success toast diff --git a/application/src/components/schedule-incident/hooks/useIncidentData.ts b/application/src/components/schedule-incident/hooks/useIncidentData.ts index d6b32cb..2e0a998 100644 --- a/application/src/components/schedule-incident/hooks/useIncidentData.ts +++ b/application/src/components/schedule-incident/hooks/useIncidentData.ts @@ -22,13 +22,13 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => const fetchIncidentData = useCallback(async (force = false) => { // Skip if already fetching if (isFetchingRef.current) { - console.log('Already fetching data, skipping additional request'); + // console.log('Already fetching data, skipping additional request'); return; } // Skip if not forced and already initialized if (initialized && !force) { - console.log('Data already initialized and no force refresh, skipping fetch'); + // console.log('Data already initialized and no force refresh, skipping fetch'); return; } @@ -46,22 +46,22 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => setError(null); try { - console.log(`Fetching incident data (force=${force})`); + // console.log(`Fetching incident data (force=${force})`); const allIncidents = await incidentService.getAllIncidents(force); if (Array.isArray(allIncidents)) { setIncidents(allIncidents); - console.log(`Successfully set ${allIncidents.length} incidents to state`); + // console.log(`Successfully set ${allIncidents.length} incidents to state`); } else { setIncidents([]); - console.warn('No incidents returned from service'); + // console.warn('No incidents returned from service'); } setInitialized(true); setLoading(false); setIsRefreshing(false); } catch (error) { - console.error('Error fetching incident data:', error); + // console.error('Error fetching incident data:', error); setError('Failed to load incident data. Please try again later.'); setIncidents([]); setInitialized(true); @@ -79,7 +79,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => useEffect(() => { // Skip if the refresh trigger hasn't changed (prevents duplicate effect calls) if (refreshTrigger === lastRefreshTriggerRef.current && initialized) { - console.log('Refresh trigger unchanged, skipping fetch'); + // console.log('Refresh trigger unchanged, skipping fetch'); return; } @@ -90,7 +90,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => const abortController = new AbortController(); let isMounted = true; - console.log(`useIncidentData effect running, refreshTrigger: ${refreshTrigger}`); + // console.log(`useIncidentData effect running, refreshTrigger: ${refreshTrigger}`); // Use a longer delay to ensure we don't trigger too many API calls const fetchTimer = setTimeout(() => { @@ -101,7 +101,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => // Cleanup function to abort any in-flight requests and clear timers return () => { - console.log('Cleaning up incident data fetch effect'); + // console.log('Cleaning up incident data fetch effect'); isMounted = false; clearTimeout(fetchTimer); abortController.abort(); @@ -112,7 +112,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) => const incidentData = useMemo(() => { if (!initialized || incidents.length === 0) return []; - console.log(`Filtering incidents by: ${filter}`); + // console.log(`Filtering incidents by: ${filter}`); if (filter === "unresolved") { return incidents.filter(item => { diff --git a/application/src/components/schedule-incident/maintenance/form/MaintenanceNotificationSettingsField.tsx b/application/src/components/schedule-incident/maintenance/form/MaintenanceNotificationSettingsField.tsx index 65174a6..9ec629a 100644 --- a/application/src/components/schedule-incident/maintenance/form/MaintenanceNotificationSettingsField.tsx +++ b/application/src/components/schedule-incident/maintenance/form/MaintenanceNotificationSettingsField.tsx @@ -27,7 +27,7 @@ export const MaintenanceNotificationSettingsField = () => { try { setIsLoading(true); const channels = await alertConfigService.getAlertConfigurations(); - console.log("Fetched notification channels for form:", channels); + // console.log("Fetched notification channels for form:", channels); // Only show enabled channels const enabledChannels = channels.filter(channel => channel.enabled); @@ -38,18 +38,18 @@ export const MaintenanceNotificationSettingsField = () => { const currentChannel = getValues('notification_channel_id'); const shouldNotify = getValues('notify_subscribers'); - console.log("Current notification values:", { - currentChannel, - shouldNotify, - availableChannels: enabledChannels.length - }); + // console.log("Current notification values:", { + // currentChannel, + // shouldNotify, + // availableChannels: enabledChannels.length + // }); if (shouldNotify && (!currentChannel || currentChannel === 'none') && enabledChannels.length > 0) { - console.log("Setting default notification channel:", enabledChannels[0].id); + // console.log("Setting default notification channel:", enabledChannels[0].id); setValue('notification_channel_id', enabledChannels[0].id); } } catch (error) { - console.error('Error fetching notification channels:', error); + // console.error('Error fetching notification channels:', error); toast({ title: t('error'), description: t('errorFetchingNotificationChannels'), @@ -64,12 +64,12 @@ export const MaintenanceNotificationSettingsField = () => { }, [t, toast, setValue, getValues]); // Log value changes for debugging - useEffect(() => { - console.log("Current notification settings:", { - channel_id: getValues('notification_channel_id'), - notify: notifySubscribers - }); - }, [notifySubscribers, notificationChannelId, getValues]); + // useEffect(() => { + // console.log("Current notification settings:", { + // channel_id: getValues('notification_channel_id'), + // notify: notifySubscribers + // }); + // }, [notifySubscribers, notificationChannelId, getValues]); return (
@@ -98,7 +98,7 @@ export const MaintenanceNotificationSettingsField = () => { checked={field.value} onCheckedChange={(checked) => { field.onChange(checked); - console.log("Notification toggle changed to:", checked); + // console.log("Notification toggle changed to:", checked); // If notifications are disabled, also clear the notification channel if (!checked) { setValue('notification_channel_id', ''); @@ -120,10 +120,10 @@ export const MaintenanceNotificationSettingsField = () => { // Make sure to handle both empty string and "none" as special cases const displayValue = field.value || ""; - console.log("Rendering notification channel field with value:", { - fieldValue: field.value, - displayValue - }); + // console.log("Rendering notification channel field with value:", { + // fieldValue: field.value, + // displayValue + // }); return ( @@ -135,7 +135,7 @@ export const MaintenanceNotificationSettingsField = () => {