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 // Given a time attribute like "abandoned_ts", humanTime returns a function | |
| 216 // that returns the human-friendly version of that attribute. The human | |
| 217 // friendly time was created in task-list-data. | |
| 218 function humanTime(attr) { | |
| 219 return function(task) { | |
| 220 return this._attribute(task, "human_" + attr)[0]; | |
| 221 } | |
| 222 } | |
| 214 var columnMap = { | 223 var columnMap = { |
| 224 abandoned_ts: humanTime("abandoned_ts"), | |
| 225 completed_ts: humanTime("completed_ts"), | |
| 215 costs_usd: function(task) { | 226 costs_usd: function(task) { |
| 216 return this._attribute(task, "costs_usd", 0)[0]; | 227 return this._attribute(task, "costs_usd", 0)[0]; |
| 217 }, | 228 }, |
| 229 created_ts: humanTime("created_ts"), | |
| 230 modified_ts: humanTime("modified_ts"), | |
| 231 started_ts: humanTime("started_ts"), | |
| 218 state: function(task) { | 232 state: function(task) { |
| 219 var state = this._attribute(task, "state")[0]; | 233 var state = this._attribute(task, "state")[0]; |
| 220 if (state === "COMPLETED") { | 234 if (state === "COMPLETED") { |
| 221 | 235 |
| 222 if (this._attribute(task, "failure", false)[0]) { | 236 if (this._attribute(task, "failure", false)[0]) { |
| 223 return "COMPLETED (FAILURE)"; | 237 return "COMPLETED (FAILURE)"; |
| 224 } | 238 } |
| 225 var tryNum = this._attribute(task, "try_number", "-1")[0]; | 239 var tryNum = this._attribute(task, "try_number", "-1")[0]; |
| 226 if (tryNum === "0") { | 240 if (tryNum === "0") { |
| 227 return "COMPLETED (DEDUPED)"; | 241 return "COMPLETED (DEDUPED)"; |
| 228 } | 242 } |
| 229 return "COMPLETED (SUCCESS)"; | 243 return "COMPLETED (SUCCESS)"; |
| 230 } | 244 } |
| 231 return state; | 245 return state; |
| 232 }, | 246 }, |
| 233 }; | 247 }; |
| 234 var headerMap = { | 248 var headerMap = { |
| 235 "user": "Requesting User", | 249 "user": "Requesting User", |
| 236 }; | 250 }; |
| 237 var specialSort = {}; | 251 |
| 252 // Given a time attribute like "abandoned_ts", humanTime returns a function | |
|
jcgregorio
2016/08/29 14:02:44
humanTime -> sortableTime
| |
| 253 // that compares the tasks based on the attribute. This is used for sorting . | |
| 254 function sortableTime(attr) { | |
| 255 // sort times based on the string they come with, formatted like | |
| 256 // "2016-08-16T13:12:40.606300" which sorts correctly. Locale time | |
| 257 // (used in the columns), does not. | |
| 258 return function(dir, a, b) { | |
| 259 var aCol = this._attribute(a, attr)[0]; | |
| 260 var bCol = this._attribute(b, attr)[0]; | |
| 261 | |
| 262 return dir * swarming.naturalCompare(aCol, bCol); | |
| 263 } | |
| 264 } | |
| 265 var specialSort = { | |
| 266 abandoned_ts: sortableTime("abandoned_ts"), | |
| 267 completed_ts: sortableTime("completed_ts"), | |
| 268 created_ts: sortableTime("created_ts"), | |
| 269 modified_ts: sortableTime("modified_ts"), | |
| 270 started_ts: sortableTime("started_ts"), | |
| 271 }; | |
| 238 | 272 |
| 239 Polymer({ | 273 Polymer({ |
| 240 is: 'task-list', | 274 is: 'task-list', |
| 241 behaviors: [ | 275 behaviors: [ |
| 242 SwarmingBehaviors.DynamicTableBehavior, | 276 SwarmingBehaviors.DynamicTableBehavior, |
| 243 ], | 277 ], |
| 244 | 278 |
| 245 properties: { | 279 properties: { |
| 246 client_id: { | 280 client_id: { |
| 247 type: String, | 281 type: String, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 if (state === "RUNNING" || state === "PENDING") { | 380 if (state === "RUNNING" || state === "PENDING") { |
| 347 return "pending"; | 381 return "pending"; |
| 348 } | 382 } |
| 349 return ""; | 383 return ""; |
| 350 } | 384 } |
| 351 | 385 |
| 352 }); | 386 }); |
| 353 })(); | 387 })(); |
| 354 </script> | 388 </script> |
| 355 </dom-module> | 389 </dom-module> |
| OLD | NEW |