Add checkbox if the user wants his debug log to be uploaded automatically

This commit is contained in:
DL6ER
2017-02-22 19:47:58 +01:00
parent 71672319af
commit 20ce214c9f
3 changed files with 19 additions and 4 deletions

View File

@@ -6,7 +6,8 @@
<h1>Generate debug log</h1>
</div>
<p>Once you click this button a debug log will be generated and automatically uploaded if we detect a working internet connection</p>
<p><input type="checkbox" id="upload" checked> Upload debug log and provide token once finished</p>
<p>Once you click this button a debug log will be generated and can automatically be uploaded if we detect a working internet connection.</p>
<button class="btn btn-lg btn-primary btn-block" id="debugBtn">Generate debug log</button>
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>

View File

@@ -27,15 +27,22 @@ function httpGet(ta,theUrl)
function eventsource() {
var ta = $("#output");
var upload = $( "#upload" );
var checked = "";
if(upload.prop("checked"))
{
checked = "upload";
}
// IE does not support EventSource - load whole content at once
if (typeof EventSource !== "function") {
httpGet(ta,"/admin/scripts/pi-hole/php/debug.php?IE");
httpGet(ta,"/admin/scripts/pi-hole/php/debug.php?IE&"+checked);
return;
}
var host = window.location.host;
var source = new EventSource("/admin/scripts/pi-hole/php/debug.php");
var source = new EventSource("/admin/scripts/pi-hole/php/debug.php?"+checked);
// Reset and show field
ta.empty();

View File

@@ -12,7 +12,14 @@ function echoEvent($datatext) {
echo $datatext;
}
$proc = popen("sudo pihole -d -a", "r");
if(isset($_GET["upload"]))
{
$proc = popen("sudo pihole -d -a", "r");
}
else
{
$proc = popen("sudo pihole -d", "r");
}
while (!feof($proc)) {
echoEvent(fread($proc, 4096));
}