@@ -381,40 +381,29 @@ class EngineScriptDashboard {
381381const activities = await this . getApiData ( "/api/activity/recent" , [ ] ) ;
382382const activityList = document . getElementById ( "recent-activity" ) ;
383383
384- if ( activityList && Array . isArray ( activities ) && activities . length > 0 ) {
385- // Clear existing content
386- activityList . innerHTML = "" ;
387-
388- // Validate and render each activity safely
389- activities . forEach ( ( activity ) => {
390- if ( this . isValidActivity ( activity ) ) {
391- const activityElement = this . createActivityElement ( activity ) ;
392- activityList . appendChild ( activityElement ) ;
393- }
394- } ) ;
384+ if ( activityList ) {
385+ if ( Array . isArray ( activities ) && activities . length > 0 ) {
386+ // Clear existing content
387+ activityList . innerHTML = "" ;
388+
389+ // Validate and render each activity safely
390+ activities . forEach ( ( activity ) => {
391+ if ( this . isValidActivity ( activity ) ) {
392+ const activityElement = this . createActivityElement ( activity ) ;
393+ activityList . appendChild ( activityElement ) ;
394+ }
395+ } ) ;
396+ } else {
397+ // Show empty state
398+ this . showEmptyActivity ( ) ;
399+ }
395400}
396401} catch ( error ) {
397402console . error ( 'Failed to load recent activity:' , error ) ;
398- // Show fallback message
399- const activityList = document . getElementById ( "recent-activity" ) ;
400- if ( activityList ) {
401- activityList . innerHTML = "" ;
402- const fallbackDiv = document . createElement ( "div" ) ;
403- fallbackDiv . className = "activity-item" ;
404-
405- const contentDiv = document . createElement ( "div" ) ;
406- contentDiv . className = "activity-content" ;
407-
408- const message = document . createElement ( "p" ) ;
409- message . textContent = "Unable to load recent activity" ;
410-
411- contentDiv . appendChild ( message ) ;
412- fallbackDiv . appendChild ( contentDiv ) ;
413- activityList . appendChild ( fallbackDiv ) ;
414- }
403+ this . showEmptyActivity ( ) ;
415404}
416405}
417-
406+
418407async loadSystemAlerts ( ) {
419408try {
420409const alerts = await this . getApiData ( "/api/alerts" , [ ] ) ;
@@ -432,28 +421,13 @@ class EngineScriptDashboard {
432421}
433422} ) ;
434423} else {
435- // Create default "all systems operational" alert
436- const defaultAlert = this . createAlertElement ( {
437- message :"All systems operational" ,
438- time :"Just now" ,
439- type :"info" ,
440- } ) ;
441- alertList . appendChild ( defaultAlert ) ;
424+ // Show empty state for all systems operational
425+ this . showEmptyAlerts ( ) ;
442426}
443427}
444428} catch ( error ) {
445429console . error ( 'Failed to load system alerts:' , error ) ;
446- // Show fallback alert
447- const alertList = document . getElementById ( "system-alerts" ) ;
448- if ( alertList ) {
449- alertList . innerHTML = '' ;
450- const errorAlert = this . createAlertElement ( {
451- message :"Unable to load system alerts" ,
452- time :"Just now" ,
453- type :"error" ,
454- } ) ;
455- alertList . appendChild ( errorAlert ) ;
456- }
430+ this . showEmptyAlerts ( ) ;
457431}
458432}
459433
@@ -562,23 +536,7 @@ class EngineScriptDashboard {
562536
563537} catch ( error ) {
564538console . error ( 'Failed to load system information:' , error ) ;
565- // Show fallback system info
566- const systemInfo = document . getElementById ( "system-info" ) ;
567- if ( systemInfo ) {
568- systemInfo . innerHTML = "" ;
569- const errorDiv = document . createElement ( "div" ) ;
570- errorDiv . className = "info-item" ;
571-
572- const label = document . createElement ( "strong" ) ;
573- label . textContent = "Error:" ;
574-
575- const value = document . createElement ( "span" ) ;
576- value . textContent = "Unable to load system information" ;
577-
578- errorDiv . appendChild ( label ) ;
579- errorDiv . appendChild ( value ) ;
580- systemInfo . appendChild ( errorDiv ) ;
581- }
539+ this . showErrorSystemInfo ( ) ;
582540}
583541}
584542
@@ -1115,6 +1073,93 @@ class EngineScriptDashboard {
11151073systemInfo . innerHTML = html ;
11161074}
11171075}
1076+
1077+ // Empty state helpers
1078+ createEmptyState ( type , icon , title , message , actionText = null , actionCallback = null ) {
1079+ const emptyState = document . createElement ( 'div' ) ;
1080+ emptyState . className = `empty-state${ type } ` ;
1081+
1082+ let html = `
1083+ <i class="fas fa-${ icon } empty-state-icon"></i>
1084+ <h3 class="empty-state-title">${ this . sanitizeInput ( title ) } </h3>
1085+ <p class="empty-state-message">${ this . sanitizeInput ( message ) } </p>
1086+ ` ;
1087+
1088+ if ( actionText && actionCallback ) {
1089+ html += `
1090+ <div class="empty-state-action">
1091+ <button class="btn btn-primary" data-action="empty-state-action">${ this . sanitizeInput ( actionText ) } </button>
1092+ </div>
1093+ ` ;
1094+ }
1095+
1096+ emptyState . innerHTML = html ;
1097+
1098+ if ( actionText && actionCallback ) {
1099+ const btn = emptyState . querySelector ( '[data-action="empty-state-action"]' ) ;
1100+ btn . addEventListener ( 'click' , actionCallback ) ;
1101+ }
1102+
1103+ return emptyState ;
1104+ }
1105+
1106+ showEmptyActivity ( ) {
1107+ const activityList = document . getElementById ( "recent-activity" ) ;
1108+ if ( activityList ) {
1109+ const emptyState = this . createEmptyState (
1110+ 'info' ,
1111+ 'history' ,
1112+ 'No Recent Activity' ,
1113+ 'Activity will appear here as the system runs'
1114+ ) ;
1115+ activityList . innerHTML = '' ;
1116+ activityList . appendChild ( emptyState ) ;
1117+ }
1118+ }
1119+
1120+ showEmptyAlerts ( ) {
1121+ const alertList = document . getElementById ( "system-alerts" ) ;
1122+ if ( alertList ) {
1123+ const emptyState = this . createEmptyState (
1124+ 'success' ,
1125+ 'check-circle' ,
1126+ 'All Systems Operational' ,
1127+ 'No alerts at this time'
1128+ ) ;
1129+ alertList . innerHTML = '' ;
1130+ alertList . appendChild ( emptyState ) ;
1131+ }
1132+ }
1133+
1134+ showEmptyUptimeMonitors ( ) {
1135+ const uptimeContainer = document . getElementById ( "uptime-summary" ) ;
1136+ if ( uptimeContainer ) {
1137+ const emptyState = this . createEmptyState (
1138+ 'warning' ,
1139+ 'radar' ,
1140+ 'Uptime Monitoring Not Configured' ,
1141+ 'Set up Uptime Robot monitoring to track site availability'
1142+ ) ;
1143+ uptimeContainer . innerHTML = '' ;
1144+ uptimeContainer . appendChild ( emptyState ) ;
1145+ }
1146+ }
1147+
1148+ showErrorSystemInfo ( ) {
1149+ const systemInfo = document . getElementById ( "system-info" ) ;
1150+ if ( systemInfo ) {
1151+ const emptyState = this . createEmptyState (
1152+ 'error' ,
1153+ 'exclamation-circle' ,
1154+ 'Unable to Load System Information' ,
1155+ 'There was an error retrieving system data' ,
1156+ 'Retry' ,
1157+ ( ) => this . loadSystemInfo ( )
1158+ ) ;
1159+ systemInfo . innerHTML = '' ;
1160+ systemInfo . appendChild ( emptyState ) ;
1161+ }
1162+ }
11181163
11191164isValidActivity ( activity ) {
11201165return (
@@ -1363,14 +1408,13 @@ class EngineScriptDashboard {
13631408
13641409if ( monitors . length === 0 ) {
13651410monitorsContainer . innerHTML = "" ;
1366- const statusDiv = document . createElement ( "div" ) ;
1367- statusDiv . className = "uptime-status" ;
1368-
1369- const message = document . createElement ( "p" ) ;
1370- message . textContent = "No monitors configured. Add websites to monitor in your Uptime Robot dashboard." ;
1371-
1372- statusDiv . appendChild ( message ) ;
1373- monitorsContainer . appendChild ( statusDiv ) ;
1411+ const emptyState = this . createEmptyState (
1412+ 'warning' ,
1413+ 'clock' ,
1414+ 'No Monitors Configured' ,
1415+ 'Add websites to monitor in your Uptime Robot dashboard'
1416+ ) ;
1417+ monitorsContainer . appendChild ( emptyState ) ;
13741418return ;
13751419}
13761420