/>
@@ -1616,7 +1617,7 @@ class="form-control"
-
From 5ddf4a7a04ce92dc34d9605f1df3677a9fdddccd Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 04:17:03 -0500
Subject: [PATCH 069/137] update chart
---
scripts/pi-hole/js/speedtest.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 7cc370bf9..26e18ffa3 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -39,6 +39,8 @@ function createChart() {
borderWidth: 3,
yAxisID: "y-axis-1",
tension: 0.4,
+ pointHitRadius: 5,
+ pointHoverRadius: 5,
},
{
label: "Mbps Upload",
@@ -48,6 +50,8 @@ function createChart() {
borderWidth: 3,
yAxisID: "y-axis-1",
tension: 0.4,
+ pointHitRadius: 5,
+ pointHoverRadius: 5,
},
{
label: "ms Ping",
@@ -57,6 +61,8 @@ function createChart() {
borderWidth: 3,
yAxisID: "y-axis-2",
tension: 0.4,
+ pointHitRadius: 5,
+ pointHoverRadius: 5,
},
],
},
@@ -176,6 +182,10 @@ function updateSpeedTestData() {
}
if (speedChart) {
+ speedChart.data.labels = speedlabels;
+ speedChart.data.datasets[0].data = downloadspeed;
+ speedChart.data.datasets[1].data = uploadspeed;
+ speedChart.data.datasets[2].data = serverPing;
speedChart.update();
$("#speedOverTimeChartOverlay").css("display", "none");
}
From 8387c675f3e0ecd02810c1c648bf2fa646cd9e29 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 04:28:46 -0500
Subject: [PATCH 070/137] fix regex
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 8cc4424a6..53dc5c96c 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -25,7 +25,7 @@
$cmdStatus = 'echo ""';
} else {
$remaining_date = sprintf('%dd %dh %dmin %ds', $remaining_seconds / 86400, $remaining_seconds / 3600 % 24, $remaining_seconds / 60 % 60, $remaining_seconds % 60);
- $remaining_date = preg_replace('/0d |0h |0min /', '', $remaining_date); // remove 0d 0h 0min
+ $remaining_date = preg_replace('/^0d |(^|(?<= ))0h |(^|(?<= ))0min /', '', $remaining_date); // remove 0d 0h 0min
$remaining_date = preg_replace('/\s(\d+s)/', '', $remaining_date); // remove seconds if not needed
$cmdStatus = 'echo '.$remaining_date;
}
From adea096ca77bf21ddfa043f64c894ae1aa44b43e Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 04:54:10 -0500
Subject: [PATCH 071/137] min 0
---
api_speedtest.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 53dc5c96c..954c8a942 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -332,8 +332,5 @@ function getRemainingTime()
return 0;
}
- $time = time();
- $remaining_time = $interval_seconds - ($time - $last_run_time);
-
- return $remaining_time;
+ return min(0, $interval_seconds - (time() - $last_run_time));
}
From 3f584c42e6811ebbc3fe4a41c08c721adb29c732 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 04:55:56 -0500
Subject: [PATCH 072/137] max
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 954c8a942..973ebe404 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -332,5 +332,5 @@ function getRemainingTime()
return 0;
}
- return min(0, $interval_seconds - (time() - $last_run_time));
+ return max(0, $interval_seconds - (time() - $last_run_time));
}
From 0abdfbede0fdc76dcec0024160c458520a368e9d Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 05:20:22 -0500
Subject: [PATCH 073/137] pretty
---
api_speedtest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 973ebe404..f413c5c92 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -309,14 +309,14 @@ function getRemainingTime()
{
$interval_seconds = speedtestExecute("grep 'interval_seconds=' /opt/pihole/speedtestmod/schedule_check.sh | cut -d'=' -f2")['data'];
- # if interval_seconds is "nan", then schedule has never been set
+ // if interval_seconds is "nan", then schedule has never been set
if (strpos($interval_seconds, 'nan') !== false) {
return -1;
}
$interval_seconds = (int) $interval_seconds;
- # if interval_seconds is less than 0, then schedule is disabled
+ // if interval_seconds is less than 0, then schedule is disabled
if ($interval_seconds < 0) {
return -1;
}
@@ -327,7 +327,7 @@ function getRemainingTime()
$last_run_time = (int) $last_run_time;
}
- # if last_run_time is -1, then speedtest has never been run
+ // if last_run_time is -1, then speedtest has never been run
if ($last_run_time == -1) {
return 0;
}
From 1e43f2c6646b0155ab4b3a33f04e9576c9a15d5a Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 14:57:53 -0500
Subject: [PATCH 074/137] use utc again
---
api_speedtest.php | 14 ++++----------
scripts/pi-hole/js/speedresults.js | 8 ++------
scripts/pi-hole/js/speedtest.js | 8 ++++----
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index f413c5c92..55ed7d2a5 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -135,17 +135,11 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
if ($durationdays == -1) {
$sql = 'SELECT * from speedtest order by id asc';
} else {
- $lastrun = getLastSpeedtestResult($dbSpeedtest);
- if (empty($lastrun)) {
- return array();
- }
-
- $system_tz = new DateTimeZone(end(explode(' ', $lastrun[0]['start_time'])));
- $curdate = new DateTime('now', $system_tz);
- $daysago = new DateTime('now', $system_tz);
+ $curdate = new DateTime('now', new DateTimeZone('UTC'));
+ $daysago = new DateTime('now', new DateTimeZone('UTC'));
$daysago->modify('-'.$durationdays.' day');
- $daysago = $daysago->format('Y-m-d H:i:s');
- $curdate = $curdate->format('Y-m-d H:i:s');
+ $curdate = $curdate->format('Y-m-d\TH:i');
+ $daysago = $daysago->format('Y-m-d\TH:i');
$sql = "SELECT * from speedtest where start_time between '{$daysago}' and '{$curdate}' order by id asc";
}
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index c90a267c8..c13951757 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,9 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
- ? moment(data, "YYYY-MM-DD HH:mm:ss Z").utcOffset(moment().utcOffset())
- : moment(new Date(data).toISOString());
+ moment().utc(data).local();
}
return data;
@@ -60,9 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
- ? moment(data, "YYYY-MM-DD HH:mm:ss Z").utcOffset(moment().utcOffset())
- : moment(new Date(data).toISOString());
+ moment().utc(data).local();
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 26e18ffa3..cc41224db 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,16 +131,16 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment(itemdate, "YYYY-MM-DD HH:mm:ss Z").utcOffset(moment().utcOffset()).format(output);
+ return moment().utc(itemdate).local().format(output);
}
- const first = moment(results[0].start_time, "YYYY-MM-DD HH:mm:ss Z");
- const last = moment(results.at(-1).start_time, "YYYY-MM-DD HH:mm:ss Z");
+ const first = moment(results[0].start_time);
+ const last = moment(results.at(-1).start_time);
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment(new Date(itemdate).toISOString()).format(output);
+ return moment().utc(itemdate).local().format(output);
}
function updateSpeedTestData() {
From f7da7d847f7da94c3ffe147421ebdb6e0c8c395b Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:10:27 -0500
Subject: [PATCH 075/137] moment
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 8 ++------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index c13951757..f5349708f 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment().utc(data).local();
+ moment.utc(data).local();
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment().utc(data).local();
+ moment.utc(data).local();
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index cc41224db..81b4c992a 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -129,18 +129,14 @@ function createChart() {
}
function formatDate(itemdate, results) {
- let output = "HH:mm";
- if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment().utc(itemdate).local().format(output);
- }
-
const first = moment(results[0].start_time);
const last = moment(results.at(-1).start_time);
+ let output = "HH:mm";
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment().utc(itemdate).local().format(output);
+ return moment.utc(itemdate).local().format(output);
}
function updateSpeedTestData() {
From 38ec7fd6b02fae2e7d230f0e2aec409830cafe9f Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:17:48 -0500
Subject: [PATCH 076/137] safari
---
scripts/pi-hole/js/speedtest.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 81b4c992a..91fc3b0ba 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -130,7 +130,7 @@ function createChart() {
function formatDate(itemdate, results) {
const first = moment(results[0].start_time);
- const last = moment(results.at(-1).start_time);
+ const last = moment(results[results.length - 1].start_time);
let output = "HH:mm";
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
From 38e01c91de80f822baff7303d13f84b4280f5f94 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:21:37 -0500
Subject: [PATCH 077/137] format
---
scripts/pi-hole/js/speedresults.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index f5349708f..724982f73 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local();
+ moment.utc(data).local().format();
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local();
+ moment.utc(data).local().format();
}
return data;
From 2f069d5ebba9d369061ace187f1d91beb14e84ca Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:29:45 -0500
Subject: [PATCH 078/137] safarii
---
scripts/pi-hole/js/speedtest.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 91fc3b0ba..d0a8028b3 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -129,9 +129,13 @@ function createChart() {
}
function formatDate(itemdate, results) {
+ let output = "HH:mm";
+ if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
+ return moment.utc(itemdate).local().format(output);
+ }
+
const first = moment(results[0].start_time);
const last = moment(results[results.length - 1].start_time);
- let output = "HH:mm";
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
From f289cab63baec1e48bb036e6291cce4b0b3e462a Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:38:49 -0500
Subject: [PATCH 079/137] reformat
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 724982f73..0a32371c8 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local().format();
+ moment.utc(data, "YYYY-MM-DDTHH:mm").local().format();
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local().format();
+ moment.utc(data, "YYYY-MM-DDTHH:mm").local().format();
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index d0a8028b3..2dae06205 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,16 +131,16 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment.utc(itemdate).local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DDTHH:mm").local().format(output);
}
- const first = moment(results[0].start_time);
- const last = moment(results[results.length - 1].start_time);
+ const first = moment(results[0].start_time, "YYYY-MM-DDTHH:mm");
+ const last = moment(results[results.length - 1].start_time, "YYYY-MM-DDTHH:mm");
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment.utc(itemdate).local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DDTHH:mm").local().format(output);
}
function updateSpeedTestData() {
@@ -168,7 +168,7 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) && days !== "-2") {
+ if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden)) {
speedChart.destroy();
speedChart = null;
}
From 83664badb956bf4d65751ff3f34a2fdce5fbca25 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 16:43:34 -0500
Subject: [PATCH 080/137] seconds
---
api_speedtest.php | 4 ++--
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 8 ++++----
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 55ed7d2a5..fd1dade55 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -138,8 +138,8 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
$curdate = new DateTime('now', new DateTimeZone('UTC'));
$daysago = new DateTime('now', new DateTimeZone('UTC'));
$daysago->modify('-'.$durationdays.' day');
- $curdate = $curdate->format('Y-m-d\TH:i');
- $daysago = $daysago->format('Y-m-d\TH:i');
+ $curdate = $curdate->format('Y-m-d\TH:i:s');
+ $daysago = $daysago->format('Y-m-d\TH:i:s');
$sql = "SELECT * from speedtest where start_time between '{$daysago}' and '{$curdate}' order by id asc";
}
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 0a32371c8..724982f73 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DDTHH:mm").local().format();
+ moment.utc(data).local().format();
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DDTHH:mm").local().format();
+ moment.utc(data).local().format();
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 2dae06205..bfee47295 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,16 +131,16 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment.utc(itemdate, "YYYY-MM-DDTHH:mm").local().format(output);
+ return moment.utc(itemdate).local().format(output);
}
- const first = moment(results[0].start_time, "YYYY-MM-DDTHH:mm");
- const last = moment(results[results.length - 1].start_time, "YYYY-MM-DDTHH:mm");
+ const first = moment(results.at(0).start_time);
+ const last = moment(results.at(-1).start_time);
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment.utc(itemdate, "YYYY-MM-DDTHH:mm").local().format(output);
+ return moment.utc(itemdate).local().format(output);
}
function updateSpeedTestData() {
From 4e86e815790e845cd765054333d5be2860e5769b Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 16:46:41 -0500
Subject: [PATCH 081/137] or days
---
scripts/pi-hole/js/speedtest.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index bfee47295..8288ec876 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -168,7 +168,7 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden)) {
+ if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) || days === "-2") {
speedChart.destroy();
speedChart = null;
}
From d28e06c6753b1c57b79da80d40ae8e612d66629f Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 16:48:29 -0500
Subject: [PATCH 082/137] and not days
---
scripts/pi-hole/js/speedtest.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 8288ec876..c31aa54ab 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -168,7 +168,7 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) || days === "-2") {
+ if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) && days !== "-2") {
speedChart.destroy();
speedChart = null;
}
From e7340f3ff234ee40b059a307305236814f5c47a2 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 17:12:01 -0500
Subject: [PATCH 083/137] format
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 724982f73..13f0264d9 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local().format();
+ moment.utc(data, "YYYY-MM-DDTHH:mm:ssZ").local().format("YYYY-MM-DDTHH:mmZ");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data).local().format();
+ moment.utc(data, "YYYY-MM-DDTHH:mm:ssZ").local().format("YYYY-MM-DDTHH:mmZ");
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index c31aa54ab..a15151b61 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,16 +131,16 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment.utc(itemdate).local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DDTHH:mm:ssZ").local().format(output);
}
- const first = moment(results.at(0).start_time);
- const last = moment(results.at(-1).start_time);
+ const first = moment(results.at(0).start_time, "YYYY-MM-DDTHH:mm:ssZ");
+ const last = moment(results.at(-1).start_time, "YYYY-MM-DDTHH:mm:ssZ");
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment.utc(itemdate).local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DDTHH:mm:ssZ").local().format(output);
}
function updateSpeedTestData() {
From 02f77e34254b21d3eb781c730752ad3e3be2b565 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 17:25:21 -0500
Subject: [PATCH 084/137] rfc
---
api_speedtest.php | 4 ++--
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 8 ++++----
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index fd1dade55..244c0667d 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -138,8 +138,8 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
$curdate = new DateTime('now', new DateTimeZone('UTC'));
$daysago = new DateTime('now', new DateTimeZone('UTC'));
$daysago->modify('-'.$durationdays.' day');
- $curdate = $curdate->format('Y-m-d\TH:i:s');
- $daysago = $daysago->format('Y-m-d\TH:i:s');
+ $curdate = $curdate->format('Y-m-d H:i:s');
+ $daysago = $daysago->format('Y-m-d H:i:s');
$sql = "SELECT * from speedtest where start_time between '{$daysago}' and '{$curdate}' order by id asc";
}
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 13f0264d9..85835ecaa 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DDTHH:mm:ssZ").local().format("YYYY-MM-DDTHH:mmZ");
+ moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DDTHH:mm:ssZ").local().format("YYYY-MM-DDTHH:mmZ");
+ moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index a15151b61..ed05b1a22 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,16 +131,16 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment.utc(itemdate, "YYYY-MM-DDTHH:mm:ssZ").local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ssZ").local().format(output);
}
- const first = moment(results.at(0).start_time, "YYYY-MM-DDTHH:mm:ssZ");
- const last = moment(results.at(-1).start_time, "YYYY-MM-DDTHH:mm:ssZ");
+ const first = moment(results.at(0).start_time, "YYYY-MM-DD HH:mm:ssZ");
+ const last = moment(results.at(-1).start_time, "YYYY-MM-DD HH:mm:ssZ");
if (last.diff(first, "hours") > 24) {
output = "Do HH:mm";
}
- return moment.utc(itemdate, "YYYY-MM-DDTHH:mm:ssZ").local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ssZ").local().format(output);
}
function updateSpeedTestData() {
From 457f814ed652faa0c9080b83c7547b493c142b96 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 17:58:08 -0500
Subject: [PATCH 085/137] last run text
---
api_speedtest.php | 27 ---------------------------
scripts/pi-hole/js/settings.js | 17 ++++++++++++++++-
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 244c0667d..fea61e20e 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -48,9 +48,6 @@
if (isset($_GET['getAllSpeedTestData'])) {
$data = array_merge($data, getAllSpeedTestData($dbSpeedtest));
}
- if (isset($_GET['getLastSpeedtestResult'])) {
- $data = array_merge($data, getLastSpeedtestResult($dbSpeedtest));
- }
if (isset($_GET['getLatestLog'])) {
$data = array_merge($data, speedtestExecute($cmdLog));
}
@@ -98,30 +95,6 @@ function getAllSpeedTestData($dbSpeedtest)
return array('data' => $newarr);
}
-function getLastSpeedtestResult($dbSpeedtest)
-{
- if (!file_exists($dbSpeedtest)) {
- return array();
- }
-
- $db = new SQLite3($dbSpeedtest);
- if (!$db) {
- return array();
- }
-
- $sql = 'SELECT * from speedtest order by id DESC limit 1';
- $dbResults = $db->query($sql);
- $dataFromSpeedDB = array();
- if (!empty($dbResults)) {
- while ($row = $dbResults->fetchArray(SQLITE3_ASSOC)) {
- array_push($dataFromSpeedDB, $row);
- }
- }
- $db->close();
-
- return $dataFromSpeedDB;
-}
-
function getSpeedTestData($dbSpeedtest, $durationdays = '1')
{
if (!file_exists($dbSpeedtest)) {
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 5f2b0b414..25eae382f 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -560,7 +560,22 @@ $(function () {
}
}
- const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}`;
+ var lastRunText = "";
+ $.ajax({
+ url: "api.php?getLatestRun",
+ dataType: "json",
+ })
+ .done(function (data) {
+ const lastRun = data?.data;
+ if (lastRun) {
+ lastRunText = `\n\nLatest run:\n${lastRun}`;
+ }
+ })
+ .fail(function () {
+ lastRunText = "\n\nFailed to get latest run";
+ });
+
+ const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
.fail(function () {
From 6dcf5b42610b320646f2224968ff1477b57ad651 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 18:07:24 -0500
Subject: [PATCH 086/137] add cond
---
scripts/pi-hole/js/settings.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 25eae382f..c62a474d7 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -560,7 +560,7 @@ $(function () {
}
}
- var lastRunText = "";
+ var lastRunText = "Latest run is unknown";
$.ajax({
url: "api.php?getLatestRun",
dataType: "json",
@@ -569,6 +569,8 @@ $(function () {
const lastRun = data?.data;
if (lastRun) {
lastRunText = `\n\nLatest run:\n${lastRun}`;
+ } else {
+ lastRunText = "";
}
})
.fail(function () {
From 67ef1ee331a21d3e3987bc07e6a100a06d8c2296 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 18:13:20 -0500
Subject: [PATCH 087/137] another way
---
scripts/pi-hole/js/settings.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index c62a474d7..29b67e7a7 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -560,29 +560,29 @@ $(function () {
}
}
- var lastRunText = "Latest run is unknown";
$.ajax({
url: "api.php?getLatestRun",
dataType: "json",
})
.done(function (data) {
const lastRun = data?.data;
+ let lastRunText = "";
if (lastRun) {
lastRunText = `\n\nLatest run:\n${lastRun}`;
- } else {
- lastRunText = "";
}
+ const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
+ codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
.fail(function () {
- lastRunText = "\n\nFailed to get latest run";
+ const lastRunText = "\nFailed to get latest run";
+ const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
+ codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
-
- const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
- codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
.fail(function () {
const triggerText = speedtestTest.attr("value") ? " awaiting confirmation" : " unknown";
- const statusText = "Failed to get schedule\nNext run is" + triggerText;
+ const lastRunText = "\nFailed to get latest run";
+ const statusText = "Failed to get schedule\nNext run is" + triggerText + lastRunText;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
};
From 1c82bf4c6a6ad37f1f7bed484efae389574fb113 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 18:41:13 -0500
Subject: [PATCH 088/137] add seconds until the next minute
---
scripts/pi-hole/js/settings.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 29b67e7a7..bd41937a7 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -540,6 +540,14 @@ $(function () {
if (!status.includes("timer")) {
scheduleStatusText = "active";
if (!speedtestTest.attr("value")) {
+ const triggerPattern = /(\d+s)/;
+ const triggerMatch = status.match(triggerPattern);
+
+ const now = new Date();
+ const secondsUntilNextMinute = 60 - now.getSeconds();
+ const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
+ const status = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
+
triggerText = status === "0s" ? " running" : ` in ${status}`;
}
} else {
From 45a41a5b772b9534d9ce71858159d26b3e57804d Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 18:44:51 -0500
Subject: [PATCH 089/137] typo
---
scripts/pi-hole/js/settings.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index bd41937a7..ea0a408cf 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -546,9 +546,9 @@ $(function () {
const now = new Date();
const secondsUntilNextMinute = 60 - now.getSeconds();
const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
- const status = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
+ const statusText = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
- triggerText = status === "0s" ? " running" : ` in ${status}`;
+ triggerText = statusText === "0s" ? " running" : ` in ${status}`;
}
} else {
const scheduleStatusPattern = /pihole-speedtest\.timer.*?Active:\s+(\w+)/s;
From 0f71f7596afd4e37f274b77aadaa505a8dd4b233 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 20:46:10 -0500
Subject: [PATCH 090/137] remainder
---
scripts/pi-hole/js/settings.js | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index ea0a408cf..c22c38902 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -543,11 +543,13 @@ $(function () {
const triggerPattern = /(\d+s)/;
const triggerMatch = status.match(triggerPattern);
- const now = new Date();
- const secondsUntilNextMinute = 60 - now.getSeconds();
- const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
- const statusText = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
-
+ let statusText = status;
+ if (triggerMatch) {
+ const now = new Date();
+ const secondsUntilNextMinute = 60 - now.getSeconds();
+ const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
+ statusText = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
+ }
triggerText = statusText === "0s" ? " running" : ` in ${status}`;
}
} else {
From 6ca138005ade899e6e9ee5b5ec2c39fd9537f2c3 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 21:18:52 -0500
Subject: [PATCH 091/137] ensure log
---
api_speedtest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index fea61e20e..3e24ba9f6 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -17,7 +17,7 @@
$setupVars = parse_ini_file('/etc/pihole/setupVars.conf');
-$cmdLog = 'cat /var/log/pimod.log';
+$cmdLog = '[[ -f /var/log/pimod.log ]] && cat /var/log/pimod.log || echo ""';
$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --list';
if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
$remaining_seconds = getRemainingTime();
@@ -34,7 +34,7 @@
} else {
$cmdStatus = 'systemctl status pihole-speedtest.timer';
}
-$cmdRun = 'cat /tmp/speedtest.log';
+$cmdRun = '[[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
From e748320520c804aba78488795f532a687505112d Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 8 Feb 2024 21:27:09 -0500
Subject: [PATCH 092/137] use Date
---
scripts/pi-hole/js/speedtest.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index ed05b1a22..fc2a8a840 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -140,7 +140,7 @@ function formatDate(itemdate, results) {
output = "Do HH:mm";
}
- return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ssZ").local().format(output);
+ return moment(new Date(itemdate).toISOString()).format(output);
}
function updateSpeedTestData() {
From ad0d7d233b244cb46fdad74e65c4503062197362 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 00:28:47 -0500
Subject: [PATCH 093/137] verbiage
---
scripts/pi-hole/js/settings.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index c22c38902..ec626b0e4 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -550,7 +550,7 @@ $(function () {
const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
statusText = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
}
- triggerText = statusText === "0s" ? " running" : ` in ${status}`;
+ triggerText = statusText === "0s" ? " queued" : ` in ${status}`;
}
} else {
const scheduleStatusPattern = /pihole-speedtest\.timer.*?Active:\s+(\w+)/s;
From a0fd45a6ff3081b2ffe921cf56416c84b3395866 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 00:34:37 -0500
Subject: [PATCH 094/137] I can pipe from inside
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 3e24ba9f6..4339dc0e0 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -34,7 +34,7 @@
} else {
$cmdStatus = 'systemctl status pihole-speedtest.timer';
}
-$cmdRun = '[[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""';
+$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || [[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
From ebe5feea21836a75ed23ee124f8bae5ae224409f Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 00:41:15 -0500
Subject: [PATCH 095/137] inline if
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 4339dc0e0..af911c5c9 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -34,7 +34,7 @@
} else {
$cmdStatus = 'systemctl status pihole-speedtest.timer';
}
-$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || [[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""';
+$cmdRun = 'if [[ -f /tmp/speedtest.log ]]; then cat /tmp/speedtest.log elif [[ -f /var/log/pihole/speedtest.log ]]; then cat /var/log/pihole/speedtest.log else echo "" fi';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
From 16dcc64bc9c00ecefcd2295a15e88326eef21946 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 00:59:35 -0500
Subject: [PATCH 096/137] use pipe
---
api_speedtest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index af911c5c9..abed78561 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -17,7 +17,7 @@
$setupVars = parse_ini_file('/etc/pihole/setupVars.conf');
-$cmdLog = '[[ -f /var/log/pimod.log ]] && cat /var/log/pimod.log || echo ""';
+$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pimod.log ]] && cat /var/log/pimod.log || echo ""; }';
$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --list';
if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
$remaining_seconds = getRemainingTime();
@@ -34,7 +34,7 @@
} else {
$cmdStatus = 'systemctl status pihole-speedtest.timer';
}
-$cmdRun = 'if [[ -f /tmp/speedtest.log ]]; then cat /tmp/speedtest.log elif [[ -f /var/log/pihole/speedtest.log ]]; then cat /var/log/pihole/speedtest.log else echo "" fi';
+$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""; }';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
From 3e948c9a940e92b8896fc5a706ad81acd5307410 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 02:17:22 -0500
Subject: [PATCH 097/137] move log
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index abed78561..46fdb0359 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -17,7 +17,7 @@
$setupVars = parse_ini_file('/etc/pihole/setupVars.conf');
-$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pimod.log ]] && cat /var/log/pimod.log || echo ""; }';
+$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pihole/mod.log ]] && cat /var/log/pihole/mod.log || echo ""; }';
$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --list';
if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
$remaining_seconds = getRemainingTime();
From d29de6d1b52612b96588cd35a65d02da59ff500f Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 04:04:03 -0500
Subject: [PATCH 098/137] data =
---
scripts/pi-hole/js/speedresults.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 85835ecaa..f34c070d2 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
From bff39b5b42fcd16479e2cbdfff01d4bd96bed035 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Fri, 9 Feb 2024 04:58:34 -0500
Subject: [PATCH 099/137] pretty
---
scripts/pi-hole/js/settings.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index ec626b0e4..984a5e425 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -548,7 +548,10 @@ $(function () {
const now = new Date();
const secondsUntilNextMinute = 60 - now.getSeconds();
const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
- statusText = statusSeconds > secondsUntilNextMinute ? `${statusSeconds - secondsUntilNextMinute}s` : "0s";
+ statusText =
+ statusSeconds > secondsUntilNextMinute
+ ? `${statusSeconds - secondsUntilNextMinute}s`
+ : "0s";
}
triggerText = statusText === "0s" ? " queued" : ` in ${status}`;
}
From 5296259f3aaed4b99f9f68dcde0d2457c918440b Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 00:27:32 -0500
Subject: [PATCH 100/137] int
---
api_speedtest.php | 2 +-
scripts/pi-hole/js/settings.js | 4 +++-
scripts/pi-hole/js/speedtest.js | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 46fdb0359..c41e2ccaf 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -105,7 +105,7 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
return array();
}
- if ($durationdays == -1) {
+ if ((int) $durationdays == -1) {
$sql = 'SELECT * from speedtest order by id asc';
} else {
$curdate = new DateTime('now', new DateTimeZone('UTC'));
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 984a5e425..f969683e0 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -547,12 +547,13 @@ $(function () {
if (triggerMatch) {
const now = new Date();
const secondsUntilNextMinute = 60 - now.getSeconds();
- const statusSeconds = parseInt(triggerMatch[0].replace("s", ""));
+ const statusSeconds = parseInt(triggerMatch[0].replace("s", ""), 10);
statusText =
statusSeconds > secondsUntilNextMinute
? `${statusSeconds - secondsUntilNextMinute}s`
: "0s";
}
+
triggerText = statusText === "0s" ? " queued" : ` in ${status}`;
}
} else {
@@ -583,6 +584,7 @@ $(function () {
if (lastRun) {
lastRunText = `\n\nLatest run:\n${lastRun}`;
}
+
const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index fc2a8a840..3dc60d2b4 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -168,12 +168,12 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) && days !== "-2") {
+ if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden)) {
speedChart.destroy();
speedChart = null;
}
- if (!speedChart || beenHidden) {
+ if (!speedChart) {
localStorage.setItem(
"speedtest_preview_hidden",
!localStorage?.getItem("speedtest_preview_shown")
From 755b07a45413b2b3e71ca228223186197c5d4c30 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 00:41:00 -0500
Subject: [PATCH 101/137] extra utc?
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index f34c070d2..2ca1a5781 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 3dc60d2b4..013aaade2 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -181,7 +181,7 @@ function updateSpeedTestData() {
createChart();
}
- if (speedChart) {
+ if (speedChart && speedChart.data.labels.join() !== speedlabels.join()) {
speedChart.data.labels = speedlabels;
speedChart.data.datasets[0].data = downloadspeed;
speedChart.data.datasets[1].data = uploadspeed;
From 3df07e9e669f18d4e71e8b2553962caa03aa95fd Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 00:53:00 -0500
Subject: [PATCH 102/137] Parse the date as UTC but ignore the time zone
conversion by using moment.utc
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 2ca1a5781..542dd1687 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment(data, "YYYY-MM-DD HH:mm:ssZ").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm");
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 013aaade2..acff782ba 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -199,5 +199,5 @@ $(function () {
updateSpeedTestData();
setInterval(function () {
updateSpeedTestData();
- }, 6000);
+ }, 1000);
});
From 3f0d3ecbec3c10ebed529752e3d8240d5066add8 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 01:03:49 -0500
Subject: [PATCH 103/137] with local()
---
scripts/pi-hole/js/speedresults.js | 4 ++--
scripts/pi-hole/js/speedtest.js | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 542dd1687..f316c077c 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -49,7 +49,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mm Z");
}
return data;
@@ -58,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mm Z");
}
return data;
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index acff782ba..80bdc3315 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -187,8 +187,9 @@ function updateSpeedTestData() {
speedChart.data.datasets[1].data = uploadspeed;
speedChart.data.datasets[2].data = serverPing;
speedChart.update();
- $("#speedOverTimeChartOverlay").css("display", "none");
}
+
+ $("#speedOverTimeChartOverlay").css("display", "none");
});
}
From 482ba9ccea7711d424e77aaded246cd62eebdebf Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 01:36:56 -0500
Subject: [PATCH 104/137] log
---
scripts/pi-hole/js/speedresults.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index f316c077c..258ad5621 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -48,17 +48,18 @@ $(document).ready(function () {
null,
{
render: function (data, type, _full, _meta) {
+ console.log("utc: " + data);
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mm Z");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mmZ");
}
-
+ console.log("local: " + data);
return data;
},
},
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mm Z");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mmZ");
}
return data;
From d4394039572450d1265b3034ae226d42fb38b0a9 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 01:49:20 -0500
Subject: [PATCH 105/137] no log
---
scripts/pi-hole/js/speedresults.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 258ad5621..512a21e15 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -48,9 +48,8 @@ $(document).ready(function () {
null,
{
render: function (data, type, _full, _meta) {
- console.log("utc: " + data);
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format();
}
console.log("local: " + data);
return data;
@@ -59,7 +58,7 @@ $(document).ready(function () {
{
render: function (data, type, _full, _meta) {
if (type === "display") {
- data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mmZ");
+ data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format();
}
return data;
From 25634a0ab0f8e736a57a6deb19d9ded9624faa93 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 01:52:22 -0500
Subject: [PATCH 106/137] pretty
---
scripts/pi-hole/js/speedresults.js | 2 +-
scripts/pi-hole/js/speedtest.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/speedresults.js b/scripts/pi-hole/js/speedresults.js
index 512a21e15..9160d7aed 100644
--- a/scripts/pi-hole/js/speedresults.js
+++ b/scripts/pi-hole/js/speedresults.js
@@ -51,7 +51,7 @@ $(document).ready(function () {
if (type === "display") {
data = moment.utc(data, "YYYY-MM-DD HH:mm:ss").local().format();
}
- console.log("local: " + data);
+
return data;
},
},
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 80bdc3315..424b311ef 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -181,7 +181,7 @@ function updateSpeedTestData() {
createChart();
}
- if (speedChart && speedChart.data.labels.join() !== speedlabels.join()) {
+ if (speedChart && speedChart.data.labels.join(",") !== speedlabels.join(",")) {
speedChart.data.labels = speedlabels;
speedChart.data.datasets[0].data = downloadspeed;
speedChart.data.datasets[1].data = uploadspeed;
From 80183345ac7fd9890418e30f2dff1496b81b9e71 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 02:11:28 -0500
Subject: [PATCH 107/137] no animation
---
scripts/pi-hole/js/speedtest.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 424b311ef..353cd18c2 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -131,7 +131,7 @@ function createChart() {
function formatDate(itemdate, results) {
let output = "HH:mm";
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ssZ").local().format(output);
+ return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ss").local().format(output);
}
const first = moment(results.at(0).start_time, "YYYY-MM-DD HH:mm:ssZ");
@@ -140,7 +140,7 @@ function formatDate(itemdate, results) {
output = "Do HH:mm";
}
- return moment(new Date(itemdate).toISOString()).format(output);
+ return moment.utc(itemdate, "YYYY-MM-DD HH:mm:ss").local().format(output);
}
function updateSpeedTestData() {
@@ -186,7 +186,7 @@ function updateSpeedTestData() {
speedChart.data.datasets[0].data = downloadspeed;
speedChart.data.datasets[1].data = uploadspeed;
speedChart.data.datasets[2].data = serverPing;
- speedChart.update();
+ speedChart.update("none");
}
$("#speedOverTimeChartOverlay").css("display", "none");
From 6e41e6c728f55ae70887895a39d9c9ce3061d2c3 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 02:16:39 -0500
Subject: [PATCH 108/137] why join
---
scripts/pi-hole/js/speedtest.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 353cd18c2..54da7927b 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -181,12 +181,12 @@ function updateSpeedTestData() {
createChart();
}
- if (speedChart && speedChart.data.labels.join(",") !== speedlabels.join(",")) {
+ if (speedChart && speedChart.data.labels !== speedlabels) {
speedChart.data.labels = speedlabels;
speedChart.data.datasets[0].data = downloadspeed;
speedChart.data.datasets[1].data = uploadspeed;
speedChart.data.datasets[2].data = serverPing;
- speedChart.update("none");
+ speedChart.update();
}
$("#speedOverTimeChartOverlay").css("display", "none");
From 7c7dd0f5a30326357e0a60c86f929c94fe6923b4 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 02:20:39 -0500
Subject: [PATCH 109/137] if days
---
scripts/pi-hole/js/speedtest.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 54da7927b..f620fce85 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -168,7 +168,7 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden)) {
+ if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) && days !== "-2") {
speedChart.destroy();
speedChart = null;
}
From 24110b15bd3086f7d92d56bed0f3a74732e20d0e Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 03:30:05 -0500
Subject: [PATCH 110/137] verbiage
---
scripts/pi-hole/js/settings.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index f969683e0..b056ef49c 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -580,23 +580,23 @@ $(function () {
})
.done(function (data) {
const lastRun = data?.data;
- let lastRunText = "";
+ let lastRunText = "Latest run is unavailable";
if (lastRun) {
- lastRunText = `\n\nLatest run:\n${lastRun}`;
+ lastRunText = `Latest run:\n\n${lastRun}`;
}
- const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
+ const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}\n${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
.fail(function () {
- const lastRunText = "\nFailed to get latest run";
+ const lastRunText = "\nLatest run is unavailable";
const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
})
.fail(function () {
const triggerText = speedtestTest.attr("value") ? " awaiting confirmation" : " unknown";
- const lastRunText = "\nFailed to get latest run";
+ const lastRunText = "\nLatest run is unavailable";
const statusText = "Failed to get schedule\nNext run is" + triggerText + lastRunText;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
From b0aca364c93aed9bc14303ae698db81203079a08 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 04:30:48 -0500
Subject: [PATCH 111/137] add help
---
scripts/pi-hole/js/settings.js | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index b056ef49c..75d03ebad 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -673,13 +673,24 @@ $(function () {
.done(function (data) {
const log = data?.data;
if (log) {
+ speedtestLog.find("p").remove();
codeBlock(speedtestLog, log, speedtestLogBtn, "log");
} else {
codeBlock(speedtestLog, "The log is empty", speedtestLogBtn, "log");
}
})
.fail(function () {
- codeBlock(speedtestLog, "Failed to get log", speedtestLogBtn, "log");
+ codeBlock(
+ speedtestLog,
+ "tmux a -t pimod; cat /var/log/pihole/mod.log",
+ speedtestLogBtn,
+ "log"
+ );
+ if (speedtestLogCtr.find("p").length === 0) {
+ speedtestLogCtr.append(
+ `
Failed to get process output. Use the above command to get it.
`
+ );
+ }
});
};
@@ -834,8 +845,10 @@ $(function () {
speedtestLogBtn.on("click", function () {
const log = speedtestLog.find("pre");
- if (log.length > 0) {
+ const info = speedtestLog.find("p");
+ if (log.length > 0 || info.length > 0) {
log.remove();
+ info.remove();
speedtestLogBtn.text("Show latest log");
} else {
latestLog();
From ca480e6eb08e8d4f83948bc0b558edccd87c0bdf Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 04:45:54 -0500
Subject: [PATCH 112/137] make it double
---
scripts/pi-hole/js/settings.js | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 75d03ebad..aaab5746c 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -597,7 +597,7 @@ $(function () {
.fail(function () {
const triggerText = speedtestTest.attr("value") ? " awaiting confirmation" : " unknown";
const lastRunText = "\nLatest run is unavailable";
- const statusText = "Failed to get schedule\nNext run is" + triggerText + lastRunText;
+ const statusText = "Schedule is unavailable\nNext run is" + triggerText + lastRunText;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
};
@@ -676,7 +676,17 @@ $(function () {
speedtestLog.find("p").remove();
codeBlock(speedtestLog, log, speedtestLogBtn, "log");
} else {
- codeBlock(speedtestLog, "The log is empty", speedtestLogBtn, "log");
+ codeBlock(
+ speedtestLog,
+ "tmux a -t pimod; cat /var/log/pihole/mod.log",
+ speedtestLogBtn,
+ "log"
+ );
+ if (speedtestLogCtr.find("p").length === 0) {
+ speedtestLogCtr.append(
+ `
Use this command to get the log while I look for it
`
+ );
+ }
}
})
.fail(function () {
@@ -688,7 +698,7 @@ $(function () {
);
if (speedtestLogCtr.find("p").length === 0) {
speedtestLogCtr.append(
- `
Failed to get process output. Use the above command to get it.
`
+ `
Use this command to get the log while I look for it
`
);
}
});
@@ -886,6 +896,17 @@ $(function () {
latestLog();
}
+ // if speedtestLogCtr has a p element, cycle through ellipsis
+ const info = speedtestLogCtr.find("p");
+ if (info.length > 0) {
+ const text = info.text();
+ if (text.includes("...")) {
+ info.text(text.replace(/\.{3}/, "."));
+ } else {
+ info.text(text + ".");
+ }
+ }
+
canRestore();
}, 1000);
});
From dc44d91b877c7b1f98a966c71e3d000aa928b4a8 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 04:48:53 -0500
Subject: [PATCH 113/137] typo
---
scripts/pi-hole/js/settings.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index aaab5746c..4927392e1 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -682,8 +682,8 @@ $(function () {
speedtestLogBtn,
"log"
);
- if (speedtestLogCtr.find("p").length === 0) {
- speedtestLogCtr.append(
+ if (speedtestLog.find("p").length === 0) {
+ speedtestLog.append(
`
Use this command to get the log while I look for it
`
);
}
@@ -696,8 +696,8 @@ $(function () {
speedtestLogBtn,
"log"
);
- if (speedtestLogCtr.find("p").length === 0) {
- speedtestLogCtr.append(
+ if (speedtestLog.find("p").length === 0) {
+ speedtestLog.append(
`
Use this command to get the log while I look for it
`
);
}
@@ -896,8 +896,8 @@ $(function () {
latestLog();
}
- // if speedtestLogCtr has a p element, cycle through ellipsis
- const info = speedtestLogCtr.find("p");
+ // if speedtestLog has a p element, cycle through ellipsis
+ const info = speedtestLog.find("p");
if (info.length > 0) {
const text = info.text();
if (text.includes("...")) {
From f2ce4b0d500de4b25133b6be29c365217831e272 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 04:52:08 -0500
Subject: [PATCH 114/137] .
---
scripts/pi-hole/js/settings.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 4927392e1..8f3ef4bb2 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -901,7 +901,7 @@ $(function () {
if (info.length > 0) {
const text = info.text();
if (text.includes("...")) {
- info.text(text.replace(/\.{3}/, "."));
+ info.text(text.replace(/\.{3}/, ""));
} else {
info.text(text + ".");
}
From e4bde7ac777089f9c8e97dbd404b5bb78e6d0db3 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 05:36:07 -0500
Subject: [PATCH 115/137] chart in pre
---
scripts/pi-hole/js/settings.js | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 8f3ef4bb2..35e0f20b2 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -502,10 +502,14 @@ $(function () {
speedtestChartType.prop("checked", type === "bar");
localStorage.setItem("speedtest_chart_type", type);
- const preCode = text => {
+ const preCode = content => {
const pre = document.createElement("pre");
const code = document.createElement("code");
- code.textContent = text;
+ if (typeof content === "string") {
+ code.textContent = content;
+ } else {
+ code.append(content);
+ }
code.style.whiteSpace = "pre";
code.style.overflowWrap = "normal";
pre.append(code);
@@ -606,7 +610,7 @@ $(function () {
if (!preview) {
localStorage.setItem("speedtest_preview_hidden", "true");
localStorage.setItem("speedtest_preview_shown", "false");
- speedtestChartPreview.find("div").remove();
+ speedtestChartPreview.find("pre").remove();
} else {
let speedtestdays = speedtestDays.val();
localStorage.setItem("speedtest_days", speedtestdays);
@@ -635,6 +639,7 @@ $(function () {
colDiv.style.marginTop = "1vw";
boxDiv.className = "box";
boxDiv.id = "queries-over-time";
+ boxDiv.style.marginBottom = "0";
boxHeaderDiv.className = "box-header with-border";
h3.className = "box-title";
h3.textContent = `Speedtest results over last ${speedtestdays}`;
@@ -658,8 +663,8 @@ $(function () {
overlayDiv.append(i);
chartDiv.append(canvas);
- speedtestChartPreview.find("div").remove();
- speedtestChartPreview.append(colDiv);
+ speedtestChartPreview.find("pre").remove();
+ speedtestChartPreview.append(preCode(colDiv));
}
speedtestChartPreviewBtn.text(preview ? "Hide preview" : "Show chart preview");
@@ -804,7 +809,7 @@ $(function () {
speedtestDays.attr("value", speedtestDays.val());
if (speedtestDays.val()) {
localStorage.setItem("speedtest_days", speedtestDays.val());
- previewChart(speedtestChartPreview.find("div").length > 0);
+ previewChart(speedtestChartPreview.find("pre").length > 0);
}
});
@@ -815,7 +820,7 @@ $(function () {
localStorage.setItem("speedtest_chart_type", type);
// Call check messages to make new setting effective
checkMessages();
- previewChart(speedtestChartPreview.find("div").length > 0);
+ previewChart(speedtestChartPreview.find("pre").length > 0);
});
speedtestChartTypeSave.on("click", function () {
@@ -823,7 +828,7 @@ $(function () {
});
speedtestChartPreviewBtn.on("click", function () {
- previewChart(speedtestChartPreview.find("div").length === 0);
+ previewChart(speedtestChartPreview.find("pre").length === 0);
});
speedtestUpdate.on("click", function () {
From 06398569523a2643af415889751a67921dda4c5c Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 05:38:50 -0500
Subject: [PATCH 116/137] nvm
---
scripts/pi-hole/js/settings.js | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 35e0f20b2..153878b1d 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -610,7 +610,7 @@ $(function () {
if (!preview) {
localStorage.setItem("speedtest_preview_hidden", "true");
localStorage.setItem("speedtest_preview_shown", "false");
- speedtestChartPreview.find("pre").remove();
+ speedtestChartPreview.find("div").remove();
} else {
let speedtestdays = speedtestDays.val();
localStorage.setItem("speedtest_days", speedtestdays);
@@ -639,7 +639,6 @@ $(function () {
colDiv.style.marginTop = "1vw";
boxDiv.className = "box";
boxDiv.id = "queries-over-time";
- boxDiv.style.marginBottom = "0";
boxHeaderDiv.className = "box-header with-border";
h3.className = "box-title";
h3.textContent = `Speedtest results over last ${speedtestdays}`;
@@ -663,8 +662,8 @@ $(function () {
overlayDiv.append(i);
chartDiv.append(canvas);
- speedtestChartPreview.find("pre").remove();
- speedtestChartPreview.append(preCode(colDiv));
+ speedtestChartPreview.find("div").remove();
+ speedtestChartPreview.append(colDiv);
}
speedtestChartPreviewBtn.text(preview ? "Hide preview" : "Show chart preview");
@@ -809,7 +808,7 @@ $(function () {
speedtestDays.attr("value", speedtestDays.val());
if (speedtestDays.val()) {
localStorage.setItem("speedtest_days", speedtestDays.val());
- previewChart(speedtestChartPreview.find("pre").length > 0);
+ previewChart(speedtestChartPreview.find("div").length > 0);
}
});
@@ -820,7 +819,7 @@ $(function () {
localStorage.setItem("speedtest_chart_type", type);
// Call check messages to make new setting effective
checkMessages();
- previewChart(speedtestChartPreview.find("pre").length > 0);
+ previewChart(speedtestChartPreview.find("div").length > 0);
});
speedtestChartTypeSave.on("click", function () {
@@ -828,7 +827,7 @@ $(function () {
});
speedtestChartPreviewBtn.on("click", function () {
- previewChart(speedtestChartPreview.find("pre").length === 0);
+ previewChart(speedtestChartPreview.find("div").length === 0);
});
speedtestUpdate.on("click", function () {
From 6cf6f0fb80b8a47a5b69ad0b3e4878dcb0e7246a Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 05:53:04 -0500
Subject: [PATCH 117/137] recheck for servers
---
scripts/pi-hole/js/settings.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 153878b1d..d9d06fb48 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -722,6 +722,10 @@ $(function () {
}
};
+ if (cmds.length === 0) {
+ cmds = ["JSONClosestServers", "getClosestServers", "curlClosestServers"];
+ }
+
$.ajax({
url: `api.php?${cmds[0]}`,
dataType: "json",
@@ -876,8 +880,7 @@ $(function () {
speedtestServerBtn.text("Show closest servers");
} else {
speedtestServerBtn.text("Retrieving servers...");
- speedtestServerCtr.find("p").remove();
- closestServers(["JSONClosestServers", "getClosestServers", "curlClosestServers"]);
+ closestServers();
}
});
@@ -911,6 +914,10 @@ $(function () {
}
}
+ if (speedtestServerCtr.find("p").length > 0) {
+ closestServers();
+ }
+
canRestore();
}, 1000);
});
From 1996ad8aa2360b06d399d9d8255dd25bb2d05efa Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 07:40:26 -0500
Subject: [PATCH 118/137] pretty
---
scripts/pi-hole/js/settings.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index d9d06fb48..8be7379c8 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -510,15 +510,16 @@ $(function () {
} else {
code.append(content);
}
+
code.style.whiteSpace = "pre";
code.style.overflowWrap = "normal";
- pre.append(code);
pre.style.width = "100%";
pre.style.maxWidth = "100%";
pre.style.maxHeight = "500px";
pre.style.overflow = "auto";
pre.style.whiteSpace = "pre";
pre.style.marginTop = "1vw";
+ pre.append(code);
return pre;
};
From f943cda287936c449e7746d014598c754029ee6d Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 17:04:50 -0500
Subject: [PATCH 119/137] destroy after one point
---
scripts/pi-hole/js/speedtest.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index f620fce85..e79b520b0 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -168,7 +168,14 @@ function updateSpeedTestData() {
serverPing.push(parseFloat(packet.server_ping));
}
});
- if (speedChart && (!daysIsTheSame || !typeIsTheSame || beenHidden) && days !== "-2") {
+ if (
+ speedChart &&
+ (!daysIsTheSame ||
+ !typeIsTheSame ||
+ beenHidden ||
+ (type === "line" && speedChart.data?.labels?.length < 2 && speedlabels?.length > 1)) &&
+ days !== "-2"
+ ) {
speedChart.destroy();
speedChart = null;
}
From cd3386e1b58078dde960836b255317cc38df6b96 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sun, 11 Feb 2024 17:21:16 -0500
Subject: [PATCH 120/137] fix if
---
scripts/pi-hole/js/settings.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 8be7379c8..1e8ebfd8f 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -723,7 +723,7 @@ $(function () {
}
};
- if (cmds.length === 0) {
+ if (!cmds || cmds.length === 0) {
cmds = ["JSONClosestServers", "getClosestServers", "curlClosestServers"];
}
From 090e4bfcc9b0ef070311bfdf1ee82b1b4becc0b1 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 06:41:03 -0500
Subject: [PATCH 121/137] getNumberOfDaysInDB
---
api_speedtest.php | 31 +++++++++
scripts/pi-hole/js/settings.js | 111 ++++++++++++++++++++-------------
2 files changed, 97 insertions(+), 45 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index c41e2ccaf..f3a7eddf1 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -66,6 +66,9 @@
if (isset($_GET['JSONClosestServers'])) {
$data = array_merge($data, JSONServers($cmdServersJSON));
}
+ if (isset($_GET['getNumberOfDaysInDB'])) {
+ $data = array_merge($data, getNumberOfDaysInDB($dbSpeedtest));
+ }
}
function hasSpeedTestBackup($dbSpeedtestOld)
@@ -301,3 +304,31 @@ function getRemainingTime()
return max(0, $interval_seconds - (time() - $last_run_time));
}
+
+function getNumberOfDaysInDB($dbSpeedtest)
+{
+ $db = new SQLite3($dbSpeedtest);
+ if (!$db) {
+ return array('data' => 0);
+ }
+
+ $sql = 'SELECT start_time from speedtest order by id asc';
+ $dbResults = $db->query($sql);
+ $dataFromSpeedDB = array();
+ if (!empty($dbResults)) {
+ while ($row = $dbResults->fetchArray(SQLITE3_ASSOC)) {
+ array_push($dataFromSpeedDB, $row);
+ }
+ }
+ $db->close();
+
+ if (empty($dataFromSpeedDB)) {
+ return array('data' => 0);
+ }
+
+ $first_date = new DateTime($dataFromSpeedDB[0]['start_time']);
+ $last_date = new DateTime($dataFromSpeedDB[count($dataFromSpeedDB) - 1]['start_time']);
+ $diff = $first_date->diff($last_date);
+
+ return array('data' => $diff->days + 1);
+}
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 1e8ebfd8f..1b4cddfc5 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -607,6 +607,48 @@ $(function () {
});
};
+ const drawChart = (days, type) => {
+ const colDiv = document.createElement("div");
+ const boxDiv = document.createElement("div");
+ const boxHeaderDiv = document.createElement("div");
+ const h3 = document.createElement("h3");
+ const boxBodyDiv = document.createElement("div");
+ const chartDiv = document.createElement("div");
+ const canvas = document.createElement("canvas");
+ const overlayDiv = document.createElement("div");
+ const i = document.createElement("i");
+
+ colDiv.className = "col-md-12";
+ colDiv.style.marginTop = "1vw";
+ boxDiv.className = "box";
+ boxDiv.id = "queries-over-time";
+ boxHeaderDiv.className = "box-header with-border";
+ h3.className = "box-title";
+ h3.textContent = `Speedtest results over last ${days}`;
+ boxBodyDiv.className = "box-body";
+ chartDiv.className = "chart";
+ chartDiv.style.position = "relative";
+ chartDiv.style.width = "100%";
+ chartDiv.style.height = "180px";
+ canvas.id = "speedOverTimeChart";
+ canvas.setAttribute("value", type);
+ overlayDiv.className = "overlay";
+ overlayDiv.id = "speedOverTimeChartOverlay";
+ i.className = "fa fa-sync fa-spin";
+
+ colDiv.append(boxDiv);
+ boxDiv.append(boxHeaderDiv);
+ boxDiv.append(boxBodyDiv);
+ boxDiv.append(overlayDiv);
+ boxHeaderDiv.append(h3);
+ boxBodyDiv.append(chartDiv);
+ overlayDiv.append(i);
+ chartDiv.append(canvas);
+
+ speedtestChartPreview.find("div").remove();
+ speedtestChartPreview.append(colDiv);
+ };
+
const previewChart = preview => {
if (!preview) {
localStorage.setItem("speedtest_preview_hidden", "true");
@@ -618,53 +660,32 @@ $(function () {
localStorage.setItem("speedtest_chart_type", type);
localStorage.setItem("speedtest_preview_shown", "true");
- if (speedtestdays === "1") {
- speedtestdays = "24 hours";
- } else if (speedtestdays === "-1") {
- speedtestdays = "however many days";
- } else {
- speedtestdays += " days";
- }
+ $.ajax({
+ url: "api.php?getNumberOfDaysInDB",
+ dataType: "json",
+ })
+ .done(function (data) {
+ if (speedtestdays === "1") {
+ speedtestdays = "24 hours";
+ } else if (speedtestdays === "-1") {
+ speedtestdays = data ? data.data : "however many days";
+ } else {
+ speedtestdays += " days";
+ }
- const colDiv = document.createElement("div");
- const boxDiv = document.createElement("div");
- const boxHeaderDiv = document.createElement("div");
- const h3 = document.createElement("h3");
- const boxBodyDiv = document.createElement("div");
- const chartDiv = document.createElement("div");
- const canvas = document.createElement("canvas");
- const overlayDiv = document.createElement("div");
- const i = document.createElement("i");
-
- colDiv.className = "col-md-12";
- colDiv.style.marginTop = "1vw";
- boxDiv.className = "box";
- boxDiv.id = "queries-over-time";
- boxHeaderDiv.className = "box-header with-border";
- h3.className = "box-title";
- h3.textContent = `Speedtest results over last ${speedtestdays}`;
- boxBodyDiv.className = "box-body";
- chartDiv.className = "chart";
- chartDiv.style.position = "relative";
- chartDiv.style.width = "100%";
- chartDiv.style.height = "180px";
- canvas.id = "speedOverTimeChart";
- canvas.setAttribute("value", type);
- overlayDiv.className = "overlay";
- overlayDiv.id = "speedOverTimeChartOverlay";
- i.className = "fa fa-sync fa-spin";
-
- colDiv.append(boxDiv);
- boxDiv.append(boxHeaderDiv);
- boxDiv.append(boxBodyDiv);
- boxDiv.append(overlayDiv);
- boxHeaderDiv.append(h3);
- boxBodyDiv.append(chartDiv);
- overlayDiv.append(i);
- chartDiv.append(canvas);
+ drawChart(speedtestdays, type);
+ })
+ .fail(function () {
+ if (speedtestdays === "1") {
+ speedtestdays = "24 hours";
+ } else if (speedtestdays === "-1") {
+ speedtestdays = "however many days";
+ } else {
+ speedtestdays += " days";
+ }
- speedtestChartPreview.find("div").remove();
- speedtestChartPreview.append(colDiv);
+ drawChart(speedtestdays, type);
+ });
}
speedtestChartPreviewBtn.text(preview ? "Hide preview" : "Show chart preview");
From 33784b824bebafed2d4082e68cd2f2f4316a5dc4 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 06:54:01 -0500
Subject: [PATCH 122/137] fix text
---
api_speedtest.php | 2 +-
scripts/pi-hole/js/settings.js | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index f3a7eddf1..8a9856acf 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -327,7 +327,7 @@ function getNumberOfDaysInDB($dbSpeedtest)
}
$first_date = new DateTime($dataFromSpeedDB[0]['start_time']);
- $last_date = new DateTime($dataFromSpeedDB[count($dataFromSpeedDB) - 1]['start_time']);
+ $last_date = new DateTime('now', new DateTimeZone('UTC'));
$diff = $first_date->diff($last_date);
return array('data' => $diff->days + 1);
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 1b4cddfc5..ac2cce52f 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -665,10 +665,12 @@ $(function () {
dataType: "json",
})
.done(function (data) {
+ if (speedtestdays === "-1") {
+ speedtestdays = data ? data.data : "however many";
+ }
+
if (speedtestdays === "1") {
speedtestdays = "24 hours";
- } else if (speedtestdays === "-1") {
- speedtestdays = data ? data.data : "however many days";
} else {
speedtestdays += " days";
}
@@ -676,10 +678,12 @@ $(function () {
drawChart(speedtestdays, type);
})
.fail(function () {
+ if (speedtestdays === "-1") {
+ speedtestdays = "however many";
+ }
+
if (speedtestdays === "1") {
speedtestdays = "24 hours";
- } else if (speedtestdays === "-1") {
- speedtestdays = "however many days";
} else {
speedtestdays += " days";
}
From 0788b8ce51be6692210281c328de24b4cfc8ba69 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 12:02:35 -0500
Subject: [PATCH 123/137] getNumberOfDaysInDB on the dashboard too
---
scripts/pi-hole/php/header_authenticated.php | 40 +++++++++++++++++---
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/scripts/pi-hole/php/header_authenticated.php b/scripts/pi-hole/php/header_authenticated.php
index fb8dcf5f6..4de326ad9 100644
--- a/scripts/pi-hole/php/header_authenticated.php
+++ b/scripts/pi-hole/php/header_authenticated.php
@@ -149,6 +149,35 @@ function getTemperature()
// Get memory usage
$memory_usage = getMemUsage();
+$dbSpeedtest = '/etc/pihole/speedtest.db';
+function getNumberOfDaysInDB($dbSpeedtest)
+{
+ $db = new SQLite3($dbSpeedtest);
+ if (!$db) {
+ return 0;
+ }
+
+ $sql = 'SELECT start_time from speedtest order by id asc';
+ $dbResults = $db->query($sql);
+ $dataFromSpeedDB = array();
+ if (!empty($dbResults)) {
+ while ($row = $dbResults->fetchArray(SQLITE3_ASSOC)) {
+ array_push($dataFromSpeedDB, $row);
+ }
+ }
+ $db->close();
+
+ if (empty($dataFromSpeedDB)) {
+ return 0;
+ }
+
+ $first_date = new DateTime($dataFromSpeedDB[0]['start_time']);
+ $last_date = new DateTime('now', new DateTimeZone('UTC'));
+ $diff = $first_date->diff($last_date);
+
+ return $diff->days + 1;
+}
+
$speedtestschedule = false;
$speedtestdays = '';
$speedtestcharttype = 'line';
@@ -156,15 +185,16 @@ function getTemperature()
$speedtestschedule = $setupVars['SPEEDTESTSCHEDULE'];
}
if (isset($setupVars['SPEEDTEST_CHART_DAYS'])) {
- if ($setupVars['SPEEDTEST_CHART_DAYS'] > 1) {
- $speedtestdays = $setupVars['SPEEDTEST_CHART_DAYS'].' days';
+ if ($setupVars['SPEEDTEST_CHART_DAYS'] == -1) {
+ $speedtestdays = getNumberOfDaysInDB($dbSpeedtest).' days';
}
if ($setupVars['SPEEDTEST_CHART_DAYS'] == 1) {
$speedtestdays = '24 hours';
+ } else {
+ $speedtestdays = $setupVars['SPEEDTEST_CHART_DAYS'].' days';
}
- if ($setupVars['SPEEDTEST_CHART_DAYS'] == -1) {
- $speedtestdays = 'however many days';
- }
+
+
}
if (isset($setupVars['SPEEDTEST_CHART_TYPE'])) {
$speedtestcharttype = $setupVars['SPEEDTEST_CHART_TYPE'];
From 2773fb8125ff3571b3948fcecf44fc85c7c1a657 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 12:11:20 -0500
Subject: [PATCH 124/137] else if
---
scripts/pi-hole/php/header_authenticated.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/pi-hole/php/header_authenticated.php b/scripts/pi-hole/php/header_authenticated.php
index 4de326ad9..6d8b76182 100644
--- a/scripts/pi-hole/php/header_authenticated.php
+++ b/scripts/pi-hole/php/header_authenticated.php
@@ -187,8 +187,7 @@ function getNumberOfDaysInDB($dbSpeedtest)
if (isset($setupVars['SPEEDTEST_CHART_DAYS'])) {
if ($setupVars['SPEEDTEST_CHART_DAYS'] == -1) {
$speedtestdays = getNumberOfDaysInDB($dbSpeedtest).' days';
- }
- if ($setupVars['SPEEDTEST_CHART_DAYS'] == 1) {
+ } else if ($setupVars['SPEEDTEST_CHART_DAYS'] == 1) {
$speedtestdays = '24 hours';
} else {
$speedtestdays = $setupVars['SPEEDTEST_CHART_DAYS'].' days';
From 62e3de20ec80335e04c9f1af84cbc592ff65470a Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 12:29:10 -0500
Subject: [PATCH 125/137] verbiage
---
scripts/pi-hole/js/settings.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index ac2cce52f..d408bfd7c 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -714,7 +714,7 @@ $(function () {
);
if (speedtestLog.find("p").length === 0) {
speedtestLog.append(
- `
Use this command to get the log while I look for it
`
+ `
Use this command to get the log while the connection is reestablished
`
);
}
}
@@ -728,7 +728,7 @@ $(function () {
);
if (speedtestLog.find("p").length === 0) {
speedtestLog.append(
- `
Use this command to get the log while I look for it
`
+ `
Use this command to get the log while the connection is reestablished
`
);
}
});
From b8bfbf69bf7ab7d607f67453ed7bf14a7355b898 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 13:16:29 -0500
Subject: [PATCH 126/137] get log from volume
---
api_speedtest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 8a9856acf..76b57866d 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -34,7 +34,7 @@
} else {
$cmdStatus = 'systemctl status pihole-speedtest.timer';
}
-$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /var/log/pihole/speedtest.log ]] && cat /var/log/pihole/speedtest.log || echo ""; }';
+$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /etc/pihole/speedtest.log ]] && cat /etc/pihole/speedtest.log || echo ""; }';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
From 474c741a27a73006360f6b75eefa628d682399c8 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 13:43:05 -0500
Subject: [PATCH 127/137] pretty
---
scripts/pi-hole/php/header_authenticated.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/scripts/pi-hole/php/header_authenticated.php b/scripts/pi-hole/php/header_authenticated.php
index 6d8b76182..1990795cf 100644
--- a/scripts/pi-hole/php/header_authenticated.php
+++ b/scripts/pi-hole/php/header_authenticated.php
@@ -187,13 +187,11 @@ function getNumberOfDaysInDB($dbSpeedtest)
if (isset($setupVars['SPEEDTEST_CHART_DAYS'])) {
if ($setupVars['SPEEDTEST_CHART_DAYS'] == -1) {
$speedtestdays = getNumberOfDaysInDB($dbSpeedtest).' days';
- } else if ($setupVars['SPEEDTEST_CHART_DAYS'] == 1) {
+ } elseif ($setupVars['SPEEDTEST_CHART_DAYS'] == 1) {
$speedtestdays = '24 hours';
} else {
$speedtestdays = $setupVars['SPEEDTEST_CHART_DAYS'].' days';
}
-
-
}
if (isset($setupVars['SPEEDTEST_CHART_TYPE'])) {
$speedtestcharttype = $setupVars['SPEEDTEST_CHART_TYPE'];
From b5dacaf6dab8953880869c850405110c39208317 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 17:38:52 -0500
Subject: [PATCH 128/137] getStatusCmd
---
api_speedtest.php | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 76b57866d..eec772c06 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -19,21 +19,6 @@
$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pihole/mod.log ]] && cat /var/log/pihole/mod.log || echo ""; }';
$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --list';
-if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
- $remaining_seconds = getRemainingTime();
- if ($remaining_seconds < 0) {
- $cmdStatus = 'echo ""';
- } else {
- $remaining_date = sprintf('%dd %dh %dmin %ds', $remaining_seconds / 86400, $remaining_seconds / 3600 % 24, $remaining_seconds / 60 % 60, $remaining_seconds % 60);
- $remaining_date = preg_replace('/^0d |(^|(?<= ))0h |(^|(?<= ))0min /', '', $remaining_date); // remove 0d 0h 0min
- $remaining_date = preg_replace('/\s(\d+s)/', '', $remaining_date); // remove seconds if not needed
- $cmdStatus = 'echo '.$remaining_date;
- }
-} elseif (!file_exists('/bin/systemctl')) {
- $cmdStatus = 'echo ""';
-} else {
- $cmdStatus = 'systemctl status pihole-speedtest.timer';
-}
$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /etc/pihole/speedtest.log ]] && cat /etc/pihole/speedtest.log || echo ""; }';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
@@ -55,7 +40,7 @@
$data = array_merge($data, getServers($cmdServers));
}
if (isset($_GET['getSpeedTestStatus'])) {
- $data = array_merge($data, speedtestExecute($cmdStatus));
+ $data = array_merge($data, speedtestExecute(getStatusCmd()));
}
if (isset($_GET['getLatestRun'])) {
$data = array_merge($data, speedtestExecute($cmdRun));
@@ -332,3 +317,21 @@ function getNumberOfDaysInDB($dbSpeedtest)
return array('data' => $diff->days + 1);
}
+
+function getStatusCmd()
+{
+ $cmdStatus = 'echo ""';
+ if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
+ $remaining_seconds = getRemainingTime();
+ if ($remaining_seconds >= 0) {
+ $remaining_date = sprintf('%dd %dh %dmin %ds', $remaining_seconds / 86400, $remaining_seconds / 3600 % 24, $remaining_seconds / 60 % 60, $remaining_seconds % 60);
+ $remaining_date = preg_replace('/^0d |(^|(?<= ))0h |(^|(?<= ))0min /', '', $remaining_date); // remove 0d 0h 0min
+ $remaining_date = preg_replace('/\s(\d+s)/', '', $remaining_date); // remove seconds if not needed
+ $cmdStatus = 'echo '.$remaining_date;
+ }
+ } elseif (file_exists('/bin/systemctl')) {
+ $cmdStatus = 'systemctl status pihole-speedtest.timer';
+ }
+
+ return $cmdStatus;
+}
From 9bafaa920643aeda29c235e8cc4b247747951905 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 17:52:56 -0500
Subject: [PATCH 129/137] dedup code
---
scripts/pi-hole/js/settings.js | 32 +++++++++++---------------------
1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index d408bfd7c..9d17a4834 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -608,6 +608,16 @@ $(function () {
};
const drawChart = (days, type) => {
+ if (days === "-1") {
+ days = "however many";
+ }
+
+ if (days === "1") {
+ days = "24 hours";
+ } else {
+ days += " days";
+ }
+
const colDiv = document.createElement("div");
const boxDiv = document.createElement("div");
const boxHeaderDiv = document.createElement("div");
@@ -665,29 +675,9 @@ $(function () {
dataType: "json",
})
.done(function (data) {
- if (speedtestdays === "-1") {
- speedtestdays = data ? data.data : "however many";
- }
-
- if (speedtestdays === "1") {
- speedtestdays = "24 hours";
- } else {
- speedtestdays += " days";
- }
-
- drawChart(speedtestdays, type);
+ drawChart(speedtestdays === "-1" && data ? data.data : speedtestdays, type);
})
.fail(function () {
- if (speedtestdays === "-1") {
- speedtestdays = "however many";
- }
-
- if (speedtestdays === "1") {
- speedtestdays = "24 hours";
- } else {
- speedtestdays += " days";
- }
-
drawChart(speedtestdays, type);
});
}
From 20f2165b1696bded013d11325afa36cca1d66e3f Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 13 Feb 2024 17:58:03 -0500
Subject: [PATCH 130/137] pretty
---
scripts/pi-hole/js/settings.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 9d17a4834..ebd619aa0 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -665,7 +665,7 @@ $(function () {
localStorage.setItem("speedtest_preview_shown", "false");
speedtestChartPreview.find("div").remove();
} else {
- let speedtestdays = speedtestDays.val();
+ const speedtestdays = speedtestDays.val();
localStorage.setItem("speedtest_days", speedtestdays);
localStorage.setItem("speedtest_chart_type", type);
localStorage.setItem("speedtest_preview_shown", "true");
From 9ded01a7bb78b005dbba494590690b23fec6e3ee Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Mon, 19 Feb 2024 04:09:26 -0500
Subject: [PATCH 131/137] count from now
---
api_speedtest.php | 2 +-
scripts/pi-hole/js/speedtest.js | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index eec772c06..71fab7a07 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -18,7 +18,7 @@
$setupVars = parse_ini_file('/etc/pihole/setupVars.conf');
$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pihole/mod.log ]] && cat /var/log/pihole/mod.log || echo ""; }';
-$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --list';
+$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --secure --list';
$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /etc/pihole/speedtest.log ]] && cat /etc/pihole/speedtest.log || echo ""; }';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index e79b520b0..5e65b8a17 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -135,8 +135,7 @@ function formatDate(itemdate, results) {
}
const first = moment(results.at(0).start_time, "YYYY-MM-DD HH:mm:ssZ");
- const last = moment(results.at(-1).start_time, "YYYY-MM-DD HH:mm:ssZ");
- if (last.diff(first, "hours") > 24) {
+ if (moment.utc().diff(first, "hours") > 24) {
output = "Do HH:mm";
}
From ca5a063aba5e9cb6f85147e307734272e6611af7 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Tue, 27 Feb 2024 21:01:36 -0500
Subject: [PATCH 132/137] support librespeed (#89)
* extra checks
* typos
* support librespeed
* dont filter
* redirect
* words
---
api_speedtest.php | 10 +++++++-
scripts/pi-hole/js/settings.js | 44 ++++++++++++++++++++-------------
scripts/pi-hole/js/speedtest.js | 11 +++++++--
settings.php | 4 +--
4 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index 71fab7a07..c66046aff 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -18,7 +18,7 @@
$setupVars = parse_ini_file('/etc/pihole/setupVars.conf');
$cmdLog = '[[ -f /tmp/pimod.log ]] && cat /tmp/pimod.log || { [[ -f /var/log/pihole/mod.log ]] && cat /var/log/pihole/mod.log || echo ""; }';
-$cmdServers = 'speedtest -h | grep -q official && sudo speedtest -L || speedtest --secure --list';
+$cmdServers = '/usr/bin/speedtest -h | grep -q official && sudo /usr/bin/speedtest -L || /usr/bin/speedtest --secure --list 2>&1';
$cmdRun = '[[ -f /tmp/speedtest.log ]] && cat /tmp/speedtest.log || { [[ -f /etc/pihole/speedtest.log ]] && cat /etc/pihole/speedtest.log || echo ""; }';
$cmdServersCurl = "curl 'https://c.speedtest.net/speedtest-servers-static.php' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
$cmdServersJSON = "curl 'https://www.speedtest.net/api/js/servers' --compressed -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1' -H 'Sec-GPC: 1'";
@@ -54,6 +54,9 @@
if (isset($_GET['getNumberOfDaysInDB'])) {
$data = array_merge($data, getNumberOfDaysInDB($dbSpeedtest));
}
+ if (isset($_GET['isLibrespeed'])) {
+ $data = array_merge($data, array('data' => isLibrespeed()));
+ }
}
function hasSpeedTestBackup($dbSpeedtestOld)
@@ -335,3 +338,8 @@ function getStatusCmd()
return $cmdStatus;
}
+
+function isLibrespeed()
+{
+ return strpos(speedtestExecute('/usr/bin/speedtest --version')['data'], 'LibreSpeed') !== false;
+}
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index ebd619aa0..92e85d85e 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -739,25 +739,35 @@ $(function () {
};
if (!cmds || cmds.length === 0) {
- cmds = ["JSONClosestServers", "getClosestServers", "curlClosestServers"];
- }
-
- $.ajax({
- url: `api.php?${cmds[0]}`,
- dataType: "json",
- })
- .done(function (data) {
- const serversInfo = data?.data;
- if (serversInfo) {
- speedtestServerCtr.find("p").remove();
- codeBlock(speedtestServerCtr, serversInfo, speedtestServerBtn, "servers");
+ $.ajax({
+ url: `api.php?isLibrespeed`,
+ dataType: "json",
+ }).done(function (data) {
+ const librespeed = data?.data;
+ if (librespeed) {
+ closestServers(["getClosestServers"]);
} else {
- tryNextCmd();
+ closestServers(["JSONClosestServers", "getClosestServers", "curlClosestServers"]);
}
- })
- .fail(function () {
- tryNextCmd();
});
+ } else {
+ $.ajax({
+ url: `api.php?${cmds[0]}`,
+ dataType: "json",
+ })
+ .done(function (data) {
+ const serversInfo = data?.data;
+ if (serversInfo) {
+ speedtestServerCtr.find("p").remove();
+ codeBlock(speedtestServerCtr, serversInfo, speedtestServerBtn, "servers");
+ } else {
+ tryNextCmd();
+ }
+ })
+ .fail(function () {
+ tryNextCmd();
+ });
+ }
};
const hasBackup = callback => {
@@ -893,7 +903,7 @@ $(function () {
const closestServersList = speedtestServerCtr.find("pre");
if (closestServersList.length > 0) {
closestServersList.remove();
- speedtestServerBtn.text("Show closest servers");
+ speedtestServerBtn.text("Show available servers");
} else {
speedtestServerBtn.text("Retrieving servers...");
closestServers();
diff --git a/scripts/pi-hole/js/speedtest.js b/scripts/pi-hole/js/speedtest.js
index 5e65b8a17..b4c52cda1 100644
--- a/scripts/pi-hole/js/speedtest.js
+++ b/scripts/pi-hole/js/speedtest.js
@@ -24,7 +24,9 @@ var serverPing = [];
function createChart() {
var gridColor = getCSSval("graphs-grid", "background-color");
var ticksColor = getCSSval("graphs-ticks", "color");
- var speedChartctx = document.getElementById("speedOverTimeChart")?.getContext("2d");
+ const chartElement = document.getElementById("speedOverTimeChart");
+ if (chartElement === null || chartElement === undefined) return;
+ var speedChartctx = chartElement.getContext("2d");
if (speedChartctx === null || speedChartctx === undefined) return;
speedChart = new Chart(speedChartctx, {
type: getGraphType(1),
@@ -187,7 +189,12 @@ function updateSpeedTestData() {
createChart();
}
- if (speedChart && speedChart.data.labels !== speedlabels) {
+ if (
+ speedChart &&
+ speedChart !== null &&
+ speedChart !== undefined &&
+ speedChart.data.labels !== speedlabels
+ ) {
speedChart.data.labels = speedlabels;
speedChart.data.datasets[0].data = downloadspeed;
speedChart.data.datasets[1].data = uploadspeed;
diff --git a/settings.php b/settings.php
index 3e8fbe25a..770adf05c 100644
--- a/settings.php
+++ b/settings.php
@@ -1638,7 +1638,7 @@ class="form-control"
From f69d4596dbf0b4b92578e377e3820815a708711c Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Thu, 29 Feb 2024 01:09:10 -0500
Subject: [PATCH 133/137] show mod version (#90)
* check version
---
api_speedtest.php | 18 +++++++--
scripts/pi-hole/js/settings.js | 51 +++++++++++++++++---------
scripts/pi-hole/php/footer.php | 5 +++
scripts/pi-hole/php/update_checker.php | 27 +++++++++++++-
settings.php | 2 +-
5 files changed, 79 insertions(+), 24 deletions(-)
diff --git a/api_speedtest.php b/api_speedtest.php
index c66046aff..6c905d4b4 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -54,8 +54,8 @@
if (isset($_GET['getNumberOfDaysInDB'])) {
$data = array_merge($data, getNumberOfDaysInDB($dbSpeedtest));
}
- if (isset($_GET['isLibrespeed'])) {
- $data = array_merge($data, array('data' => isLibrespeed()));
+ if (isset($_GET['whichSpeedtest'])) {
+ $data = array_merge($data, array('data' => whichSpeedtest()));
}
}
@@ -339,7 +339,17 @@ function getStatusCmd()
return $cmdStatus;
}
-function isLibrespeed()
+function whichSpeedtest()
{
- return strpos(speedtestExecute('/usr/bin/speedtest --version')['data'], 'LibreSpeed') !== false;
+ if (!file_exists('/usr/bin/speedtest')) {
+ return 'official';
+ }
+ $version = speedtestExecute('/usr/bin/speedtest --version')['data'];
+ if (strpos($version, 'LibreSpeed') !== false) {
+ return 'LibreSpeed';
+ } elseif (strpos($version, 'Python') !== false) {
+ return 'sivel\'s';
+ } else {
+ return 'official';
+ }
}
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index 92e85d85e..9547aed6b 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -532,7 +532,28 @@ $(function () {
}
};
+ const whichSpeedtest = () => {
+ $.ajax({
+ url: "api.php?whichSpeedtest",
+ dataType: "json",
+ })
+ .done(function (data) {
+ const speedtest = data?.data;
+ if (speedtest) {
+ // set in localStorage for use in other functions
+ localStorage.setItem("speedtest", speedtest);
+ } else {
+ localStorage.setItem("speedtest", "official");
+ }
+ })
+ .fail(function () {
+ localStorage.setItem("speedtest", "unknown");
+ });
+ };
+
const serviceStatus = () => {
+ whichSpeedtest();
+ const speedtestVersion = localStorage.getItem("speedtest") || "unknown";
$.ajax({
url: "api.php?getSpeedTestStatus",
dataType: "json",
@@ -590,19 +611,19 @@ $(function () {
lastRunText = `Latest run:\n\n${lastRun}`;
}
- const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}\n${lastRunText}`;
+ const statusText = `Using ${speedtestVersion} CLI\nSchedule is ${scheduleStatusText}\nNext run is${triggerText}\n${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
})
.fail(function () {
- const lastRunText = "\nLatest run is unavailable";
- const statusText = `Schedule is ${scheduleStatusText}\nNext run is${triggerText}${lastRunText}`;
+ const lastRunText = "Latest run is unavailable";
+ const statusText = `Using ${speedtestVersion} CLI\nSchedule is ${scheduleStatusText}\nNext run is${triggerText}\n${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
})
.fail(function () {
- const triggerText = speedtestTest.attr("value") ? " awaiting confirmation" : " unknown";
- const lastRunText = "\nLatest run is unavailable";
- const statusText = "Schedule is unavailable\nNext run is" + triggerText + lastRunText;
+ const triggerText = speedtestTest.attr("value") ? "awaiting confirmation" : "unknown";
+ const lastRunText = "Latest run is unavailable";
+ const statusText = `Using ${speedtestVersion} CLI\nSchedule is unavailable\nNext run is ${triggerText}\n${lastRunText}`;
codeBlock(speedtestStatus, statusText, speedtestStatusBtn, "status");
});
};
@@ -739,17 +760,13 @@ $(function () {
};
if (!cmds || cmds.length === 0) {
- $.ajax({
- url: `api.php?isLibrespeed`,
- dataType: "json",
- }).done(function (data) {
- const librespeed = data?.data;
- if (librespeed) {
- closestServers(["getClosestServers"]);
- } else {
- closestServers(["JSONClosestServers", "getClosestServers", "curlClosestServers"]);
- }
- });
+ whichSpeedtest();
+ const speedtestVersion = localStorage.getItem("speedtest");
+ if (speedtestVersion === "LibreSpeed") {
+ closestServers(["getClosestServers"]);
+ } else {
+ closestServers(["JSONClosestServers", "getClosestServers", "curlClosestServers"]);
+ }
} else {
$.ajax({
url: `api.php?${cmds[0]}`,
diff --git a/scripts/pi-hole/php/footer.php b/scripts/pi-hole/php/footer.php
index 15dd17297..3b03e7dd5 100644
--- a/scripts/pi-hole/php/footer.php
+++ b/scripts/pi-hole/php/footer.php
@@ -87,6 +87,11 @@
·
diff --git a/scripts/pi-hole/php/update_checker.php b/scripts/pi-hole/php/update_checker.php
index cd2ce2586..e6bf0240a 100644
--- a/scripts/pi-hole/php/update_checker.php
+++ b/scripts/pi-hole/php/update_checker.php
@@ -22,6 +22,10 @@ function checkUpdate($currentVersion, $latestVersion)
$web_current = 'N/A';
$web_update = false;
+ $speedtest_branch = 'master';
+ $speedtest_current = 'N/A';
+ $speedtest_update = false;
+
$FTL_current = 'N/A';
$FTL_update = false;
@@ -49,6 +53,15 @@ function checkUpdate($currentVersion, $latestVersion)
$web_current = explode('-', $versions['WEB_VERSION'])[0];
}
+ // Get Speedtest Mod branch / version / commit
+ $speedtest_branch = $versions['SPEEDTEST_BRANCH'];
+ if ($speedtest_branch !== 'master') {
+ $speedtest_current = 'vDev';
+ $speedtest_commit = $versions['SPEEDTEST_VERSION'];
+ } else {
+ $speedtest_current = explode('-', $versions['SPEEDTEST_VERSION'])[0];
+ }
+
// Get Pi-hole FTL (not a git repository)
$FTL_branch = $versions['FTL_BRANCH'];
if (substr($versions['FTL_VERSION'], 0, 4) === 'vDev') {
@@ -68,6 +81,7 @@ function checkUpdate($currentVersion, $latestVersion)
// Get data from GitHub
$core_latest = $versions['GITHUB_CORE_VERSION'];
$web_latest = $versions['GITHUB_WEB_VERSION'];
+ $speedtest_latest = $versions['GITHUB_SPEEDTEST_VERSION'];
$FTL_latest = $versions['GITHUB_FTL_VERSION'];
if (isset($versions['GITHUB_DOCKER_VERSION'])) {
$docker_latest = $versions['GITHUB_DOCKER_VERSION'];
@@ -77,6 +91,7 @@ function checkUpdate($currentVersion, $latestVersion)
$core_update = false;
$web_update = false;
+ $speedtest_update = false;
$FTL_update = false;
// Version comparison
@@ -92,6 +107,7 @@ function checkUpdate($currentVersion, $latestVersion)
// Components comparison
$core_update = checkUpdate($core_current, $core_latest);
$web_update = checkUpdate($web_current, $web_latest);
+ $speedtest_update = checkUpdate($speedtest_current, $speedtest_latest);
$FTL_update = checkUpdate($FTL_current, $FTL_latest);
// Not a docker container
@@ -101,9 +117,10 @@ function checkUpdate($currentVersion, $latestVersion)
// URLs for the links
$coreUrl = 'https://github.com/pi-hole/pi-hole/releases';
-$webUrl = 'https://github.com/arevindh/AdminLTE/releases';
+$webUrl = 'https://github.com/pi-hole/AdminLTE/releases';
$ftlUrl = 'https://github.com/pi-hole/FTL/releases';
-$dockerUrl = 'https://github.com/arevindh/docker-pi-hole/releases';
+$dockerUrl = 'https://github.com/pi-hole/docker-pi-hole/releases';
+$speedtestUrl = 'https://github.com/arevindh/pihole-speedtest/releases';
// Version strings (encoded to avoid code execution)
// If "vDev" show branch/commit, else show link
@@ -119,6 +136,12 @@ function checkUpdate($currentVersion, $latestVersion)
$webVersionStr = ''.htmlentities($web_current).'';
}
+if (isset($speedtest_commit)) {
+ $speedtestVersionStr = htmlentities($speedtest_current.' ('.$speedtest_branch.', '.$speedtest_commit.')');
+} else {
+ $speedtestVersionStr = ''.htmlentities($speedtest_current).'';
+}
+
if (isset($FTL_commit)) {
$ftlVersionStr = htmlentities($FTL_current.' ('.$FTL_branch.', '.$FTL_commit.')');
} else {
diff --git a/settings.php b/settings.php
index 770adf05c..26698dda1 100644
--- a/settings.php
+++ b/settings.php
@@ -1618,7 +1618,7 @@ class="form-control"
From 91bd55ec481f70c92814b7ff3159c91e7ba683ac Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Sat, 9 Mar 2024 13:08:49 -0500
Subject: [PATCH 136/137] workaround ookla error (#93)
* avoid calling ookla's cli to get version
---
api_speedtest.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/api_speedtest.php b/api_speedtest.php
index efacd731c..6a61c2fc9 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -342,10 +342,18 @@ function getStatusCmd()
function whichSpeedtest()
{
if (file_exists('/usr/bin/speedtest')) {
+ $officialInstalled = speedtestExecute('SKIP_MOD=true ; . /opt/pihole/speedtestmod/mod.sh ; notInstalled speedtest && echo "false" || echo "true"')['data'];
+
+ if ($officialInstalled === 'true') {
+ return 'official';
+ }
+
$version = speedtestExecute('/usr/bin/speedtest --version')['data'];
+
if (strpos($version, 'LibreSpeed') !== false) {
return 'LibreSpeed';
}
+
if (strpos($version, 'Python') !== false) {
return 'sivel\'s';
}
From a6373e2b6a94c62862d8062d3306a165afdf32e0 Mon Sep 17 00:00:00 2001
From: ipitio <21136719+ipitio@users.noreply.github.com>
Date: Wed, 13 Mar 2024 21:43:30 -0400
Subject: [PATCH 137/137] fix ookla and sql issues (#94)
* suppress error
* redirect stderr
* redirect both
* bypass ookla
* forgot var
* add sc
* check if file exists
* account for no table
---
api_speedtest.php | 10 +++++++---
img/st-chart.png | Bin 0 -> 254536 bytes
img/st-pref.png | Bin 0 -> 109957 bytes
scripts/pi-hole/php/header_authenticated.php | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
create mode 100644 img/st-chart.png
create mode 100644 img/st-pref.png
diff --git a/api_speedtest.php b/api_speedtest.php
index 6a61c2fc9..5d6f6c717 100644
--- a/api_speedtest.php
+++ b/api_speedtest.php
@@ -92,7 +92,7 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
return array();
}
$db = new SQLite3($dbSpeedtest);
- if (!$db) {
+ if (!$db || !$db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table" AND name="speedtest"')) {
return array();
}
@@ -265,7 +265,11 @@ function JSONServers($cmdServersJSON)
function getRemainingTime()
{
- $interval_seconds = speedtestExecute("grep 'interval_seconds=' /opt/pihole/speedtestmod/schedule_check.sh | cut -d'=' -f2")['data'];
+ $interval_seconds = -1;
+
+ if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
+ $interval_seconds = speedtestExecute("grep 'interval_seconds=' /opt/pihole/speedtestmod/schedule_check.sh | cut -d'=' -f2")['data'];
+ }
// if interval_seconds is "nan", then schedule has never been set
if (strpos($interval_seconds, 'nan') !== false) {
@@ -296,7 +300,7 @@ function getRemainingTime()
function getNumberOfDaysInDB($dbSpeedtest)
{
$db = new SQLite3($dbSpeedtest);
- if (!$db) {
+ if (!$db || !$db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table" AND name="speedtest"')) {
return array('data' => 0);
}
diff --git a/img/st-chart.png b/img/st-chart.png
new file mode 100644
index 0000000000000000000000000000000000000000..c038da2245d612cab7b56047954e0c45623e5e40
GIT binary patch
literal 254536
zcmV*9Kybf_P)