summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/requests-menu-view.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-02-28 12:17:13 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-02-28 12:17:13 +0100
commit627f167bf41935cad572b04c5b412f9294293ecb (patch)
tree76abf91246d7f90c25311d0fda82208169c7d8cc /devtools/client/netmonitor/requests-menu-view.js
parentb19e4e2cf0c1537c8c2a56d0b783d38b6b25de7f (diff)
downloadUXP-627f167bf41935cad572b04c5b412f9294293ecb.tar
UXP-627f167bf41935cad572b04c5b412f9294293ecb.tar.gz
UXP-627f167bf41935cad572b04c5b412f9294293ecb.tar.lz
UXP-627f167bf41935cad572b04c5b412f9294293ecb.tar.xz
UXP-627f167bf41935cad572b04c5b412f9294293ecb.zip
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
Diffstat (limited to 'devtools/client/netmonitor/requests-menu-view.js')
-rw-r--r--devtools/client/netmonitor/requests-menu-view.js105
1 files changed, 10 insertions, 95 deletions
diff --git a/devtools/client/netmonitor/requests-menu-view.js b/devtools/client/netmonitor/requests-menu-view.js
index 6ea6381ec..d8c66b05d 100644
--- a/devtools/client/netmonitor/requests-menu-view.js
+++ b/devtools/client/netmonitor/requests-menu-view.js
@@ -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.
@@ -1559,59 +1527,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
*/