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 <task-list> | 9 <task-list> |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 </tbody> | 204 </tbody> |
| 205 </table> | 205 </table> |
| 206 </div> | 206 </div> |
| 207 | 207 |
| 208 </swarming-app> | 208 </swarming-app> |
| 209 | 209 |
| 210 </template> | 210 </template> |
| 211 <script> | 211 <script> |
| 212 (function(){ | 212 (function(){ |
| 213 var specialColumns = ["deduped_from", "name", "state"]; | 213 var specialColumns = ["deduped_from", "name", "state"]; |
| 214 | |
| 215 function humanTime(attr) { | |
|
stephana
2016/08/29 13:41:10
There is a lot of abstraction, could you add a com
kjlubick
2016/08/29 13:46:33
Done. This idiom is probably more Go-like, but I
| |
| 216 return function(task) { | |
| 217 return this._attribute(task, "human_" + attr)[0]; | |
| 218 } | |
| 219 } | |
| 214 var columnMap = { | 220 var columnMap = { |
| 221 abandoned_ts: humanTime("abandoned_ts"), | |
| 222 completed_ts: humanTime("completed_ts"), | |
| 215 costs_usd: function(task) { | 223 costs_usd: function(task) { |
| 216 return this._attribute(task, "costs_usd", 0)[0]; | 224 return this._attribute(task, "costs_usd", 0)[0]; |
| 217 }, | 225 }, |
| 226 created_ts: humanTime("created_ts"), | |
| 227 modified_ts: humanTime("modified_ts"), | |
| 228 started_ts: humanTime("started_ts"), | |
| 218 state: function(task) { | 229 state: function(task) { |
| 219 var state = this._attribute(task, "state")[0]; | 230 var state = this._attribute(task, "state")[0]; |
| 220 if (state === "COMPLETED") { | 231 if (state === "COMPLETED") { |
| 221 | 232 |
| 222 if (this._attribute(task, "failure", false)[0]) { | 233 if (this._attribute(task, "failure", false)[0]) { |
| 223 return "COMPLETED (FAILURE)"; | 234 return "COMPLETED (FAILURE)"; |
| 224 } | 235 } |
| 225 var tryNum = this._attribute(task, "try_number", "-1")[0]; | 236 var tryNum = this._attribute(task, "try_number", "-1")[0]; |
| 226 if (tryNum === "0") { | 237 if (tryNum === "0") { |
| 227 return "COMPLETED (DEDUPED)"; | 238 return "COMPLETED (DEDUPED)"; |
| 228 } | 239 } |
| 229 return "COMPLETED (SUCCESS)"; | 240 return "COMPLETED (SUCCESS)"; |
| 230 } | 241 } |
| 231 return state; | 242 return state; |
| 232 }, | 243 }, |
| 233 }; | 244 }; |
| 234 var headerMap = { | 245 var headerMap = { |
| 235 "user": "Requesting User", | 246 "user": "Requesting User", |
| 236 }; | 247 }; |
| 237 var specialSort = {}; | 248 |
| 249 function sortableTime(attr) { | |
| 250 // sort times based on the string they come with, formatted like | |
| 251 // "2016-08-16T13:12:40.606300" which sorts correctly. Locale time | |
| 252 // (used in the columns), does not. | |
| 253 return function(dir, a, b) { | |
| 254 var aCol = this._attribute(a, attr)[0]; | |
| 255 var bCol = this._attribute(b, attr)[0]; | |
| 256 | |
| 257 return dir * swarming.naturalCompare(aCol, bCol); | |
| 258 } | |
| 259 } | |
| 260 var specialSort = { | |
| 261 abandoned_ts: sortableTime("abandoned_ts"), | |
| 262 completed_ts: sortableTime("completed_ts"), | |
| 263 created_ts: sortableTime("created_ts"), | |
| 264 modified_ts: sortableTime("modified_ts"), | |
| 265 started_ts: sortableTime("started_ts"), | |
| 266 }; | |
| 238 | 267 |
| 239 Polymer({ | 268 Polymer({ |
| 240 is: 'task-list', | 269 is: 'task-list', |
| 241 behaviors: [ | 270 behaviors: [ |
| 242 SwarmingBehaviors.DynamicTableBehavior, | 271 SwarmingBehaviors.DynamicTableBehavior, |
| 243 ], | 272 ], |
| 244 | 273 |
| 245 properties: { | 274 properties: { |
| 246 client_id: { | 275 client_id: { |
| 247 type: String, | 276 type: String, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 if (state === "RUNNING" || state === "PENDING") { | 375 if (state === "RUNNING" || state === "PENDING") { |
| 347 return "pending"; | 376 return "pending"; |
| 348 } | 377 } |
| 349 return ""; | 378 return ""; |
| 350 } | 379 } |
| 351 | 380 |
| 352 }); | 381 }); |
| 353 })(); | 382 })(); |
| 354 </script> | 383 </script> |
| 355 </dom-module> | 384 </dom-module> |
| OLD | NEW |