Bug 1308415 - Update about:telemetry to show keyed scalars. r=gfritzsche

This commit is contained in:
Alessio Placitelli 2016-10-07 03:35:00 -04:00
parent 44dd1f666b
commit b945a720fc
3 changed files with 48 additions and 0 deletions

View File

@ -1580,6 +1580,40 @@ var Scalars = {
}
};
var KeyedScalars = {
/**
* Render the keyed scalar data - if present - from the payload in a simple key-value table.
* @param aPayload A payload object to render the data from.
*/
render: function(aPayload) {
let scalarsSection = document.getElementById("keyed-scalars");
removeAllChildNodes(scalarsSection);
if (!aPayload.processes || !aPayload.processes.parent) {
return;
}
let keyedScalars = aPayload.processes.parent.keyedScalars;
const hasData = keyedScalars && Object.keys(keyedScalars).length > 0;
setHasData("keyed-scalars-section", hasData);
if (!hasData) {
return;
}
const headingName = bundle.GetStringFromName("namesHeader");
const headingValue = bundle.GetStringFromName("valuesHeader");
for (let scalar in keyedScalars) {
// Add the name of the scalar.
let scalarNameSection = document.createElement("h2");
scalarNameSection.appendChild(document.createTextNode(scalar));
scalarsSection.appendChild(scalarNameSection);
// Populate the section with the key-value pairs from the scalar.
const table = KeyValueTable.render(keyedScalars[scalar], headingName, headingValue);
scalarsSection.appendChild(table);
}
}
};
/**
* Helper function for showing either the toggle element or "No data collected" message for a section
*
@ -1956,6 +1990,7 @@ function displayPingData(ping, updatePayloadList = false) {
// Show scalar data.
Scalars.render(payload);
KeyedScalars.render(payload);
// Show histogram data
let hgramDiv = document.getElementById("histograms");

View File

@ -144,6 +144,15 @@
</div>
</section>
<section id="keyed-scalars-section" class="data-section">
<input type="checkbox" class="statebox"/>
<h1 class="section-name">&aboutTelemetry.keyedScalarsSection;</h1>
<span class="toggle-caption">&aboutTelemetry.toggle;</span>
<span class="empty-caption">&aboutTelemetry.emptySection;</span>
<div id="keyed-scalars" class="data">
</div>
</section>
<section id="histograms-section" class="data-section">
<input type="checkbox" class="statebox"/>
<h1 class="section-name">&aboutTelemetry.histogramsSection;</h1>

View File

@ -104,6 +104,10 @@ Ping
Scalars
">
<!ENTITY aboutTelemetry.keyedScalarsSection "
Keyed Scalars
">
<!ENTITY aboutTelemetry.histogramsSection "
Histograms
">