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

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

Issue 2617923002: bluetooth: Add service list to DeviceDetailsPage in internals page. (Closed)
Patch Set: Add CSS variable for expandable list item border 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 ServiceList and ServiceListItem, served from
7 * chrome://bluetooth-internals/.
8 */
9
10 cr.define('service_list', function() {
11 /** @const */ var ExpandableList = expandable_list.ExpandableList;
12 /** @const */ var ExpandableListItem = expandable_list.ExpandableListItem;
13
14 /**
15 * Property names that will be displayed in the ObjectFieldSet which contains
16 * the ServiceInfo object.
17 */
18 var PROPERTY_NAMES = {
19 id: 'ID',
20 'uuid.uuid': 'UUID',
21 is_primary: 'Type',
22 }
dpapad 2017/01/14 00:32:57 Semicolon missing.
mbrunson 2017/01/14 01:36:12 Done.
23
24 /**
25 * A list item that displays the data in a ServiceInfo object. The brief
26 * section contains the UUID of the given |serviceInfo|. The expanded section
27 * contains an ObjectFieldSet that displays all of the properties in the
28 * given |serviceInfo|.
29 * @param {!interfaces.BluetoothDevice.ServiceInfo} serviceInfo
30 * @constructor
31 */
32 function ServiceListItem(serviceInfo) {
33 var listItem = new ExpandableListItem();
34 listItem.__proto__ = ServiceListItem.prototype;
35
36 listItem.info = serviceInfo;
37 listItem.decorate();
38
39 return listItem;
40 }
41
42 ServiceListItem.prototype = {
43 __proto__: ExpandableListItem.prototype,
44
45 /**
46 * Decorates the element as a service list item. Creates layout and caches
47 * references to the created header and fieldset.
48 * @override
49 */
50 decorate: function() {
51 this.classList.add('service-list-item');
52
53 /** @private {!HTMLElement} */
54 this.infoDiv_ = document.createElement('div');
55 this.infoDiv_.classList.add('info-container');
56
57 /** @private {!object_fieldset.ObjectFieldSet} */
58 this.serviceFieldSet_ = object_fieldset.ObjectFieldSet();
59 this.serviceFieldSet_.setPropertyDisplayNames(PROPERTY_NAMES);
60 var serviceViewObj = {
dpapad 2017/01/14 00:32:57 Nit: How about inlining as follows? this.serviceF
mbrunson 2017/01/14 01:36:12 Done.
61 id: this.info.id,
62 'uuid.uuid': this.info.uuid.uuid,
63 is_primary: this.info.is_primary ? 'Primary' : 'Secondary',
64 };
65 this.serviceFieldSet_.setObject(serviceViewObj);
66
67 // Create content for display in brief content container.
68 var serviceHeaderText = document.createElement('div');
69 serviceHeaderText.textContent = 'Service:';
70
71 var serviceHeaderValue = document.createElement('div');
72 serviceHeaderValue.textContent = this.info.uuid.uuid;
73
74 var serviceHeader = document.createElement('div');
75 serviceHeader.appendChild(serviceHeaderText);
76 serviceHeader.appendChild(serviceHeaderValue);
77 this.briefContent_.appendChild(serviceHeader);
78
79 // Create content for display in expanded content container.
80 var serviceInfoHeader = document.createElement('h4');
81 serviceInfoHeader.textContent = 'Service Info';
82
83 var serviceDiv = document.createElement('div');
84 serviceDiv.classList.add('flex');
85 serviceDiv.appendChild(this.serviceFieldSet_);
86
87 this.infoDiv_.appendChild(serviceInfoHeader);
88 this.infoDiv_.appendChild(serviceDiv);
89 this.expandedContent_.appendChild(this.infoDiv_);
90 },
91 };
92
93 /**
94 * A list that displays ServiceListItems.
95 * @constructor
96 */
97 var ServiceList = cr.ui.define('list');
98
99 ServiceList.prototype = {
100 __proto__: ExpandableList.prototype,
101
102 /** @override */
103 decorate: function() {
104 ExpandableList.prototype.decorate.call(this);
105 this.classList.add('service-list');
106 this.setEmptyMessage('No Services Found');
107 },
108
109 /** @override */
110 createItem: function(data) {
111 return new ServiceListItem(data);
112 },
113 };
114
115 return {
116 ServiceList: ServiceList,
117 ServiceListItem: ServiceListItem,
118 };
119 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698