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

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

Issue 2338383002: Refactor prior to adding task-page (Closed) Base URL: git@github.com:luci/luci-py@master
Patch Set: Address nits 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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return; 209 return;
210 } 210 }
211 this._getJsonAsync("_list", "/_ah/api/swarming/v1/tasks/list", 211 this._getJsonAsync("_list", "/_ah/api/swarming/v1/tasks/list",
212 "_busy1", this.auth_headers, this.query_params); 212 "_busy1", this.auth_headers, this.query_params);
213 }, 213 },
214 214
215 _tasks: function() { 215 _tasks: function() {
216 if (!this._list || !this._list.items) { 216 if (!this._list || !this._list.items) {
217 return []; 217 return [];
218 } 218 }
219 // Date.toString() looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)"
220 // we want to extract the time zone part and append it to the
221 // locale time.
222 var now = new Date(); 219 var now = new Date();
223 var str = now.toString();
224 var timeZone = str.substring(str.indexOf("("))
225 220
226 // Do any preprocessing here 221 // Do any preprocessing here
227 this._list.items.forEach(function(t) { 222 this._list.items.forEach(function(t) {
228 var tagMap = {}; 223 var tagMap = {};
224 t.tags = t.tags || [];
229 t.tags.forEach(function(tag) { 225 t.tags.forEach(function(tag) {
230 var split = tag.split(":", 1) 226 var split = tag.split(":", 1)
231 var key = split[0]; 227 var key = split[0];
232 var rest = tag.substring(key.length + 1); 228 var rest = tag.substring(key.length + 1);
233 tagMap[key] = rest; 229 tagMap[key] = rest;
234 }); 230 });
235 t.tagMap = tagMap; 231 t.tagMap = tagMap;
232
236 TIMES.forEach(function(time) { 233 TIMES.forEach(function(time) {
237 if (t[time]) { 234 if (t[time]) {
238 t[time] = new Date(t[time]); 235 t[time] = new Date(t[time]);
239 var locale = t[time].toLocaleString(); 236 t["human_"+time] = sk.human.localeTime(t[time]);
240 t["human_"+time] = locale + " " + timeZone;
241 } 237 }
242 }); 238 });
243 // Running tasks have no duration set, so we can figure it out. 239 // Running tasks have no duration set, so we can figure it out.
244 if (!t.duration && t.state === "RUNNING" && t.started_ts){ 240 if (!t.duration && t.state === "RUNNING" && t.started_ts){
245 t.duration = (now - t.started_ts) / 1000; 241 t.duration = (now - t.started_ts) / 1000;
246 } 242 }
247 // Make the duration human readable 243 // Make the duration human readable
248 if (t.duration){ 244 if (t.duration){
249 t.human_duration = sk.human.strDuration(t.duration); 245 t.human_duration = this._humanDuration(t.duration);
250 } 246 }
251 }); 247 }.bind(this));
252 return this._list.items; 248 return this._list.items;
253 } 249 }
254 }); 250 });
255 })(); 251 })();
256 </script> 252 </script>
257 </dom-module> 253 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list.html ('k') | appengine/swarming/elements/res/js/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698