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>} */ |
| 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 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; | 20 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
| 25 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); | 21 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); |
| 26 | 22 |
| 27 /** @type {!Array<{time: number, element: !Element}>} */ | 23 /** @type {!Array<{time: number, element: !Element}>} */ |
| 28 this._eventDividers = []; | 24 this._eventDividers = []; |
| 29 | 25 |
| 30 this._gridMode = true; | 26 this._gridMode = true; |
| 31 | 27 |
| 32 /** @type {?WebInspector.DataGrid} */ | 28 /** @type {?WebInspector.DataGrid} */ |
| 33 this._dataGrid = null; | 29 this._dataGrid = null; |
| 34 /** @type {!Array.<!WebInspector.ColumnConfig>} */ | 30 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ |
| 35 this._columns = []; | 31 this._columns = []; |
| 36 /** @type {!Object.<string, function(!WebInspector.NetworkDataGridNode, !Web Inspector.NetworkDataGridNode) : number>} */ | |
| 37 this._sortingFunctions = {}; | |
| 38 /** @type {!Object.<string, !WebInspector.NetworkTimeCalculator>} */ | |
| 39 this._calculators = {}; | |
| 40 /** @type {?Element} */ | |
| 41 this._timelineSortSelector = null; | |
| 42 | 32 |
| 43 /** @type {?WebInspector.TimelineGrid} */ | 33 /** @type {?WebInspector.TimelineGrid} */ |
| 44 this._timelineGrid = null; | 34 this._timelineGrid = null; |
| 45 | 35 |
| 46 /** @type {!WebInspector.Linkifier} */ | 36 /** @type {!WebInspector.Linkifier} */ |
| 47 this._popupLinkifier = new WebInspector.Linkifier(); | 37 this._popupLinkifier = new WebInspector.Linkifier(); |
| 48 } | 38 } |
| 49 | 39 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; |
| 50 WebInspector.NetworkLogViewColumns._responseHeaderColumns = ["Cache-Control", "C onnection", "Content-Encoding", "Content-Length", "ETag", "Keep-Alive", "Last-Mo dified", "Server", "Vary"]; | |
| 51 WebInspector.NetworkLogViewColumns._defaultColumnsVisibility = { | |
| 52 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, | |
| 53 "Cache-Control": false, "Connection": false, "Content-Encoding": false, "Con tent-Length": false, "ETag": false, "Keep-Alive": false, "Last-Modified": false, "Server": false, "Vary": false | |
| 54 }; | |
| 55 | 40 |
| 56 /** | 41 /** |
| 57 * @typedef {{ | 42 * @typedef {{ |
| 58 * id: string, | 43 * id: string, |
| 59 * title: string, | 44 * title: string, |
| 60 * titleDOMFragment: !DocumentFragment, | 45 * subtitle: (string|null), |
| 61 * sortable: boolean, | 46 * visible: boolean, |
| 62 * weight: number, | 47 * weight: number, |
| 63 * sort: (?WebInspector.DataGrid.Order|undefined), | 48 * hideable: boolean, |
| 64 * align: (?WebInspector.DataGrid.Align|undefined), | 49 * nonSelectable: boolean, |
| 50 * sortable: boolean, | |
| 51 * align: (?WebInspector.DataGrid.Align|undefined), | |
| 52 * isResponseHeader: boolean, | |
| 53 * sortConfig: !WebInspector.NetworkLogViewColumns.SortConfig | |
| 65 * }} | 54 * }} |
| 66 */ | 55 */ |
| 67 WebInspector.ColumnConfig; | 56 WebInspector.NetworkLogViewColumns.Descriptor; |
| 68 | 57 |
| 69 /** @type {!Object.<string, string>} */ | 58 /** |
| 70 WebInspector.NetworkLogViewColumns._columnTitles = { | 59 * @typedef {{ |
| 71 "name": WebInspector.UIString("Name"), | 60 * sortingFunction: (!function(!WebInspector.NetworkDataGridNode, !WebInspec tor.NetworkDataGridNode):number|undefined), |
| 72 "method": WebInspector.UIString("Method"), | 61 * entries: (!Array.<!WebInspector.DataGrid.ColumnDescriptor>|undefined) |
| 73 "status": WebInspector.UIString("Status"), | 62 * }} |
| 74 "protocol": WebInspector.UIString("Protocol"), | 63 */ |
| 75 "scheme": WebInspector.UIString("Scheme"), | 64 WebInspector.NetworkLogViewColumns.SortConfig; |
| 76 "domain": WebInspector.UIString("Domain"), | 65 |
| 77 "remoteAddress": WebInspector.UIString("Remote Address"), | 66 /** @enum {string} */ |
| 78 "type": WebInspector.UIString("Type"), | 67 WebInspector.NetworkLogViewColumns._calculatorTypes = { |
| 79 "initiator": WebInspector.UIString("Initiator"), | 68 Duration: "Duration", |
| 80 "cookies": WebInspector.UIString("Cookies"), | 69 Time: "Time" |
| 81 "setCookies": WebInspector.UIString("Set-Cookies"), | |
| 82 "size": WebInspector.UIString("Size"), | |
| 83 "time": WebInspector.UIString("Time"), | |
| 84 "connectionId": WebInspector.UIString("Connection Id"), | |
| 85 "priority": WebInspector.UIString("Priority"), | |
| 86 "timeline": WebInspector.UIString("Timeline"), | |
| 87 | |
| 88 // Response header columns | |
| 89 "Cache-Control": WebInspector.UIString("Cache-Control"), | |
| 90 "Connection": WebInspector.UIString("Connection"), | |
| 91 "Content-Encoding": WebInspector.UIString("Content-Encoding"), | |
| 92 "Content-Length": WebInspector.UIString("Content-Length"), | |
| 93 "ETag": WebInspector.UIString("ETag"), | |
| 94 "Keep-Alive": WebInspector.UIString("Keep-Alive"), | |
| 95 "Last-Modified": WebInspector.UIString("Last-Modified"), | |
| 96 "Server": WebInspector.UIString("Server"), | |
| 97 "Vary": WebInspector.UIString("Vary") | |
| 98 }; | 70 }; |
| 99 | 71 |
| 72 /** | |
| 73 * @type {!Object} column | |
| 74 */ | |
| 75 WebInspector.NetworkLogViewColumns._defaultColumnConfig = { | |
| 76 subtitle: null, | |
| 77 visible: false, | |
| 78 weight: 6, | |
| 79 sortable: true, | |
| 80 hideable: true, | |
| 81 nonSelectable: true, | |
| 82 isResponseHeader: false | |
| 83 }; | |
| 84 | |
| 85 /** | |
| 86 * @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} column | |
| 87 */ | |
| 88 WebInspector.NetworkLogViewColumns._defaultColumns = [ | |
| 89 { | |
| 90 id: "name", | |
| 91 title: WebInspector.UIString("Name"), | |
| 92 subtitle: WebInspector.UIString("Path"), | |
| 93 visible: true, | |
| 94 weight: 20, | |
| 95 hideable: false, | |
| 96 nonSelectable: false, | |
| 97 sortConfig: { | |
| 98 sortingFunction: WebInspector.NetworkDataGridNode.NameComparator | |
| 99 } | |
| 100 }, | |
| 101 { | |
| 102 id: "method", | |
| 103 title: WebInspector.UIString("Method"), | |
| 104 sortConfig: { | |
| 105 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "requestMethod") | |
| 106 } | |
| 107 }, | |
| 108 { | |
| 109 id: "status", | |
| 110 title: WebInspector.UIString("Status"), | |
| 111 visible: true, | |
| 112 subtitle: WebInspector.UIString("Text"), | |
| 113 sortConfig: { | |
| 114 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "statusCode") | |
| 115 } | |
| 116 }, | |
| 117 { | |
| 118 id: "protocol", | |
| 119 title: WebInspector.UIString("Protocol"), | |
| 120 sortConfig: { | |
| 121 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "protocol") | |
| 122 } | |
| 123 }, | |
| 124 { | |
| 125 id: "scheme", | |
| 126 title: WebInspector.UIString("Scheme"), | |
| 127 sortConfig: { | |
| 128 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "scheme") | |
| 129 } | |
| 130 }, | |
| 131 { | |
| 132 id: "domain", | |
| 133 title: WebInspector.UIString("Domain"), | |
| 134 sortConfig: { | |
| 135 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "domain") | |
| 136 } | |
| 137 }, | |
| 138 { | |
| 139 id: "remoteaddress", | |
| 140 title: WebInspector.UIString("Remote Address"), | |
| 141 weight: 10, | |
| 142 align: WebInspector.DataGrid.Align.Right, | |
| 143 sortConfig: { | |
| 144 sortingFunction: WebInspector.NetworkDataGridNode.RemoteAddressCompa rator | |
| 145 } | |
| 146 }, | |
| 147 { | |
| 148 id: "type", | |
| 149 title: WebInspector.UIString("Type"), | |
| 150 visible: true, | |
| 151 sortConfig: { | |
| 152 sortingFunction: WebInspector.NetworkDataGridNode.TypeComparator | |
| 153 } | |
| 154 }, | |
| 155 { | |
| 156 id: "initiator", | |
| 157 title: WebInspector.UIString("Initiator"), | |
| 158 visible: true, | |
| 159 weight: 10, | |
| 160 sortConfig: { | |
| 161 sortingFunction: WebInspector.NetworkDataGridNode.InitiatorComparato r | |
| 162 } | |
| 163 }, | |
| 164 { | |
| 165 id: "cookies", | |
| 166 title: WebInspector.UIString("Cookies"), | |
| 167 align: WebInspector.DataGrid.Align.Right, | |
| 168 sortConfig: { | |
| 169 sortingFunction: WebInspector.NetworkDataGridNode.RequestCookiesCoun tComparator | |
| 170 } | |
| 171 }, | |
| 172 { | |
| 173 id: "setcookies", | |
| 174 title: WebInspector.UIString("Set Cookies"), | |
| 175 align: WebInspector.DataGrid.Align.Right, | |
| 176 sortConfig: { | |
| 177 sortingFunction: WebInspector.NetworkDataGridNode.ResponseCookiesCou ntComparator | |
| 178 } | |
| 179 }, | |
| 180 { | |
| 181 id: "size", | |
| 182 title: WebInspector.UIString("Size"), | |
| 183 visible: true, | |
| 184 subtitle: WebInspector.UIString("Content"), | |
| 185 align: WebInspector.DataGrid.Align.Right, | |
| 186 sortConfig: { | |
| 187 sortingFunction: WebInspector.NetworkDataGridNode.SizeComparator | |
| 188 } | |
| 189 }, | |
| 190 { | |
| 191 id: "time", | |
| 192 title: WebInspector.UIString("Time"), | |
| 193 visible: true, | |
| 194 subtitle: WebInspector.UIString("Latency"), | |
| 195 align: WebInspector.DataGrid.Align.Right, | |
| 196 sortConfig: { | |
| 197 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "duration") | |
| 198 } | |
| 199 }, | |
| 200 { | |
| 201 id: "priority", | |
| 202 title: WebInspector.UIString("Priority"), | |
| 203 sortConfig: { | |
| 204 sortingFunction: WebInspector.NetworkDataGridNode.InitialPriorityCom parator | |
| 205 } | |
| 206 }, | |
| 207 { | |
| 208 id: "connectionid", | |
| 209 title: WebInspector.UIString("Connection ID"), | |
| 210 sortConfig: { | |
| 211 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "connectionId") | |
| 212 } | |
| 213 }, | |
| 214 { | |
| 215 id: "timeline", | |
| 216 title: WebInspector.UIString("Timeline"), | |
| 217 visible: true, | |
| 218 weight: 40, | |
| 219 sortable: false, | |
| 220 hideable: false, | |
| 221 sortConfig: { | |
| 222 entries: [ | |
| 223 { | |
| 224 id: "starttime", | |
| 225 title: WebInspector.UIString("Timeline \u2013 Start Time"), | |
| 226 sort: WebInspector.DataGrid.Order.Ascending, | |
| 227 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "startTime"), | |
| 228 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 229 }, | |
| 230 { | |
| 231 id: "responsetime", | |
| 232 title: WebInspector.UIString("Timeline \u2013 Response Time" ), | |
| 233 sort: WebInspector.DataGrid.Order.Ascending, | |
| 234 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "responseReceivedTime"), | |
| 235 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 236 }, | |
| 237 { | |
| 238 id: "endtime", | |
| 239 title: WebInspector.UIString("Timeline \u2013 End Time"), | |
| 240 sort: WebInspector.DataGrid.Order.Ascending, | |
| 241 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "endTime"), | |
| 242 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 243 }, | |
| 244 { | |
| 245 id: "duration", | |
| 246 title: WebInspector.UIString("Timeline \u2013 Total Duration "), | |
| 247 sort: WebInspector.DataGrid.Order.Descending, | |
| 248 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "duration"), | |
| 249 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 250 }, | |
| 251 { | |
| 252 id: "latency", | |
| 253 title: WebInspector.UIString("Timeline \u2013 Latency"), | |
| 254 sort: WebInspector.DataGrid.Order.Descending, | |
| 255 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "latency"), | |
| 256 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 257 } | |
| 258 ] | |
| 259 } | |
| 260 }, | |
| 261 { | |
| 262 id: "cache-control", | |
| 263 isResponseHeader: true, | |
| 264 title: WebInspector.UIString("Cache-Control"), | |
| 265 sortConfig: { | |
| 266 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "cache-control") | |
| 267 } | |
| 268 }, | |
| 269 { | |
| 270 id: "connection", | |
| 271 isResponseHeader: true, | |
| 272 title: WebInspector.UIString("Connection"), | |
| 273 sortConfig: { | |
| 274 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "connection") | |
| 275 } | |
| 276 }, | |
| 277 { | |
| 278 id: "content-encoding", | |
| 279 isResponseHeader: true, | |
| 280 title: WebInspector.UIString("Content-Encoding"), | |
| 281 sortConfig: { | |
| 282 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "content-encoding") | |
| 283 } | |
| 284 }, | |
| 285 { | |
| 286 id: "content-length", | |
| 287 isResponseHeader: true, | |
| 288 title: WebInspector.UIString("Content-Length"), | |
| 289 align: WebInspector.DataGrid.Align.Right, | |
| 290 sortConfig: { | |
| 291 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderNumb erComparator.bind(null, "content-length") | |
| 292 } | |
| 293 }, | |
| 294 { | |
| 295 id: "etag", | |
| 296 isResponseHeader: true, | |
| 297 title: WebInspector.UIString("ETag"), | |
| 298 sortConfig: { | |
| 299 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "etag") | |
| 300 } | |
| 301 }, | |
| 302 { | |
| 303 id: "keep-alive", | |
| 304 isResponseHeader: true, | |
| 305 title: WebInspector.UIString("Keep-Alive"), | |
| 306 sortConfig: { | |
| 307 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "keep-alive") | |
| 308 } | |
| 309 }, | |
| 310 { | |
| 311 id: "last-modified", | |
| 312 isResponseHeader: true, | |
| 313 title: WebInspector.UIString("Last-Modified"), | |
| 314 sortConfig: { | |
| 315 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderDate Comparator.bind(null, "last-modified") | |
| 316 } | |
| 317 }, | |
| 318 { | |
| 319 id: "server", | |
| 320 isResponseHeader: true, | |
| 321 title: WebInspector.UIString("Server"), | |
| 322 sortConfig: { | |
| 323 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "server") | |
| 324 } | |
| 325 }, | |
| 326 { | |
| 327 id: "vary", | |
| 328 isResponseHeader: true, | |
| 329 title: WebInspector.UIString("Vary"), | |
| 330 sortConfig: { | |
| 331 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "vary") | |
| 332 } | |
| 333 } | |
| 334 ]; | |
| 335 | |
| 336 WebInspector.NetworkLogViewColumns._saveableConfigs = ["visible", "title"]; | |
| 337 | |
| 100 WebInspector.NetworkLogViewColumns.prototype = { | 338 WebInspector.NetworkLogViewColumns.prototype = { |
| 101 willHide: function() | 339 willHide: function() |
| 102 { | 340 { |
| 103 this._popoverHelper.hidePopover(); | 341 this._popoverHelper.hidePopover(); |
| 104 }, | 342 }, |
| 105 | 343 |
| 106 reset: function() | 344 reset: function() |
| 107 { | 345 { |
| 108 if (this._popoverHelper) | 346 if (this._popoverHelper) |
| 109 this._popoverHelper.hidePopover(); | 347 this._popoverHelper.hidePopover(); |
| 110 this._timelineGrid.removeEventDividers(); | 348 this._timelineGrid.removeEventDividers(); |
| 111 this.updateDividersIfNeeded(); | 349 this.updateDividersIfNeeded(); |
| 112 }, | 350 }, |
| 113 | 351 |
| 114 /** | 352 /** |
| 115 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | 353 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator |
| 116 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or | 354 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or |
| 117 * @return {!WebInspector.SortableDataGrid} dataGrid | 355 * @return {!WebInspector.SortableDataGrid} dataGrid |
| 118 */ | 356 */ |
| 119 createGrid: function(timeCalculator, durationCalculator) | 357 createGrid: function(timeCalculator, durationCalculator) |
| 120 { | 358 { |
| 121 this._createSortingFunctions(); | 359 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; |
| 360 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol umnConfig; | |
| 361 | |
| 362 this._columns = /** @type {!Array.<!WebInspector.NetworkLogViewColumns.D escriptor>} */ ([]); | |
| 363 for (var currentConfigColumn of defaultColumns) { | |
| 364 var columnConfig = /** @type {!WebInspector.NetworkLogViewColumns.De scriptor} */ (Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, cu rrentConfigColumn)); | |
|
dgozman
2016/07/27 17:47:56
Let's construct it explicitly and rename nonSelect
allada
2016/08/01 22:54:10
I am not going to change nonSelectable because it
| |
| 365 columnConfig.id = columnConfig.id; | |
| 366 if (columnConfig.subtitle) | |
| 367 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC onfig.title, columnConfig.subtitle); | |
| 368 this._columns.push(columnConfig); | |
| 369 } | |
| 370 this._loadColumns(); | |
| 371 | |
| 372 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ | |
| 373 this._calculatorsMap = new Map(); | |
| 374 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT ypes.Time, timeCalculator); | |
| 375 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT ypes.Duration, durationCalculator); | |
| 376 | |
| 122 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); | 377 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); |
| 123 | 378 |
| 124 this._calculators.timeline = timeCalculator; | |
| 125 this._calculators.startTime = timeCalculator; | |
| 126 this._calculators.endTime = timeCalculator; | |
| 127 this._calculators.responseTime = timeCalculator; | |
| 128 this._calculators.duration = durationCalculator; | |
| 129 this._calculators.latency = durationCalculator; | |
| 130 | |
| 131 var columns = []; | |
| 132 columns.push({ | |
| 133 id: "name", | |
| 134 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Na me"), WebInspector.UIString("Path")), | |
| 135 title: WebInspector.NetworkLogViewColumns._columnTitles["name"], | |
| 136 weight: 20 | |
| 137 }); | |
| 138 | |
| 139 columns.push({ | |
| 140 id: "method", | |
| 141 title: WebInspector.NetworkLogViewColumns._columnTitles["method"], | |
| 142 weight: 6 | |
| 143 }); | |
| 144 | |
| 145 columns.push({ | |
| 146 id: "status", | |
| 147 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("St atus"), WebInspector.UIString("Text")), | |
| 148 title: WebInspector.NetworkLogViewColumns._columnTitles["status"], | |
| 149 weight: 6 | |
| 150 }); | |
| 151 | |
| 152 columns.push({ | |
| 153 id: "protocol", | |
| 154 title: WebInspector.NetworkLogViewColumns._columnTitles["protocol"], | |
| 155 weight: 6 | |
| 156 }); | |
| 157 | |
| 158 columns.push({ | |
| 159 id: "scheme", | |
| 160 title: WebInspector.NetworkLogViewColumns._columnTitles["scheme"], | |
| 161 weight: 6 | |
| 162 }); | |
| 163 | |
| 164 columns.push({ | |
| 165 id: "domain", | |
| 166 title: WebInspector.NetworkLogViewColumns._columnTitles["domain"], | |
| 167 weight: 6 | |
| 168 }); | |
| 169 | |
| 170 columns.push({ | |
| 171 id: "remoteAddress", | |
| 172 title: WebInspector.NetworkLogViewColumns._columnTitles["remoteAddre ss"], | |
| 173 weight: 10, | |
| 174 align: WebInspector.DataGrid.Align.Right | |
| 175 }); | |
| 176 | |
| 177 columns.push({ | |
| 178 id: "type", | |
| 179 title: WebInspector.NetworkLogViewColumns._columnTitles["type"], | |
| 180 weight: 6 | |
| 181 }); | |
| 182 | |
| 183 columns.push({ | |
| 184 id: "initiator", | |
| 185 title: WebInspector.NetworkLogViewColumns._columnTitles["initiator"] , | |
| 186 weight: 10 | |
| 187 }); | |
| 188 | |
| 189 columns.push({ | |
| 190 id: "cookies", | |
| 191 title: WebInspector.NetworkLogViewColumns._columnTitles["cookies"], | |
| 192 weight: 6, | |
| 193 align: WebInspector.DataGrid.Align.Right | |
| 194 }); | |
| 195 | |
| 196 columns.push({ | |
| 197 id: "setCookies", | |
| 198 title: WebInspector.NetworkLogViewColumns._columnTitles["setCookies" ], | |
| 199 weight: 6, | |
| 200 align: WebInspector.DataGrid.Align.Right | |
| 201 }); | |
| 202 | |
| 203 columns.push({ | |
| 204 id: "size", | |
| 205 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Si ze"), WebInspector.UIString("Content")), | |
| 206 title: WebInspector.NetworkLogViewColumns._columnTitles["size"], | |
| 207 weight: 6, | |
| 208 align: WebInspector.DataGrid.Align.Right | |
| 209 }); | |
| 210 | |
| 211 columns.push({ | |
| 212 id: "time", | |
| 213 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Ti me"), WebInspector.UIString("Latency")), | |
| 214 title: WebInspector.NetworkLogViewColumns._columnTitles["time"], | |
| 215 weight: 6, | |
| 216 align: WebInspector.DataGrid.Align.Right | |
| 217 }); | |
| 218 | |
| 219 columns.push({ | |
| 220 id: "priority", | |
| 221 title: WebInspector.NetworkLogViewColumns._columnTitles["priority"], | |
| 222 weight: 6 | |
| 223 }); | |
| 224 | |
| 225 columns.push({ | |
| 226 id: "connectionId", | |
| 227 title: WebInspector.NetworkLogViewColumns._columnTitles["connectionI d"], | |
| 228 weight: 6 | |
| 229 }); | |
| 230 | |
| 231 var responseHeaderColumns = WebInspector.NetworkLogViewColumns._response HeaderColumns; | |
| 232 for (var i = 0; i < responseHeaderColumns.length; ++i) { | |
| 233 var headerName = responseHeaderColumns[i]; | |
| 234 var descriptor = { | |
| 235 id: headerName, | |
| 236 title: WebInspector.NetworkLogViewColumns._columnTitles[headerNa me], | |
| 237 weight: 6 | |
| 238 }; | |
| 239 if (headerName === "Content-Length") | |
| 240 descriptor.align = WebInspector.DataGrid.Align.Right; | |
| 241 columns.push(descriptor); | |
| 242 } | |
| 243 | |
| 244 columns.push({ | |
| 245 id: "timeline", | |
| 246 title: WebInspector.NetworkLogViewColumns._columnTitles["timeline"], | |
| 247 sortable: false, | |
| 248 weight: 40, | |
| 249 sort: WebInspector.DataGrid.Order.Ascending | |
| 250 }); | |
| 251 | |
| 252 for (var column of columns) { | |
| 253 column.sortable = column.id !== "timeline"; | |
| 254 column.nonSelectable = column.id !== "name"; | |
| 255 } | |
| 256 this._columns = columns; | |
| 257 | |
| 258 this._networkLogView.switchViewMode(true); | |
| 259 | |
| 260 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); | 379 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); |
| 261 | 380 |
| 262 this._dataGrid.asWidget().show(this._networkLogView.element); | 381 this._dataGrid.asWidget().show(this._networkLogView.element); |
| 263 | 382 |
| 383 this._updateColumns(); | |
| 384 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); | |
| 385 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 386 | |
| 264 this._timelineGrid = new WebInspector.TimelineGrid(); | 387 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 265 this._timelineGrid.element.classList.add("network-timeline-grid"); | 388 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 266 this._dataGrid.element.appendChild(this._timelineGrid.element); | 389 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 390 this._setupDropdownColumns(); | |
| 267 | 391 |
| 268 this._updateColumns(); | 392 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 269 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | |
| 270 this._dataGrid.sortNodes(this._sortingFunctions.startTime, false); | |
| 271 this._patchTimelineHeader(); | |
| 272 | |
| 273 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 274 | 393 |
| 275 this._updateRowsSize(); | 394 this._updateRowsSize(); |
| 276 | 395 |
| 277 return this._dataGrid; | 396 return this._dataGrid; |
| 278 }, | 397 }, |
| 279 | 398 |
| 280 _createSortingFunctions: function() | 399 _setupDropdownColumns: function() |
| 281 { | 400 { |
| 282 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameCompa rator; | 401 for (var columnConfig of this._columns) { |
| 283 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "requestMethod"); | 402 if (!columnConfig.sortConfig || !columnConfig.sortConfig.entries) |
| 284 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "statusCode"); | 403 continue; |
| 285 this._sortingFunctions.protocol = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "protocol"); | 404 var select = createElement("select"); |
| 286 this._sortingFunctions.scheme = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "scheme"); | 405 var placeHolderOption = select.createChild("option"); |
| 287 this._sortingFunctions.domain = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "domain"); | 406 placeHolderOption.classList.add("hidden"); |
| 288 this._sortingFunctions.remoteAddress = WebInspector.NetworkDataGridNode. RemoteAddressComparator; | 407 for (var entry of columnConfig.sortConfig.entries) { |
| 289 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.TypeCompa rator; | 408 var option = select.createChild("option"); |
| 290 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.Init iatorComparator; | 409 option.value = entry.id; |
| 291 this._sortingFunctions.cookies = WebInspector.NetworkDataGridNode.Reques tCookiesCountComparator; | 410 option.label = entry.title; |
| 292 this._sortingFunctions.setCookies = WebInspector.NetworkDataGridNode.Res ponseCookiesCountComparator; | 411 select.appendChild(option); |
| 293 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeCompa rator; | 412 } |
| 294 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.RequestPr opertyComparator.bind(null, "duration"); | 413 var header = this._dataGrid.headerTableHeader(columnConfig.id); |
| 295 this._sortingFunctions.connectionId = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "connectionId"); | 414 header.replaceChild(select, header.firstChild); |
| 296 this._sortingFunctions.priority = WebInspector.NetworkDataGridNode.Initi alPriorityComparator; | 415 header.createChild("div", "sort-order-icon-container").createChild(" div", "sort-order-icon"); |
| 297 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "startTime"); | 416 columnConfig.selectBox = select; |
| 298 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.Requ estPropertyComparator.bind(null, "startTime"); | 417 select.addEventListener("change", this._sortByDropdownItem.bind(this , columnConfig), false); |
| 299 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "endTime"); | 418 this._dropDownColumnSelectors.push(select); |
| 300 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "responseReceivedTime"); | 419 } |
| 301 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "duration"); | |
| 302 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "latency"); | |
| 303 | |
| 304 this._sortingFunctions["Cache-Control"] = WebInspector.NetworkDataGridNo de.ResponseHeaderStringComparator.bind(null, "Cache-Control"); | |
| 305 this._sortingFunctions["Connection"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Connection"); | |
| 306 this._sortingFunctions["Content-Encoding"] = WebInspector.NetworkDataGri dNode.ResponseHeaderStringComparator.bind(null, "Content-Encoding"); | |
| 307 this._sortingFunctions["Content-Length"] = WebInspector.NetworkDataGridN ode.ResponseHeaderNumberComparator.bind(null, "Content-Length"); | |
| 308 this._sortingFunctions["ETag"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "ETag"); | |
| 309 this._sortingFunctions["Keep-Alive"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Keep-Alive"); | |
| 310 this._sortingFunctions["Last-Modified"] = WebInspector.NetworkDataGridNo de.ResponseHeaderDateComparator.bind(null, "Last-Modified"); | |
| 311 this._sortingFunctions["Server"] = WebInspector.NetworkDataGridNode.Resp onseHeaderStringComparator.bind(null, "Server"); | |
| 312 this._sortingFunctions["Vary"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "Vary"); | |
| 313 }, | 420 }, |
| 314 | 421 |
| 315 _sortItems: function() | 422 sortByCurrentColumn: function() |
| 316 { | 423 { |
| 317 this._networkLogView.removeAllNodeHighlights(); | 424 this._sortHandler(); |
| 425 }, | |
| 426 | |
| 427 _sortHandler: function() | |
| 428 { | |
| 318 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | 429 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); |
| 319 if (!columnIdentifier) | 430 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnIdentifier); |
| 431 if (!columnConfig) | |
| 320 return; | 432 return; |
| 321 if (columnIdentifier === "timeline") { | 433 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { |
| 322 this._sortByTimeline(); | 434 this._sortByDropdownItem(columnConfig); |
| 323 return; | 435 return; |
| 324 } | 436 } |
| 325 var sortingFunction = this._sortingFunctions[columnIdentifier]; | 437 if (!columnConfig.sortConfig.sortingFunction) |
| 326 if (!sortingFunction) | |
| 327 return; | 438 return; |
| 328 | 439 |
| 329 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | 440 this._networkLogView.removeAllNodeHighlights(); |
| 330 this._timelineSortSelector.selectedIndex = 0; | 441 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); |
| 331 this._networkLogView.dataGridSorted(); | 442 this._networkLogView.dataGridSorted(); |
| 332 }, | 443 }, |
| 333 | 444 |
| 334 _sortByTimeline: function() | 445 /** |
| 446 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | |
| 447 */ | |
| 448 _sortByDropdownItem: function(columnConfig) | |
| 335 { | 449 { |
| 336 this._networkLogView.removeAllNodeHighlights(); | 450 this._networkLogView.removeAllNodeHighlights(); |
| 337 var selectedIndex = this._timelineSortSelector.selectedIndex; | 451 var selectedIndex = columnConfig.selectBox.selectedIndex; |
| 338 if (!selectedIndex) | 452 if (!selectedIndex) |
| 339 selectedIndex = 1; // Sort by start time by default. | 453 selectedIndex = 1; // Sort by first item by default. |
| 340 var selectedOption = this._timelineSortSelector[selectedIndex]; | 454 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. |
| 455 var selectedOption = columnConfig.selectBox[selectedIndex]; | |
| 341 var value = selectedOption.value; | 456 var value = selectedOption.value; |
| 342 | 457 |
| 343 this._networkLogView.setCalculator(this._calculators[value]); | 458 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); |
| 344 var sortingFunction = this._sortingFunctions[value]; | 459 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); |
| 345 this._dataGrid.sortNodes(sortingFunction); | 460 if (selectedItemConfig.calculator) |
| 346 | 461 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator)); |
| 462 columnConfig.selectBox.options[0].label = selectedItemConfig.title; | |
| 463 columnConfig.selectBox.selectedIndex = 0; | |
| 347 this._networkLogView.dataGridSorted(); | 464 this._networkLogView.dataGridSorted(); |
| 348 | |
| 349 this._dataGrid.markColumnAsSortedBy("timeline", selectedOption.sortOrder ); | |
| 350 }, | |
| 351 | |
| 352 _patchTimelineHeader: function() | |
| 353 { | |
| 354 var timelineSorting = createElement("select"); | |
| 355 | |
| 356 var option = createElement("option"); | |
| 357 option.value = "startTime"; | |
| 358 option.label = WebInspector.UIString("Timeline"); | |
| 359 option.disabled = true; | |
| 360 timelineSorting.appendChild(option); | |
| 361 | |
| 362 option = createElement("option"); | |
| 363 option.value = "startTime"; | |
| 364 option.label = WebInspector.UIString("Timeline \u2013 Start Time"); | |
| 365 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 366 timelineSorting.appendChild(option); | |
| 367 | |
| 368 option = createElement("option"); | |
| 369 option.value = "responseTime"; | |
| 370 option.label = WebInspector.UIString("Timeline \u2013 Response Time"); | |
| 371 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 372 timelineSorting.appendChild(option); | |
| 373 | |
| 374 option = createElement("option"); | |
| 375 option.value = "endTime"; | |
| 376 option.label = WebInspector.UIString("Timeline \u2013 End Time"); | |
| 377 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 378 timelineSorting.appendChild(option); | |
| 379 | |
| 380 option = createElement("option"); | |
| 381 option.value = "duration"; | |
| 382 option.label = WebInspector.UIString("Timeline \u2013 Total Duration"); | |
| 383 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 384 timelineSorting.appendChild(option); | |
| 385 | |
| 386 option = createElement("option"); | |
| 387 option.value = "latency"; | |
| 388 option.label = WebInspector.UIString("Timeline \u2013 Latency"); | |
| 389 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 390 timelineSorting.appendChild(option); | |
| 391 | |
| 392 var header = this._dataGrid.headerTableHeader("timeline"); | |
| 393 header.replaceChild(timelineSorting, header.firstChild); | |
| 394 header.createChild("div", "sort-order-icon-container").createChild("div" , "sort-order-icon"); | |
| 395 | |
| 396 timelineSorting.selectedIndex = 1; | |
| 397 timelineSorting.addEventListener("click", function(event) { event.consum e(); }, false); | |
| 398 timelineSorting.addEventListener("change", this._sortByTimeline.bind(thi s), false); | |
| 399 this._timelineSortSelector = timelineSorting; | |
| 400 }, | 465 }, |
| 401 | 466 |
| 402 _updateColumns: function() | 467 _updateColumns: function() |
| 403 { | 468 { |
| 404 if (!this._dataGrid) | 469 if (!this._dataGrid) |
| 405 return; | 470 return; |
| 406 var gridMode = this._gridMode; | 471 var gridMode = this._gridMode; |
| 407 var visibleColumns = {"name": true}; | 472 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); |
| 408 if (gridMode) | 473 if (this._columns[0].id !== "name") { |
| 409 visibleColumns["timeline"] = true; | 474 var index = this._columns.findIndex(columnConfig => columnConfig.id === "name"); |
| 475 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 476 this._columns.unshift(columnConfig); | |
| 477 } | |
| 478 if (this._columns[this._columns.length - 1].id !== "timeline") { | |
| 479 var index = this._columns.findIndex(columnConfig => columnConfig.id === "timeline"); | |
| 480 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 481 this._columns.push(columnConfig); | |
| 482 } | |
| 410 if (gridMode) { | 483 if (gridMode) { |
| 411 var columnsVisibility = this._columnsVisibilitySetting.get(); | 484 for (var columnConfig of this._columns) |
| 412 for (var columnIdentifier in columnsVisibility) | 485 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable); |
| 413 visibleColumns[columnIdentifier] = columnsVisibility[columnIdent ifier]; | 486 } else { |
| 487 visibleColumns = {"name": true}; | |
| 414 } | 488 } |
| 415 | |
| 416 this._dataGrid.setColumnsVisiblity(visibleColumns); | 489 this._dataGrid.setColumnsVisiblity(visibleColumns); |
| 417 }, | 490 }, |
| 418 | 491 |
| 419 /** | 492 /** |
| 420 * @param {boolean} gridMode | 493 * @param {boolean} gridMode |
| 421 */ | 494 */ |
| 422 switchViewMode: function(gridMode) | 495 switchViewMode: function(gridMode) |
| 423 { | 496 { |
| 424 if (this._gridMode === gridMode) | 497 if (this._gridMode === gridMode) |
| 425 return; | 498 return; |
| 426 this._gridMode = gridMode; | 499 this._gridMode = gridMode; |
| 427 | 500 |
| 428 if (gridMode) { | 501 if (gridMode) { |
| 429 if (this._dataGrid.selectedNode) | 502 if (this._dataGrid.selectedNode) |
| 430 this._dataGrid.selectedNode.selected = false; | 503 this._dataGrid.selectedNode.selected = false; |
| 431 } else { | 504 } else { |
| 432 this._networkLogView.removeAllNodeHighlights(); | 505 this._networkLogView.removeAllNodeHighlights(); |
| 433 this._popoverHelper.hidePopover(); | 506 this._popoverHelper.hidePopover(); |
| 434 } | 507 } |
| 435 | 508 |
| 436 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 509 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
| 437 this._updateColumns(); | 510 this._updateColumns(); |
| 438 }, | 511 }, |
| 439 | 512 |
| 440 /** | 513 /** |
| 441 * @param {string} columnIdentifier | 514 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
| 442 */ | 515 */ |
| 443 _toggleColumnVisibility: function(columnIdentifier) | 516 _toggleColumnVisibility: function(columnConfig) |
| 444 { | 517 { |
| 445 var columnsVisibility = this._columnsVisibilitySetting.get(); | 518 this._loadColumns(); |
| 446 columnsVisibility[columnIdentifier] = !columnsVisibility[columnIdentifie r]; | 519 columnConfig.visible = !columnConfig.visible; |
| 447 this._columnsVisibilitySetting.set(columnsVisibility); | 520 this._saveColumns(); |
| 448 | |
| 449 this._updateColumns(); | 521 this._updateColumns(); |
| 450 }, | 522 }, |
| 451 | 523 |
| 452 /** | 524 _saveColumns: function() |
| 453 * @return {!Array.<string>} | |
| 454 */ | |
| 455 _getConfigurableColumnIDs: function() | |
| 456 { | 525 { |
| 457 if (this._configurableColumnIDs) | 526 var saveableSettings = {}; |
| 458 return this._configurableColumnIDs; | 527 var keys = WebInspector.NetworkLogViewColumns._saveableConfigs; |
| 528 for (var columnConfig of this._columns) { | |
| 529 var saveObject = {}; | |
| 530 for (var key of keys) { | |
| 531 if (columnConfig.hasOwnProperty(key)) | |
| 532 saveObject[key] = columnConfig[key]; | |
| 533 } | |
| 534 saveableSettings[columnConfig.id] = saveObject; | |
| 535 } | |
| 536 this._persistantSettings.set(saveableSettings); | |
| 537 }, | |
| 459 | 538 |
| 460 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 539 _loadColumns: function() |
| 461 function compare(id1, id2) | 540 { |
| 462 { | 541 var savedSettings = this._persistantSettings.get(); |
| 463 return columnTitles[id1].compareTo(columnTitles[id2]); | 542 var allowedSettings = WebInspector.NetworkLogViewColumns._saveableConfig s; |
| 543 var columnIds = Object.keys(savedSettings); | |
| 544 for (var columnId of columnIds) { | |
| 545 var setting = savedSettings[columnId]; | |
| 546 var columnConfig = this._columns.find(columnConfig => columnConfig.i d === columnId); | |
| 547 if (!columnConfig) | |
| 548 continue; | |
| 549 | |
| 550 for (var settingName of allowedSettings) { | |
| 551 if (setting.hasOwnProperty(settingName)) | |
| 552 columnConfig[settingName] = setting[settingName]; | |
| 553 } | |
| 464 } | 554 } |
| 465 | |
| 466 var columnIDs = Object.keys(this._columnsVisibilitySetting.get()); | |
| 467 this._configurableColumnIDs = columnIDs.sort(compare); | |
| 468 return this._configurableColumnIDs; | |
| 469 }, | 555 }, |
| 470 | 556 |
| 471 /** | 557 /** |
| 472 * @param {string} title | 558 * @param {string} title |
| 473 * @param {string} subtitle | 559 * @param {string} subtitle |
| 474 * @return {!DocumentFragment} | 560 * @return {!DocumentFragment} |
| 475 */ | 561 */ |
| 476 _makeHeaderFragment: function(title, subtitle) | 562 _makeHeaderFragment: function(title, subtitle) |
| 477 { | 563 { |
| 478 var fragment = createDocumentFragment(); | 564 var fragment = createDocumentFragment(); |
| 479 fragment.createTextChild(title); | 565 fragment.createTextChild(title); |
| 480 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | 566 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; |
| 481 subtitleDiv.createTextChild(subtitle); | 567 subtitleDiv.createTextChild(subtitle); |
| 482 return fragment; | 568 return fragment; |
| 483 }, | 569 }, |
| 484 | 570 |
| 485 /** | 571 /** |
| 486 * @param {!Event} event | 572 * @param {!Event} event |
| 487 * @return {boolean} | 573 * @return {boolean} |
| 488 */ | 574 */ |
| 489 contextMenu: function(event) | 575 contextMenu: function(event) |
| 490 { | 576 { |
| 491 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) | 577 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) |
| 492 return false; | 578 return false; |
| 493 | 579 |
| 580 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); | |
| 494 var contextMenu = new WebInspector.ContextMenu(event); | 581 var contextMenu = new WebInspector.ContextMenu(event); |
| 582 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader); | |
| 583 for (var columnConfig of nonResponseHeaders) | |
| 584 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); | |
| 495 | 585 |
| 496 var columnsVisibility = this._columnsVisibilitySetting.get(); | 586 contextMenu.appendSeparator(); |
| 497 var columnIDs = this._getConfigurableColumnIDs(); | 587 |
| 498 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 588 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers")); |
| 499 for (var i = 0; i < columnIDs.length; ++i) { | 589 var responseHeaders = columnConfigs.filter(columnConfig => columnConfig. isResponseHeader); |
| 500 var columnIdentifier = columnIDs[i]; | 590 for (var columnConfig of responseHeaders) |
| 501 contextMenu.appendCheckboxItem(columnTitles[columnIdentifier], this. _toggleColumnVisibility.bind(this, columnIdentifier), !!columnsVisibility[column Identifier]); | 591 responseSubMenu.appendCheckboxItem(columnConfig.title, this._toggleC olumnVisibility.bind(this, columnConfig), columnConfig.visible); |
| 502 } | 592 |
| 503 contextMenu.show(); | 593 contextMenu.show(); |
| 504 return true; | 594 return true; |
| 505 }, | 595 }, |
| 506 | 596 |
| 507 updateDividersIfNeeded: function() | 597 updateDividersIfNeeded: function() |
| 508 { | 598 { |
| 509 if (!this._networkLogView.isShowing()) { | 599 if (!this._networkLogView.isShowing()) { |
| 510 this._networkLogView.scheduleRefresh(); | 600 this._networkLogView.scheduleRefresh(); |
| 511 return; | 601 return; |
| 512 } | 602 } |
| 513 | 603 |
| 514 var timelineOffset = this._dataGrid.columnOffset("timeline"); | 604 var timelineOffset = this._dataGrid.columnOffset("timeline"); |
| 515 // Position timline grid location. | 605 // Position timline grid location. |
| 516 if (timelineOffset) | 606 if (timelineOffset) |
| 517 this._timelineGrid.element.style.left = timelineOffset + "px"; | 607 this._timelineGrid.element.style.left = timelineOffset + "px"; |
| 518 | 608 |
| 519 var calculator = this._networkLogView.calculator(); | 609 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time); |
| 520 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); | 610 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); |
| 521 this._timelineGrid.updateDividers(calculator, 75); | 611 this._timelineGrid.updateDividers(calculator, 75); |
| 522 | 612 |
| 523 if (calculator.startAtZero) { | 613 if (calculator.startAtZero) { |
| 524 // If our current sorting method starts at zero, that means it shows all | 614 // If our current sorting method starts at zero, that means it shows all |
| 525 // requests starting at the same point, and so onLoad event and DOMC ontent | 615 // requests starting at the same point, and so onLoad event and DOMC ontent |
| 526 // event lines really wouldn't make much sense here, so don't render them. | 616 // event lines really wouldn't make much sense here, so don't render them. |
| 527 return; | 617 return; |
| 528 } | 618 } |
| 529 | 619 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 this._eventDividers.push({time: times[i], element: element}); | 676 this._eventDividers.push({time: times[i], element: element}); |
| 587 } | 677 } |
| 588 // Update event dividers immediately | 678 // Update event dividers immediately |
| 589 this._updateEventDividers(); | 679 this._updateEventDividers(); |
| 590 // Schedule refresh in case dividers change the calculator span. | 680 // Schedule refresh in case dividers change the calculator span. |
| 591 this._networkLogView.scheduleRefresh(); | 681 this._networkLogView.scheduleRefresh(); |
| 592 }, | 682 }, |
| 593 | 683 |
| 594 _updateEventDividers: function() | 684 _updateEventDividers: function() |
| 595 { | 685 { |
| 596 var calculator = this._networkLogView.calculator(); | 686 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time); |
| 597 for (var divider of this._eventDividers) { | 687 for (var divider of this._eventDividers) { |
| 598 var timePercent = calculator.computePercentageFromEventTime(divider. time); | 688 var timePercent = calculator.computePercentageFromEventTime(divider. time); |
| 599 divider.element.classList.toggle("invisible", timePercent < 0); | 689 divider.element.classList.toggle("invisible", timePercent < 0); |
| 600 divider.element.style.left = timePercent + "%"; | 690 divider.element.style.left = timePercent + "%"; |
| 601 } | 691 } |
| 602 }, | 692 }, |
| 603 | 693 |
| 604 hideEventDividers: function() | 694 hideEventDividers: function() |
| 605 { | 695 { |
| 606 this._timelineGrid.hideEventDividers(); | 696 this._timelineGrid.hideEventDividers(); |
| 607 }, | 697 }, |
| 608 | 698 |
| 609 showEventDividers: function() | 699 showEventDividers: function() |
| 610 { | 700 { |
| 611 this._timelineGrid.showEventDividers(); | 701 this._timelineGrid.showEventDividers(); |
| 612 }, | 702 }, |
| 613 | 703 |
| 614 _updateRowsSize: function() | 704 _updateRowsSize: function() |
| 615 { | 705 { |
| 616 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get()); | 706 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get()); |
| 617 } | 707 } |
| 618 } | 708 } |
| OLD | NEW |