Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: appengine/swarming/elements/res/imp/tasklist/task-list-data.html

Issue 2297853002: Make durations look nice on the task list (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 "_busy1", this.auth_headers, this.query_params); 230 "_busy1", this.auth_headers, this.query_params);
231 }, 231 },
232 232
233 _tasks: function() { 233 _tasks: function() {
234 if (!this._list || !this._list.items) { 234 if (!this._list || !this._list.items) {
235 return []; 235 return [];
236 } 236 }
237 // Date.toString() looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)" 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 238 // we want to extract the time zone part and append it to the
239 // locale time. 239 // locale time.
240 var str = (new Date()).toString(); 240 var now = new Date();
241 var str = now.toString();
241 var timeZone = str.substring(str.indexOf("(")) 242 var timeZone = str.substring(str.indexOf("("))
242 243
243 // Do any preprocessing here 244 // Do any preprocessing here
244 this._list.items.forEach(function(t) { 245 this._list.items.forEach(function(t) {
245 var tagMap = {}; 246 var tagMap = {};
246 t.tags.forEach(function(tag) { 247 t.tags.forEach(function(tag) {
247 var split = tag.split(":", 1) 248 var split = tag.split(":", 1)
248 var key = split[0]; 249 var key = split[0];
249 var rest = tag.substring(key.length + 1); 250 var rest = tag.substring(key.length + 1);
250 tagMap[key] = rest; 251 tagMap[key] = rest;
251 }); 252 });
252 t.tagMap = tagMap; 253 t.tagMap = tagMap;
253 TIMES.forEach(function(time) { 254 TIMES.forEach(function(time) {
254 if (t[time]) { 255 if (t[time]) {
255 var d = new Date(t[time]); 256 t[time] = new Date(t[time]);
256 var locale = d.toLocaleString(); 257 var locale = t[time].toLocaleString();
257 t["human_"+time] = locale + " " + timeZone; 258 t["human_"+time] = locale + " " + timeZone;
258 } 259 }
259 }); 260 });
261 // Running tasks have no duration set, so we can figure it out.
262 if (!t.duration && t.state === "RUNNING" && t.started_ts){
263 t.duration = (now - t.started_ts) / 1000;
264 }
265 // Make the duration human readable
266 if (t.duration){
267 t.human_duration = sk.human.strDuration(t.duration);
268 }
260 }); 269 });
261 return this._list.items; 270 return this._list.items;
262 } 271 }
263 }); 272 });
264 })(); 273 })();
265 </script> 274 </script>
266 </dom-module> 275 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698