| 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 window.SwarmingBehaviors.BotListBehavior contains any shared functions and | 6 window.SwarmingBehaviors.BotListBehavior contains any shared functions and |
| 7 constants used by the bot-list and its sub-elements. | 7 constants used by the bot-list and its sub-elements. |
| 8 | 8 |
| 9 To use it, include | 9 To use it, include |
| 10 behaviors: [SwarmingBehaviors.BotListBehavior] | 10 behaviors: [SwarmingBehaviors.BotListBehavior] |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // _attribute looks first in dimension and then in state for the | 33 // _attribute looks first in dimension and then in state for the |
| 34 // specified attribute. This will always return an array. If there is | 34 // specified attribute. This will always return an array. If there is |
| 35 // no matching attribute, ["unknown"] will be returned. | 35 // no matching attribute, ["unknown"] will be returned. |
| 36 _attribute: function(bot, attr, none) { | 36 _attribute: function(bot, attr, none) { |
| 37 none = none || UNKNOWN; | 37 none = none || UNKNOWN; |
| 38 return this._dimension(bot, attr) || this._state(bot, attr) || [none]; | 38 return this._dimension(bot, attr) || this._state(bot, attr) || [none]; |
| 39 }, | 39 }, |
| 40 | 40 |
| 41 _devices: function(bot) { | 41 _devices: function(bot) { |
| 42 return bot.state.devices; | 42 return bot.state.devices || []; |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 // _deviceType returns the codename of a given Android device. | 45 // _deviceType returns the codename of a given Android device. |
| 46 _deviceType: function(device) { | 46 _deviceType: function(device) { |
| 47 return device.device_type.toLowerCase(); | 47 return device.device_type.toLowerCase(); |
| 48 }, | 48 }, |
| 49 | 49 |
| 50 // _dimension returns the given dimension of a bot. If it is defined, it | 50 // _dimension returns the given dimension of a bot. If it is defined, it |
| 51 // is an array of strings. | 51 // is an array of strings. |
| 52 _dimension: function(bot, dim) { | 52 _dimension: function(bot, dim) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 _taskId: function(bot) { | 78 _taskId: function(bot) { |
| 79 if (bot && bot.task_id) { | 79 if (bot && bot.task_id) { |
| 80 return bot.task_id; | 80 return bot.task_id; |
| 81 } | 81 } |
| 82 return "idle"; | 82 return "idle"; |
| 83 }, | 83 }, |
| 84 | 84 |
| 85 }]; | 85 }]; |
| 86 })() | 86 })() |
| 87 </script> | 87 </script> |
| OLD | NEW |