mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Change js from moment to luxon style
Signed-off-by: yubiuser <github@yubiuser.dev>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
/* global utils:false, moment:false */
|
||||
/* global utils:false, luxon:false */
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -262,9 +262,9 @@ function updateFtlInfo() {
|
||||
);
|
||||
updateQueryFrequency(intl, ftl.query_frequency);
|
||||
$("#sysinfo-pid-ftl").text(ftl.pid);
|
||||
const startdate = moment()
|
||||
.subtract(ftl.uptime, "milliseconds")
|
||||
.format("dddd, MMMM Do YYYY, HH:mm:ss");
|
||||
const startdate = luxon.DateTime.now()
|
||||
.minus({ milliseconds: ftl.uptime })
|
||||
.toFormat("dddd, MMMM Do YYYY, HH:mm:ss");
|
||||
$("#sysinfo-uptime-ftl").text(startdate);
|
||||
|
||||
$(".destructive_action").prop("disabled", !ftl.allow_destructive);
|
||||
@@ -371,19 +371,19 @@ function updateSystemInfo() {
|
||||
$("#sysinfo-cpu-ftl").text("(" + system.ftl["%cpu"].toFixed(1) + "% used by FTL)");
|
||||
$("#sysinfo-ram-ftl").text("(" + system.ftl["%mem"].toFixed(1) + "% used by FTL)");
|
||||
|
||||
const startdate = moment()
|
||||
.subtract(system.uptime, "seconds")
|
||||
.format("dddd, MMMM Do YYYY, HH:mm:ss");
|
||||
const startdate = luxon.DateTime.now()
|
||||
.minus({ seconds: system.uptime })
|
||||
.toFormat("dddd, MMMM Do YYYY, HH:mm:ss");
|
||||
$("#status").prop(
|
||||
"title",
|
||||
"System uptime: " +
|
||||
moment.duration(1000 * system.uptime).humanize() +
|
||||
luxon.Duration.fromMillis(1000 * system.uptime).toRelative() +
|
||||
" (running since " +
|
||||
startdate +
|
||||
")"
|
||||
);
|
||||
$("#sysinfo-uptime").text(
|
||||
moment.duration(1000 * system.uptime).humanize() + " (running since " + startdate + ")"
|
||||
luxon.Duration.fromMillis(1000 * system.uptime).toRelative() + " (running since " + startdate + ")"
|
||||
);
|
||||
$("#sysinfo-system-overlay").hide();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
/* global moment:false, utils:false, REFRESH_INTERVAL:false */
|
||||
/* global luxon:false, utils:false, REFRESH_INTERVAL:false */
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -95,25 +95,25 @@ function initDateRangePicker() {
|
||||
timePickerIncrement: 5,
|
||||
timePicker24Hour: true,
|
||||
locale: { format: dateformat },
|
||||
startDate: moment(from * 1000), // convert to milliseconds since epoch
|
||||
endDate: moment(until * 1000), // convert to milliseconds since epoch
|
||||
startDate: luxon.DateTime.fromMillis(from * 1000), // convert to milliseconds since epoch
|
||||
endDate: luxon.DateTime.fromMillis(until * 1000), // convert to milliseconds since epoch
|
||||
ranges: {
|
||||
"Last 10 Minutes": [moment().subtract(10, "minutes"), moment()],
|
||||
"Last Hour": [moment().subtract(1, "hours"), moment()],
|
||||
Today: [moment().startOf("day"), maxDateMoment],
|
||||
"Last 10 Minutes": [luxon.DateTime.now().minus({ minutes: 10 }), luxon.DateTime.now()],
|
||||
"Last Hour": [luxon.DateTime.now().minus({ hours: 1 }), luxon.DateTime.now()],
|
||||
Today: [luxon.DateTime.now().startOf("day"), luxon.DateTime.now().endOf("day")],
|
||||
Yesterday: [
|
||||
moment().subtract(1, "days").startOf("day"),
|
||||
moment().subtract(1, "days").endOf("day"),
|
||||
luxon.DateTime.now().minus({ days: 1 }).startOf("day"),
|
||||
luxon.DateTime.now().minus({ days: 1 }).endOf("day"),
|
||||
],
|
||||
"Last 7 Days": [moment().subtract(6, "days").startOf("day"), maxDateMoment],
|
||||
"Last 30 Days": [moment().subtract(29, "days").startOf("day"), maxDateMoment],
|
||||
"This Month": [moment().startOf("month"), maxDateMoment],
|
||||
"Last 7 Days": [luxon.DateTime.now().minus({ days: 6 }), luxon.DateTime.now().endOf("day")],
|
||||
"Last 30 Days": [luxon.DateTime.now().minus({ days: 29 }), luxon.DateTime.now().endOf("day")],
|
||||
"This Month": [luxon.DateTime.now().startOf("month"), luxon.DateTime.now().endOf("month")],
|
||||
"Last Month": [
|
||||
moment().subtract(1, "month").startOf("month"),
|
||||
moment().subtract(1, "month").endOf("month"),
|
||||
luxon.DateTime.now().minus({ months: 1 }).startOf("month"),
|
||||
luxon.DateTime.now().minus({ months: 1 }).endOf("month"),
|
||||
],
|
||||
"This Year": [moment().startOf("year"), maxDateMoment],
|
||||
"All Time": [minDateMoment, maxDateMoment],
|
||||
"This Year": [luxon.DateTime.now().startOf("year"), luxon.DateTime.now().endOf("year")],
|
||||
"All Time": [luxon.DateTime.fromMillis(beginningOfTime * 1000), luxon.DateTime.fromMillis(endOfTime * 1000)], // convert to milliseconds since epoch
|
||||
},
|
||||
// Don't allow selecting dates outside the database range
|
||||
minDate: minDateMoment,
|
||||
@@ -125,8 +125,8 @@ function initDateRangePicker() {
|
||||
(startt, endt) => {
|
||||
// Update global variables
|
||||
// Convert milliseconds (JS) to seconds (API)
|
||||
from = moment(startt).utc().valueOf() / 1000;
|
||||
until = moment(endt).utc().valueOf() / 1000;
|
||||
from = luxon.DateTime.fromMillis(startt).utc().valueOf() / 1000;
|
||||
until = luxon.DateTime.fromMillis(endt).utc().valueOf() / 1000;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -389,7 +389,7 @@ function formatInfo(data) {
|
||||
ttlInfo =
|
||||
divStart +
|
||||
"Time-to-live (TTL): " +
|
||||
moment.duration(data.ttl, "s").humanize() +
|
||||
luxon.Duration.fromObject({ seconds: data.ttl }).toRelative() +
|
||||
" (" +
|
||||
data.ttl +
|
||||
"s)</div>";
|
||||
@@ -443,7 +443,7 @@ function formatInfo(data) {
|
||||
'<div class="row">' +
|
||||
divStart +
|
||||
"Query received on: " +
|
||||
moment.unix(data.time).format("Y-MM-DD HH:mm:ss.SSS z") +
|
||||
luxon.DateTime.fromMillis(data.time * 1000).toFormat("yyyy-MM-dd HH:mm:ss.SSS z") +
|
||||
"</div>" +
|
||||
clientInfo +
|
||||
dnssecInfo +
|
||||
@@ -603,7 +603,7 @@ $(() => {
|
||||
width: "10%",
|
||||
render(data, type) {
|
||||
if (type === "display") {
|
||||
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
return luxon.DateTime.fromMillis(data * 1000).toFormat("yyyy-MM-dd [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -638,12 +638,12 @@ $(() => {
|
||||
if (querystatus.icon !== false) {
|
||||
$("td:eq(1)", row).html(
|
||||
"<i class='fa fa-fw " +
|
||||
querystatus.icon +
|
||||
" " +
|
||||
querystatus.colorClass +
|
||||
"' title='" +
|
||||
utils.escapeHtml(querystatus.fieldtext) +
|
||||
"'></i>"
|
||||
querystatus.icon +
|
||||
" " +
|
||||
querystatus.colorClass +
|
||||
"' title='" +
|
||||
utils.escapeHtml(querystatus.fieldtext) +
|
||||
"'></i>"
|
||||
);
|
||||
} else if (querystatus.colorClass !== false) {
|
||||
$(row).addClass(querystatus.colorClass);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
/* global moment: false, apiFailure: false, utils: false, REFRESH_INTERVAL: false */
|
||||
/* global luxon: false, apiFailure: false, utils: false, REFRESH_INTERVAL: false */
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -179,7 +179,7 @@ function getData() {
|
||||
|
||||
// Create and add new log entry to fragment
|
||||
const logEntry = document.createElement("div");
|
||||
const logEntryDate = moment(1000 * line.timestamp).format("YYYY-MM-DD HH:mm:ss.SSS");
|
||||
const logEntryDate = luxon.DateTime.fromMillis(1000 * line.timestamp).toFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
logEntry.className = `log-entry${fadeIn ? " hidden-entry" : ""}`;
|
||||
logEntry.innerHTML = `<span class="text-muted">${logEntryDate}</span> ${line.message}`;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
/* global moment:false, apiFailure: false, updateFtlInfo: false, NProgress:false, WaitMe:false */
|
||||
/* global luxon:false, apiFailure: false, updateFtlInfo: false, NProgress:false, WaitMe:false */
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -154,14 +154,14 @@ function datetime(date, html, humanReadable) {
|
||||
|
||||
const format =
|
||||
html === false ? "Y-MM-DD HH:mm:ss z" : "Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z";
|
||||
const timestr = moment.unix(Math.floor(date)).format(format).trim();
|
||||
const timestr = luxon.DateTime.fromMillis(Math.floor(date)).toFormat(format).trim();
|
||||
return humanReadable
|
||||
? '<span title="' + timestr + '">' + moment.unix(Math.floor(date)).fromNow() + "</span>"
|
||||
? '<span title="' + timestr + '">' + luxon.DateTime.fromMillis(Math.floor(date)).toRelative() + "</span>"
|
||||
: timestr;
|
||||
}
|
||||
|
||||
function datetimeRelative(date) {
|
||||
return moment.unix(Math.floor(date)).fromNow();
|
||||
return luxon.DateTime.fromMillis(Math.floor(date)).toRelative();
|
||||
}
|
||||
|
||||
function disableAll() {
|
||||
|
||||
Reference in New Issue
Block a user