зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1122480 - Part 8 - Update the settings: show upload & extended recording. r=rvitillo
This commit is contained in:
Родитель
3c93e0c10a
Коммит
6cb102d9f2
|
@ -27,11 +27,16 @@ h2 {
|
|||
padding: 10px;
|
||||
}
|
||||
|
||||
#description-enabled > span {
|
||||
.description-enabled,
|
||||
.description-disabled {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.description-enabled > span {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#description-disabled > span {
|
||||
.description-disabled > span {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
|
|||
const PREF_DEBUG_SLOW_SQL = "toolkit.telemetry.debugSlowSql";
|
||||
const PREF_SYMBOL_SERVER_URI = "profiler.symbolicationUrl";
|
||||
const DEFAULT_SYMBOL_SERVER_URI = "http://symbolapi.mozilla.org";
|
||||
const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
|
||||
|
||||
// ms idle before applying the filter (allow uninterrupted typing)
|
||||
const FILTER_IDLE_TIMEOUT = 500;
|
||||
|
@ -125,37 +126,52 @@ function sectionalizeObject(obj) {
|
|||
return map;
|
||||
}
|
||||
|
||||
let observer = {
|
||||
let Settings = {
|
||||
SETTINGS: [
|
||||
// data upload
|
||||
{
|
||||
pref: PREF_FHR_UPLOAD_ENABLED,
|
||||
defaultPrefValue: false,
|
||||
descriptionEnabledId: "description-upload-enabled",
|
||||
descriptionDisabledId: "description-upload-disabled",
|
||||
},
|
||||
// extended "Telemetry" recording
|
||||
{
|
||||
pref: PREF_TELEMETRY_ENABLED,
|
||||
defaultPrefValue: false,
|
||||
descriptionEnabledId: "description-extended-recording-enabled",
|
||||
descriptionDisabledId: "description-extended-recording-disabled",
|
||||
},
|
||||
],
|
||||
|
||||
enableTelemetry: bundle.GetStringFromName("enableTelemetry"),
|
||||
attachObservers: function() {
|
||||
for (let s of this.SETTINGS) {
|
||||
let setting = s;
|
||||
Preferences.observe(setting.pref, this.render, this);
|
||||
}
|
||||
},
|
||||
|
||||
disableTelemetry: bundle.GetStringFromName("disableTelemetry"),
|
||||
|
||||
/**
|
||||
* Observer is called whenever Telemetry is enabled or disabled
|
||||
*/
|
||||
observe: function observe(aSubject, aTopic, aData) {
|
||||
if (aData == PREF_TELEMETRY_ENABLED) {
|
||||
this.updatePrefStatus();
|
||||
detachObservers: function() {
|
||||
for (let setting of this.SETTINGS) {
|
||||
Preferences.ignore(setting.pref, this.render, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the button & text at the top of the page to reflect Telemetry state.
|
||||
*/
|
||||
updatePrefStatus: function updatePrefStatus() {
|
||||
// Notify user whether Telemetry is enabled
|
||||
let enabledElement = document.getElementById("description-enabled");
|
||||
let disabledElement = document.getElementById("description-disabled");
|
||||
let toggleElement = document.getElementById("toggle-telemetry");
|
||||
if (Preferences.get(PREF_TELEMETRY_ENABLED, false)) {
|
||||
render: function() {
|
||||
for (let setting of this.SETTINGS) {
|
||||
let enabledElement = document.getElementById(setting.descriptionEnabledId);
|
||||
let disabledElement = document.getElementById(setting.descriptionDisabledId);
|
||||
|
||||
if (Preferences.get(setting.pref, setting.defaultPrefValue)) {
|
||||
enabledElement.classList.remove("hidden");
|
||||
disabledElement.classList.add("hidden");
|
||||
toggleElement.innerHTML = this.disableTelemetry;
|
||||
} else {
|
||||
enabledElement.classList.add("hidden");
|
||||
disabledElement.classList.remove("hidden");
|
||||
toggleElement.innerHTML = this.enableTelemetry;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1050,20 +1066,13 @@ function setupPageHeader()
|
|||
* Initializes load/unload, pref change and mouse-click listeners
|
||||
*/
|
||||
function setupListeners() {
|
||||
Services.prefs.addObserver(PREF_TELEMETRY_ENABLED, observer, false);
|
||||
observer.updatePrefStatus();
|
||||
Settings.attachObservers();
|
||||
|
||||
// Clean up observers when page is closed
|
||||
window.addEventListener("unload",
|
||||
function unloadHandler(aEvent) {
|
||||
window.removeEventListener("unload", unloadHandler);
|
||||
Services.prefs.removeObserver(PREF_TELEMETRY_ENABLED, observer);
|
||||
}, false);
|
||||
|
||||
document.getElementById("toggle-telemetry").addEventListener("click",
|
||||
function () {
|
||||
let value = Preferences.get(PREF_TELEMETRY_ENABLED, false);
|
||||
Preferences.set(PREF_TELEMETRY_ENABLED, !value);
|
||||
Settings.detachObservers();
|
||||
}, false);
|
||||
|
||||
document.getElementById("chrome-hangs-fetch-symbols").addEventListener("click",
|
||||
|
@ -1133,6 +1142,9 @@ function onLoad() {
|
|||
// Set up event listeners
|
||||
setupListeners();
|
||||
|
||||
// Render settings.
|
||||
Settings.render();
|
||||
|
||||
// Get the Telemetry Ping payload
|
||||
Telemetry.asyncFetchTelemetryData(displayPingData);
|
||||
|
||||
|
|
|
@ -29,10 +29,20 @@
|
|||
|
||||
<h2 id="page-subtitle"></h2>
|
||||
|
||||
<p id="description-enabled">&aboutTelemetry.telemetryEnabled;</p>
|
||||
<p id="description-disabled">&aboutTelemetry.telemetryDisabled;</p>
|
||||
|
||||
<button id="toggle-telemetry" type="button"/>
|
||||
<table id="settings">
|
||||
<tr>
|
||||
<td>
|
||||
<p id="description-upload-enabled" class="description-enabled">&aboutTelemetry.uploadEnabled;</p>
|
||||
<p id="description-upload-disabled" class="description-disabled">&aboutTelemetry.uploadDisabled;</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p id="description-extended-recording-enabled" class="description-enabled">&aboutTelemetry.extendedRecordingEnabled;</p>
|
||||
<p id="description-extended-recording-disabled" class="description-disabled">&aboutTelemetry.extendedRecordingDisabled;</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</header>
|
||||
|
||||
<section id="general-data-section" class="data-section">
|
||||
|
|
|
@ -4,12 +4,20 @@
|
|||
|
||||
<!ENTITY aboutTelemetry.pageTitle "Telemetry Data">
|
||||
|
||||
<!ENTITY aboutTelemetry.telemetryEnabled "
|
||||
Telemetry is <span>enabled</span>.
|
||||
<!ENTITY aboutTelemetry.uploadEnabled "
|
||||
FHR data upload is <span>enabled</span>.
|
||||
">
|
||||
|
||||
<!ENTITY aboutTelemetry.telemetryDisabled "
|
||||
Telemetry is <span>disabled</span>.
|
||||
<!ENTITY aboutTelemetry.uploadDisabled "
|
||||
FHR data upload is <span>disabled</span>.
|
||||
">
|
||||
|
||||
<!ENTITY aboutTelemetry.extendedRecordingEnabled "
|
||||
Extended Telemetry recording is <span>enabled</span>.
|
||||
">
|
||||
|
||||
<!ENTITY aboutTelemetry.extendedRecordingDisabled "
|
||||
Extended Telemetry recording is <span>disabled</span>.
|
||||
">
|
||||
|
||||
<!ENTITY aboutTelemetry.generalDataSection "
|
||||
|
|
|
@ -58,10 +58,6 @@ histogramSum = sum
|
|||
|
||||
histogramCopy = Copy
|
||||
|
||||
disableTelemetry = Disable Telemetry
|
||||
|
||||
enableTelemetry = Enable Telemetry
|
||||
|
||||
keysHeader = Property
|
||||
|
||||
valuesHeader = Value
|
||||
|
|
Загрузка…
Ссылка в новой задаче