Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: chrome/browser/resources/bluetooth_internals/characteristic_list.js

Issue 2622393002: bluetooth: Add characteristic list to DeviceDetailsPage in internals page. (Closed)
Patch Set: Inline setting of characteristic fieldset object Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Javascript for CharacteristicList and CharacteristicListItem, served from
7 * chrome://bluetooth-internals/.
8 */
9
10 cr.define('characteristic_list', function() {
11 /** @const */ var ExpandableList = expandable_list.ExpandableList;
12 /** @const */ var ExpandableListItem = expandable_list.ExpandableListItem;
13
14 /** Property names for the CharacteristicInfo fieldset */
15 var INFO_PROPERTY_NAMES = {
16 id: 'ID',
17 'uuid.uuid': 'UUID',
18 };
19
20 /** Property names for the Properties fieldset. */
21 var PROPERTIES_PROPERTY_NAMES = {
22 broadcast: 'Broadcast',
23 read: 'Read',
24 write_without_response: 'Write Without Response',
25 write: 'Write',
26 notify: 'Notify',
27 indicate: 'Indicate',
28 authenticated_signed_writes: 'Authenticated Signed Writes',
29 extended_properties: 'Extended Properties',
30 reliable_write: 'Reliable Write',
31 writable_auxiliaries: 'Writable Auxiliaries',
32 read_encrypted: 'Read Encrypted',
33 write_encrypted: 'Write Encrypted',
34 read_encrypted_authenticated: 'Read Encrypted Authenticated',
35 write_encrypted_authenticated: 'Write Encrypted Authenticated',
36 };
37
38 /**
39 * A list item that displays the properties of a CharacteristicInfo object.
40 * Two fieldsets are created within the element: one for the primitive
41 * properties, 'id' and 'uuid', and one for the 'properties' object within the
42 * CharacteristicInfo object.
43 * @constructor
44 * @param {!interfaces.BluetoothDevice.CharacteristicInfo} characteristicInfo
45 */
46 function CharacteristicListItem(characteristicInfo) {
47 var listItem = new ExpandableListItem();
48 listItem.__proto__ = CharacteristicListItem.prototype;
49
50 listItem.info = characteristicInfo;
51 listItem.decorate();
52
53 return listItem;
54 }
55
56 CharacteristicListItem.prototype = {
57 __proto__: ExpandableListItem.prototype,
58
59 /**
60 * Decorates the element as a characteristic list item. Creates and caches
61 * two fieldsets for displaying property values.
62 * @override
63 */
64 decorate: function() {
65 this.classList.add('characteristic-list-item');
66
67 /** @private {!object_fieldset.ObjectFieldSet} */
68 this.characteristicFieldSet_ = object_fieldset.ObjectFieldSet();
69 this.characteristicFieldSet_.setPropertyDisplayNames(INFO_PROPERTY_NAMES);
70 this.characteristicFieldSet_.setObject({
71 id: this.info.id,
72 'uuid.uuid': this.info.uuid.uuid,
73 });
74
75 /** @private {!object_fieldset.ObjectFieldSet} */
76 this.propertiesFieldSet_ = new object_fieldset.ObjectFieldSet();
77 this.propertiesFieldSet_.setPropertyDisplayNames(
78 PROPERTIES_PROPERTY_NAMES);
79 this.propertiesFieldSet_.setObject(this.info.properties);
80
81 // Create content for display in brief content container.
82 var characteristicHeaderText = document.createElement('div');
83 characteristicHeaderText.textContent = 'Characteristic:';
84
85 var characteristicHeaderValue = document.createElement('div');
86 characteristicHeaderValue.textContent = this.info.uuid.uuid;
87
88 var characteristicHeader = document.createElement('div');
89 characteristicHeader.appendChild(characteristicHeaderText);
90 characteristicHeader.appendChild(characteristicHeaderValue);
91 this.briefContent_.appendChild(characteristicHeader);
92
93 // Create content for display in expanded content container.
94 var characteristicInfoHeader = document.createElement('h4');
95 characteristicInfoHeader.textContent = 'Characteristic Info';
96
97 var characteristicDiv = document.createElement('div');
98 characteristicDiv.classList.add('flex');
99 characteristicDiv.appendChild(this.characteristicFieldSet_);
100
101 var propertiesHeader = document.createElement('h4');
102 propertiesHeader.textContent = 'Properties';
103
104 var propertiesDiv = document.createElement('div');
105 propertiesDiv.classList.add('flex');
106 propertiesDiv.appendChild(this.propertiesFieldSet_);
107
108 var infoDiv = document.createElement('div');
109 infoDiv.classList.add('info-container');
110 infoDiv.appendChild(characteristicInfoHeader);
111 infoDiv.appendChild(characteristicDiv);
112 infoDiv.appendChild(propertiesHeader);
113 infoDiv.appendChild(propertiesDiv);
114
115 this.expandedContent_.appendChild(infoDiv);
116 },
117 };
118
119 /**
120 * A list that displays CharacteristicListItems.
121 * @constructor
122 */
123 var CharacteristicList = cr.ui.define('list');
124
125 CharacteristicList.prototype = {
126 __proto__: ExpandableList.prototype,
127
128 /** @override */
129 decorate: function() {
130 ExpandableList.prototype.decorate.call(this);
131 this.classList.add('characteristic-list');
132 this.setEmptyMessage('No Characteristics Found');
133 },
134
135 /** @override */
136 createItem: function(data) {
137 return new CharacteristicListItem(data);
138 },
139 };
140
141 return {
142 CharacteristicList: CharacteristicList,
143 CharacteristicListItem: CharacteristicListItem,
144 };
145 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698