| 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 12 matching lines...) Expand all Loading... |
| 23 server-side. This can have dimensions:Array<String>, quarantined:String | 23 server-side. This can have dimensions:Array<String>, quarantined:String |
| 24 and is_dead: String. For example: | 24 and is_dead: String. For example: |
| 25 { | 25 { |
| 26 "dimensions": ["pool:Skia", "device_type:sprout"], | 26 "dimensions": ["pool:Skia", "device_type:sprout"], |
| 27 "quarantined": "FALSE", // optional | 27 "quarantined": "FALSE", // optional |
| 28 "is_dead": "TRUE", // optional | 28 "is_dead": "TRUE", // optional |
| 29 } | 29 } |
| 30 For a full list of dimensions in the fleet, see the API call: | 30 For a full list of dimensions in the fleet, see the API call: |
| 31 https://[swarming_url]/api/swarming/v1/bots/dimensions | 31 https://[swarming_url]/api/swarming/v1/bots/dimensions |
| 32 // outputs | 32 // outputs |
| 33 dimensions: Array<String>, of all valid dimensions. |
| 33 tasks: Array<Object>, all tasks returned by the server. | 34 tasks: Array<Object>, all tasks returned by the server. |
| 35 primary_map: Object, a mapping of primary keys to secondary items. |
| 36 The primary keys are things that can be columns or sorted by. The |
| 37 primary values (aka the secondary items) are things that can be filtered |
| 38 on. Primary consists of tags and state. Secondary contains the |
| 39 values primary things can be. |
| 40 primary_arr: Array<String>, the display order of the primary keys. |
| 34 | 41 |
| 35 Methods: | 42 Methods: |
| 36 signIn(): Force a signin of the user using OAuth. This happens | 43 signIn(): Force a signin of the user using OAuth. This happens |
| 37 automatically when auth_headers is set. | 44 automatically when auth_headers is set. |
| 38 | 45 |
| 39 Events: | 46 Events: |
| 40 None. | 47 None. |
| 41 --> | 48 --> |
| 42 | 49 |
| 43 <link rel="import" href="/res/imp/common/common-behavior.html"> | 50 <link rel="import" href="/res/imp/common/common-behavior.html"> |
| 44 <link rel="import" href="/res/imp/common/task-behavior.html"> | 51 <link rel="import" href="/res/imp/common/task-behavior.html"> |
| 45 | 52 |
| 46 <dom-module id="task-list-data"> | 53 <dom-module id="task-list-data"> |
| 47 <script> | 54 <script> |
| 48 (function(){ | 55 (function(){ |
| 49 var TIMES = ["abandoned_ts", "completed_ts", "created_ts", "modified_ts", "s
tarted_ts"]; | 56 var TIMES = ["abandoned_ts", "completed_ts", "created_ts", "modified_ts", "s
tarted_ts"]; |
| 57 var BLACKLIST_DIMENSIONS = ["quarantined", "error"]; |
| 58 |
| 50 Polymer({ | 59 Polymer({ |
| 51 is: 'task-list-data', | 60 is: 'task-list-data', |
| 52 | 61 |
| 53 behaviors: [ | 62 behaviors: [ |
| 54 SwarmingBehaviors.CommonBehavior, | 63 SwarmingBehaviors.CommonBehavior, |
| 55 SwarmingBehaviors.TaskBehavior, | 64 SwarmingBehaviors.TaskBehavior, |
| 56 ], | 65 ], |
| 57 | 66 |
| 58 properties: { | 67 properties: { |
| 59 // inputs | 68 // inputs |
| 60 auth_headers: { | 69 auth_headers: { |
| 61 type: Object, | 70 type: Object, |
| 62 observer: "signIn", | 71 observer: "signIn", |
| 63 }, | 72 }, |
| 64 query_params: { | 73 query_params: { |
| 65 type: Object, | 74 type: Object, |
| 66 }, | 75 }, |
| 67 tasks: { | 76 tasks: { |
| 68 type: Array, | 77 type: Array, |
| 69 }, | 78 }, |
| 70 | 79 |
| 71 // outputs | 80 // outputs |
| 72 busy: { | 81 busy: { |
| 73 type: Boolean, | 82 type: Boolean, |
| 74 computed: "_or(_busy2,_busy1)", | 83 computed: "_or(_busy2,_busy1)", |
| 75 notify: true, | 84 notify: true, |
| 76 }, | 85 }, |
| 86 dimensions: { |
| 87 type: Array, |
| 88 computed: "_makeArray(_dimensions)", |
| 89 notify: true, |
| 90 }, |
| 77 primary_map: { | 91 primary_map: { |
| 78 type: Object, | 92 type: Object, |
| 79 computed: "_primaryMap(_tags,_dimensions,tasks.*)", | 93 computed: "_primaryMap(_tags,_dimensions,tasks.*)", |
| 80 notify: true, | 94 notify: true, |
| 81 }, | 95 }, |
| 82 primary_arr: { | 96 primary_arr: { |
| 83 type: Array, | 97 type: Array, |
| 84 computed: "_primaryArr(primary_map)", | 98 computed: "_primaryArr(primary_map)", |
| 85 notify: true, | 99 notify: true, |
| 86 }, | 100 }, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 106 }, | 120 }, |
| 107 }, | 121 }, |
| 108 | 122 |
| 109 signIn: function(){ | 123 signIn: function(){ |
| 110 this._getJsonAsync("_tags", "/api/swarming/v1/tasks/tags", | 124 this._getJsonAsync("_tags", "/api/swarming/v1/tasks/tags", |
| 111 "_busy2", this.auth_headers); | 125 "_busy2", this.auth_headers); |
| 112 this._getJsonAsync("_dimensions","/api/swarming/v1/bots/dimensions", | 126 this._getJsonAsync("_dimensions","/api/swarming/v1/bots/dimensions", |
| 113 "_busy1", this.auth_headers); | 127 "_busy1", this.auth_headers); |
| 114 }, | 128 }, |
| 115 | 129 |
| 130 _makeArray: function(dimObj) { |
| 131 if (!dimObj || !dimObj.bots_dimensions) { |
| 132 return []; |
| 133 } |
| 134 var dims = []; |
| 135 dimObj.bots_dimensions.forEach(function(d){ |
| 136 if (BLACKLIST_DIMENSIONS.indexOf(d.key) === -1) { |
| 137 dims.push(d.key); |
| 138 } |
| 139 }); |
| 140 dims.push("id"); |
| 141 dims.sort(); |
| 142 return dims; |
| 143 }, |
| 144 |
| 116 _primaryArr: function(map) { | 145 _primaryArr: function(map) { |
| 117 var arr = Object.keys(map); | 146 var arr = Object.keys(map); |
| 118 arr.sort(); | 147 arr.sort(); |
| 119 return arr; | 148 return arr; |
| 120 }, | 149 }, |
| 121 | 150 |
| 122 _primaryMap: function(tags, dims) { | 151 _primaryMap: function(tags, dims) { |
| 123 tags = (tags && tags.tasks_tags) || []; | 152 tags = (tags && tags.tasks_tags) || []; |
| 124 dims = (dims && dims.bots_dimensions) || []; | 153 dims = (dims && dims.bots_dimensions) || []; |
| 125 tasks = this.tasks || []; | 154 tasks = this.tasks || []; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (t.duration){ | 263 if (t.duration){ |
| 235 t.human_duration = this._humanDuration(t.duration); | 264 t.human_duration = this._humanDuration(t.duration); |
| 236 } | 265 } |
| 237 }.bind(this)); | 266 }.bind(this)); |
| 238 return json.items; | 267 return json.items; |
| 239 } | 268 } |
| 240 }); | 269 }); |
| 241 })(); | 270 })(); |
| 242 </script> | 271 </script> |
| 243 </dom-module> | 272 </dom-module> |
| OLD | NEW |