Days handling URLs visualization, exception handling url_processor

This commit is contained in:
Luciano Gervasoni
2025-03-27 12:32:18 +01:00
parent 8dce5206af
commit a6b25fe915
4 changed files with 33 additions and 26 deletions

View File

@@ -152,11 +152,13 @@ input[type="checkbox"] {
<!-- Filter by Time Range -->
<h3>Fetch Date</h3>
<select id="timeFilterSelect" name="selected_days">
<select id="timeFilterSelect" name="days">
<option value="0.25" {% if selected_days|stringformat:"s" == '0.25' %}selected{% endif %}>Last 6 hours</option>
<option value="1" {% if selected_days|stringformat:"s" == '1' %}selected{% endif %}>Last 24 hours</option>
<option value="7" {% if selected_days|stringformat:"s" == '7' %}selected{% endif %}>Last 7 days</option>
<option value="30" {% if selected_days|stringformat:"s" == '30' %}selected{% endif %}>Last 30 days</option>
<option value="90" {% if selected_days|stringformat:"s" == '90' %}selected{% endif %}>Last 90 days</option>
<option value="365" {% if selected_days|stringformat:"s" == '365' %}selected{% endif %}>Last 365 days</option>
</select>
<br><br>
@@ -200,6 +202,7 @@ input[type="checkbox"] {
</form>
</div>
<!-- Table URLs data -->
<div class="table-container">
<table>
<thead>
@@ -296,21 +299,20 @@ input[type="checkbox"] {
var selectedSearch = {{ selected_search|safe }};
var selectedSource = {{ selected_source|safe }};
var perPage = {{ per_page|default:"25" }};
//var selectedDays = {{ selected_days|default:"30" }};
</script>
<script>
//////////////////////////////////////////////////////////////////////
document.addEventListener("DOMContentLoaded", function () {
//////////////////////////////////////////////
// Theme
const themeToggle = document.getElementById("themeToggle");
const body = document.body;
// Load theme from localStorage
if (localStorage.getItem("theme") === "dark") {
body.classList.add("dark-mode");
themeToggle.textContent = "🌞";
}
// Toggle theme on button click
themeToggle.addEventListener("click", function () {
if (body.classList.contains("dark-mode")) {
@@ -323,7 +325,10 @@ input[type="checkbox"] {
themeToggle.textContent = "🌞";
}
});
//////////////////////////////////////////////
//////////////////////////////////////////////
// Timestamp to local timezone
document.querySelectorAll(".ts-fetch").forEach(element => {
let utcDate = element.getAttribute("data-ts"); // Get timestamp from data attribute
let options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12:false};
@@ -332,6 +337,7 @@ input[type="checkbox"] {
element.textContent = localDate; // Update the text content
}
});
//////////////////////////////////////////////
});
//////////////////////////////////////////////////////////////////////
@@ -342,7 +348,6 @@ input[type="checkbox"] {
currentUrl.searchParams.set('page', pageNumber); // Update page parameter
window.location.href = currentUrl.toString(); // Redirect to the updated URL
}
// Attach event listeners to pagination links
document.querySelectorAll('.pagination-link').forEach(link => {
link.addEventListener('click', function(e) {
@@ -398,9 +403,11 @@ input[type="checkbox"] {
document.getElementById('timeFilterSelect').addEventListener('change', function() {
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.set('selected_days', this.value); // Update per_page value
currentUrl.searchParams.set('days', this.value); // Update days value
currentUrl.searchParams.set('page', 1); // Reset page number to 1 when any checkbox changes
window.location.href = currentUrl.toString(); // Redirect to the updated URL with new per_page value
window.location.href = currentUrl.toString(); // Redirect to the updated URL with new days value
//document.getElementById('filterForm').submit(); // Submits the form instead of manually changing the URL
});