| OLD | NEW |
| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 var v = deviceColumnMap[col](device); | 492 var v = deviceColumnMap[col](device); |
| 493 v = parseFloat(swarming.alias.unapply(v)) || 0; | 493 v = parseFloat(swarming.alias.unapply(v)) || 0; |
| 494 avgA += v / devsA.length; | 494 avgA += v / devsA.length; |
| 495 }.bind(this)); | 495 }.bind(this)); |
| 496 var devsB = this._devices(botB); | 496 var devsB = this._devices(botB); |
| 497 devsB.forEach(function(device) { | 497 devsB.forEach(function(device) { |
| 498 var v = deviceColumnMap[col](device); | 498 var v = deviceColumnMap[col](device); |
| 499 v = parseFloat(swarming.alias.unapply(v)) || 0; | 499 v = parseFloat(swarming.alias.unapply(v)) || 0; |
| 500 avgB += v / devsB.length; | 500 avgB += v / devsB.length; |
| 501 }.bind(this)); | 501 }.bind(this)); |
| 502 return dir * swarming.naturalCompare(avgA, avgB); | 502 return dir * naturalSort(avgA, avgB); |
| 503 }; | 503 }; |
| 504 } | 504 } |
| 505 | 505 |
| 506 var specialSort = { | 506 var specialSort = { |
| 507 android_devices: function(dir, botA, botB) { | 507 android_devices: function(dir, botA, botB) { |
| 508 // We sort on the number of attached devices. Note that this | 508 // We sort on the number of attached devices. Note that this |
| 509 // may not be the same as android_devices, because _devices().length | 509 // may not be the same as android_devices, because _devices().length |
| 510 // counts all devices plugged into the bot, whereas android_devices | 510 // counts all devices plugged into the bot, whereas android_devices |
| 511 // counts just devices ready for work. | 511 // counts just devices ready for work. |
| 512 var botACol = this._devices(botA).length; | 512 var botACol = this._devices(botA).length; |
| 513 var botBCol = this._devices(botB).length; | 513 var botBCol = this._devices(botB).length; |
| 514 return dir * swarming.naturalCompare(botACol, botBCol); | 514 return dir * naturalSort(botACol, botBCol); |
| 515 }, | 515 }, |
| 516 | 516 |
| 517 battery_health: deviceAverage("battery_health"), | 517 battery_health: deviceAverage("battery_health"), |
| 518 battery_level: deviceAverage("battery_level"), | 518 battery_level: deviceAverage("battery_level"), |
| 519 battery_status: deviceAverage("battery_status"), | 519 battery_status: deviceAverage("battery_status"), |
| 520 battery_temperature: deviceAverage("battery_temperature"), | 520 battery_temperature: deviceAverage("battery_temperature"), |
| 521 battery_voltage: deviceAverage("battery_voltage"), | 521 battery_voltage: deviceAverage("battery_voltage"), |
| 522 device_temperature: deviceAverage("device_temperature"), | 522 device_temperature: deviceAverage("device_temperature"), |
| 523 | 523 |
| 524 bot_temperature: function(dir, botA, botB) { | 524 bot_temperature: function(dir, botA, botB) { |
| 525 // Sort by average temperature. | 525 // Sort by average temperature. |
| 526 var botACol = botA.state.temp.average || 0; | 526 var botACol = botA.state.temp.average || 0; |
| 527 var botBCol = botB.state.temp.average || 0; | 527 var botBCol = botB.state.temp.average || 0; |
| 528 return dir * swarming.naturalCompare(botACol, botBCol); | 528 return dir * naturalSort(botACol, botBCol); |
| 529 }, | 529 }, |
| 530 disk_space: function(dir, botA, botB) { | 530 disk_space: function(dir, botA, botB) { |
| 531 // We sort based on the raw number of MB of the first disk. | 531 // We sort based on the raw number of MB of the first disk. |
| 532 var botACol = botA.disks[0].mb; | 532 var botACol = botA.disks[0].mb; |
| 533 var botBCol = botB.disks[0].mb; | 533 var botBCol = botB.disks[0].mb; |
| 534 return dir * swarming.naturalCompare(botACol, botBCol); | 534 return dir * naturalSort(botACol, botBCol); |
| 535 }, | 535 }, |
| 536 first_seen: function(dir, botA, botB) { | 536 first_seen: function(dir, botA, botB) { |
| 537 var botACol = botA.first_seen_ts; | 537 var botACol = botA.first_seen_ts; |
| 538 var botBCol = botB.first_seen_ts; | 538 var botBCol = botB.first_seen_ts; |
| 539 return dir * swarming.naturalCompare(botACol, botBCol); | 539 return dir * naturalSort(botACol, botBCol); |
| 540 }, | 540 }, |
| 541 last_seen: function(dir, botA, botB) { | 541 last_seen: function(dir, botA, botB) { |
| 542 var botACol = botA.last_seen_ts; | 542 var botACol = botA.last_seen_ts; |
| 543 var botBCol = botB.last_seen_ts; | 543 var botBCol = botB.last_seen_ts; |
| 544 return dir * swarming.naturalCompare(botACol, botBCol) | 544 return dir * naturalSort(botACol, botBCol) |
| 545 }, | 545 }, |
| 546 running_time: function(dir, botA, botB) { | 546 running_time: function(dir, botA, botB) { |
| 547 var botACol = this._state(botA, "running_time") || 0; | 547 var botACol = this._state(botA, "running_time") || 0; |
| 548 var botBCol = this._state(botB, "running_time") || 0; | 548 var botBCol = this._state(botB, "running_time") || 0; |
| 549 return dir * swarming.naturalCompare(botACol, botBCol) | 549 return dir * naturalSort(botACol, botBCol) |
| 550 }, | 550 }, |
| 551 uptime: function(dir, botA, botB) { | 551 uptime: function(dir, botA, botB) { |
| 552 var botACol = this._state(botA, "uptime") || 0; | 552 var botACol = this._state(botA, "uptime") || 0; |
| 553 var botBCol = this._state(botB, "uptime") || 0; | 553 var botBCol = this._state(botB, "uptime") || 0; |
| 554 return dir * swarming.naturalCompare(botACol, botBCol) | 554 return dir * naturalSort(botACol, botBCol) |
| 555 }, | 555 }, |
| 556 }; | 556 }; |
| 557 | 557 |
| 558 Polymer({ | 558 Polymer({ |
| 559 is: 'bot-list', | 559 is: 'bot-list', |
| 560 | 560 |
| 561 // The order behaviors are applied in matters - later ones overwrite | 561 // The order behaviors are applied in matters - later ones overwrite |
| 562 // attributes of earlier ones | 562 // attributes of earlier ones |
| 563 behaviors: [ | 563 behaviors: [ |
| 564 SwarmingBehaviors.BotListBehavior, | 564 SwarmingBehaviors.BotListBehavior, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 return; | 699 return; |
| 700 } | 700 } |
| 701 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu
ery_params); | 701 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu
ery_params); |
| 702 this.$.page_bots.load(url,this._auth_headers); | 702 this.$.page_bots.load(url,this._auth_headers); |
| 703 } | 703 } |
| 704 | 704 |
| 705 }); | 705 }); |
| 706 })(); | 706 })(); |
| 707 </script> | 707 </script> |
| 708 </dom-module> | 708 </dom-module> |
| OLD | NEW |