OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 * @fileoverview |
7 * Class representing the host-list portion of the home screen UI. | 7 * Class representing the host-list portion of the home screen UI. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 this.table_.innerHTML = ''; | 115 this.table_.innerHTML = ''; |
116 this.showError_(null); | 116 this.showError_(null); |
117 this.hostTableEntries_ = []; | 117 this.hostTableEntries_ = []; |
118 | 118 |
119 /** @type {remoting.HostList} */ | 119 /** @type {remoting.HostList} */ |
120 var that = this; | 120 var that = this; |
121 for (var i = 0; i < hosts.length; ++i) { | 121 for (var i = 0; i < hosts.length; ++i) { |
122 /** @type {remoting.Host} */ | 122 /** @type {remoting.Host} */ |
123 var host = hosts[i]; | 123 var host = hosts[i]; |
124 // Validate the entry to make sure it has all the fields we expect. | 124 // Validate the entry to make sure it has all the fields we expect. |
125 if (host.hostName && host.hostId && host.status && host.jabberId && | 125 if (host.hostName && host.hostId && host.status && host.publicKey) { |
Jamie
2011/11/23 20:53:23
I think we still need to check for jabberId. The p
Sergey Ulanov
2011/11/23 21:10:47
JabberId may not be set if the host was registered
Sergey Ulanov
2011/11/23 21:16:50
Reverted this change for now. Will address in a se
| |
126 host.publicKey) { | |
127 var onRename = function() { that.renameHost_(host.hostId); } | 126 var onRename = function() { that.renameHost_(host.hostId); } |
128 var onDelete = function() { that.deleteHost_(host.hostId); } | 127 var onDelete = function() { that.deleteHost_(host.hostId); } |
129 var hostTableEntry = new remoting.HostTableEntry(); | 128 var hostTableEntry = new remoting.HostTableEntry(); |
130 hostTableEntry.init(host, onRename, onDelete); | 129 hostTableEntry.init(host, onRename, onDelete); |
131 this.hostTableEntries_[i] = hostTableEntry; | 130 this.hostTableEntries_[i] = hostTableEntry; |
132 this.table_.appendChild(hostTableEntry.tableRow); | 131 this.table_.appendChild(hostTableEntry.tableRow); |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 this.showOrHide_(this.hostTableEntries_.length != 0); | 135 this.showOrHide_(this.hostTableEntries_.length != 0); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 if (!hostTableEntry) { | 213 if (!hostTableEntry) { |
215 console.error('No host registered for id ' + hostId); | 214 console.error('No host registered for id ' + hostId); |
216 return; | 215 return; |
217 } | 216 } |
218 /** @param {string} token */ | 217 /** @param {string} token */ |
219 var renameHost = function(token) { | 218 var renameHost = function(token) { |
220 var headers = { | 219 var headers = { |
221 'Authorization': 'OAuth ' + token, | 220 'Authorization': 'OAuth ' + token, |
222 'Content-type' : 'application/json; charset=UTF-8' | 221 'Content-type' : 'application/json; charset=UTF-8' |
223 }; | 222 }; |
224 var newHostDetails = { data: hostTableEntry.host }; | 223 var newHostDetails = { data: { |
224 hostId: hostTableEntry.host.hostId, | |
225 hostName: hostTableEntry.host.hostName, | |
226 publicKey: hostTableEntry.host.publicKey | |
227 } }; | |
225 remoting.xhr.put( | 228 remoting.xhr.put( |
226 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + hostId, | 229 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + hostId, |
227 function(xhr) {}, | 230 function(xhr) {}, |
228 JSON.stringify(newHostDetails), | 231 JSON.stringify(newHostDetails), |
229 headers); | 232 headers); |
230 } | 233 } |
231 remoting.oauth2.callWithToken(renameHost); | 234 remoting.oauth2.callWithToken(renameHost); |
232 }; | 235 }; |
233 | 236 |
234 /** | 237 /** |
235 * Class name for the host list when it is collapsed. | 238 * Class name for the host list when it is collapsed. |
236 * @private | 239 * @private |
237 */ | 240 */ |
238 remoting.HostList.COLLAPSED_ = 'collapsed'; | 241 remoting.HostList.COLLAPSED_ = 'collapsed'; |
239 | 242 |
240 /** @type {remoting.HostList} */ | 243 /** @type {remoting.HostList} */ |
241 remoting.hostList = null; | 244 remoting.hostList = null; |
OLD | NEW |