main.js: updated code to support minute stats with new datetime picker option for custom date range.

This commit is contained in:
Shreyas Zare
2025-01-11 18:04:57 +05:30
parent ac9c3bdc1a
commit 3b13789908

View File

@@ -1,6 +1,6 @@
/* /*
Technitium DNS Server Technitium DNS Server
Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com) Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -2137,12 +2137,12 @@ function refreshDashboard(hideLoader) {
return; return;
} }
var start = moment(txtStart, "YYYY-MM-DD"); var start = moment(txtStart);
var end = moment(txtEnd, "YYYY-MM-DD"); var end = moment(txtEnd);
if ((end.diff(start, "days") + 1) > 7) { if ((end.diff(start, "days") + 1) > 7) {
start = moment.utc(txtStart, "YYYY-MM-DD").toISOString(); start = moment.utc(txtStart).toISOString();
end = moment.utc(txtEnd, "YYYY-MM-DD").toISOString(); end = moment.utc(txtEnd).toISOString();
} }
else { else {
start = start.toISOString(); start = start.toISOString();
@@ -2438,21 +2438,33 @@ function showTopStats(statsType, limit) {
var custom = ""; var custom = "";
if (type === "custom") { if (type === "custom") {
var start = $("#dpCustomDayWiseStart").val(); var txtStart = $("#dpCustomDayWiseStart").val();
if (start === null || (start === "")) { if (txtStart === null || (txtStart === "")) {
showAlert("warning", "Missing!", "Please select a start date."); showAlert("warning", "Missing!", "Please select a start date.");
$("#dpCustomDayWiseStart").focus(); $("#dpCustomDayWiseStart").focus();
return; return;
} }
var end = $("#dpCustomDayWiseEnd").val(); var txtEnd = $("#dpCustomDayWiseEnd").val();
if (end === null || (end === "")) { if (txtEnd === null || (txtEnd === "")) {
showAlert("warning", "Missing!", "Please select an end date."); showAlert("warning", "Missing!", "Please select an end date.");
$("#dpCustomDayWiseEnd").focus(); $("#dpCustomDayWiseEnd").focus();
return; return;
} }
custom = "&start=" + start + "&end=" + end; var start = moment(txtStart);
var end = moment(txtEnd);
if ((end.diff(start, "days") + 1) > 7) {
start = moment.utc(txtStart).toISOString();
end = moment.utc(txtEnd).toISOString();
}
else {
start = start.toISOString();
end = end.toISOString();
}
custom = "&start=" + encodeURIComponent(start) + "&end=" + encodeURIComponent(end);
} }
HTTPRequest({ HTTPRequest({