Chromium Code Reviews| Index: appengine/swarming/elements/res/imp/tasklist/task-list.html |
| diff --git a/appengine/swarming/elements/res/imp/tasklist/task-list.html b/appengine/swarming/elements/res/imp/tasklist/task-list.html |
| index bf61fcbeefe81459b247cd909741b7d2d19f2c65..7f6c3fa2355f602d6034b8eaa33cb7e16c7b9d06 100644 |
| --- a/appengine/swarming/elements/res/imp/tasklist/task-list.html |
| +++ b/appengine/swarming/elements/res/imp/tasklist/task-list.html |
| @@ -211,10 +211,21 @@ |
| <script> |
| (function(){ |
| var specialColumns = ["deduped_from", "name", "state"]; |
| + |
| + 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
|
| + return function(task) { |
| + return this._attribute(task, "human_" + attr)[0]; |
| + } |
| + } |
| var columnMap = { |
| + abandoned_ts: humanTime("abandoned_ts"), |
| + completed_ts: humanTime("completed_ts"), |
| costs_usd: function(task) { |
| return this._attribute(task, "costs_usd", 0)[0]; |
| }, |
| + created_ts: humanTime("created_ts"), |
| + modified_ts: humanTime("modified_ts"), |
| + started_ts: humanTime("started_ts"), |
| state: function(task) { |
| var state = this._attribute(task, "state")[0]; |
| if (state === "COMPLETED") { |
| @@ -234,7 +245,25 @@ |
| var headerMap = { |
| "user": "Requesting User", |
| }; |
| - var specialSort = {}; |
| + |
| + function sortableTime(attr) { |
| + // sort times based on the string they come with, formatted like |
| + // "2016-08-16T13:12:40.606300" which sorts correctly. Locale time |
| + // (used in the columns), does not. |
| + return function(dir, a, b) { |
| + var aCol = this._attribute(a, attr)[0]; |
| + var bCol = this._attribute(b, attr)[0]; |
| + |
| + return dir * swarming.naturalCompare(aCol, bCol); |
| + } |
| + } |
| + var specialSort = { |
| + abandoned_ts: sortableTime("abandoned_ts"), |
| + completed_ts: sortableTime("completed_ts"), |
| + created_ts: sortableTime("created_ts"), |
| + modified_ts: sortableTime("modified_ts"), |
| + started_ts: sortableTime("started_ts"), |
| + }; |
| Polymer({ |
| is: 'task-list', |