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

Side by Side Diff: appengine/swarming/elements/build/elements.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 | « no previous file | appengine/swarming/elements/res/imp/tasklist/task-list.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html><html><head><!-- 1 <!DOCTYPE html><html><head><!--
2 @license 2 @license
3 Copyright (c) 2016 The Polymer Project Authors. All rights reserved. 3 Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt 4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also 7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 --><!-- 9 --><!--
10 @license 10 @license
(...skipping 24233 matching lines...) Expand 10 before | Expand all | Expand 10 after
24244 "_busy1", this.auth_headers, this.query_params); 24244 "_busy1", this.auth_headers, this.query_params);
24245 }, 24245 },
24246 24246
24247 _tasks: function() { 24247 _tasks: function() {
24248 if (!this._list || !this._list.items) { 24248 if (!this._list || !this._list.items) {
24249 return []; 24249 return [];
24250 } 24250 }
24251 // Date.toString() looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)" 24251 // Date.toString() looks like "Mon Aug 29 2016 09:03:41 GMT-0400 (EDT)"
24252 // we want to extract the time zone part and append it to the 24252 // we want to extract the time zone part and append it to the
24253 // locale time. 24253 // locale time.
24254 var str = (new Date()).toString(); 24254 var now = new Date();
24255 var str = now.toString();
24255 var timeZone = str.substring(str.indexOf("(")) 24256 var timeZone = str.substring(str.indexOf("("))
24256 24257
24257 // Do any preprocessing here 24258 // Do any preprocessing here
24258 this._list.items.forEach(function(t) { 24259 this._list.items.forEach(function(t) {
24259 var tagMap = {}; 24260 var tagMap = {};
24260 t.tags.forEach(function(tag) { 24261 t.tags.forEach(function(tag) {
24261 var split = tag.split(":", 1) 24262 var split = tag.split(":", 1)
24262 var key = split[0]; 24263 var key = split[0];
24263 var rest = tag.substring(key.length + 1); 24264 var rest = tag.substring(key.length + 1);
24264 tagMap[key] = rest; 24265 tagMap[key] = rest;
24265 }); 24266 });
24266 t.tagMap = tagMap; 24267 t.tagMap = tagMap;
24267 TIMES.forEach(function(time) { 24268 TIMES.forEach(function(time) {
24268 if (t[time]) { 24269 if (t[time]) {
24269 var d = new Date(t[time]); 24270 t[time] = new Date(t[time]);
24270 var locale = d.toLocaleString(); 24271 var locale = t[time].toLocaleString();
24271 t["human_"+time] = locale + " " + timeZone; 24272 t["human_"+time] = locale + " " + timeZone;
24272 } 24273 }
24273 }); 24274 });
24275 // Running tasks have no duration set, so we can figure it out.
24276 if (!t.duration && t.state === "RUNNING" && t.started_ts){
24277 t.duration = (now - t.started_ts) / 1000;
24278 }
24279 // Make the duration human readable
24280 if (t.duration){
24281 t.human_duration = sk.human.strDuration(t.duration);
24282 }
24274 }); 24283 });
24275 return this._list.items; 24284 return this._list.items;
24276 } 24285 }
24277 }); 24286 });
24278 })(); 24287 })();
24279 </script> 24288 </script>
24280 </dom-module> 24289 </dom-module>
24281 <dom-module id="task-list" assetpath="/res/imp/tasklist/"> 24290 <dom-module id="task-list" assetpath="/res/imp/tasklist/">
24282 <template> 24291 <template>
24283 <style include="iron-flex iron-flex-alignment iron-positioning swarming-app- style dynamic-table-style"> 24292 <style include="iron-flex iron-flex-alignment iron-positioning swarming-app- style dynamic-table-style">
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
24389 </table> 24398 </table>
24390 </div> 24399 </div>
24391 24400
24392 </swarming-app> 24401 </swarming-app>
24393 24402
24394 </template> 24403 </template>
24395 <script> 24404 <script>
24396 (function(){ 24405 (function(){
24397 var specialColumns = ["deduped_from", "name", "state"]; 24406 var specialColumns = ["deduped_from", "name", "state"];
24398 24407
24408 // Given a time attribute like "abandoned_ts", humanTime returns a function
24409 // that returns the human-friendly version of that attribute. The human
24410 // friendly time was created in task-list-data.
24399 function humanTime(attr) { 24411 function humanTime(attr) {
24400 return function(task) { 24412 return function(task) {
24401 return this._attribute(task, "human_" + attr)[0]; 24413 return this._attribute(task, "human_" + attr)[0];
24402 } 24414 }
24403 } 24415 }
24404 var columnMap = { 24416 var columnMap = {
24405 abandoned_ts: humanTime("abandoned_ts"), 24417 abandoned_ts: humanTime("abandoned_ts"),
24406 completed_ts: humanTime("completed_ts"), 24418 completed_ts: humanTime("completed_ts"),
24407 costs_usd: function(task) { 24419 costs_usd: function(task) {
24408 return this._attribute(task, "costs_usd", 0)[0]; 24420 return this._attribute(task, "costs_usd", 0)[0];
24409 }, 24421 },
24410 created_ts: humanTime("created_ts"), 24422 created_ts: humanTime("created_ts"),
24423 duration: humanTime("duration"),
24411 modified_ts: humanTime("modified_ts"), 24424 modified_ts: humanTime("modified_ts"),
24412 started_ts: humanTime("started_ts"), 24425 started_ts: humanTime("started_ts"),
24413 state: function(task) { 24426 state: function(task) {
24414 var state = this._attribute(task, "state")[0]; 24427 var state = this._attribute(task, "state")[0];
24415 if (state === "COMPLETED") { 24428 if (state === "COMPLETED") {
24416 24429
24417 if (this._attribute(task, "failure", false)[0]) { 24430 if (this._attribute(task, "failure", false)[0]) {
24418 return "COMPLETED (FAILURE)"; 24431 return "COMPLETED (FAILURE)";
24419 } 24432 }
24420 var tryNum = this._attribute(task, "try_number", "-1")[0]; 24433 var tryNum = this._attribute(task, "try_number", "-1")[0];
24421 if (tryNum === "0") { 24434 if (tryNum === "0") {
24422 return "COMPLETED (DEDUPED)"; 24435 return "COMPLETED (DEDUPED)";
24423 } 24436 }
24424 return "COMPLETED (SUCCESS)"; 24437 return "COMPLETED (SUCCESS)";
24425 } 24438 }
24426 return state; 24439 return state;
24427 }, 24440 },
24428 }; 24441 };
24429 var headerMap = { 24442 var headerMap = {
24430 "user": "Requesting User", 24443 "user": "Requesting User",
24431 }; 24444 };
24432 24445
24446 // Given a time attribute like "abandoned_ts", sortableTime returns a functi on
24447 // that compares the tasks based on the attribute. This is used for sorting .
24433 function sortableTime(attr) { 24448 function sortableTime(attr) {
24434 // sort times based on the string they come with, formatted like 24449 // sort times based on the string they come with, formatted like
24435 // "2016-08-16T13:12:40.606300" which sorts correctly. Locale time 24450 // "2016-08-16T13:12:40.606300" which sorts correctly. Locale time
24436 // (used in the columns), does not. 24451 // (used in the columns), does not.
24437 return function(dir, a, b) { 24452 return function(dir, a, b) {
24438 var aCol = this._attribute(a, attr)[0]; 24453 var aCol = this._attribute(a, attr)[0];
24439 var bCol = this._attribute(b, attr)[0]; 24454 var bCol = this._attribute(b, attr)[0];
24440 24455
24441 return dir * swarming.naturalCompare(aCol, bCol); 24456 return dir * (aCol - bCol);
24442 } 24457 }
24443 } 24458 }
24444 var specialSort = { 24459 var specialSort = {
24445 abandoned_ts: sortableTime("abandoned_ts"), 24460 abandoned_ts: sortableTime("abandoned_ts"),
24446 completed_ts: sortableTime("completed_ts"), 24461 completed_ts: sortableTime("completed_ts"),
24447 created_ts: sortableTime("created_ts"), 24462 created_ts: sortableTime("created_ts"),
24463 duration: sortableTime("duration"),
24448 modified_ts: sortableTime("modified_ts"), 24464 modified_ts: sortableTime("modified_ts"),
24449 started_ts: sortableTime("started_ts"), 24465 started_ts: sortableTime("started_ts"),
24450 }; 24466 };
24451 24467
24452 Polymer({ 24468 Polymer({
24453 is: 'task-list', 24469 is: 'task-list',
24454 behaviors: [ 24470 behaviors: [
24455 SwarmingBehaviors.DynamicTableBehavior, 24471 SwarmingBehaviors.DynamicTableBehavior,
24456 ], 24472 ],
24457 24473
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
24535 return undefined; 24551 return undefined;
24536 } 24552 }
24537 return task.tagMap[col]; 24553 return task.tagMap[col];
24538 }, 24554 },
24539 24555
24540 _taskLink: function(taskId) { 24556 _taskLink: function(taskId) {
24541 if (!taskId) { 24557 if (!taskId) {
24542 return undefined; 24558 return undefined;
24543 } 24559 }
24544 // TODO(kjlubick) Make this point to /newui/ when appropriate. 24560 // TODO(kjlubick) Make this point to /newui/ when appropriate.
24545 return "/restricted/task/"+taskId; 24561 return "/user/task/"+taskId;
24546 }, 24562 },
24547 24563
24548 _taskClass: function(task) { 24564 _taskClass: function(task) {
24549 var state = this._column("state", task); 24565 var state = this._column("state", task);
24550 if (state === "CANCELED" ||state === "TIMED_OUT" || state === "EXPIRED") { 24566 if (state === "CANCELED" ||state === "TIMED_OUT" || state === "EXPIRED") {
24551 return "exception"; 24567 return "exception";
24552 } 24568 }
24553 if (state === "BOT_DIED") { 24569 if (state === "BOT_DIED") {
24554 return "died"; 24570 return "died";
24555 } 24571 }
24556 if (state === "COMPLETED (FAILURE)") { 24572 if (state === "COMPLETED (FAILURE)") {
24557 return "failed"; 24573 return "failed";
24558 } 24574 }
24559 if (state === "RUNNING" || state === "PENDING") { 24575 if (state === "RUNNING" || state === "PENDING") {
24560 return "pending"; 24576 return "pending";
24561 } 24577 }
24562 return ""; 24578 return "";
24563 } 24579 }
24564 24580
24565 }); 24581 });
24566 })(); 24582 })();
24567 </script> 24583 </script>
24568 </dom-module></div></body></html> 24584 </dom-module></div></body></html>
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/elements/res/imp/tasklist/task-list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698