| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @param {!WebInspector.NetworkRequest} request | 8 * @param {!WebInspector.NetworkRequest} request |
| 9 */ | 9 */ |
| 10 WebInspector.EventSourceMessagesView = function(request) | 10 WebInspector.EventSourceMessagesView = function(request) |
| 11 { | 11 { |
| 12 WebInspector.VBox.call(this); | 12 WebInspector.VBox.call(this); |
| 13 this.registerRequiredCSS("network/eventSourceMessagesView.css"); | 13 this.registerRequiredCSS("network/eventSourceMessagesView.css"); |
| 14 this.element.classList.add("event-source-messages-view"); | 14 this.element.classList.add("event-source-messages-view"); |
| 15 this._request = request; | 15 this._request = request; |
| 16 | 16 |
| 17 var columns = [ | 17 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */
([ |
| 18 {id: "id", title: WebInspector.UIString("Id"), sortable: true, weight: 8
}, | 18 {id: "id", title: WebInspector.UIString("Id"), sortable: true, weight: 8
}, |
| 19 {id: "type", title: WebInspector.UIString("Type"), sortable: true, weigh
t: 8}, | 19 {id: "type", title: WebInspector.UIString("Type"), sortable: true, weigh
t: 8}, |
| 20 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig
ht: 88}, | 20 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig
ht: 88}, |
| 21 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh
t: 8} | 21 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh
t: 8} |
| 22 ]; | 22 ]); |
| 23 | 23 |
| 24 this._dataGrid = new WebInspector.SortableDataGrid(columns); | 24 this._dataGrid = new WebInspector.SortableDataGrid(columns); |
| 25 this._dataGrid.setStickToBottom(true); | 25 this._dataGrid.setStickToBottom(true); |
| 26 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce
nding); | 26 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce
nding); |
| 27 this._sortItems(); | 27 this._sortItems(); |
| 28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._sortItems, this); | 28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._sortItems, this); |
| 29 | 29 |
| 30 this._dataGrid.setName("EventSourceMessagesView"); | 30 this._dataGrid.setName("EventSourceMessagesView"); |
| 31 this._dataGrid.asWidget().show(this.element); | 31 this._dataGrid.asWidget().show(this.element); |
| 32 }; | 32 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 * @param {!WebInspector.Event} event | 51 * @param {!WebInspector.Event} event |
| 52 */ | 52 */ |
| 53 _messageAdded: function(event) | 53 _messageAdded: function(event) |
| 54 { | 54 { |
| 55 var message = /** @type {!WebInspector.NetworkRequest.EventSourceMessage
} */ (event.data); | 55 var message = /** @type {!WebInspector.NetworkRequest.EventSourceMessage
} */ (event.data); |
| 56 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(messa
ge)); | 56 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(messa
ge)); |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 _sortItems: function() | 59 _sortItems: function() |
| 60 { | 60 { |
| 61 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier(); | 61 var sortColumnId = this._dataGrid.sortColumnId(); |
| 62 if (!sortColumnIdentifier) | 62 if (!sortColumnId) |
| 63 return; | 63 return; |
| 64 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortCol
umnIdentifier]; | 64 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortCol
umnId]; |
| 65 if (!comparator) | 65 if (!comparator) |
| 66 return; | 66 return; |
| 67 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscendin
g()); | 67 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscendin
g()); |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 __proto__: WebInspector.VBox.prototype | 70 __proto__: WebInspector.VBox.prototype |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @constructor | 74 * @constructor |
| (...skipping 27 matching lines...) Expand all Loading... |
| 102 var bValue = b._message[field]; | 102 var bValue = b._message[field]; |
| 103 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; | 103 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ | 106 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ |
| 107 WebInspector.EventSourceMessageNode.Comparators = { | 107 WebInspector.EventSourceMessageNode.Comparators = { |
| 108 "id": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventId"), | 108 "id": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventId"), |
| 109 "type": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventName"
), | 109 "type": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventName"
), |
| 110 "time": WebInspector.EventSourceMessageNodeComparator.bind(null, "time") | 110 "time": WebInspector.EventSourceMessageNodeComparator.bind(null, "time") |
| 111 }; | 111 }; |
| OLD | NEW |