| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 | 5 |
| 6 This in an HTML Import-able file that contains the definition | 6 This in an HTML Import-able file that contains the definition |
| 7 of the following elements: | 7 of the following elements: |
| 8 | 8 |
| 9 <bot-list-data> | 9 <bot-list-data> |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 parseBots: function(json){ | 159 parseBots: function(json){ |
| 160 if (!json || !json.items) { | 160 if (!json || !json.items) { |
| 161 return []; | 161 return []; |
| 162 } | 162 } |
| 163 // Do any preprocessing here | 163 // Do any preprocessing here |
| 164 json.items.forEach(function(bot){ | 164 json.items.forEach(function(bot){ |
| 165 // Parse the state, which is a JSON string. This contains a lot of | 165 // Parse the state, which is a JSON string. This contains a lot of |
| 166 // interesting information like details about the devices attached. | 166 // interesting information like details about the devices attached. |
| 167 bot.state = bot.state || "{}"; | 167 bot.state = bot.state || "{}"; |
| 168 bot.state = JSON.parse(bot.state); | 168 bot.state = JSON.parse(bot.state) || {}; |
| 169 // get the disks in an easier to deal with format, sorted by size. | 169 // get the disks in an easier to deal with format, sorted by size. |
| 170 var disks = bot.state.disks || {}; | 170 var disks = bot.state.disks || {}; |
| 171 var keys = Object.keys(disks); | 171 var keys = Object.keys(disks); |
| 172 if (!keys.length) { | 172 if (!keys.length) { |
| 173 bot.disks = [{"id": "unknown", "mb": 0}]; | 173 bot.disks = [{"id": "unknown", "mb": 0}]; |
| 174 } else { | 174 } else { |
| 175 bot.disks = []; | 175 bot.disks = []; |
| 176 for (var i = 0; i < keys.length; i++) { | 176 for (var i = 0; i < keys.length; i++) { |
| 177 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb}); | 177 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb}); |
| 178 } | 178 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 205 devices.push(o); | 205 devices.push(o); |
| 206 } | 206 } |
| 207 bot.state.devices = devices; | 207 bot.state.devices = devices; |
| 208 | 208 |
| 209 if (bot.last_seen_ts) { | 209 if (bot.last_seen_ts) { |
| 210 bot.last_seen_ts = new Date(bot.last_seen_ts); | 210 bot.last_seen_ts = new Date(bot.last_seen_ts); |
| 211 } | 211 } |
| 212 if (bot.first_seen_ts) { | 212 if (bot.first_seen_ts) { |
| 213 bot.first_seen_ts = new Date(bot.first_seen_ts); | 213 bot.first_seen_ts = new Date(bot.first_seen_ts); |
| 214 } | 214 } |
| 215 if (bot.lease_expiration_ts) { |
| 216 bot.lease_expiration_ts = new Date(bot.lease_expiration_ts); |
| 217 } |
| 215 | 218 |
| 216 }.bind(this)); | 219 }.bind(this)); |
| 217 return json.items; | 220 return json.items; |
| 218 }, | 221 }, |
| 219 | 222 |
| 220 _fleet: function() { | 223 _fleet: function() { |
| 221 if (!this._count) { | 224 if (!this._count) { |
| 222 return {}; | 225 return {}; |
| 223 } | 226 } |
| 224 return { | 227 return { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 287 |
| 285 // No need to sort any of this, bot-filters sorts secondary items | 288 // No need to sort any of this, bot-filters sorts secondary items |
| 286 // automatically, especially when the user types a query. | 289 // automatically, especially when the user types a query. |
| 287 return pMap; | 290 return pMap; |
| 288 }, | 291 }, |
| 289 | 292 |
| 290 }); | 293 }); |
| 291 })(); | 294 })(); |
| 292 </script> | 295 </script> |
| 293 </dom-module> | 296 </dom-module> |
| OLD | NEW |