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

Side by Side Diff: ui/webui/resources/cr_elements/network/cr_network_select.js

Issue 2250773002: WebUI: cr-network-list: Use a single list of cr-network-list-items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add show-separators Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @fileoverview Polymer element wrapping cr-network-list including the 6 * @fileoverview Polymer element wrapping cr-network-list including the
7 * networkingPrivate calls to populate it. 7 * networkingPrivate calls to populate it.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
11 is: 'cr-network-select', 11 is: 'cr-network-select',
12 12
13 properties: { 13 properties: {
14 /** 14 /**
15 * Network state for the active network. 15 * Network state for the active network.
16 * @type {?CrOnc.NetworkStateProperties} 16 * @type {?CrOnc.NetworkStateProperties}
17 */ 17 */
18 activeNetworkState: { 18 activeNetworkState: Object,
19 type: Object,
20 value: null
21 },
22 19
23 /** 20 /**
24 * If true, the element includes an 'expand' button that toggles the 21 * If true, the element includes an 'expand' button that toggles the
25 * expanded state of the network list. 22 * expanded state of the network list.
26 */ 23 */
27 expandable: { 24 expandable: {
28 type: Boolean, 25 type: Boolean,
29 value: false 26 value: false,
30 }, 27 },
31 28
32 /** 29 /**
33 * The maximum height in pixels for the list. 30 * The maximum height in pixels for the list.
34 */ 31 */
35 maxHeight: { 32 maxHeight: {
36 type: Number, 33 type: Number,
37 value: 1000 34 value: 1000,
38 }, 35 },
39 36
40 /** 37 /**
41 * If true, expand the network list. 38 * If true, expand the network list.
42 */ 39 */
43 networkListOpened: { 40 networkListOpened: {
44 type: Boolean, 41 type: Boolean,
45 value: true, 42 value: true,
46 observer: "networkListOpenedChanged_" 43 observer: 'networkListOpenedChanged_',
47 }, 44 },
48 45
49 /** 46 /**
50 * If true, show the active network state. 47 * If true, show the active network state.
51 */ 48 */
52 showActive: { 49 showActive: {
53 type: Boolean, 50 type: Boolean,
54 value: false 51 value: false,
55 }, 52 reflectToAttribute: true,
56
57 /**
58 * List of all network state data for all visible networks.
59 * See <cr-network-list-network-item/> for details.
60 *
61 * @type {!Array<!CrOnc.NetworkStateProperties>}
62 */
63 networkStateList: {
64 type: Array,
65 value: function() { return []; }
66 },
67
68 /**
69 * List of custom items to display at the end of networks list.
70 * See <cr-network-list-custom-item/> for details.
71 *
72 * @type {!Array<Object>}
73 */
74 customItems: {
75 type: Array,
76 value: function() { return []; },
77 }, 53 },
78 54
79 /** 55 /**
80 * Show all buttons in list items. 56 * Show all buttons in list items.
81 */ 57 */
82 showButtons: { 58 showButtons: {
83 type: Boolean, 59 type: Boolean,
84 value: false, 60 value: false,
61 reflectToAttribute: true,
85 }, 62 },
86 63
87 /** 64 /**
65 * Show separators between all items.
66 */
67 showSeparators: {
68 type: Boolean,
69 value: false,
70 reflectToAttribute: true,
71 },
72
73 /**
74 * List of all network state data for all visible networks.
75 * @type {!Array<!CrOnc.NetworkStateProperties>}
76 */
77 networkStateList: {
78 type: Array,
79 value: function() {
80 return [];
81 }
82 },
83
84 /**
85 * The list of custom items to display after the list of networks.
86 * See CrNetworkList for details.
87 * @type {!Array<CrNetworkList.CustomItemState>}
88 */
89 customItems: {
90 type: Array,
91 value: function() {
92 return [];
93 },
94 },
95
96 /**
88 * Whether to handle "item-selected" for network items. 97 * Whether to handle "item-selected" for network items.
89 * If this property is false, "network-item-selected" event is fired 98 * If this property is false, "network-item-selected" event is fired
90 * carrying CrOnc.NetworkStateProperties as event detail. 99 * carrying CrOnc.NetworkStateProperties as event detail.
91 * 100 *
92 * @type {Function} 101 * @type {Function}
93 */ 102 */
94 handleNetworkItemSelected: { 103 handleNetworkItemSelected: {
95 type: Boolean, 104 type: Boolean,
96 value: false, 105 value: false,
106 reflectToAttribute: true,
97 }, 107 },
98 }, 108 },
99 109
100 /** 110 /**
101 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. 111 * Listener function for chrome.networkingPrivate.onNetworkListChanged event.
102 * @type {function(!Array<string>)} 112 * @type {function(!Array<string>)}
103 * @private 113 * @private
104 */ 114 */
105 networkListChangedListener_: function() {}, 115 networkListChangedListener_: function() {},
106 116
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 }; 165 };
156 chrome.networkingPrivate.getNetworks( 166 chrome.networkingPrivate.getNetworks(
157 filter, this.getNetworksCallback_.bind(this)); 167 filter, this.getNetworksCallback_.bind(this));
158 }, 168 },
159 169
160 /** 170 /**
161 * @param {!Array<!CrOnc.NetworkStateProperties>} states 171 * @param {!Array<!CrOnc.NetworkStateProperties>} states
162 * @private 172 * @private
163 */ 173 */
164 getNetworksCallback_: function(states) { 174 getNetworksCallback_: function(states) {
165 this.activeNetworkState = states[0] || null; 175 this.activeNetworkState = states[0] || undefined;
166 this.networkStateList = states; 176 this.networkStateList = states;
167 }, 177 },
168 178
169 /** 179 /**
170 * Event triggered when a cr-network-list-network-item is selected. 180 * Event triggered when a cr-network-list-item is selected.
171 * @param {!{detail: !CrOnc.NetworkStateProperties}} event 181 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
172 * @private 182 * @private
173 */ 183 */
174 onNetworkListItemSelected_: function(event) { 184 onNetworkListItemSelected_: function(event) {
175 var state = event.detail; 185 var state = event.detail;
176 186
177 if (!this.handleNetworkItemSelected) { 187 if (!this.handleNetworkItemSelected) {
178 this.fire("network-item-selected", state); 188 this.fire('network-item-selected', state);
179 return; 189 return;
180 } 190 }
181 191
182 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) 192 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED)
183 return; 193 return;
184 194
185 chrome.networkingPrivate.startConnect(state.GUID, function() { 195 chrome.networkingPrivate.startConnect(state.GUID, function() {
186 var lastError = chrome.runtime.lastError; 196 var lastError = chrome.runtime.lastError;
187 if (lastError && lastError != 'connecting') 197 if (lastError && lastError != 'connecting')
188 console.error('networkingPrivate.startConnect error: ' + lastError); 198 console.error('networkingPrivate.startConnect error: ' + lastError);
189 }); 199 });
190 }, 200 },
191 }); 201 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.html ('k') | ui/webui/resources/cr_elements_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698