Sanoopsn commited on
Commit
517957c
·
verified ·
1 Parent(s): e3b3c40

add ids to all Filters and referernce using ids

Browse files
Files changed (2) hide show
  1. index.html +15 -15
  2. script.js +13 -12
index.html CHANGED
@@ -41,18 +41,18 @@
41
  <div class="bg-white rounded-lg shadow p-4 mb-6">
42
  <div class="grid grid-cols-1 md:grid-cols-5 gap-4">
43
  <div>
44
- <label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
45
- <select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
46
- <option>All</option>
47
  <option>200</option>
48
  <option>400</option>
49
  <option>500</option>
50
  </select>
51
  </div>
52
  <div>
53
- <label class="block text-sm font-medium text-gray-700 mb-1">Method</label>
54
- <select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
55
- <option>All</option>
56
  <option>GET</option>
57
  <option>POST</option>
58
  <option>PUT</option>
@@ -72,18 +72,18 @@
72
  <input id="customHoursInput" type="number" min="1" placeholder="Enter hours"
73
  class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm hidden">
74
  </div>
75
- <div>
76
- <label class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
77
- <input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
78
- </div>
79
  <div>
80
- <label class="block text-sm font-medium text-gray-700 mb-1">Error Contains</label>
81
- <input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
82
- </div>
 
 
 
 
83
  </div>
84
  <div class="flex justify-end mt-4">
85
- <button class="px-4 py-2 bg-primary-500 text-white rounded-md hover:bg-primary-600 transition">Apply Filters</button>
86
- </div>
87
  </div>
88
 
89
  <!-- Logs Table -->
 
41
  <div class="bg-white rounded-lg shadow p-4 mb-6">
42
  <div class="grid grid-cols-1 md:grid-cols-5 gap-4">
43
  <div>
44
+ <label for="statusFilter" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
45
+ <select id="statusFilter" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
46
+ <option>All</option>
47
  <option>200</option>
48
  <option>400</option>
49
  <option>500</option>
50
  </select>
51
  </div>
52
  <div>
53
+ <label for="methodFilter" class="block text-sm font-medium text-gray-700 mb-1">Method</label>
54
+ <select id="methodFilter" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
55
+ <option>All</option>
56
  <option>GET</option>
57
  <option>POST</option>
58
  <option>PUT</option>
 
72
  <input id="customHoursInput" type="number" min="1" placeholder="Enter hours"
73
  class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm hidden">
74
  </div>
 
 
 
 
75
  <div>
76
+ <label for="urlFilter" class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
77
+ <input id="urlFilter" type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
78
+ </div>
79
+ <div>
80
+ <label for="errorFilter" class="block text-sm font-medium text-gray-700 mb-1">Error Contains</label>
81
+ <input id="errorFilter" type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
82
+ </div>
83
  </div>
84
  <div class="flex justify-end mt-4">
85
+ <button id="applyFilters" class="px-4 py-2 bg-primary-500 text-white rounded-md hover:bg-primary-600 transition">Apply Filters</button>
86
+ </div>
87
  </div>
88
 
89
  <!-- Logs Table -->
script.js CHANGED
@@ -378,9 +378,9 @@ document.addEventListener('DOMContentLoaded', () => {
378
  errorModal = createModalElements();
379
 
380
  // Apply Filters button functionality
381
- document.querySelector('.container button').addEventListener('click', () => {
382
- const statusFilter = document.querySelector('select:nth-of-type(1)').value;
383
- const methodFilter = document.querySelector('select:nth-of-type(2)').value;
384
  const timeFilterSelect = document.getElementById('timeRangeSelect');
385
  const customHoursInput = document.getElementById('customHoursInput');
386
 
@@ -391,9 +391,9 @@ document.addEventListener('DOMContentLoaded', () => {
391
  hours = parseInt(timeFilterSelect.value);
392
  }
393
 
394
- const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
395
- const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
396
- 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);
@@ -429,9 +429,9 @@ document.addEventListener('DOMContentLoaded', () => {
429
  });
430
 
431
  // Apply Filters button functionality
432
- document.querySelector('.container button').addEventListener('click', () => {
433
- const statusFilter = document.querySelector('select:nth-of-type(1)').value;
434
- const methodFilter = document.querySelector('select:nth-of-type(2)').value;
435
  const timeFilterSelect = document.getElementById('timeRangeSelect');
436
  const customHoursInput = document.getElementById('customHoursInput');
437
 
@@ -441,9 +441,10 @@ document.addEventListener('DOMContentLoaded', () => {
441
  } else {
442
  hours = parseInt(timeFilterSelect.value);
443
  }
444
- const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
445
- const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
446
- const now = new Date();
 
447
  const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
448
  const filteredLogs = sampleLogs.filter(log => {
449
  const logDate = new Date(log.time);
 
378
  errorModal = createModalElements();
379
 
380
  // Apply Filters button functionality
381
+ document.getElementById('applyFilters').addEventListener('click', () => {
382
+ const statusFilter = document.getElementById('statusFilter').value;
383
+ const methodFilter = document.getElementById('methodFilter').value;
384
  const timeFilterSelect = document.getElementById('timeRangeSelect');
385
  const customHoursInput = document.getElementById('customHoursInput');
386
 
 
391
  hours = parseInt(timeFilterSelect.value);
392
  }
393
 
394
+ const urlFilter = document.getElementById('urlFilter').value;
395
+ const errorFilter = document.getElementById('errorFilter').value;
396
+ 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);
 
429
  });
430
 
431
  // Apply Filters button functionality
432
+ document.getElementById('applyFilters').addEventListener('click', () => {
433
+ const statusFilter = document.getElementById('statusFilter').value;
434
+ const methodFilter = document.getElementById('methodFilter').value;
435
  const timeFilterSelect = document.getElementById('timeRangeSelect');
436
  const customHoursInput = document.getElementById('customHoursInput');
437
 
 
441
  } else {
442
  hours = parseInt(timeFilterSelect.value);
443
  }
444
+
445
+ const urlFilter = document.getElementById('urlFilter').value;
446
+ const errorFilter = document.getElementById('errorFilter').value;
447
+ const now = new Date();
448
  const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
449
  const filteredLogs = sampleLogs.filter(log => {
450
  const logDate = new Date(log.time);