| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. |
| 5 |
| 6 This in an HTML Import-able file that contains the definition |
| 7 of the following elements: |
| 8 |
| 9 <bot-list-data> |
| 10 |
| 11 This makes calls authenticated with Oauth 2 to the swarming apis. It parses |
| 12 that data into usable data structures. |
| 13 |
| 14 Usage: |
| 15 |
| 16 <bot-list-data></bot-list-data> |
| 17 |
| 18 Properties: |
| 19 // inputs |
| 20 auth_headers: Object, the OAuth2 header to include in the request. This |
| 21 should come from swarming-app. |
| 22 query_params: Object, The query params that will filter the query |
| 23 server-side. This can have dimensions:Array<String>, quarantined:String |
| 24 and is_dead: String. For example: |
| 25 { |
| 26 "dimensions": ["pool:Skia", "device_type:sprout"], |
| 27 "quarantined": "FALSE", // optional |
| 28 "is_dead": "TRUE", // optional |
| 29 } |
| 30 For a full list of dimensions in the fleet, see the API call: |
| 31 https://[swarming_url]/_ah/api/swarming/v1/bots/dimensions |
| 32 // outputs |
| 33 tasks: Array<Object>, all tasks returned by the server. |
| 34 |
| 35 Methods: |
| 36 signIn(): Force a signin of the user using OAuth. This happens |
| 37 automatically when auth_headers is set. |
| 38 |
| 39 Events: |
| 40 None. |
| 41 --> |
| 42 |
| 43 <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html"> |
| 44 |
| 45 <dom-module id="task-list-data"> |
| 46 <template> |
| 47 <iron-ajax id="tasklist" |
| 48 url="/_ah/api/swarming/v1/tasks/list" |
| 49 headers="[[auth_headers]]" |
| 50 params="[[query_params]]" |
| 51 handle-as="json" |
| 52 last-response="{{_list}}" |
| 53 loading="{{_busy1}}"> |
| 54 </iron-ajax> |
| 55 <!-- TODO(kjlubick): Make more requests (like all tags) --> |
| 56 |
| 57 </template> |
| 58 <script> |
| 59 (function(){ |
| 60 Polymer({ |
| 61 is: 'task-list-data', |
| 62 |
| 63 behaviors: [SwarmingBehaviors.SwarmingBehavior], |
| 64 |
| 65 properties: { |
| 66 // inputs |
| 67 auth_headers: { |
| 68 type: Object, |
| 69 observer: "signIn", |
| 70 }, |
| 71 query_params: { |
| 72 type: Object, |
| 73 }, |
| 74 |
| 75 //outputs |
| 76 busy: { |
| 77 type: Boolean, |
| 78 computed: "_or(_busy1)", |
| 79 notify: true, |
| 80 }, |
| 81 tasks: { |
| 82 type: Array, |
| 83 computed: "_tasks(_list)", |
| 84 notify: true, |
| 85 } |
| 86 }, |
| 87 signIn: function(){ |
| 88 // Auto on iron-ajax means to automatically re-make the request if |
| 89 // the url or the query params change. Auto does not trigger if the |
| 90 // [auth] headers change, so we wait until the user is signed in |
| 91 // before making any requests. |
| 92 this.$.tasklist.auto = true; |
| 93 }, |
| 94 |
| 95 _tasks: function() { |
| 96 if (!this._list || !this._list.items) { |
| 97 return []; |
| 98 } |
| 99 // Do any preprocessing here |
| 100 return this._list.items; |
| 101 } |
| 102 }); |
| 103 })(); |
| 104 </script> |
| 105 </dom-module> |
| OLD | NEW |