| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 Methods: | 55 Methods: |
| 56 signIn(): Force a signin of the user using OAuth. This happens | 56 signIn(): Force a signin of the user using OAuth. This happens |
| 57 automatically when auth_headers is set. | 57 automatically when auth_headers is set. |
| 58 | 58 |
| 59 Events: | 59 Events: |
| 60 None. | 60 None. |
| 61 --> | 61 --> |
| 62 | 62 |
| 63 <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html"> | 63 <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html"> |
| 64 | 64 |
| 65 <link rel="import" href="bot-list-shared.html"> | 65 <link rel="import" href="bot-list-shared-behavior.html"> |
| 66 | 66 |
| 67 <dom-module id="bot-list-data"> | 67 <dom-module id="bot-list-data"> |
| 68 <template> | 68 <template> |
| 69 <iron-ajax id="botlist" | 69 <iron-ajax id="botlist" |
| 70 url="/_ah/api/swarming/v1/bots/list" | 70 url="/_ah/api/swarming/v1/bots/list" |
| 71 headers="[[auth_headers]]" | 71 headers="[[auth_headers]]" |
| 72 params="[[query_params]]" | 72 params="[[query_params]]" |
| 73 handle-as="json" | 73 handle-as="json" |
| 74 last-response="{{_list}}" | 74 last-response="{{_list}}" |
| 75 loading="{{_busy1}}"> | 75 loading="{{_busy1}}"> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 91 loading="{{_busy3}}"> | 91 loading="{{_busy3}}"> |
| 92 </iron-ajax> | 92 </iron-ajax> |
| 93 </template> | 93 </template> |
| 94 <script> | 94 <script> |
| 95 (function(){ | 95 (function(){ |
| 96 var BLACKLIST_DIMENSIONS = ["quarantined", "error"]; | 96 var BLACKLIST_DIMENSIONS = ["quarantined", "error"]; |
| 97 | 97 |
| 98 Polymer({ | 98 Polymer({ |
| 99 is: 'bot-list-data', | 99 is: 'bot-list-data', |
| 100 | 100 |
| 101 behaviors: [SwarmingBehaviors.BotListBehavior], | 101 behaviors: [ |
| 102 SwarmingBehaviors.BotListBehavior, |
| 103 ], |
| 102 | 104 |
| 103 properties: { | 105 properties: { |
| 104 // inputs | 106 // inputs |
| 105 auth_headers: { | 107 auth_headers: { |
| 106 type: Object, | 108 type: Object, |
| 107 observer: "signIn", | 109 observer: "signIn", |
| 108 }, | 110 }, |
| 109 query_params: { | 111 query_params: { |
| 110 type: Object, | 112 type: Object, |
| 111 }, | 113 }, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 type: Array, | 127 type: Array, |
| 126 computed: "_makeArray(_dimensions)", | 128 computed: "_makeArray(_dimensions)", |
| 127 notify: true, | 129 notify: true, |
| 128 }, | 130 }, |
| 129 fleet: { | 131 fleet: { |
| 130 type: Object, | 132 type: Object, |
| 131 computed: "_fleet(_count)", | 133 computed: "_fleet(_count)", |
| 132 notify: true, | 134 notify: true, |
| 133 }, | 135 }, |
| 134 primary_map: { | 136 primary_map: { |
| 135 type:Object, | 137 type: Object, |
| 136 computed: "_primaryMap(_dimensions)", | 138 computed: "_primaryMap(_dimensions)", |
| 137 notify: true, | 139 notify: true, |
| 138 }, | 140 }, |
| 139 primary_arr: { | 141 primary_arr: { |
| 140 type: Array, | 142 type: Array, |
| 141 //BOT_PROPERTIES is inherited from BotListBehavior | 143 //BOT_PROPERTIES is inherited from BotListBehavior |
| 142 computed: "_primaryArr(dimensions, BOT_PROPERTIES)", | 144 computed: "_primaryArr(dimensions, BOT_PROPERTIES)", |
| 143 notify: true, | 145 notify: true, |
| 144 }, | 146 }, |
| 145 | 147 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 _makeArray: function(dimObj) { | 214 _makeArray: function(dimObj) { |
| 213 if (!dimObj || !dimObj.bots_dimensions) { | 215 if (!dimObj || !dimObj.bots_dimensions) { |
| 214 return []; | 216 return []; |
| 215 } | 217 } |
| 216 var dims = []; | 218 var dims = []; |
| 217 dimObj.bots_dimensions.forEach(function(d){ | 219 dimObj.bots_dimensions.forEach(function(d){ |
| 218 if (BLACKLIST_DIMENSIONS.indexOf(d.key) === -1) { | 220 if (BLACKLIST_DIMENSIONS.indexOf(d.key) === -1) { |
| 219 dims.push(d.key); | 221 dims.push(d.key); |
| 220 } | 222 } |
| 221 }); | 223 }); |
| 224 dims.push("id"); |
| 222 dims.sort(); | 225 dims.sort(); |
| 223 return dims; | 226 return dims; |
| 224 }, | 227 }, |
| 225 | 228 |
| 226 _primaryArr: function(dimensions, properties) { | 229 _primaryArr: function(dimensions, properties) { |
| 227 return dimensions.concat(properties); | 230 return dimensions.concat(properties); |
| 228 }, | 231 }, |
| 229 | 232 |
| 230 _primaryMap: function(dimensions){ | 233 _primaryMap: function(dimensions){ |
| 231 // pMap will have a list of columns to available values (primary key | 234 // pMap will have a list of columns to available values (primary key |
| 232 // to secondary values). This includes bot dimensions, but also | 235 // to secondary values). This includes bot dimensions, but also |
| 233 // includes state like disk_space, quarantined, busy, etc. | 236 // includes state like disk_space, quarantined, busy, etc. |
| 234 dimensions = dimensions.bots_dimensions; | 237 dimensions = dimensions.bots_dimensions; |
| 235 | 238 |
| 236 var pMap = {}; | 239 var pMap = {}; |
| 237 dimensions.forEach(function(d){ | 240 dimensions.forEach(function(d){ |
| 238 if (this.DIMENSIONS_WITH_ALIASES.indexOf(d.key) === -1) { | 241 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(d.key) === -1) { |
| 239 // value is an array of all seen values for the dimension d.key | 242 // value is an array of all seen values for the dimension d.key |
| 240 pMap[d.key] = d.value; | 243 pMap[d.key] = d.value; |
| 241 } else if (d.key === "gpu") { | 244 } else if (d.key === "gpu") { |
| 242 var gpus = []; | 245 var gpus = []; |
| 243 d.value.forEach(function(g){ | 246 d.value.forEach(function(g){ |
| 244 var alias = this._gpuAlias(g); | 247 var alias = swarming.alias.gpu(g); |
| 245 if (alias !== "unknown") { | 248 if (alias !== "unknown") { |
| 246 gpus.push(this._applyAlias(g, alias)); | 249 gpus.push(swarming.alias.apply(g, alias)); |
| 247 } else { | 250 } else { |
| 248 gpus.push(g); | 251 gpus.push(g); |
| 249 } | 252 } |
| 250 }.bind(this)); | 253 }.bind(this)); |
| 251 pMap["gpu"] = gpus; | 254 pMap["gpu"] = gpus; |
| 252 } else if (d.key === "device_type") { | 255 } else if (d.key === "device_type") { |
| 253 var devs = []; | 256 var devs = []; |
| 254 d.value.forEach(function(dt){ | 257 d.value.forEach(function(dt){ |
| 255 var alias = this._androidAlias(dt); | 258 var alias = swarming.alias.android(dt); |
| 256 if (alias !== "unknown") { | 259 if (alias !== "unknown") { |
| 257 devs.push(this._applyAlias(dt, alias)); | 260 devs.push(swarming.alias.apply(dt, alias)); |
| 258 } else { | 261 } else { |
| 259 devs.push(dt); | 262 devs.push(dt); |
| 260 } | 263 } |
| 261 }.bind(this)); | 264 }.bind(this)); |
| 262 pMap["device_type"] = devs; | 265 pMap["device_type"] = devs; |
| 263 } else { | 266 } else { |
| 264 console.log("Unknown alias type: ", d); | 267 console.log("Unknown alias type: ", d); |
| 265 } | 268 } |
| 266 }.bind(this)); | 269 }); |
| 267 | 270 |
| 268 // Add some options that might not show up. | 271 // Add some options that might not show up. |
| 269 pMap["android_devices"].push("0"); | 272 pMap["android_devices"].push("0"); |
| 270 pMap["device_os"].push("none"); | 273 pMap["device_os"].push("none"); |
| 271 pMap["device_type"].push("none"); | 274 pMap["device_type"].push("none"); |
| 272 | 275 |
| 273 pMap["id"] = []; | 276 pMap["id"] = []; |
| 274 | 277 |
| 275 // Create custom filter options | 278 // Create custom filter options |
| 276 pMap["disk_space"] = []; | 279 pMap["disk_space"] = []; |
| 277 pMap["task"] = ["busy", "idle"]; | 280 pMap["task"] = ["busy", "idle"]; |
| 278 pMap["status"] = ["alive", "dead", "quarantined"]; | 281 pMap["status"] = ["alive", "dead", "quarantined"]; |
| 279 | 282 |
| 280 // No need to sort any of this, bot-filters sorts secondary items | 283 // No need to sort any of this, bot-filters sorts secondary items |
| 281 // automatically, especially when the user types a query. | 284 // automatically, especially when the user types a query. |
| 282 return pMap; | 285 return pMap; |
| 283 }, | 286 }, |
| 284 | 287 |
| 285 }); | 288 }); |
| 286 })(); | 289 })(); |
| 287 </script> | 290 </script> |
| 288 </dom-module> | 291 </dom-module> |
| OLD | NEW |