| 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 * Javascript for DeviceTable UI, served from chrome://bluetooth-internals/. | 6 * Javascript for DeviceTable UI, served from chrome://bluetooth-internals/. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('device_table', function() { | 9 cr.define('device_table', function() { |
| 10 var COLUMNS = { | 10 var COLUMNS = { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 this.updateRow_(this.devices_.item(event.index), event.index); | 70 this.updateRow_(this.devices_.item(event.index), event.index); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Fires a inspect pressed event for the row |index|. | 74 * Fires a inspect pressed event for the row |index|. |
| 75 * @private | 75 * @private |
| 76 * @param {number} index | 76 * @param {number} index |
| 77 */ | 77 */ |
| 78 handleInspectBtn_: function(index) { | 78 handleInspectBtn_: function(index) { |
| 79 var event = new CustomEvent('inspectpressed', { | 79 var event = new CustomEvent('inspectpressed', { |
| 80 bubbles: true, |
| 80 detail: { | 81 detail: { |
| 81 address: this.devices_.item(index).address, | 82 address: this.devices_.item(index).address, |
| 82 } | 83 } |
| 83 }); | 84 }); |
| 84 this.dispatchEvent(event); | 85 this.dispatchEvent(event); |
| 85 }, | 86 }, |
| 86 | 87 |
| 87 /** | 88 /** |
| 88 * Updates table row on splice event of the device collection. | 89 * Updates table row on splice event of the device collection. |
| 89 * @private | 90 * @private |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 case device_collection.ConnectionStatus.CONNECTING: | 169 case device_collection.ConnectionStatus.CONNECTING: |
| 169 inspectButton.disabled = true; | 170 inspectButton.disabled = true; |
| 170 break; | 171 break; |
| 171 default: assert('case not handled'); | 172 default: assert('case not handled'); |
| 172 } | 173 } |
| 173 | 174 |
| 174 // TODO(crbug.com/663830): Replace connection error column with better | 175 // TODO(crbug.com/663830): Replace connection error column with better |
| 175 // notification system. | 176 // notification system. |
| 176 var connectErrorCell = row.cells[COLUMNS.CONNECTION_ERROR]; | 177 var connectErrorCell = row.cells[COLUMNS.CONNECTION_ERROR]; |
| 177 connectErrorCell.textContent = device.connectionMessage; | 178 connectErrorCell.textContent = device.connectionMessage; |
| 179 connectErrorCell.hidden = !device.connectionMessage; |
| 178 | 180 |
| 179 // Update the properties based on the header field path. | 181 // Update the properties based on the header field path. |
| 180 for (var i = 0; i < this.headers_.length; i++) { | 182 for (var i = 0; i < this.headers_.length; i++) { |
| 181 var header = this.headers_[i]; | 183 var header = this.headers_[i]; |
| 182 var propName = header.dataset.field; | 184 var propName = header.dataset.field; |
| 183 | 185 |
| 184 var parts = propName.split('.'); | 186 var parts = propName.split('.'); |
| 185 var obj = device; | 187 var obj = device; |
| 186 while (obj != null && parts.length > 0) { | 188 while (obj != null && parts.length > 0) { |
| 187 var part = parts.shift(); | 189 var part = parts.shift(); |
| 188 obj = obj[part]; | 190 obj = obj[part]; |
| 189 } | 191 } |
| 190 | 192 |
| 191 if (propName == 'is_gatt_connected') { | 193 if (propName == 'is_gatt_connected') { |
| 192 obj = obj ? 'Connected' : 'Not Connected'; | 194 obj = obj ? 'Connected' : 'Not Connected'; |
| 193 } | 195 } |
| 194 | 196 |
| 195 var cell = row.cells[i]; | 197 var cell = row.cells[i]; |
| 196 cell.textContent = obj == null ? 'Unknown' : obj; | 198 cell.textContent = obj == null ? 'Unknown' : obj; |
| 197 cell.dataset.label = header.textContent; | 199 cell.dataset.label = header.textContent; |
| 198 } | 200 } |
| 199 }, | 201 }, |
| 200 }; | 202 }; |
| 201 | 203 |
| 202 return { | 204 return { |
| 203 DeviceTable: DeviceTable, | 205 DeviceTable: DeviceTable, |
| 204 }; | 206 }; |
| 205 }); | 207 }); |
| OLD | NEW |