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

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: Update copyrights, remove unneeded import 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 var PROPERTY_NAMES = {
15 id: 'ID',
16 'uuid.uuid': 'UUID',
17 is_primary: 'Type',
18 }
19
20 /**
21 * A list item that displays the data in a ServiceInfo object. The brief
22 * section contains the shortened UUID of the given |serviceInfo|. The
23 * expanded section contains an ObjectFieldSet that displays all of the
24 * properties in the given |serviceInfo|.
25 * @param {!interfaces.BluetoothDevice.ServiceInfo} serviceInfo
26 * @constructor
27 */
28 function ServiceListItem(serviceInfo) {
29 var listItem = new ExpandableListItem();
30 listItem.__proto__ = ServiceListItem.prototype;
31
32 listItem.info = serviceInfo;
33 listItem.decorate();
34
35 return listItem;
36 }
37
38 ServiceListItem.prototype = {
39 __proto__: ExpandableListItem.prototype,
40
41 /**
42 * Decorates the element as a service list item. Creates layout and caches
43 * references to the created header and fieldset.
44 * @override
45 */
46 decorate: function() {
47 this.classList.add('service-list-item');
48
49 var uuidString = this.info.uuid.uuid.split('-')[0];
scheib 2017/01/12 21:53:16 For a basic display of UUID (which I think we shou
mbrunson 2017/01/12 22:59:59 Done.
50 var uuidValue = parseInt(uuidString, 16);
51 var uuidHexString = '0x' + uuidValue.toString(16);
52
53 var serviceHeader = document.createElement('div');
54
55 var serviceHeaderText = document.createElement('div');
56 serviceHeaderText.textContent = 'Service:';
57 serviceHeader.appendChild(serviceHeaderText);
58
59 var serviceHeaderValue = document.createElement('div');
60 serviceHeaderValue.textContent = uuidHexString;
61 serviceHeader.appendChild(serviceHeaderValue);
62
63 this.briefContent_.appendChild(serviceHeader);
64
65 this.infoDiv_ = document.createElement('div');
66 this.infoDiv_.classList.add('info-container');
67
68 var serviceInfoHeader = document.createElement('h4');
69 serviceInfoHeader.textContent = 'Service Info';
70 this.infoDiv_.appendChild(serviceInfoHeader);
71
72 var serviceDiv = document.createElement('div');
73 serviceDiv.classList.add('flex');
74
75 this.serviceFieldSet_ = object_fieldset.ObjectFieldSet();
76 this.serviceFieldSet_.setPropertyDisplayNames(PROPERTY_NAMES);
77 var serviceViewObj = {
78 id: this.info.id,
79 'uuid.uuid': this.info.uuid.uuid,
80 is_primary: this.info.is_primary ? 'Primary' : 'Secondary',
81 };
82
83 this.serviceFieldSet_.setObject(serviceViewObj);
84 serviceDiv.appendChild(this.serviceFieldSet_);
85
86 this.infoDiv_.appendChild(serviceDiv);
87 this.expandedContent_.appendChild(this.infoDiv_);
88 },
89 };
90
91 /**
92 * A list that displays ServiceListItems.
93 * @constructor
94 */
95 var ServiceList = cr.ui.define('list');
96
97 ServiceList.prototype = {
98 __proto__: ExpandableList.prototype,
99
100 /** @override */
101 decorate: function() {
102 ExpandableList.prototype.decorate.call(this);
103 this.classList.add('service-list');
104 this.setEmptyMessage('No Services Found');
105 },
106
107 /** @override */
108 createItem: function(data) {
109 return new ServiceListItem(data);
110 },
111 };
112
113 return {
114 ServiceList: ServiceList,
115 ServiceListItem: ServiceListItem,
116 };
117 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698