Sanoopsn commited on
Commit
bc9950a
·
verified ·
1 Parent(s): 81f5465

table is empty after applying filter

Browse files
Files changed (1) hide show
  1. script.js +28 -15
script.js CHANGED
@@ -397,15 +397,26 @@ const now = new Date();
397
  const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
398
  const filteredLogs = sampleLogs.filter(log => {
399
  const logDate = new Date(log.time);
400
- const timeMatch = hours === 'all' || logDate >= timeAgo;
401
- return timeMatch &&
402
- (statusFilter === 'All' || log.status.toString() === statusFilter) &&
403
- (methodFilter === 'All' || log.method === methodFilter) &&
404
- (urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
405
- (errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
 
406
  });
407
-
408
- renderLogsTableWithFilter(filteredLogs);
 
 
 
 
 
 
 
 
 
 
409
  });
410
  // Setup event listeners for modal
411
  errorModal.addEventListener('click', (e) => {
@@ -440,17 +451,19 @@ const now = new Date();
440
  const filteredLogs = sampleLogs.filter(log => {
441
  const logDate = new Date(log.time);
442
  const timeMatch = hours === 'all' || logDate >= timeAgo;
 
 
 
 
 
443
 
444
- return (statusFilter === 'All' || log.status.toString() === statusFilter) &&
445
- (methodFilter === 'All' || log.method === methodFilter) &&
446
- timeMatch &&
447
- (urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
448
- (errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
449
  });
 
450
  if (filteredLogs.length === 0) {
451
  logsTable.innerHTML = `
452
- <tr class="text-center py-4">
453
- <td colspan="7" class="py-4 text-gray-500">
454
  No logs found matching your filters
455
  </td>
456
  </tr>
 
397
  const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
398
  const filteredLogs = sampleLogs.filter(log => {
399
  const logDate = new Date(log.time);
400
+ const timeMatch = isNaN(hours) || hours === 'all' || logDate >= timeAgo;
401
+ const statusMatch = statusFilter === 'All' || log.status.toString() === statusFilter;
402
+ const methodMatch = methodFilter === 'All' || log.method === methodFilter;
403
+ const urlMatch = urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase());
404
+ const errorMatch = errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase());
405
+
406
+ return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
407
  });
408
+
409
+ if (filteredLogs.length === 0) {
410
+ logsTable.innerHTML = `
411
+ <tr>
412
+ <td colspan="7" class="py-4 text-gray-500 text-center">
413
+ No logs found matching your filters
414
+ </td>
415
+ </tr>
416
+ `;
417
+ } else {
418
+ renderLogsTableWithFilter(filteredLogs);
419
+ }
420
  });
421
  // Setup event listeners for modal
422
  errorModal.addEventListener('click', (e) => {
 
451
  const filteredLogs = sampleLogs.filter(log => {
452
  const logDate = new Date(log.time);
453
  const timeMatch = hours === 'all' || logDate >= timeAgo;
454
+ const timeMatch = isNaN(hours) || hours === 'all' || logDate >= timeAgo;
455
+ const statusMatch = statusFilter === 'All' || log.status.toString() === statusFilter;
456
+ const methodMatch = methodFilter === 'All' || log.method === methodFilter;
457
+ const urlMatch = urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase());
458
+ const errorMatch = errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase());
459
 
460
+ return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
 
 
 
 
461
  });
462
+
463
  if (filteredLogs.length === 0) {
464
  logsTable.innerHTML = `
465
+ <tr>
466
+ <td colspan="7" class="py-4 text-gray-500 text-center">
467
  No logs found matching your filters
468
  </td>
469
  </tr>