Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @param {!WebInspector.NetworkLogView} networkLogView | 7 * @param {!WebInspector.NetworkLogView} networkLogView |
| 8 * @param {!WebInspector.Setting} networkLogLargeRowsSetting | 8 * @param {!WebInspector.Setting} networkLogLargeRowsSetting |
| 9 */ | 9 */ |
| 10 WebInspector.NetworkLogViewColumns = function(networkLogView, networkLogLargeRow sSetting) | 10 WebInspector.NetworkLogViewColumns = function(networkLogView, networkLogLargeRow sSetting) |
| 11 { | 11 { |
| 12 this._networkLogView = networkLogView; | 12 this._networkLogView = networkLogView; |
| 13 | 13 |
| 14 var defaultColumnsVisibility = WebInspector.NetworkLogViewColumns._defaultCo lumnsVisibility; | |
| 15 /** @type {!WebInspector.Setting} */ | 14 /** @type {!WebInspector.Setting} */ |
| 16 this._columnsVisibilitySetting = WebInspector.settings.createSetting("networ kLogColumnsVisibility", defaultColumnsVisibility); | 15 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo lumns", {}); |
| 17 var savedColumnsVisibility = this._columnsVisibilitySetting.get(); | 16 |
| 18 /** @type {!Object.<boolean>} */ | 17 /** @type {!Array.<!Element>} */ |
|
dgozman
2016/07/14 05:28:06
Modern syntax requires omitting dot before "<". Pl
allada
2016/07/14 22:27:07
Done.
| |
| 19 var columnsVisibility = {}; | 18 this._dropDownColumnSelectors = []; |
| 20 for (var columnId in defaultColumnsVisibility) | |
| 21 columnsVisibility[columnId] = savedColumnsVisibility.hasOwnProperty(colu mnId) ? savedColumnsVisibility[columnId] : defaultColumnsVisibility[columnId]; | |
| 22 this._columnsVisibilitySetting.set(columnsVisibility); | |
| 23 | 19 |
| 24 networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, this); | 20 networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, this); |
| 25 | 21 |
| 26 /** @type {!Array<{time: number, element: !Element}>} */ | 22 /** @type {!Array<{time: number, element: !Element}>} */ |
| 27 this._eventDividers = []; | 23 this._eventDividers = []; |
| 28 | 24 |
| 29 this._gridMode = true; | 25 this._gridMode = true; |
| 30 | 26 |
| 31 /** @type {?WebInspector.DataGrid} */ | 27 /** @type {?WebInspector.DataGrid} */ |
| 32 this._dataGrid = null; | 28 this._dataGrid = null; |
| 33 /** @type {!Array.<!WebInspector.ColumnConfig>} */ | 29 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.ColumnDescriptor>} */ |
| 34 this._columns = []; | 30 this._columns = []; |
| 35 /** @type {!Object.<string, function(!WebInspector.NetworkDataGridNode, !Web Inspector.NetworkDataGridNode) : number>} */ | |
| 36 this._sortingFunctions = {}; | |
| 37 /** @type {!Object.<string, !WebInspector.NetworkTimeCalculator>} */ | |
| 38 this._calculators = {}; | |
| 39 /** @type {?Element} */ | |
| 40 this._timelineSortSelector = null; | |
| 41 | 31 |
| 42 /** @type {?WebInspector.TimelineGrid} */ | 32 /** @type {?WebInspector.TimelineGrid} */ |
| 43 this._timelineGrid = null; | 33 this._timelineGrid = null; |
| 44 | 34 |
| 45 /** @type {!WebInspector.Linkifier} */ | 35 /** @type {!WebInspector.Linkifier} */ |
| 46 this._popupLinkifier = new WebInspector.Linkifier(); | 36 this._popupLinkifier = new WebInspector.Linkifier(); |
| 47 } | 37 } |
| 48 | 38 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; |
| 49 WebInspector.NetworkLogViewColumns._responseHeaderColumns = ["Cache-Control", "C onnection", "Content-Encoding", "Content-Length", "ETag", "Keep-Alive", "Last-Mo dified", "Server", "Vary"]; | |
| 50 WebInspector.NetworkLogViewColumns._defaultColumnsVisibility = { | |
| 51 method: false, status: true, protocol: false, scheme: false, domain: false, remoteAddress: false, type: true, initiator: true, cookies: false, setCookies: f alse, size: true, time: true, priority: false, connectionId: false, | |
| 52 "Cache-Control": false, "Connection": false, "Content-Encoding": false, "Con tent-Length": false, "ETag": false, "Keep-Alive": false, "Last-Modified": false, "Server": false, "Vary": false | |
| 53 }; | |
| 54 | 39 |
| 55 /** | 40 /** |
| 56 * @typedef {{ | 41 * @typedef {{ |
| 57 * id: string, | 42 * id: string, |
| 58 * title: string, | 43 * title: string, |
| 59 * titleDOMFragment: !DocumentFragment, | 44 * subTitle: string, |
|
dgozman
2016/07/14 05:28:06
"subtitle" is widespread in our code.
allada
2016/07/14 22:27:07
Done.
| |
| 60 * sortable: boolean, | 45 * visible: boolean, |
| 61 * weight: number, | 46 * weight: number, |
| 62 * sort: (?WebInspector.DataGrid.Order|undefined), | 47 * hideable: boolean, |
| 63 * align: (?WebInspector.DataGrid.Align|undefined), | 48 * nonSelectable: boolean, |
|
dgozman
2016/07/14 05:28:06
selectable?
allada
2016/07/14 22:27:08
It is how WebInspector.DataGrid.ColumnDescriptor d
| |
| 49 * sortable: boolean, | |
| 50 * align: (?WebInspector.DataGrid.Align|undefined), | |
| 51 * isResponseHeader: boolean, | |
| 52 * sortConfig: (!WebInspector.NetworkLogViewColumns.SortConfig) | |
|
dgozman
2016/07/14 05:28:07
No need in extra ()
allada
2016/07/14 22:27:07
Done.
| |
| 64 * }} | 53 * }} |
| 65 */ | 54 */ |
| 66 WebInspector.ColumnConfig; | 55 WebInspector.NetworkLogViewColumns.ColumnDescriptor; |
|
dgozman
2016/07/14 05:28:06
I think we may avoid mentioning "column" twice.
allada
2016/07/14 22:27:08
Done.
| |
| 67 | 56 |
| 68 /** @type {!Object.<string, string>} */ | 57 /** |
| 69 WebInspector.NetworkLogViewColumns._columnTitles = { | 58 * @typedef {{ |
| 70 "name": WebInspector.UIString("Name"), | 59 * sortingFunction: (!function(!WebInspector.NetworkDataGridNode, !WebInspec tor.NetworkDataGridNode):number|undefined), |
| 71 "method": WebInspector.UIString("Method"), | 60 * entries: (!Array.<!WebInspector.DataGrid.ColumnDescriptor>|undefined) |
| 72 "status": WebInspector.UIString("Status"), | 61 * }} |
| 73 "protocol": WebInspector.UIString("Protocol"), | 62 */ |
| 74 "scheme": WebInspector.UIString("Scheme"), | 63 WebInspector.NetworkLogViewColumns.SortConfig; |
| 75 "domain": WebInspector.UIString("Domain"), | 64 |
| 76 "remoteAddress": WebInspector.UIString("Remote Address"), | 65 /** @enum {string} */ |
| 77 "type": WebInspector.UIString("Type"), | 66 WebInspector.NetworkLogViewColumns._calculatorTypes = { |
| 78 "initiator": WebInspector.UIString("Initiator"), | 67 Duration: "Duration", |
| 79 "cookies": WebInspector.UIString("Cookies"), | 68 Time: "Time" |
| 80 "setCookies": WebInspector.UIString("Set-Cookies"), | |
| 81 "size": WebInspector.UIString("Size"), | |
| 82 "time": WebInspector.UIString("Time"), | |
| 83 "connectionId": WebInspector.UIString("Connection Id"), | |
| 84 "priority": WebInspector.UIString("Priority"), | |
| 85 "timeline": WebInspector.UIString("Timeline"), | |
| 86 | |
| 87 // Response header columns | |
| 88 "Cache-Control": WebInspector.UIString("Cache-Control"), | |
| 89 "Connection": WebInspector.UIString("Connection"), | |
| 90 "Content-Encoding": WebInspector.UIString("Content-Encoding"), | |
| 91 "Content-Length": WebInspector.UIString("Content-Length"), | |
| 92 "ETag": WebInspector.UIString("ETag"), | |
| 93 "Keep-Alive": WebInspector.UIString("Keep-Alive"), | |
| 94 "Last-Modified": WebInspector.UIString("Last-Modified"), | |
| 95 "Server": WebInspector.UIString("Server"), | |
| 96 "Vary": WebInspector.UIString("Vary") | |
| 97 }; | 69 }; |
| 98 | 70 |
| 71 /** | |
| 72 * @type {!Object} column | |
| 73 */ | |
| 74 WebInspector.NetworkLogViewColumns._defaultColumnConfig = { | |
| 75 subTitle: null, | |
|
dgozman
2016/07/14 05:28:06
null is not a {string}
allada
2016/07/14 22:27:08
Done.
| |
| 76 visible: false, | |
| 77 weight: 6, | |
| 78 sortable: true, | |
| 79 hideable: true, | |
| 80 nonSelectable: true, | |
| 81 isResponseHeader: false | |
| 82 }; | |
| 83 | |
| 84 /** | |
| 85 * @type {!Array.<!WebInspector.NetworkLogViewColumns.ColumnDescriptor>} column | |
| 86 */ | |
| 87 WebInspector.NetworkLogViewColumns._defaultColumns = [ | |
| 88 { | |
| 89 id: "name", | |
| 90 title: WebInspector.UIString("Name"), | |
| 91 subTitle: WebInspector.UIString("Path"), | |
| 92 visible: true, | |
| 93 weight: 20, | |
| 94 hideable: false, | |
| 95 nonSelectable: false, | |
| 96 sortConfig: { | |
| 97 sortingFunction: WebInspector.NetworkDataGridNode.NameComparator | |
| 98 } | |
| 99 }, | |
| 100 { | |
| 101 id: "method", | |
| 102 title: WebInspector.UIString("Method"), | |
| 103 sortConfig: { | |
| 104 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "requestMethod") | |
| 105 } | |
| 106 }, | |
| 107 { | |
| 108 id: "status", | |
| 109 title: WebInspector.UIString("Status"), | |
| 110 visible: true, | |
| 111 subTitle: WebInspector.UIString("Text"), | |
| 112 sortConfig: { | |
| 113 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "statusCode") | |
| 114 } | |
| 115 }, | |
| 116 { | |
| 117 id: "protocol", | |
| 118 title: WebInspector.UIString("Protocol"), | |
| 119 sortConfig: { | |
| 120 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "protocol") | |
| 121 } | |
| 122 }, | |
| 123 { | |
| 124 id: "scheme", | |
| 125 title: WebInspector.UIString("Scheme"), | |
| 126 sortConfig: { | |
| 127 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "scheme") | |
| 128 } | |
| 129 }, | |
| 130 { | |
| 131 id: "domain", | |
| 132 title: WebInspector.UIString("Domain"), | |
| 133 sortConfig: { | |
| 134 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "domain") | |
| 135 } | |
| 136 }, | |
| 137 { | |
| 138 id: "remoteAddress", | |
| 139 title: WebInspector.UIString("Remote Address"), | |
| 140 weight: 10, | |
| 141 align: WebInspector.DataGrid.Align.Right, | |
| 142 sortConfig: { | |
| 143 sortingFunction: WebInspector.NetworkDataGridNode.RemoteAddressCompa rator | |
| 144 } | |
| 145 }, | |
| 146 { | |
| 147 id: "type", | |
| 148 title: WebInspector.UIString("Type"), | |
| 149 visible: true, | |
| 150 sortConfig: { | |
| 151 sortingFunction: WebInspector.NetworkDataGridNode.TypeComparator | |
| 152 } | |
| 153 }, | |
| 154 { | |
| 155 id: "initiator", | |
| 156 title: WebInspector.UIString("Initiator"), | |
| 157 visible: true, | |
| 158 weight: 10, | |
| 159 sortConfig: { | |
| 160 sortingFunction: WebInspector.NetworkDataGridNode.InitiatorComparato r | |
| 161 } | |
| 162 }, | |
| 163 { | |
| 164 id: "cookies", | |
| 165 title: WebInspector.UIString("Cookies"), | |
| 166 align: WebInspector.DataGrid.Align.Right, | |
| 167 sortConfig: { | |
| 168 sortingFunction: WebInspector.NetworkDataGridNode.RequestCookiesCoun tComparator | |
| 169 } | |
| 170 }, | |
| 171 { | |
| 172 id: "setCookies", | |
|
dgozman
2016/07/14 05:28:06
Shouldn't all these be lowercase (based on code in
allada
2016/07/14 22:27:07
Done.
| |
| 173 title: WebInspector.UIString("Set Cookies"), | |
| 174 align: WebInspector.DataGrid.Align.Right, | |
| 175 sortConfig: { | |
| 176 sortingFunction: WebInspector.NetworkDataGridNode.ResponseCookiesCou ntComparator | |
| 177 } | |
| 178 }, | |
| 179 { | |
| 180 id: "size", | |
| 181 title: WebInspector.UIString("Size"), | |
| 182 visible: true, | |
| 183 subTitle: WebInspector.UIString("Content"), | |
| 184 align: WebInspector.DataGrid.Align.Right, | |
| 185 sortConfig: { | |
| 186 sortingFunction: WebInspector.NetworkDataGridNode.SizeComparator | |
| 187 } | |
| 188 }, | |
| 189 { | |
| 190 id: "time", | |
| 191 title: WebInspector.UIString("Time"), | |
| 192 visible: true, | |
| 193 subTitle: WebInspector.UIString("Latency"), | |
| 194 align: WebInspector.DataGrid.Align.Right, | |
| 195 sortConfig: { | |
| 196 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "duration") | |
| 197 } | |
| 198 }, | |
| 199 { | |
| 200 id: "priority", | |
| 201 title: WebInspector.UIString("Priority"), | |
| 202 sortConfig: { | |
| 203 sortingFunction: WebInspector.NetworkDataGridNode.InitialPriorityCom parator | |
| 204 } | |
| 205 }, | |
| 206 { | |
| 207 id: "connectionId", | |
| 208 title: WebInspector.UIString("Connection ID"), | |
| 209 sortConfig: { | |
| 210 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "connectionId") | |
| 211 } | |
| 212 }, | |
| 213 { | |
| 214 id: "timeline", | |
| 215 title: WebInspector.UIString("Timeline"), | |
| 216 visible: true, | |
| 217 weight: 40, | |
| 218 sortable: false, | |
|
dgozman
2016/07/14 05:28:07
sortable: false, but with sortConfig?
Let's remove
allada
2016/07/14 22:27:08
Because this is a superset of WebInspector.DataGri
dgozman
2016/07/15 23:47:49
We should either force JSCompiler to check this fo
| |
| 219 hideable: false, | |
| 220 sortConfig: { | |
| 221 entries: [ | |
| 222 { | |
| 223 id: "startTime", | |
| 224 title: WebInspector.UIString("Timeline \u2013 Start Time"), | |
| 225 sort: WebInspector.DataGrid.Order.Ascending, | |
| 226 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "startTime"), | |
| 227 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 228 }, | |
| 229 { | |
| 230 id: "responseTime", | |
| 231 title: WebInspector.UIString("Timeline \u2013 Response Time" ), | |
| 232 sort: WebInspector.DataGrid.Order.Ascending, | |
| 233 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "responseReceivedTime"), | |
| 234 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 235 }, | |
| 236 { | |
| 237 id: "endtime", | |
| 238 title: WebInspector.UIString("Timeline \u2013 End Time"), | |
| 239 sort: WebInspector.DataGrid.Order.Ascending, | |
| 240 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "endTime"), | |
| 241 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 242 }, | |
| 243 { | |
| 244 id: "duration", | |
| 245 title: WebInspector.UIString("Timeline \u2013 Total Duration "), | |
| 246 sort: WebInspector.DataGrid.Order.Descending, | |
| 247 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "duration"), | |
| 248 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 249 }, | |
| 250 { | |
| 251 id: "latency", | |
| 252 title: WebInspector.UIString("Timeline \u2013 Latency"), | |
| 253 sort: WebInspector.DataGrid.Order.Descending, | |
| 254 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "latency"), | |
| 255 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 256 } | |
| 257 ] | |
| 258 } | |
| 259 }, | |
| 260 { | |
| 261 id: "cache-control", | |
| 262 isResponseHeader: true, | |
| 263 title: WebInspector.UIString("Cache-Control"), | |
| 264 sortConfig: { | |
| 265 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "cache-control") | |
| 266 } | |
| 267 }, | |
| 268 { | |
| 269 id: "connection", | |
| 270 isResponseHeader: true, | |
| 271 title: WebInspector.UIString("Connection"), | |
| 272 sortConfig: { | |
| 273 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "connection") | |
| 274 } | |
| 275 }, | |
| 276 { | |
| 277 id: "content-encoding", | |
| 278 isResponseHeader: true, | |
| 279 title: WebInspector.UIString("Content-Encoding"), | |
| 280 sortConfig: { | |
| 281 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "content-encoding") | |
| 282 } | |
| 283 }, | |
| 284 { | |
| 285 id: "content-length", | |
| 286 isResponseHeader: true, | |
| 287 title: WebInspector.UIString("Content-Length"), | |
| 288 align: WebInspector.DataGrid.Align.Right, | |
| 289 sortConfig: { | |
| 290 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderNumb erComparator.bind(null, "content-length") | |
| 291 } | |
| 292 }, | |
| 293 { | |
| 294 id: "etag", | |
| 295 isResponseHeader: true, | |
| 296 title: WebInspector.UIString("ETag"), | |
| 297 sortConfig: { | |
| 298 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "etag") | |
| 299 } | |
| 300 }, | |
| 301 { | |
| 302 id: "keep-alive", | |
| 303 isResponseHeader: true, | |
| 304 title: WebInspector.UIString("Keep-Alive"), | |
| 305 sortConfig: { | |
| 306 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "keep-alive") | |
| 307 } | |
| 308 }, | |
| 309 { | |
| 310 id: "last-modified", | |
| 311 isResponseHeader: true, | |
| 312 title: WebInspector.UIString("Last-Modified"), | |
| 313 sortConfig: { | |
| 314 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderDate Comparator.bind(null, "last-modified") | |
| 315 } | |
| 316 }, | |
| 317 { | |
| 318 id: "server", | |
| 319 isResponseHeader: true, | |
| 320 title: WebInspector.UIString("Server"), | |
| 321 sortConfig: { | |
| 322 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "server") | |
| 323 } | |
| 324 }, | |
| 325 { | |
| 326 id: "vary", | |
| 327 isResponseHeader: true, | |
| 328 title: WebInspector.UIString("Vary"), | |
| 329 sortConfig: { | |
| 330 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "vary") | |
| 331 } | |
| 332 } | |
| 333 ]; | |
| 334 | |
| 335 WebInspector.NetworkLogViewColumns._orderrideableConfigs = ["visible", "title"]; | |
|
dgozman
2016/07/14 05:28:07
I don't get the "orderrideable". Let's rename.
allada
2016/07/14 22:27:08
Done.
| |
| 336 | |
| 99 WebInspector.NetworkLogViewColumns.prototype = { | 337 WebInspector.NetworkLogViewColumns.prototype = { |
| 100 willHide: function() | 338 willHide: function() |
| 101 { | 339 { |
| 102 this._popoverHelper.hidePopover(); | 340 this._popoverHelper.hidePopover(); |
| 103 }, | 341 }, |
| 104 | 342 |
| 105 reset: function() | 343 reset: function() |
| 106 { | 344 { |
| 107 if (this._popoverHelper) | 345 if (this._popoverHelper) |
| 108 this._popoverHelper.hidePopover(); | 346 this._popoverHelper.hidePopover(); |
| 109 this._timelineGrid.removeEventDividers(); | 347 this._timelineGrid.removeEventDividers(); |
| 110 this.updateDividersIfNeeded(); | 348 this.updateDividersIfNeeded(); |
| 111 }, | 349 }, |
| 112 | 350 |
| 113 /** | 351 /** |
| 352 WRONG!!!! | |
|
dgozman
2016/07/14 05:28:06
It's wrong!
allada
2016/07/14 22:27:07
Done.
| |
| 114 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | 353 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator |
| 115 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or | 354 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or |
| 116 * @return {!WebInspector.SortableDataGrid} dataGrid | 355 * @return {!WebInspector.SortableDataGrid} dataGrid |
| 117 */ | 356 */ |
| 118 createGrid: function(timeCalculator, durationCalculator) | 357 createGrid: function(timeCalculator, durationCalculator) |
| 119 { | 358 { |
| 120 this._createSortingFunctions(); | 359 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; |
| 121 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); | 360 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol umnConfig; |
| 122 | 361 |
| 123 this._calculators.timeline = timeCalculator; | 362 for (var currentConfigColumn of defaultColumns) { |
| 124 this._calculators.startTime = timeCalculator; | 363 var columnConfig = /** @type {!WebInspector.NetworkLogViewColumns.Co lumnDescriptor} */ (Object.assign(/** @type {!Object} */ ({}), defaultColumnConf ig, currentConfigColumn)); |
| 125 this._calculators.endTime = timeCalculator; | 364 columnConfig.id = columnConfig.id.toLowerCase(); |
| 126 this._calculators.responseTime = timeCalculator; | 365 if (columnConfig.subTitle) |
| 127 this._calculators.duration = durationCalculator; | 366 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC onfig.title, columnConfig.subTitle); |
| 128 this._calculators.latency = durationCalculator; | 367 this._columns.push(columnConfig); |
|
dgozman
2016/07/14 05:28:07
Create this._columns in this method.
allada
2016/07/14 22:27:08
Done.
| |
| 129 | |
| 130 var columns = []; | |
| 131 columns.push({ | |
| 132 id: "name", | |
| 133 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Na me"), WebInspector.UIString("Path")), | |
| 134 title: WebInspector.NetworkLogViewColumns._columnTitles["name"], | |
| 135 weight: 20 | |
| 136 }); | |
| 137 | |
| 138 columns.push({ | |
| 139 id: "method", | |
| 140 title: WebInspector.NetworkLogViewColumns._columnTitles["method"], | |
| 141 weight: 6 | |
| 142 }); | |
| 143 | |
| 144 columns.push({ | |
| 145 id: "status", | |
| 146 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("St atus"), WebInspector.UIString("Text")), | |
| 147 title: WebInspector.NetworkLogViewColumns._columnTitles["status"], | |
| 148 weight: 6 | |
| 149 }); | |
| 150 | |
| 151 columns.push({ | |
| 152 id: "protocol", | |
| 153 title: WebInspector.NetworkLogViewColumns._columnTitles["protocol"], | |
| 154 weight: 6 | |
| 155 }); | |
| 156 | |
| 157 columns.push({ | |
| 158 id: "scheme", | |
| 159 title: WebInspector.NetworkLogViewColumns._columnTitles["scheme"], | |
| 160 weight: 6 | |
| 161 }); | |
| 162 | |
| 163 columns.push({ | |
| 164 id: "domain", | |
| 165 title: WebInspector.NetworkLogViewColumns._columnTitles["domain"], | |
| 166 weight: 6 | |
| 167 }); | |
| 168 | |
| 169 columns.push({ | |
| 170 id: "remoteAddress", | |
| 171 title: WebInspector.NetworkLogViewColumns._columnTitles["remoteAddre ss"], | |
| 172 weight: 10, | |
| 173 align: WebInspector.DataGrid.Align.Right | |
| 174 }); | |
| 175 | |
| 176 columns.push({ | |
| 177 id: "type", | |
| 178 title: WebInspector.NetworkLogViewColumns._columnTitles["type"], | |
| 179 weight: 6 | |
| 180 }); | |
| 181 | |
| 182 columns.push({ | |
| 183 id: "initiator", | |
| 184 title: WebInspector.NetworkLogViewColumns._columnTitles["initiator"] , | |
| 185 weight: 10 | |
| 186 }); | |
| 187 | |
| 188 columns.push({ | |
| 189 id: "cookies", | |
| 190 title: WebInspector.NetworkLogViewColumns._columnTitles["cookies"], | |
| 191 weight: 6, | |
| 192 align: WebInspector.DataGrid.Align.Right | |
| 193 }); | |
| 194 | |
| 195 columns.push({ | |
| 196 id: "setCookies", | |
| 197 title: WebInspector.NetworkLogViewColumns._columnTitles["setCookies" ], | |
| 198 weight: 6, | |
| 199 align: WebInspector.DataGrid.Align.Right | |
| 200 }); | |
| 201 | |
| 202 columns.push({ | |
| 203 id: "size", | |
| 204 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Si ze"), WebInspector.UIString("Content")), | |
| 205 title: WebInspector.NetworkLogViewColumns._columnTitles["size"], | |
| 206 weight: 6, | |
| 207 align: WebInspector.DataGrid.Align.Right | |
| 208 }); | |
| 209 | |
| 210 columns.push({ | |
| 211 id: "time", | |
| 212 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Ti me"), WebInspector.UIString("Latency")), | |
| 213 title: WebInspector.NetworkLogViewColumns._columnTitles["time"], | |
| 214 weight: 6, | |
| 215 align: WebInspector.DataGrid.Align.Right | |
| 216 }); | |
| 217 | |
| 218 columns.push({ | |
| 219 id: "priority", | |
| 220 title: WebInspector.NetworkLogViewColumns._columnTitles["priority"], | |
| 221 weight: 6 | |
| 222 }); | |
| 223 | |
| 224 columns.push({ | |
| 225 id: "connectionId", | |
| 226 title: WebInspector.NetworkLogViewColumns._columnTitles["connectionI d"], | |
| 227 weight: 6 | |
| 228 }); | |
| 229 | |
| 230 var responseHeaderColumns = WebInspector.NetworkLogViewColumns._response HeaderColumns; | |
| 231 for (var i = 0; i < responseHeaderColumns.length; ++i) { | |
| 232 var headerName = responseHeaderColumns[i]; | |
| 233 var descriptor = { | |
| 234 id: headerName, | |
| 235 title: WebInspector.NetworkLogViewColumns._columnTitles[headerNa me], | |
| 236 weight: 6 | |
| 237 }; | |
| 238 if (headerName === "Content-Length") | |
| 239 descriptor.align = WebInspector.DataGrid.Align.Right; | |
| 240 columns.push(descriptor); | |
| 241 } | 368 } |
| 242 | 369 |
| 243 columns.push({ | 370 this._setupCalculators(timeCalculator, durationCalculator); |
| 244 id: "timeline", | 371 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); |
| 245 title: WebInspector.NetworkLogViewColumns._columnTitles["timeline"], | |
| 246 sortable: false, | |
| 247 weight: 40, | |
| 248 sort: WebInspector.DataGrid.Order.Ascending | |
| 249 }); | |
| 250 | |
| 251 for (var column of columns) { | |
| 252 column.sortable = column.id !== "timeline"; | |
| 253 column.nonSelectable = column.id !== "name"; | |
| 254 } | |
| 255 this._columns = columns; | |
| 256 | |
| 257 this._networkLogView.switchViewMode(true); | |
| 258 | 372 |
| 259 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); | 373 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); |
| 260 | 374 |
| 261 this._dataGrid.asWidget().show(this._networkLogView.element); | 375 this._dataGrid.asWidget().show(this._networkLogView.element); |
| 262 | 376 |
| 377 this._updateColumns(); | |
| 378 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); | |
| 379 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 380 | |
| 263 this._timelineGrid = new WebInspector.TimelineGrid(); | 381 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 264 this._timelineGrid.element.classList.add("network-timeline-grid"); | 382 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 265 this._dataGrid.element.appendChild(this._timelineGrid.element); | 383 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 384 this._setupDropdownColumns(); | |
| 266 | 385 |
| 267 this._updateColumns(); | 386 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 268 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | 387 this._sortHandler(); |
| 269 this._dataGrid.sortNodes(this._sortingFunctions.startTime, false); | |
| 270 this._patchTimelineHeader(); | |
| 271 | |
| 272 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 273 | 388 |
| 274 return this._dataGrid; | 389 return this._dataGrid; |
| 275 }, | 390 }, |
| 276 | 391 |
| 277 _createSortingFunctions: function() | 392 _setupDropdownColumns: function() |
| 278 { | 393 { |
| 279 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameCompa rator; | 394 for (var columnConfig of this._columns) { |
| 280 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "requestMethod"); | 395 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { |
|
dgozman
2016/07/14 05:28:07
if (!...) continue;
allada
2016/07/14 22:27:08
Done.
| |
| 281 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "statusCode"); | 396 var select = createElement("select"); |
| 282 this._sortingFunctions.protocol = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "protocol"); | 397 var placeHolderOption = select.createChild("option"); |
| 283 this._sortingFunctions.scheme = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "scheme"); | 398 placeHolderOption.style.display = "none"; |
|
dgozman
2016/07/14 05:28:06
Toggle hidden class instead.
allada
2016/07/14 22:27:07
Done.
| |
| 284 this._sortingFunctions.domain = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "domain"); | 399 for (var entry of columnConfig.sortConfig.entries) { |
| 285 this._sortingFunctions.remoteAddress = WebInspector.NetworkDataGridNode. RemoteAddressComparator; | 400 var option = select.createChild("option"); |
| 286 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.TypeCompa rator; | 401 option.value = entry.id; |
| 287 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.Init iatorComparator; | 402 option.label = entry.title; |
| 288 this._sortingFunctions.cookies = WebInspector.NetworkDataGridNode.Reques tCookiesCountComparator; | 403 select.appendChild(option); |
| 289 this._sortingFunctions.setCookies = WebInspector.NetworkDataGridNode.Res ponseCookiesCountComparator; | 404 } |
| 290 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeCompa rator; | 405 var header = this._dataGrid.headerTableHeader(columnConfig.id); |
| 291 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.RequestPr opertyComparator.bind(null, "duration"); | 406 header.replaceChild(select, header.firstChild); |
| 292 this._sortingFunctions.connectionId = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "connectionId"); | 407 header.createChild("div", "sort-order-icon-container").createChi ld("div", "sort-order-icon"); |
| 293 this._sortingFunctions.priority = WebInspector.NetworkDataGridNode.Initi alPriorityComparator; | 408 columnConfig.selectBox = select; |
| 294 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "startTime"); | 409 select.addEventListener("change", this._sortByDropdownItem.bind( this, columnConfig), false); |
| 295 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.Requ estPropertyComparator.bind(null, "startTime"); | 410 this._dropDownColumnSelectors.push(select); |
| 296 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "endTime"); | 411 } |
| 297 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "responseReceivedTime"); | 412 } |
| 298 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "duration"); | |
| 299 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "latency"); | |
| 300 | |
| 301 this._sortingFunctions["Cache-Control"] = WebInspector.NetworkDataGridNo de.ResponseHeaderStringComparator.bind(null, "Cache-Control"); | |
| 302 this._sortingFunctions["Connection"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Connection"); | |
| 303 this._sortingFunctions["Content-Encoding"] = WebInspector.NetworkDataGri dNode.ResponseHeaderStringComparator.bind(null, "Content-Encoding"); | |
| 304 this._sortingFunctions["Content-Length"] = WebInspector.NetworkDataGridN ode.ResponseHeaderNumberComparator.bind(null, "Content-Length"); | |
| 305 this._sortingFunctions["ETag"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "ETag"); | |
| 306 this._sortingFunctions["Keep-Alive"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Keep-Alive"); | |
| 307 this._sortingFunctions["Last-Modified"] = WebInspector.NetworkDataGridNo de.ResponseHeaderDateComparator.bind(null, "Last-Modified"); | |
| 308 this._sortingFunctions["Server"] = WebInspector.NetworkDataGridNode.Resp onseHeaderStringComparator.bind(null, "Server"); | |
| 309 this._sortingFunctions["Vary"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "Vary"); | |
| 310 }, | 413 }, |
| 311 | 414 |
| 312 _sortItems: function() | 415 /** |
| 416 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | |
| 417 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or | |
| 418 */ | |
| 419 _setupCalculators: function(timeCalculator, durationCalculator) | |
| 420 { | |
| 421 for (var columnConfig of this._columns) { | |
| 422 if (columnConfig.sortConfig.entries) { | |
|
dgozman
2016/07/14 05:28:06
if (!...) continue;
allada
2016/07/14 22:27:08
Done.
| |
| 423 for (var entry of columnConfig.sortConfig.entries) { | |
| 424 if (!entry.calculator) | |
| 425 continue; | |
| 426 if (entry.calculator === WebInspector.NetworkLogViewColumns. _calculatorTypes.Time) { | |
| 427 entry.calculator = timeCalculator; | |
|
dgozman
2016/07/14 05:28:06
This is weird. Let's use different fields for calc
allada
2016/07/14 22:27:08
Done.
| |
| 428 } else if (entry.calculator === WebInspector.NetworkLogViewC olumns._calculatorTypes.Duration) { | |
| 429 entry.calculator = durationCalculator; | |
| 430 } | |
| 431 } | |
| 432 } | |
| 433 } | |
| 434 }, | |
| 435 | |
| 436 _sortHandler: function() | |
| 437 { | |
| 438 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | |
| 439 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnIdentifier); | |
| 440 if (!columnConfig) | |
| 441 return; | |
| 442 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { | |
| 443 this._sortByDropdownItem(columnConfig); | |
| 444 return; | |
| 445 } | |
| 446 if (!columnConfig.sortConfig.sortingFunction) | |
| 447 return; | |
| 448 | |
| 449 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); | |
| 450 }, | |
| 451 | |
| 452 /** | |
| 453 * @param {!WebInspector.NetworkLogViewColumns.ColumnDescriptor} columnConfi g | |
| 454 */ | |
| 455 _sortByDropdownItem: function(columnConfig) | |
| 313 { | 456 { |
| 314 this._networkLogView.removeAllNodeHighlights(); | 457 this._networkLogView.removeAllNodeHighlights(); |
|
dgozman
2016/07/14 05:28:06
You probably want to do this in _sortHandler as we
allada
2016/07/14 22:27:07
Done.
| |
| 315 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | 458 var selectedIndex = columnConfig.selectBox.selectedIndex; |
| 316 if (!columnIdentifier) | |
| 317 return; | |
| 318 if (columnIdentifier === "timeline") { | |
| 319 this._sortByTimeline(); | |
| 320 return; | |
| 321 } | |
| 322 var sortingFunction = this._sortingFunctions[columnIdentifier]; | |
| 323 if (!sortingFunction) | |
| 324 return; | |
| 325 | |
| 326 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | |
| 327 this._timelineSortSelector.selectedIndex = 0; | |
| 328 this._networkLogView.dataGridSorted(); | |
|
dgozman
2016/07/14 05:28:06
Where did this call go?
allada
2016/07/14 22:27:07
Done.
| |
| 329 }, | |
| 330 | |
| 331 _sortByTimeline: function() | |
| 332 { | |
| 333 this._networkLogView.removeAllNodeHighlights(); | |
| 334 var selectedIndex = this._timelineSortSelector.selectedIndex; | |
| 335 if (!selectedIndex) | 459 if (!selectedIndex) |
| 336 selectedIndex = 1; // Sort by start time by default. | 460 selectedIndex = 1; // Sort by first item by default. |
| 337 var selectedOption = this._timelineSortSelector[selectedIndex]; | 461 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. |
| 462 var selectedOption = columnConfig.selectBox[selectedIndex]; | |
| 338 var value = selectedOption.value; | 463 var value = selectedOption.value; |
| 339 | 464 |
| 340 this._networkLogView.setCalculator(this._calculators[value]); | 465 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); |
| 341 var sortingFunction = this._sortingFunctions[value]; | 466 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); |
| 342 this._dataGrid.sortNodes(sortingFunction); | 467 if (selectedItemConfig.calculator) |
| 343 | 468 this._networkLogView.setCalculator(selectedItemConfig.calculator); |
| 344 this._networkLogView.dataGridSorted(); | 469 columnConfig.selectBox.options[0].label = selectedItemConfig.title; |
|
dgozman
2016/07/14 05:28:06
And this?
allada
2016/07/14 22:27:07
Done.
| |
| 345 | 470 columnConfig.selectBox.selectedIndex = 0; |
| 346 this._dataGrid.markColumnAsSortedBy("timeline", selectedOption.sortOrder ); | |
| 347 }, | |
| 348 | |
| 349 _patchTimelineHeader: function() | |
| 350 { | |
| 351 var timelineSorting = createElement("select"); | |
| 352 | |
| 353 var option = createElement("option"); | |
| 354 option.value = "startTime"; | |
| 355 option.label = WebInspector.UIString("Timeline"); | |
| 356 option.disabled = true; | |
| 357 timelineSorting.appendChild(option); | |
| 358 | |
| 359 option = createElement("option"); | |
| 360 option.value = "startTime"; | |
| 361 option.label = WebInspector.UIString("Timeline \u2013 Start Time"); | |
| 362 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 363 timelineSorting.appendChild(option); | |
| 364 | |
| 365 option = createElement("option"); | |
| 366 option.value = "responseTime"; | |
| 367 option.label = WebInspector.UIString("Timeline \u2013 Response Time"); | |
| 368 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 369 timelineSorting.appendChild(option); | |
| 370 | |
| 371 option = createElement("option"); | |
| 372 option.value = "endTime"; | |
| 373 option.label = WebInspector.UIString("Timeline \u2013 End Time"); | |
| 374 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 375 timelineSorting.appendChild(option); | |
| 376 | |
| 377 option = createElement("option"); | |
| 378 option.value = "duration"; | |
| 379 option.label = WebInspector.UIString("Timeline \u2013 Total Duration"); | |
| 380 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 381 timelineSorting.appendChild(option); | |
| 382 | |
| 383 option = createElement("option"); | |
| 384 option.value = "latency"; | |
| 385 option.label = WebInspector.UIString("Timeline \u2013 Latency"); | |
| 386 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 387 timelineSorting.appendChild(option); | |
| 388 | |
| 389 var header = this._dataGrid.headerTableHeader("timeline"); | |
| 390 header.replaceChild(timelineSorting, header.firstChild); | |
| 391 header.createChild("div", "sort-order-icon-container").createChild("div" , "sort-order-icon"); | |
| 392 | |
| 393 timelineSorting.selectedIndex = 1; | |
| 394 timelineSorting.addEventListener("click", function(event) { event.consum e(); }, false); | |
| 395 timelineSorting.addEventListener("change", this._sortByTimeline.bind(thi s), false); | |
| 396 this._timelineSortSelector = timelineSorting; | |
| 397 }, | 471 }, |
| 398 | 472 |
| 399 _updateColumns: function() | 473 _updateColumns: function() |
| 400 { | 474 { |
| 401 if (!this._dataGrid) | 475 if (!this._dataGrid) |
| 402 return; | 476 return; |
| 403 var gridMode = this._gridMode; | 477 var gridMode = this._gridMode; |
| 404 var visibleColumns = {"name": true}; | 478 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); |
| 405 if (gridMode) | 479 if (this._columns[0].id !== "name") { |
| 406 visibleColumns["timeline"] = true; | 480 var index = this._columns.findIndex(columnConfig => columnConfig.id === "name"); |
| 481 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 482 this._columns.unshift(columnConfig); | |
| 483 } | |
| 484 if (this._columns[this._columns.length - 1].id !== "timeline") { | |
| 485 var index = this._columns.findIndex(columnConfig => columnConfig.id === "timeline"); | |
| 486 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 487 this._columns.push(columnConfig); | |
| 488 } | |
| 407 if (gridMode) { | 489 if (gridMode) { |
| 408 var columnsVisibility = this._columnsVisibilitySetting.get(); | 490 for (var columnConfig of this._columns) |
| 409 for (var columnIdentifier in columnsVisibility) | 491 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable) |
| 410 visibleColumns[columnIdentifier] = columnsVisibility[columnIdent ifier]; | 492 } else { |
| 493 visibleColumns = {"name": true}; | |
| 411 } | 494 } |
| 412 | 495 this._dataGrid.setColumnsVisiblity(visibleColumns) |
|
dgozman
2016/07/14 05:28:07
semicolons please!
allada
2016/07/14 22:27:08
Done.
| |
| 413 this._dataGrid.setColumnsVisiblity(visibleColumns); | |
| 414 }, | 496 }, |
| 415 | 497 |
| 416 /** | 498 /** |
| 417 * @param {boolean} gridMode | 499 * @param {boolean} gridMode |
| 418 */ | 500 */ |
| 419 switchViewMode: function(gridMode) | 501 switchViewMode: function(gridMode) |
| 420 { | 502 { |
| 421 if (this._gridMode === gridMode) | 503 if (this._gridMode === gridMode) |
| 422 return; | 504 return; |
| 423 this._gridMode = gridMode; | 505 this._gridMode = gridMode; |
| 424 | 506 |
| 425 if (gridMode) { | 507 if (gridMode) { |
| 426 if (this._dataGrid.selectedNode) | 508 if (this._dataGrid.selectedNode) |
| 427 this._dataGrid.selectedNode.selected = false; | 509 this._dataGrid.selectedNode.selected = false; |
| 428 } else { | 510 } else { |
| 429 this._networkLogView.removeAllNodeHighlights(); | 511 this._networkLogView.removeAllNodeHighlights(); |
| 430 this._popoverHelper.hidePopover(); | 512 this._popoverHelper.hidePopover(); |
| 431 } | 513 } |
| 432 | 514 |
| 433 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 515 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
| 434 this._updateColumns(); | 516 this._updateColumns(); |
| 435 }, | 517 }, |
| 436 | 518 |
| 437 /** | 519 /** |
| 438 * @param {string} columnIdentifier | 520 * @param {!WebInspector.NetworkLogViewColumns.ColumnDescriptor} columnConfi g |
| 439 */ | 521 */ |
| 440 _toggleColumnVisibility: function(columnIdentifier) | 522 _toggleColumnVisibility: function(columnConfig) |
| 441 { | 523 { |
| 442 var columnsVisibility = this._columnsVisibilitySetting.get(); | 524 this._loadColumns(); |
|
dgozman
2016/07/14 05:28:07
Why load all the time? Let's do it once during ini
allada
2016/07/14 22:27:08
loadColumns() re-syncs from the settings. I am fol
dgozman
2016/07/15 23:47:49
Well, I'm not sure that old way was good. Let's im
| |
| 443 columnsVisibility[columnIdentifier] = !columnsVisibility[columnIdentifie r]; | 525 columnConfig.visible = !columnConfig.visible; |
| 444 this._columnsVisibilitySetting.set(columnsVisibility); | 526 this._saveColumns(); |
| 445 | |
| 446 this._updateColumns(); | 527 this._updateColumns(); |
| 447 }, | 528 }, |
| 448 | 529 |
| 449 /** | 530 _saveColumns: function() |
| 450 * @return {!Array.<string>} | |
| 451 */ | |
| 452 _getConfigurableColumnIDs: function() | |
| 453 { | 531 { |
| 454 if (this._configurableColumnIDs) | 532 var saveableSettings = {}; |
| 455 return this._configurableColumnIDs; | 533 var keys = WebInspector.NetworkLogViewColumns._orderrideableConfigs; |
| 534 for (var columnConfig of this._columns) { | |
| 535 var saveObject = {}; | |
| 536 for (var key of keys) { | |
| 537 if (columnConfig.hasOwnProperty(key)) | |
| 538 saveObject[key] = columnConfig[key]; | |
| 539 } | |
| 540 saveableSettings[columnConfig.id] = saveObject; | |
| 541 } | |
| 542 this._persistantSettings.set(saveableSettings); | |
| 543 }, | |
| 456 | 544 |
| 457 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 545 _loadColumns: function() |
| 458 function compare(id1, id2) | 546 { |
| 459 { | 547 var savedSettings = this._persistantSettings.get(); |
| 460 return columnTitles[id1].compareTo(columnTitles[id2]); | 548 var allowedSettings = WebInspector.NetworkLogViewColumns._orderrideableC onfigs; |
| 549 var columnIds = Object.keys(savedSettings); | |
| 550 for (var columnId of columnIds) { | |
| 551 var setting = savedSettings[columnId]; | |
| 552 var columnConfig = this._columns.find(columnConfig => columnConfig.i d === columnId); | |
| 553 if (!columnConfig) | |
| 554 continue; | |
| 555 | |
| 556 for (var settingName of allowedSettings) { | |
| 557 if (setting.hasOwnProperty(settingName)) | |
| 558 columnConfig[settingName] = setting[settingName]; | |
| 559 } | |
| 461 } | 560 } |
| 462 | |
| 463 var columnIDs = Object.keys(this._columnsVisibilitySetting.get()); | |
| 464 this._configurableColumnIDs = columnIDs.sort(compare); | |
| 465 return this._configurableColumnIDs; | |
| 466 }, | 561 }, |
| 467 | 562 |
| 468 /** | 563 /** |
| 469 * @param {string} title | 564 * @param {string} title |
| 470 * @param {string} subtitle | 565 * @param {string} subtitle |
| 471 * @return {!DocumentFragment} | 566 * @return {!DocumentFragment} |
| 472 */ | 567 */ |
| 473 _makeHeaderFragment: function(title, subtitle) | 568 _makeHeaderFragment: function(title, subtitle) |
| 474 { | 569 { |
| 475 var fragment = createDocumentFragment(); | 570 var fragment = createDocumentFragment(); |
| 476 fragment.createTextChild(title); | 571 fragment.createTextChild(title); |
| 477 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | 572 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; |
| 478 subtitleDiv.createTextChild(subtitle); | 573 subtitleDiv.createTextChild(subtitle); |
| 479 return fragment; | 574 return fragment; |
| 480 }, | 575 }, |
| 481 | 576 |
| 482 /** | 577 /** |
| 483 * @param {!Event} event | 578 * @param {!Event} event |
| 484 * @return {boolean} | 579 * @return {boolean} |
| 485 */ | 580 */ |
| 486 contextMenu: function(event) | 581 contextMenu: function(event) |
| 487 { | 582 { |
| 583 | |
|
dgozman
2016/07/14 05:28:07
stray blank line
allada
2016/07/14 22:27:07
Done.
| |
| 488 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) | 584 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) |
| 489 return false; | 585 return false; |
| 490 | 586 |
| 587 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); | |
| 491 var contextMenu = new WebInspector.ContextMenu(event); | 588 var contextMenu = new WebInspector.ContextMenu(event); |
| 589 columnConfigs.filter(columnConfig => !columnConfig.isResponseHeader) | |
| 590 .forEach(appendMenuItem.bind(this, contextMenu)); | |
| 492 | 591 |
| 493 var columnsVisibility = this._columnsVisibilitySetting.get(); | 592 contextMenu.appendSeparator(); |
| 494 var columnIDs = this._getConfigurableColumnIDs(); | 593 |
| 495 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 594 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers")); |
| 496 for (var i = 0; i < columnIDs.length; ++i) { | 595 |
| 497 var columnIdentifier = columnIDs[i]; | 596 columnConfigs.filter(columnConfig => columnConfig.isResponseHeader) |
| 498 contextMenu.appendCheckboxItem(columnTitles[columnIdentifier], this. _toggleColumnVisibility.bind(this, columnIdentifier), !!columnsVisibility[column Identifier]); | 597 .forEach(appendMenuItem.bind(this, responseSubMenu)); |
| 499 } | 598 |
| 500 contextMenu.show(); | 599 contextMenu.show(); |
| 501 return true; | 600 return true; |
| 601 | |
| 602 /** | |
| 603 * @param {!WebInspector.ContextMenu|!WebInspector.ContextSubMenuItem} c ontextMenu | |
| 604 * @param {!WebInspector.NetworkLogViewColumns.ColumnDescriptor} columnC onfig | |
| 605 * @this {WebInspector.NetworkLogViewColumns} | |
| 606 */ | |
| 607 function appendMenuItem(contextMenu, columnConfig) | |
| 608 { | |
| 609 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); | |
| 610 } | |
| 502 }, | 611 }, |
| 503 | 612 |
| 504 updateDividersIfNeeded: function() | 613 updateDividersIfNeeded: function() |
| 505 { | 614 { |
| 506 if (!this._networkLogView.isShowing()) { | 615 if (!this._networkLogView.isShowing()) { |
| 507 this._networkLogView.scheduleRefresh(); | 616 this._networkLogView.scheduleRefresh(); |
| 508 return; | 617 return; |
| 509 } | 618 } |
| 510 | 619 |
| 511 var timelineOffset = this._dataGrid.columnOffset("timeline"); | 620 var timelineOffset = this._dataGrid.columnOffset("timeline"); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 }, | 718 }, |
| 610 | 719 |
| 611 /** | 720 /** |
| 612 * @param {!WebInspector.Event} event | 721 * @param {!WebInspector.Event} event |
| 613 */ | 722 */ |
| 614 _updateRowsSize: function(event) | 723 _updateRowsSize: function(event) |
| 615 { | 724 { |
| 616 this._timelineGrid.element.classList.toggle("small", !event.data); | 725 this._timelineGrid.element.classList.toggle("small", !event.data); |
| 617 } | 726 } |
| 618 } | 727 } |
| OLD | NEW |