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

Side by Side Diff: appengine/swarming/ui/res/imp/botlist/bot-list.html

Issue 2988773002: Fix sorting of status to account for time bot has been dead. (Closed)
Patch Set: Rebuild Created 3 years, 5 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> 9 <bot-list>
10 10
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 }, 330 },
331 battery_voltage: function(){ 331 battery_voltage: function(){
332 return ""; 332 return "";
333 }, 333 },
334 bot_temperature: function(bot){ 334 bot_temperature: function(bot){
335 if (this._verbose) { 335 if (this._verbose) {
336 return bot.state.temp.zones || UNKNOWN; 336 return bot.state.temp.zones || UNKNOWN;
337 } 337 }
338 return bot.state.temp.average || UNKNOWN; 338 return bot.state.temp.average || UNKNOWN;
339 }, 339 },
340 cpu: function(bot) {
341 if (this._verbose) {
342 return this._attribute(bot, "cpu", "none").join(" | ");
343 }
344 return swarming.longest(this._attribute(bot, "cpu", "none"));
345 },
340 device_temperature: function(){ 346 device_temperature: function(){
341 return ""; 347 return "";
342 }, 348 },
343 device_os: function(bot) { 349 device_os: function(bot) {
344 if (this._verbose) { 350 if (this._verbose) {
345 return this._attribute(bot, "device_os", "none").join(" | "); 351 return this._attribute(bot, "device_os", "none").join(" | ");
346 } 352 }
347 // This assumes that all devices hooked up to a bot are the same OS. 353 // This assumes that all devices hooked up to a bot are the same OS.
348 return swarming.longest(this._attribute(bot, "device_os", "none")); 354 return swarming.longest(this._attribute(bot, "device_os", "none"));
349 }, 355 },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 var u = this._state(bot, "running_time"); 405 var u = this._state(bot, "running_time");
400 if (!u) { 406 if (!u) {
401 return "unknown"; 407 return "unknown";
402 } 408 }
403 return sk.human.strDuration(u); 409 return sk.human.strDuration(u);
404 }, 410 },
405 status: function(bot) { 411 status: function(bot) {
406 // If a bot is both dead and quarantined, show the deadness over the 412 // If a bot is both dead and quarantined, show the deadness over the
407 // quarentinedness. 413 // quarentinedness.
408 if (bot.is_dead) { 414 if (bot.is_dead) {
409 return "Dead. Last seen " + sk.human.diffDate(bot.last_seen_ts) + 415 return "Dead. Last seen " + sk.human.diffDate(bot.last_seen_ts) +
410 " ago"; 416 " ago";
411 } 417 }
412 if (bot.quarantined) { 418 if (bot.quarantined) {
413 var msg = this._state(bot, "quarantined"); 419 var msg = this._state(bot, "quarantined");
414 if (msg) { 420 if (msg) {
415 msg = msg[0]; 421 msg = msg[0];
416 }; 422 };
417 // Sometimes, the quarantined message is actually in "error". This 423 // Sometimes, the quarantined message is actually in "error". This
418 // happens when the bot code has thrown an exception. 424 // happens when the bot code has thrown an exception.
419 if (!msg || msg === "true" || msg === true) { 425 if (!msg || msg === "true" || msg === true) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 last_seen: function(dir, botA, botB) { 567 last_seen: function(dir, botA, botB) {
562 var botACol = botA.last_seen_ts; 568 var botACol = botA.last_seen_ts;
563 var botBCol = botB.last_seen_ts; 569 var botBCol = botB.last_seen_ts;
564 return dir * naturalSort(botACol, botBCol) 570 return dir * naturalSort(botACol, botBCol)
565 }, 571 },
566 running_time: function(dir, botA, botB) { 572 running_time: function(dir, botA, botB) {
567 var botACol = this._state(botA, "running_time") || 0; 573 var botACol = this._state(botA, "running_time") || 0;
568 var botBCol = this._state(botB, "running_time") || 0; 574 var botBCol = this._state(botB, "running_time") || 0;
569 return dir * naturalSort(botACol, botBCol) 575 return dir * naturalSort(botACol, botBCol)
570 }, 576 },
577 status: function(dir, botA, botB) {
578 // Case 1: One of the bots is dead, sort dead bot over alive/quarantined bot.
579 if (botA.is_dead !== botB.is_dead) {
580 if (botA.is_dead) {
581 return dir;
582 } else {
583 return -dir;
584 }
585 }
586 // Case 2: Bots match on deadness, quarantinedness, or aliveness
587 // In this case, sort by last seen time.
588 if (botA.is_dead && botB.is_dead ||
589 botA.quarantined && botB.quarantined ||
590 !botA.is_dead && !botB.is_dead && !botA.quarantined && !botB.quarant ined ) {
591 var botACol = botA.last_seen_ts;
592 var botBCol = botB.last_seen_ts;
593 return dir * naturalSort(botACol, botBCol)
594 }
595 // Case 3: One of the bots is quarantined. Sort quarantined bot over al ive bot.
596 if (botA.quarantined) {
597 return dir;
598 }
599 return -dir;
600 },
571 uptime: function(dir, botA, botB) { 601 uptime: function(dir, botA, botB) {
572 var botACol = this._state(botA, "uptime") || 0; 602 var botACol = this._state(botA, "uptime") || 0;
573 var botBCol = this._state(botB, "uptime") || 0; 603 var botBCol = this._state(botB, "uptime") || 0;
574 return dir * naturalSort(botACol, botBCol) 604 return dir * naturalSort(botACol, botBCol)
575 }, 605 },
576 }; 606 };
577 607
578 Polymer({ 608 Polymer({
579 is: 'bot-list', 609 is: 'bot-list',
580 610
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return; 739 return;
710 } 740 }
711 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu ery_params); 741 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu ery_params);
712 this.$.page_bots.load(url,this._auth_headers); 742 this.$.page_bots.load(url,this._auth_headers);
713 } 743 }
714 744
715 }); 745 });
716 })(); 746 })();
717 </script> 747 </script>
718 </dom-module> 748 </dom-module>
OLDNEW
« no previous file with comments | « appengine/swarming/ui/build/elements.html ('k') | appengine/swarming/ui/res/imp/common/swarming-app.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698