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

Unified Diff: appengine/swarming/elements/res/imp/botlist/bot-list-data.html

Issue 2359993002: Medium sized improvements to bot-list and task-list (Closed) Base URL: git@github.com:luci/luci-py@master
Patch Set: fix dangling div 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/imp/botlist/bot-list-data.html
diff --git a/appengine/swarming/elements/res/imp/botlist/bot-list-data.html b/appengine/swarming/elements/res/imp/botlist/bot-list-data.html
index 3219243dfaba58d68eb12a768333d77d4871e195..1d6d6e69189797d0deb51ab61f13db85b7485438 100644
--- a/appengine/swarming/elements/res/imp/botlist/bot-list-data.html
+++ b/appengine/swarming/elements/res/imp/botlist/bot-list-data.html
@@ -66,8 +66,31 @@
<script>
(function(){
+ var AVAILABLE = "available";
var BLACKLIST_DIMENSIONS = ["quarantined", "error"];
+ function aggregateTemps(temps) {
+ if (!temps) {
+ return {};
+ }
+ var zones = [];
+ var avg = 0;
+ for (k in temps) {
+ zones.push(k +" : "+temps[k]);
+ avg += temps[k];
+ }
+ avg = avg / zones.length
+ if (avg) {
+ avg = avg.toFixed(1);
+ } else {
+ avg = "unknown";
+ }
+ return {
+ average: avg,
+ zones: zones.join(" | ") || "unknown",
+ }
+ }
+
Polymer({
is: 'bot-list-data',
@@ -178,7 +201,35 @@
});
}
- });
+ // Make sure every bot has a state.temp object and precompute
+ // average and list of temps by zone if applicable.
+ bot.state.temp = aggregateTemps(bot.state.temp);
+
+ var devices = [];
+ var d = (bot && bot.state && bot.state.devices) || {};
+ // state.devices is like {Serial:Object}, so we need to keep the serial
+ for (key in d) {
+ var o = d[key];
+ o.serial = key;
+ o.okay = (o.state === AVAILABLE);
+ // It is easier to assume all devices on a bot are of the same type
+ // than to pick through the (incomplete) device state and find it.
+ o.device_type = this._dimension(bot, "device_type")[0];
+ devices.push(o);
+ }
+ bot.state.devices = devices;
+ devices.forEach(function(d){
+ d.temp = aggregateTemps(d.temp);
jcgregorio 2016/09/21 19:42:22 Why not do this in the above loop?
kjlubick 2016/09/21 20:05:53 Done.
+ });
+
+ if (bot.last_seen_ts) {
+ bot.last_seen_ts = new Date(bot.last_seen_ts);
+ }
+ if (bot.first_seen_ts) {
+ bot.first_seen_ts = new Date(bot.first_seen_ts);
+ }
+
+ }.bind(this));
return this._list.items;
},

Powered by Google App Engine
This is Rietveld 408576698