bug 1163971 - Add a simple select to about:telemetry to allow viewing child payloads, when present. r=gfritzsche

This commit is contained in:
Chris H-C 2015-10-29 07:36:00 +01:00
parent 32c65f3064
commit 6047eea25d
4 changed files with 76 additions and 6 deletions

View File

@ -298,6 +298,9 @@ var PingPicker = {
.addEventListener("click", () => this._movePingIndex(-1), false);
document.getElementById("older-ping")
.addEventListener("click", () => this._movePingIndex(1), false);
document.getElementById("choose-payload")
.addEventListener("change", () => displayPingData(gPingData), false);
},
onPingSourceChanged: function() {
@ -322,13 +325,13 @@ var PingPicker = {
_updateCurrentPingData: function() {
const subsession = document.getElementById("show-subsession-data").checked;
const ping = TelemetryController.getCurrentPingData(subsession);
displayPingData(ping);
displayPingData(ping, true);
},
_updateArchivedPingData: function() {
let id = this._getSelectedPingId();
TelemetryArchive.promiseArchivedPingById(id)
.then((ping) => displayPingData(ping));
.then((ping) => displayPingData(ping, true));
},
_updateArchivedPingList: function() {
@ -1531,12 +1534,49 @@ function sortStartupMilestones(aSimpleMeasurements) {
return result;
}
function displayPingData(ping) {
function renderPayloadList(ping) {
// Rebuild the payload select with options:
// Parent Payload (selected)
// Child Payload 1..ping.payload.childPayloads.length
let listEl = document.getElementById("choose-payload");
removeAllChildNodes(listEl);
let option = document.createElement("option");
let text = bundle.GetStringFromName("parentPayload");
let content = document.createTextNode(text);
let payloadIndex = 0;
option.appendChild(content);
option.setAttribute("value", payloadIndex++);
option.selected = true;
listEl.appendChild(option);
if (!ping.payload.childPayloads) {
listEl.disabled = true;
return
}
listEl.disabled = false;
for (; payloadIndex <= ping.payload.childPayloads.length; ++payloadIndex) {
option = document.createElement("option");
text = bundle.formatStringFromName("childPayload", [payloadIndex], 1);
content = document.createTextNode(text);
option.appendChild(content);
option.setAttribute("value", payloadIndex);
listEl.appendChild(option);
}
}
function displayPingData(ping, updatePayloadList = false) {
gPingData = ping;
const keysHeader = bundle.GetStringFromName("keysHeader");
const valuesHeader = bundle.GetStringFromName("valuesHeader");
// Update the payload list
if (updatePayloadList) {
renderPayloadList(ping);
}
// Show general data.
GeneralData.render(ping);
@ -1558,8 +1598,17 @@ function displayPingData(ping) {
// Render Addon details.
AddonDetails.render(ping);
// Show simple measurements
// Select payload to render
let payloadSelect = document.getElementById("choose-payload");
let payloadOption = payloadSelect.selectedOptions.item(0);
let payloadIndex = payloadOption.getAttribute("value");
let payload = ping.payload;
if (payloadIndex > 0) {
payload = ping.payload.childPayloads[payloadIndex - 1];
}
// Show simple measurements
let simpleMeasurements = sortStartupMilestones(payload.simpleMeasurements);
let hasData = Object.keys(simpleMeasurements).length > 0;
setHasData("simple-measurements-section", hasData);
@ -1574,13 +1623,13 @@ function displayPingData(ping) {
LateWritesSingleton.renderLateWrites(payload.lateWrites);
// Show basic system info gathered
hasData = Object.keys(payload.info).length > 0;
hasData = Object.keys(ping.payload.info).length > 0;
setHasData("system-info-section", hasData);
let infoSection = document.getElementById("system-info");
removeAllChildNodes(infoSection);
if (hasData) {
infoSection.appendChild(KeyValueTable.render(payload.info,
infoSection.appendChild(KeyValueTable.render(ping.payload.info,
keysHeader, valuesHeader));
}

View File

@ -82,6 +82,17 @@
</tr>
</table>
</div>
<table>
<tr>
<th>&aboutTelemetry.payloadChoiceHeader;</th>
</tr>
<tr>
<td>
<select id="choose-payload">
</select>
</td>
</tr>
</table>
</div>
</header>

View File

@ -135,3 +135,7 @@ Ping
<!ENTITY aboutTelemetry.filterText "
Filter (strings or /regexp/)
">
<!ENTITY aboutTelemetry.payloadChoiceHeader "
Payload
">

View File

@ -69,3 +69,9 @@ addonTableDetails = Details
# Note to translators:
# - The %1$S will be replaced with the name of an Add-on Provider (e.g. "XPI", "Plugin")
addonProvider = %1$S Provider
parentPayload = Parent Payload
# Note to translators:
# - The %1$s will be replaced with the number of the child payload (e.g. "1", "2")
childPayload = Child Payload %1$s