@@ -57,7 +57,7 @@ function renderDeviceGrid(devices) {
5757 console . log ( 'devices-container not found in renderDeviceGrid' ) ;
5858 return ;
5959 }
60-
60+
6161 console . log ( 'Devices length:' , devices ? devices . length : 'null/undefined' ) ;
6262 if ( ! devices || devices . length === 0 ) {
6363 console . log ( 'No devices found, showing empty message' ) ;
@@ -70,12 +70,35 @@ function renderDeviceGrid(devices) {
7070 ` ;
7171 return ;
7272 }
73-
74- console . log ( 'Rendering' , devices . length , 'devices' ) ;
73+
74+ // Filter out devices that have never been online
75+ // Only show devices that have been seen at least once (have LastSeenOnlineAt timestamp or are currently online/offline)
76+ const onlineDevices = devices . filter ( device => {
77+ return device . LastSeenOnlineAt ||
78+ device . status === 'online' ||
79+ device . status === 'offline' ||
80+ device . status === 'idle' ;
81+ } ) ;
82+
83+ console . log ( 'Filtered to' , onlineDevices . length , 'devices that have been online (from' , devices . length , 'total)' ) ;
84+
85+ if ( onlineDevices . length === 0 ) {
86+ console . log ( 'No online devices found, showing empty message' ) ;
87+ devicesContainer . innerHTML = `
88+ <div class="text-center py-8 text-gray-400">
89+ <i class="ti ti-router text-4xl mb-2 block"></i>
90+ <p>No devices have been seen online</p>
91+ <p class="text-sm text-gray-500">Start a network scan to discover devices</p>
92+ </div>
93+ ` ;
94+ return ;
95+ }
96+
97+ console . log ( 'Rendering' , onlineDevices . length , 'online devices' ) ;
7598
7699 let gridHTML = '<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6">' ;
77-
78- devices . forEach ( device => {
100+
101+ onlineDevices . forEach ( device => {
79102 // Count ports
80103 let openPorts = 0 ;
81104 let filteredPorts = 0 ;
@@ -154,7 +177,7 @@ function renderDeviceModal(device, screenshotsEnabled = false) {
154177 ${ device . mac ? `<div><span style="color: var(--text-muted);">MAC Address:</span> <span class="text-blue-400">${ device . mac } </span></div>` : '' }
155178 ${ device . hostname ? `<div><span style="color: var(--text-muted);">Hostname:</span> <span style="color: var(--text-primary);">${ device . hostname } </span></div>` : '' }
156179 <div><span style="color: var(--text-muted);">Status:</span> <span class="px-2 py-1 rounded text-xs ${ getStatusBadgeColor ( device . status ) } ">${ device . status } </span></div>
157- ${ device . LastSeen ? `<div><span style="color: var(--text-muted);">Last Seen:</span> <span style="color: var(--text-primary);">${ formatLogTime ( device . LastSeen ) } </span></div>` : '' }
180+ ${ device . LastSeenOnlineAt ? `<div><span style="color: var(--text-muted);">Last Seen:</span> <span style="color: var(--text-primary);">${ formatLogTime ( device . LastSeenOnlineAt ) } </span></div>` : '' }
158181 </div>
159182 </div>
160183
0 commit comments