Skip to content

Commit

Permalink
Add system information bases on check-system output
Browse files Browse the repository at this point in the history
  • Loading branch information
hifiberry committed Jul 22, 2020
1 parent bf70030 commit 0af4650
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,48 @@ $(document).on("hifiberry-debug", function(event, data) {
$("#resampling-rate").text("Unknown");
}
}

if (data.header == "sysinfo") {
updateSystemInfo(data.content)
}
});


function collect() {
beo.send({target: "hifiberry-debug", header: "collect"});
}


function create_line(block, d1,d2) {

console.log(d1,d2);

var div1 = document.createElement("div");
div1.innerHTML = d1;
div1.setAttribute('class', 'hifiberry-debug-sysinfo-left')

var div2 = document.createElement("div");
div2.innerHTML = d2;
div2.setAttribute('class', 'hifiberry-debug-sysinfo-right')

block.appendChild(div1);
block.appendChild(div2);
}


function updateSystemInfo(info) {
block = document.getElementById("hifiberry-debug-sysinfo");
block.innerHTML = "";

for (var i = 0; i <info.length; i++) {
var row = document.createElement("div");
row.setAttribute('class', 'hifiberry-debug-sysinfo-row')
block.appendChild(row)
create_line(row, info[i][0], info[i][1]);
}

}

function download() {
window.location = archiveURL;
}
Expand Down
13 changes: 13 additions & 0 deletions Beocreate2/beo-extensions/hifiberry-debug/hifiberry-debug.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.hifiberry-debug-sysinfo-left {
float: left;
width: 30%;
}

.hifiberry-debug-sysinfo-right {
}

.hifiberry-debug-sysinfo-row:after {
content: "";
display: table;
clear: both;
}
27 changes: 27 additions & 0 deletions Beocreate2/beo-extensions/hifiberry-debug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ beo.bus.on('general', function(event) {
}

beo.sendToUI("hifiberry-debug", {header: "state", content: {exclusiveAudio: exclusiveAudio, resamplingRate: resamplingRate}});
reportSysInfo();

}

if (event.content.extension != previousExtension) {
Expand Down Expand Up @@ -154,6 +156,31 @@ function reportActivation(key, active) {
}
}

function reportSysInfo() {
var child = exec("/opt/hifiberry/bin/check-system",
function (error, stdout, stderr) {
var res = []
var output = stdout.split(/\r\n|\r|\n/);
for (var i = 0; i <output.length; i++) {
var parts = output[i].split(": ");
if (parts.length == 2) {
res.push(parts);
} else {
console.error("can't parse line "+output[i]);
}
}

if (error !== null) {
res=["Sysinfo","failed"];
}


beo.sendToUI("hifiberry-debug", {header: "sysinfo", content: res});

}
);
}

module.exports = {
reportUsage: reportUsage,
reportActivation: reportActivation,
Expand Down
14 changes: 13 additions & 1 deletion Beocreate2/beo-extensions/hifiberry-debug/menu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="menu-screen" id="hifiberry-debug" data-icon="diagnose.svg" data-menu-title="Diagnostics" data-context="general-settings/more">
<div class="menu-screen" id="hifiberry-debug" data-icon="diagnose.svg" data-menu-title="Diagnostics" data-context="general-settings/more" data-stylesheet="hifiberry-debug.css">

<header>
<div class="back-button master"></div>
Expand All @@ -14,8 +14,20 @@ <h1>Diagnostics</h1>
<div class="button pill black" onclick="hifiberry_debug.download();" id="diagnostic-download-button">Download Archive</div>
<p class="privacy margin-top">No personal information is included in the archive.</p>
</div>

<h2 class="disclosure" data-disclosure="#hifiberry-debug-advanced">System information</h2>
<div id="hifiberry-debug-advanced" class="hidden">

<div id="hifiberry-debug-sysinfo">test</div>

</div>


</div>

</div>



</div>

Expand Down

0 comments on commit 0af4650

Please sign in to comment.