| 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] |
| 11 in the creation of your Polymer element. | 11 in the creation of your Polymer element. |
| 12 --> | 12 --> |
| 13 <link rel="import" href="/res/imp/common/swarming-app.html"> | 13 <link rel="import" href="/res/imp/common/swarming-app.html"> |
| 14 <script> | 14 <script> |
| 15 (function(){ | 15 (function(){ |
| 16 var ANDROID_ALIASES = { | |
| 17 "bullhead": "Nexus 5X", | |
| 18 "flo": "Nexus 7 (2013)", | |
| 19 "flounder": "Nexus 9", | |
| 20 "foster": "NVIDIA Shield", | |
| 21 "fugu": "Nexus Player", | |
| 22 "grouper": "Nexus 7 (2012)", | |
| 23 "hammerhead": "Nexus 5", | |
| 24 "m0": "Galaxy S3", | |
| 25 "mako": "Nexus 4", | |
| 26 "manta": "Nexus 10", | |
| 27 "shamu": "Nexus 6", | |
| 28 "sprout": "Android One", | |
| 29 }; | |
| 30 // Taken from http://developer.android.com/reference/android/os/BatteryManag
er.html | 16 // Taken from http://developer.android.com/reference/android/os/BatteryManag
er.html |
| 31 var BATTERY_HEALTH_UNKNOWN = 1; | 17 var BATTERY_HEALTH_UNKNOWN = 1; |
| 32 var BATTERY_HEALTH_GOOD = 2; | 18 var BATTERY_HEALTH_GOOD = 2; |
| 33 var BATTERY_STATUS_CHARGING = 2; | 19 var BATTERY_STATUS_CHARGING = 2; |
| 34 | 20 |
| 35 var UNAUTHENTICATED = "unauthenticated"; | 21 var UNAUTHENTICATED = "unauthenticated"; |
| 36 var AVAILABLE = "available"; | 22 var AVAILABLE = "available"; |
| 37 var UNKNOWN = "unknown"; | 23 var UNKNOWN = "unknown"; |
| 38 | 24 |
| 39 var GPU_ALIASES = { | |
| 40 "1002": "AMD", | |
| 41 "1002:6779": "AMD Radeon HD 6450/7450/8450", | |
| 42 "1002:6821": "AMD Radeon HD 8870M", | |
| 43 "1002:683d": "AMD Radeon HD 7770/8760", | |
| 44 "1002:9830": "AMD Radeon HD 8400", | |
| 45 "102b": "Matrox", | |
| 46 "102b:0522": "Matrox MGA G200e", | |
| 47 "102b:0532": "Matrox MGA G200eW", | |
| 48 "102b:0534": "Matrox G200eR2", | |
| 49 "10de": "NVIDIA", | |
| 50 "10de:08a4": "NVIDIA GeForce 320M", | |
| 51 "10de:08aa": "NVIDIA GeForce 320M", | |
| 52 "10de:0fe9": "NVIDIA GeForce GT 750M Mac Edition", | |
| 53 "10de:104a": "NVIDIA GeForce GT 610", | |
| 54 "10de:11c0": "NVIDIA GeForce GTX 660", | |
| 55 "10de:1244": "NVIDIA GeForce GTX 550 Ti", | |
| 56 "10de:1401": "NVIDIA GeForce GTX 960", | |
| 57 "8086": "Intel", | |
| 58 "8086:0412": "Intel Haswell Integrated", | |
| 59 "8086:041a": "Intel Xeon Integrated", | |
| 60 "8086:0a2e": "Intel Haswell Integrated", | |
| 61 "8086:0d26": "Intel Crystal Well Integrated", | |
| 62 "8086:22b1": "Intel Braswell Integrated", | |
| 63 } | |
| 64 | |
| 65 // For consistency, all aliases are displayed like: | |
| 66 // Nexus 5X (bullhead) | |
| 67 // This regex matches a string like "ALIAS (ORIG)", with ORIG as group 1. | |
| 68 var ALIAS_REGEXP = /.+ \((.*)\)/; | |
| 69 | |
| 70 // This behavior wraps up all the shared bot-list functionality by | 25 // This behavior wraps up all the shared bot-list functionality by |
| 71 // extending SwarmingBehaviors.SwarmingBehavior | 26 // extending SwarmingBehaviors.SwarmingBehavior |
| 72 SwarmingBehaviors.BotListBehavior = [SwarmingBehaviors.SwarmingBehavior, { | 27 SwarmingBehaviors.BotListBehavior = [SwarmingBehaviors.SwarmingBehavior, { |
| 73 | 28 |
| 74 properties: { | 29 properties: { |
| 75 DIMENSIONS_WITH_ALIASES: { | |
| 76 type: Array, | |
| 77 value: function(){ | |
| 78 return ["device_type", "gpu"]; | |
| 79 }, | |
| 80 }, | |
| 81 BOT_PROPERTIES: { | 30 BOT_PROPERTIES: { |
| 82 type: Array, | 31 type: Array, |
| 83 value: function() { | 32 value: function() { |
| 84 // TODO(kjlubick): Add more of these things from state, as they | 33 // TODO(kjlubick): Add more of these things from state, as they |
| 85 // needed/useful/requested. | 34 // needed/useful/requested. |
| 86 return ["disk_space", "task", "status"]; | 35 return ["disk_space", "task", "status"]; |
| 87 } | 36 } |
| 88 }, | 37 }, |
| 89 }, | 38 }, |
| 90 | 39 |
| 91 _androidAlias: function(dt) { | |
| 92 return ANDROID_ALIASES[dt] || UNKNOWN; | |
| 93 }, | |
| 94 | |
| 95 // _applyAlias is the consistent way to modify a string to show its alias. | |
| 96 _applyAlias: function(orig, alias) { | |
| 97 return alias +" ("+orig+")"; | |
| 98 }, | |
| 99 | |
| 100 // _attribute looks first in dimension and then in state for the | 40 // _attribute looks first in dimension and then in state for the |
| 101 // specified attribute. This will always return an array. If there is | 41 // specified attribute. This will always return an array. If there is |
| 102 // no matching attribute, ["unknown"] will be returned. | 42 // no matching attribute, ["unknown"] will be returned. |
| 103 _attribute: function(bot, attr, none) { | 43 _attribute: function(bot, attr, none) { |
| 104 none = none || UNKNOWN; | 44 none = none || UNKNOWN; |
| 105 return this._dimension(bot, attr) || this._state(bot, attr) || [none]; | 45 return this._dimension(bot, attr) || this._state(bot, attr) || [none]; |
| 106 }, | 46 }, |
| 107 | 47 |
| 108 _devices: function(bot) { | 48 _devices: function(bot) { |
| 109 var devices = []; | 49 var devices = []; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 return undefined; | 73 return undefined; |
| 134 } | 74 } |
| 135 for (var i = 0; i < bot.dimensions.length; i++) { | 75 for (var i = 0; i < bot.dimensions.length; i++) { |
| 136 if (bot.dimensions[i].key === dim) { | 76 if (bot.dimensions[i].key === dim) { |
| 137 return bot.dimensions[i].value; | 77 return bot.dimensions[i].value; |
| 138 } | 78 } |
| 139 } | 79 } |
| 140 return undefined; | 80 return undefined; |
| 141 }, | 81 }, |
| 142 | 82 |
| 143 _gpuAlias: function(gpu) { | |
| 144 return GPU_ALIASES[gpu] || UNKNOWN; | |
| 145 }, | |
| 146 | |
| 147 // _state returns the requested attribute from a bot's state. | 83 // _state returns the requested attribute from a bot's state. |
| 148 // For consistency with _dimension, if the attribute is not an array, | 84 // For consistency with _dimension, if the attribute is not an array, |
| 149 // it is put as the only element in an array. | 85 // it is put as the only element in an array. |
| 150 _state: function(bot, attr) { | 86 _state: function(bot, attr) { |
| 151 if (!bot || !bot.state || !bot.state[attr]) { | 87 if (!bot || !bot.state || !bot.state[attr]) { |
| 152 return undefined | 88 return undefined |
| 153 } | 89 } |
| 154 var state = bot.state[attr]; | 90 var state = bot.state[attr]; |
| 155 if (Array.isArray(state)) { | 91 if (Array.isArray(state)) { |
| 156 return state; | 92 return state; |
| 157 } | 93 } |
| 158 return [state]; | 94 return [state]; |
| 159 }, | 95 }, |
| 160 | 96 |
| 161 _taskId: function(bot) { | 97 _taskId: function(bot) { |
| 162 if (bot && bot.task_id) { | 98 if (bot && bot.task_id) { |
| 163 return bot.task_id; | 99 return bot.task_id; |
| 164 } | 100 } |
| 165 return "idle"; | 101 return "idle"; |
| 166 }, | 102 }, |
| 167 | 103 |
| 168 // _unalias will return the base dimension/state with its alias removed | |
| 169 // if it had one. This is handy for sorting and filtering. | |
| 170 _unalias: function(str) { | |
| 171 var match = ALIAS_REGEXP.exec(str); | |
| 172 if (match) { | |
| 173 return match[1]; | |
| 174 } | |
| 175 return str; | |
| 176 }, | |
| 177 }]; | 104 }]; |
| 178 })() | 105 })() |
| 179 </script> | 106 </script> |
| OLD | NEW |