Chromium Code Reviews| 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 } |
| 238 // Do any preprocessing here | 237 // Do any preprocessing here |
| 239 this._list.items.forEach(function(t) { | 238 this._list.items.forEach(function(t) { |
| 240 var tagMap = {}; | 239 var tagMap = {}; |
| 241 t.tags.forEach(function(tag) { | 240 t.tags.forEach(function(tag) { |
| 242 var split = tag.split(":", 1) | 241 var split = tag.split(":", 1) |
| 243 var key = split[0]; | 242 var key = split[0]; |
| 244 var rest = tag.substring(key.length + 1); | 243 var rest = tag.substring(key.length + 1); |
| 245 tagMap[key] = rest; | 244 tagMap[key] = rest; |
| 246 }); | 245 }); |
| 247 t.tagMap = tagMap; | 246 t.tagMap = tagMap; |
| 247 TIMES.forEach(function(time) { | |
| 248 if (t[time]) { | |
| 249 var d = new Date(t[time]); | |
| 250 // d.toString looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)" | |
| 251 // we want to extract the time zone part and append it to the | |
| 252 // locale time. | |
| 253 var str = d.toString(); | |
| 254 var timeZone = str.substring(str.indexOf("(")) | |
|
jcgregorio
2016/08/29 13:28:14
The timezone is always going to be the same, extra
kjlubick
2016/08/29 13:36:49
But what if this code had been running at a partic
| |
| 255 var locale = d.toLocaleString(); | |
| 256 t["human_"+time] = locale + " " + timeZone; | |
| 257 } | |
| 258 }); | |
| 248 }); | 259 }); |
| 249 return this._list.items; | 260 return this._list.items; |
| 250 } | 261 } |
| 251 }); | 262 }); |
| 252 })(); | 263 })(); |
| 253 </script> | 264 </script> |
| 254 </dom-module> | 265 </dom-module> |
| OLD | NEW |