mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
Bug 1309194: Implement summary info in Net Panel Toolbar; Bug 1317205: CSS improvement for summary button
Required for: https://github.com/MoonchildProductions/moebius/pull/93
This commit is contained in:
parent
4d57ef767e
commit
2f496e3f1e
22 changed files with 333 additions and 240 deletions
|
|
@ -19,7 +19,6 @@ const {setImageTooltip, getImageDimensions} =
|
|||
const {Heritage, WidgetMethods, setNamedTimeout} =
|
||||
require("devtools/client/shared/widgets/view-helpers");
|
||||
const {CurlUtils} = require("devtools/client/shared/curl");
|
||||
const {PluralForm} = require("devtools/shared/plural-form");
|
||||
const {Filters, isFreetextMatch} = require("./filter-predicates");
|
||||
const {Sorters} = require("./sort-predicates");
|
||||
const {L10N, WEBCONSOLE_L10N} = require("./l10n");
|
||||
|
|
@ -90,10 +89,11 @@ function storeWatcher(initialValue, reduceValue, onChange) {
|
|||
let currentValue = initialValue;
|
||||
|
||||
return () => {
|
||||
const oldValue = currentValue;
|
||||
const newValue = reduceValue(currentValue);
|
||||
if (newValue !== currentValue) {
|
||||
onChange(newValue, currentValue);
|
||||
if (newValue !== oldValue) {
|
||||
currentValue = newValue;
|
||||
onChange(newValue, oldValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -129,8 +129,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
let widgetParentEl = $("#requests-menu-contents");
|
||||
this.widget = new SideMenuWidget(widgetParentEl);
|
||||
this._splitter = $("#network-inspector-view-splitter");
|
||||
this._summary = $("#requests-menu-network-summary-button");
|
||||
this._summary.setAttribute("label", L10N.getStr("networkMenu.empty"));
|
||||
|
||||
// Create a tooltip for the newly appended network request item.
|
||||
this.tooltip = new HTMLTooltip(NetMonitorController._toolbox.doc, { type: "arrow" });
|
||||
|
|
@ -211,13 +209,10 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
if (NetMonitorController.supportsPerfStats) {
|
||||
$("#requests-menu-perf-notice-button").addEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-button").addEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
$("#network-statistics-back-button").addEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
} else {
|
||||
$("#notice-perf-message").hidden = true;
|
||||
$("#requests-menu-network-summary-button").hidden = true;
|
||||
}
|
||||
|
||||
if (!NetMonitorController.supportsTransferredResponseSize) {
|
||||
|
|
@ -257,8 +252,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this._onReloadCommand, false);
|
||||
$("#requests-menu-perf-notice-button").removeEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
$("#requests-menu-network-summary-button").removeEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
$("#network-statistics-back-button").removeEventListener("command",
|
||||
this._onContextPerfCommand, false);
|
||||
|
||||
|
|
@ -422,7 +415,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
*/
|
||||
reFilterRequests: function () {
|
||||
this.filterContents(this._filterPredicate);
|
||||
this.refreshSummary();
|
||||
this.updateRequests();
|
||||
this.refreshZebra();
|
||||
},
|
||||
|
||||
|
|
@ -541,7 +534,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
break;
|
||||
}
|
||||
|
||||
this.refreshSummary();
|
||||
this.updateRequests();
|
||||
this.refreshZebra();
|
||||
},
|
||||
|
||||
|
|
@ -552,41 +545,17 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
NetMonitorController.NetworkEventsHandler.clearMarkers();
|
||||
NetMonitorView.Sidebar.toggle(false);
|
||||
|
||||
this.store.dispatch(Actions.disableToggleButton(true));
|
||||
$("#requests-menu-empty-notice").hidden = false;
|
||||
|
||||
this.empty();
|
||||
this.refreshSummary();
|
||||
this.updateRequests();
|
||||
},
|
||||
|
||||
/**
|
||||
* Refreshes the status displayed in this container's footer, providing
|
||||
* concise information about all requests.
|
||||
* Update store request itmes and trigger related UI update
|
||||
*/
|
||||
refreshSummary: function () {
|
||||
let visibleItems = this.visibleItems;
|
||||
let visibleRequestsCount = visibleItems.length;
|
||||
if (!visibleRequestsCount) {
|
||||
this._summary.setAttribute("label", L10N.getStr("networkMenu.empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
let totalBytes = this._getTotalBytesOfRequests(visibleItems);
|
||||
let totalMillis =
|
||||
this._getNewestRequest(visibleItems).attachment.endedMillis -
|
||||
this._getOldestRequest(visibleItems).attachment.startedMillis;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Localization_and_Plurals
|
||||
let str = PluralForm.get(visibleRequestsCount,
|
||||
L10N.getStr("networkMenu.summary"));
|
||||
|
||||
this._summary.setAttribute("label", str
|
||||
.replace("#1", visibleRequestsCount)
|
||||
.replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024,
|
||||
CONTENT_SIZE_DECIMALS))
|
||||
.replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000,
|
||||
REQUEST_TIME_DECIMALS))
|
||||
);
|
||||
updateRequests: function () {
|
||||
this.store.dispatch(Actions.updateRequests(this.visibleItems));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -865,7 +834,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this._updateQueue = [];
|
||||
this._addQueue = [];
|
||||
|
||||
this.store.dispatch(Actions.disableToggleButton(!this.itemCount));
|
||||
$("#requests-menu-empty-notice").hidden = !!this.itemCount;
|
||||
|
||||
// Make sure all the requests are sorted and filtered.
|
||||
|
|
@ -875,7 +843,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
// so this doesn't happen once per network event update).
|
||||
this.sortContents();
|
||||
this.filterContents();
|
||||
this.refreshSummary();
|
||||
this.updateRequests();
|
||||
this.refreshZebra();
|
||||
|
||||
// Rescale all the waterfalls so that everything is visible at once.
|
||||
|
|
@ -1558,59 +1526,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the total number of bytes representing the cumulated content size of
|
||||
* a set of requests. Returns 0 for an empty set.
|
||||
*
|
||||
* @param array itemsArray
|
||||
* @return number
|
||||
*/
|
||||
_getTotalBytesOfRequests: function (itemsArray) {
|
||||
if (!itemsArray.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let result = 0;
|
||||
itemsArray.forEach(item => {
|
||||
let size = item.attachment.contentSize;
|
||||
result += (typeof size == "number") ? size : 0;
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the oldest (first performed) request in a set. Returns null for an
|
||||
* empty set.
|
||||
*
|
||||
* @param array itemsArray
|
||||
* @return object
|
||||
*/
|
||||
_getOldestRequest: function (itemsArray) {
|
||||
if (!itemsArray.length) {
|
||||
return null;
|
||||
}
|
||||
return itemsArray.reduce((prev, curr) =>
|
||||
prev.attachment.startedMillis < curr.attachment.startedMillis ?
|
||||
prev : curr);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the newest (latest performed) request in a set. Returns null for an
|
||||
* empty set.
|
||||
*
|
||||
* @param array itemsArray
|
||||
* @return object
|
||||
*/
|
||||
_getNewestRequest: function (itemsArray) {
|
||||
if (!itemsArray.length) {
|
||||
return null;
|
||||
}
|
||||
return itemsArray.reduce((prev, curr) =>
|
||||
prev.attachment.startedMillis > curr.attachment.startedMillis ?
|
||||
prev : curr);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the available waterfall width in this container.
|
||||
* @return number
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue