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

Side by Side Diff: appengine/swarming/elements/build/elements.html

Issue 2306103002: Add aliases to bot-page and refactor duplicated code (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@fix-buttons
Patch Set: rebase 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 <!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 23256 matching lines...) Expand 10 before | Expand all | Expand 10 after
23267 // pMap will have a list of columns to available values (primary key 23267 // pMap will have a list of columns to available values (primary key
23268 // to secondary values). This includes bot dimensions, but also 23268 // to secondary values). This includes bot dimensions, but also
23269 // includes state like disk_space, quarantined, busy, etc. 23269 // includes state like disk_space, quarantined, busy, etc.
23270 dimensions = dimensions.bots_dimensions; 23270 dimensions = dimensions.bots_dimensions;
23271 23271
23272 var pMap = {}; 23272 var pMap = {};
23273 dimensions.forEach(function(d){ 23273 dimensions.forEach(function(d){
23274 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(d.key) === -1) { 23274 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(d.key) === -1) {
23275 // value is an array of all seen values for the dimension d.key 23275 // value is an array of all seen values for the dimension d.key
23276 pMap[d.key] = d.value; 23276 pMap[d.key] = d.value;
23277 } else if (d.key === "gpu") {
23278 var gpus = [];
23279 d.value.forEach(function(g){
23280 var alias = swarming.alias.gpu(g);
23281 if (alias !== "unknown") {
23282 gpus.push(swarming.alias.apply(g, alias));
23283 } else {
23284 gpus.push(g);
23285 }
23286 }.bind(this));
23287 pMap["gpu"] = gpus;
23288 } else if (d.key === "device_type") {
23289 var devs = [];
23290 d.value.forEach(function(dt){
23291 var alias = swarming.alias.android(dt);
23292 if (alias !== "unknown") {
23293 devs.push(swarming.alias.apply(dt, alias));
23294 } else {
23295 devs.push(dt);
23296 }
23297 }.bind(this));
23298 pMap["device_type"] = devs;
23299 } else { 23277 } else {
23300 console.log("Unknown alias type: ", d); 23278 var aliased = [];
23279 d.value.forEach(function(value){
23280 aliased.push(swarming.alias.apply(value, d.key));
23281 });
23282 pMap[d.key] = aliased;
23301 } 23283 }
23302 }); 23284 });
23303 23285
23304 // Add some options that might not show up. 23286 // Add some options that might not show up.
23305 pMap["android_devices"].push("0"); 23287 pMap["android_devices"].push("0");
23306 pMap["device_os"].push("none"); 23288 pMap["device_os"].push("none");
23307 pMap["device_type"].push("none"); 23289 pMap["device_type"].push("none");
23308 23290
23309 pMap["id"] = []; 23291 pMap["id"] = [];
23310 23292
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
24278 }); 24260 });
24279 }); 24261 });
24280 24262
24281 // Turn the Map<Object,Map<Boolean>> into a Map<Object,Array<String>> 24263 // Turn the Map<Object,Map<Boolean>> into a Map<Object,Array<String>>
24282 // with all of the aliases applied. 24264 // with all of the aliases applied.
24283 var pMap = {}; 24265 var pMap = {};
24284 for (key in map) { 24266 for (key in map) {
24285 var values = Object.keys(map[key]); 24267 var values = Object.keys(map[key]);
24286 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(key) === -1) { 24268 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(key) === -1) {
24287 pMap[key] = values; 24269 pMap[key] = values;
24288 } else if (key === "gpu") {
24289 var gpus = [];
24290 values.forEach(function(g){
24291 var alias = swarming.alias.gpu(g);
24292 if (alias !== "unknown") {
24293 gpus.push(swarming.alias.apply(g, alias));
24294 } else {
24295 gpus.push(g);
24296 }
24297 }.bind(this));
24298 pMap["gpu"] = gpus;
24299 } else if (key === "device_type") {
24300 var devs = [];
24301 values.forEach(function(dt){
24302 var alias = swarming.alias.android(dt);
24303 if (alias !== "unknown") {
24304 devs.push(swarming.alias.apply(dt, alias));
24305 } else {
24306 devs.push(dt);
24307 }
24308 }.bind(this));
24309 pMap["device_type"] = devs;
24310 } else { 24270 } else {
24311 console.log("Unknown alias type: ", d); 24271 var aliased = [];
24272 values.forEach(function(value){
24273 aliased.push(swarming.alias.apply(value, key));
24274 });
24275 pMap[key] = aliased;
24312 } 24276 }
24313 } 24277 }
24314 24278
24315 // Add some options that might not show up. 24279 // Add some options that might not show up.
24316 pMap["android_devices"].push("0"); 24280 pMap["android_devices"].push("0");
24317 pMap["device_os"].push("none"); 24281 pMap["device_os"].push("none");
24318 pMap["device_type"].push("none"); 24282 pMap["device_type"].push("none");
24319 pMap["user"].push("none"); 24283 pMap["user"].push("none");
24320 24284
24321 // Custom filter options 24285 // Custom filter options
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
26641 bot.disks = []; 26605 bot.disks = [];
26642 for (var i = 0; i < keys.length; i++) { 26606 for (var i = 0; i < keys.length; i++) {
26643 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb}); 26607 bot.disks.push({"id":keys[i], "mb":disks[keys[i]].free_mb});
26644 } 26608 }
26645 // Sort these so the biggest disk comes first. 26609 // Sort these so the biggest disk comes first.
26646 bot.disks.sort(function(a, b) { 26610 bot.disks.sort(function(a, b) {
26647 return b.mb - a.mb; 26611 return b.mb - a.mb;
26648 }); 26612 });
26649 } 26613 }
26650 26614
26615 bot.dimensions = bot.dimensions || [];
26616 bot.dimensions.forEach(function(dim) {
26617 if (swarming.alias.DIMENSIONS_WITH_ALIASES.indexOf(dim.key) !== -1) {
26618 dim.value.forEach(function(value, i){
26619 dim.value[i] = swarming.alias.apply(value, dim.key);
26620 });
26621 }
26622 });
26623
26651 BOT_TIMES.forEach(function(time) { 26624 BOT_TIMES.forEach(function(time) {
26652 if (bot[time]) { 26625 if (bot[time]) {
26653 bot[time] = new Date(bot[time]); 26626 bot[time] = new Date(bot[time]);
26654 bot["human_"+time] = formatDate(bot[time]); 26627 bot["human_"+time] = formatDate(bot[time]);
26655 } 26628 }
26656 }); 26629 });
26657 return bot; 26630 return bot;
26658 }, 26631 },
26659 26632
26660 _parseEvents: function(events) { 26633 _parseEvents: function(events) {
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
27179 }, 27152 },
27180 27153
27181 _toggleState: function() { 27154 _toggleState: function() {
27182 this.set("_show_state", !this._show_state); 27155 this.set("_show_state", !this._show_state);
27183 } 27156 }
27184 27157
27185 }); 27158 });
27186 })(); 27159 })();
27187 </script> 27160 </script>
27188 </dom-module></div></body></html> 27161 </dom-module></div></body></html>
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/elements/build/js/js.js » ('j') | appengine/swarming/elements/res/js/alias.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698