| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 }, | 166 }, |
| 167 | 167 |
| 168 _bots: function(){ | 168 _bots: function(){ |
| 169 if (!this._list || !this._list.items) { | 169 if (!this._list || !this._list.items) { |
| 170 return []; | 170 return []; |
| 171 } | 171 } |
| 172 // Do any preprocessing here | 172 // Do any preprocessing here |
| 173 this._list.items.forEach(function(bot){ | 173 this._list.items.forEach(function(bot){ |
| 174 // Parse the state, which is a JSON string. This contains a lot of | 174 // Parse the state, which is a JSON string. This contains a lot of |
| 175 // interesting information like details about the devices attached. | 175 // interesting information like details about the devices attached. |
| 176 bot.state = bot.state || "{}"; |
| 176 bot.state = JSON.parse(bot.state); | 177 bot.state = JSON.parse(bot.state); |
| 177 // get the disks in an easier to deal with format, sorted by size. | 178 // get the disks in an easier to deal with format, sorted by size. |
| 178 var disks = bot.state["disks"]; | 179 var disks = bot.state.disks || {}; |
| 179 var keys = Object.keys(disks); | 180 var keys = Object.keys(disks); |
| 180 if (!keys || !keys.length) { | 181 if (!keys.length) { |
| 181 bot.disks = [{"id": "unknown", "mb": 0}]; | 182 bot.disks = [{"id": "unknown", "mb": 0}]; |
| 182 } else { | 183 } else { |
| 183 bot.disks = []; | 184 bot.disks = []; |
| 184 for (var i = 0; i < keys.length; i++) { | 185 for (var i = 0; i < keys.length; i++) { |
| 185 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb}); | 186 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb}); |
| 186 } | 187 } |
| 187 // Sort these so the biggest disk comes first. | 188 // Sort these so the biggest disk comes first. |
| 188 bot.disks.sort(function(a, b) { | 189 bot.disks.sort(function(a, b) { |
| 189 return b.mb - a.mb; | 190 return b.mb - a.mb; |
| 190 }); | 191 }); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 279 |
| 279 // No need to sort any of this, bot-filters sorts secondary items | 280 // No need to sort any of this, bot-filters sorts secondary items |
| 280 // automatically, especially when the user types a query. | 281 // automatically, especially when the user types a query. |
| 281 return pMap; | 282 return pMap; |
| 282 }, | 283 }, |
| 283 | 284 |
| 284 }); | 285 }); |
| 285 })(); | 286 })(); |
| 286 </script> | 287 </script> |
| 287 </dom-module> | 288 </dom-module> |
| OLD | NEW |