Add timestamp columns to network inspector
Summary: Adds requestTimestamp, and responseTimestamp which is hidden by default. Reviewed By: passy Differential Revision: D14088403 fbshipit-source-id: c451a428d8068c5bfce199cda5502361c12d1667
This commit is contained in:
committed by
Facebook Github Bot
parent
ee54a54ff2
commit
d5dc3f9c2a
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type {TableHighlightedRows, TableRows, TableBodyRow} from 'flipper';
|
import type {TableHighlightedRows, TableRows, TableBodyRow} from 'flipper';
|
||||||
|
import {padStart} from 'lodash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
@@ -59,6 +60,8 @@ export type Header = {|
|
|||||||
|};
|
|};
|
||||||
|
|
||||||
const COLUMN_SIZE = {
|
const COLUMN_SIZE = {
|
||||||
|
requestTimestamp: 100,
|
||||||
|
responseTimestamp: 100,
|
||||||
domain: 'flex',
|
domain: 'flex',
|
||||||
method: 100,
|
method: 100,
|
||||||
status: 70,
|
status: 70,
|
||||||
@@ -66,7 +69,23 @@ const COLUMN_SIZE = {
|
|||||||
duration: 100,
|
duration: 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const COLUMN_ORDER = [
|
||||||
|
{key: 'requestTimestamp', visible: true},
|
||||||
|
{key: 'responseTimestamp', visible: false},
|
||||||
|
{key: 'domain', visible: true},
|
||||||
|
{key: 'method', visible: true},
|
||||||
|
{key: 'status', visible: true},
|
||||||
|
{key: 'size', visible: true},
|
||||||
|
{key: 'duration', visible: true},
|
||||||
|
];
|
||||||
|
|
||||||
const COLUMNS = {
|
const COLUMNS = {
|
||||||
|
requestTimestamp: {
|
||||||
|
value: 'Request Time',
|
||||||
|
},
|
||||||
|
responseTimestamp: {
|
||||||
|
value: 'Response Time',
|
||||||
|
},
|
||||||
domain: {
|
domain: {
|
||||||
value: 'Domain',
|
value: 'Domain',
|
||||||
},
|
},
|
||||||
@@ -224,6 +243,19 @@ type NetworkTableState = {|
|
|||||||
sortedRows: TableRows,
|
sortedRows: TableRows,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
function formatTimestamp(timestamp: number): string {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
return `${padStart(date.getHours().toString(), 2, '0')}:${padStart(
|
||||||
|
date.getMinutes().toString(),
|
||||||
|
2,
|
||||||
|
'0',
|
||||||
|
)}:${padStart(date.getSeconds().toString(), 2, '0')}.${padStart(
|
||||||
|
date.getMilliseconds().toString(),
|
||||||
|
3,
|
||||||
|
'0',
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
|
||||||
function buildRow(request: Request, response: ?Response): ?TableBodyRow {
|
function buildRow(request: Request, response: ?Response): ?TableBodyRow {
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
return;
|
return;
|
||||||
@@ -234,6 +266,18 @@ function buildRow(request: Request, response: ?Response): ?TableBodyRow {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
columns: {
|
columns: {
|
||||||
|
requestTimestamp: {
|
||||||
|
value: (
|
||||||
|
<TextEllipsis>{formatTimestamp(request.timestamp)}</TextEllipsis>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
responseTimestamp: {
|
||||||
|
value: (
|
||||||
|
<TextEllipsis>
|
||||||
|
{response && formatTimestamp(response.timestamp)}
|
||||||
|
</TextEllipsis>
|
||||||
|
),
|
||||||
|
},
|
||||||
domain: {
|
domain: {
|
||||||
value: (
|
value: (
|
||||||
<TextEllipsis>{friendlyName ? friendlyName : domain}</TextEllipsis>
|
<TextEllipsis>{friendlyName ? friendlyName : domain}</TextEllipsis>
|
||||||
@@ -358,6 +402,7 @@ class NetworkTable extends PureComponent<NetworkTableProps, NetworkTableState> {
|
|||||||
floating={false}
|
floating={false}
|
||||||
columnSizes={COLUMN_SIZE}
|
columnSizes={COLUMN_SIZE}
|
||||||
columns={COLUMNS}
|
columns={COLUMNS}
|
||||||
|
columnOrder={COLUMN_ORDER}
|
||||||
rows={this.state.sortedRows}
|
rows={this.state.sortedRows}
|
||||||
onRowHighlighted={this.props.onRowHighlighted}
|
onRowHighlighted={this.props.onRowHighlighted}
|
||||||
highlightedRows={this.props.highlightedRows}
|
highlightedRows={this.props.highlightedRows}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pako": "^1.0.6",
|
"pako": "^1.0.6",
|
||||||
"xml-beautifier": "^0.4.0"
|
"xml-beautifier": "^0.4.0",
|
||||||
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"icon": "internet",
|
"icon": "internet",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
lodash@^4.17.11:
|
||||||
|
version "4.17.11"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||||
|
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
|
||||||
|
|
||||||
pako@^1.0.6:
|
pako@^1.0.6:
|
||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
|
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
|
||||||
|
|||||||
Reference in New Issue
Block a user