| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 Events: | 39 Events: |
| 40 None. | 40 None. |
| 41 --> | 41 --> |
| 42 | 42 |
| 43 <link rel="import" href="/res/imp/common/common-behavior.html"> | 43 <link rel="import" href="/res/imp/common/common-behavior.html"> |
| 44 | 44 |
| 45 <dom-module id="task-list-data"> | 45 <dom-module id="task-list-data"> |
| 46 <script> | 46 <script> |
| 47 (function(){ | 47 (function(){ |
| 48 var TIMES = ["abandoned_ts", "completed_ts", "created_ts", "modified_ts", "s
tarted_ts"]; |
| 48 Polymer({ | 49 Polymer({ |
| 49 is: 'task-list-data', | 50 is: 'task-list-data', |
| 50 | 51 |
| 51 behaviors: [ | 52 behaviors: [ |
| 52 SwarmingBehaviors.CommonBehavior, | 53 SwarmingBehaviors.CommonBehavior, |
| 53 ], | 54 ], |
| 54 | 55 |
| 55 properties: { | 56 properties: { |
| 56 // inputs | 57 // inputs |
| 57 auth_headers: { | 58 auth_headers: { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 pMap["android_devices"].push("0"); | 203 pMap["android_devices"].push("0"); |
| 203 pMap["device_os"].push("none"); | 204 pMap["device_os"].push("none"); |
| 204 pMap["device_type"].push("none"); | 205 pMap["device_type"].push("none"); |
| 205 pMap["user"].push("none"); | 206 pMap["user"].push("none"); |
| 206 | 207 |
| 207 // Custom filter options | 208 // Custom filter options |
| 208 pMap["name"] = []; | 209 pMap["name"] = []; |
| 209 pMap["state"] = ["PENDING", "RUNNING", "PENDING_RUNNING", "COMPLETED", | 210 pMap["state"] = ["PENDING", "RUNNING", "PENDING_RUNNING", "COMPLETED", |
| 210 "COMPLETED_SUCCESS","COMPLETED_FAILURE", "EXPIRED", "TIMED_OUT", | 211 "COMPLETED_SUCCESS","COMPLETED_FAILURE", "EXPIRED", "TIMED_OUT", |
| 211 "BOT_DIED", "CANCELED", "ALL", "DEDUPED"]; | 212 "BOT_DIED", "CANCELED", "ALL", "DEDUPED"]; |
| 212 pMap["abandoned_ts"] = []; | |
| 213 pMap["completed_ts"] = []; | |
| 214 pMap["costs_usd"] = []; | 213 pMap["costs_usd"] = []; |
| 215 pMap["created_ts"] = []; | |
| 216 pMap["deduped_from"] = []; | 214 pMap["deduped_from"] = []; |
| 217 pMap["duration"] = []; | 215 pMap["duration"] = []; |
| 218 pMap["modified_ts"] = []; | |
| 219 pMap["server_versions"] = []; | 216 pMap["server_versions"] = []; |
| 220 pMap["started_ts"] = []; | 217 TIMES.forEach(function(t) { |
| 218 pMap[t] = []; |
| 219 }); |
| 221 | 220 |
| 222 return pMap; | 221 return pMap; |
| 223 }, | 222 }, |
| 224 | 223 |
| 225 _request: function() { | 224 _request: function() { |
| 226 // wait until the user has logged in and the filters have loaded before
requesting this to avoid double or even triple requests. | 225 // wait until the user has logged in and the filters have loaded before
requesting this to avoid double or even triple requests. |
| 227 if (!this.auth_headers || !this.query_params) { | 226 if (!this.auth_headers || !this.query_params) { |
| 228 return; | 227 return; |
| 229 } | 228 } |
| 230 this._getJsonAsync("_list", "/_ah/api/swarming/v1/tasks/list", | 229 this._getJsonAsync("_list", "/_ah/api/swarming/v1/tasks/list", |
| 231 "_busy1", this.auth_headers, this.query_params); | 230 "_busy1", this.auth_headers, this.query_params); |
| 232 }, | 231 }, |
| 233 | 232 |
| 234 _tasks: function() { | 233 _tasks: function() { |
| 235 if (!this._list || !this._list.items) { | 234 if (!this._list || !this._list.items) { |
| 236 return []; | 235 return []; |
| 237 } | 236 } |
| 237 // Date.toString() looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)" |
| 238 // we want to extract the time zone part and append it to the |
| 239 // locale time. |
| 240 var str = (new Date()).toString(); |
| 241 var timeZone = str.substring(str.indexOf("(")) |
| 242 |
| 238 // Do any preprocessing here | 243 // Do any preprocessing here |
| 239 this._list.items.forEach(function(t) { | 244 this._list.items.forEach(function(t) { |
| 240 var tagMap = {}; | 245 var tagMap = {}; |
| 241 t.tags.forEach(function(tag) { | 246 t.tags.forEach(function(tag) { |
| 242 var split = tag.split(":", 1) | 247 var split = tag.split(":", 1) |
| 243 var key = split[0]; | 248 var key = split[0]; |
| 244 var rest = tag.substring(key.length + 1); | 249 var rest = tag.substring(key.length + 1); |
| 245 tagMap[key] = rest; | 250 tagMap[key] = rest; |
| 246 }); | 251 }); |
| 247 t.tagMap = tagMap; | 252 t.tagMap = tagMap; |
| 253 TIMES.forEach(function(time) { |
| 254 if (t[time]) { |
| 255 var d = new Date(t[time]); |
| 256 var locale = d.toLocaleString(); |
| 257 t["human_"+time] = locale + " " + timeZone; |
| 258 } |
| 259 }); |
| 248 }); | 260 }); |
| 249 return this._list.items; | 261 return this._list.items; |
| 250 } | 262 } |
| 251 }); | 263 }); |
| 252 })(); | 264 })(); |
| 253 </script> | 265 </script> |
| 254 </dom-module> | 266 </dom-module> |
| OLD | NEW |