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

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

Issue 2211163003: Update new botlist to use dimensions endpoint (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@limiting
Patch Set: put demo data in luci-py wiki Created 4 years, 4 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-filters.html
diff --git a/appengine/swarming/elements/res/imp/botlist/bot-filters.html b/appengine/swarming/elements/res/imp/botlist/bot-filters.html
index 2f066f9d3b25f8842fe61a59f4fe1e938b36beb4..06b3d965988dfd7bb0e394ed089d51d8ec35aa6b 100644
--- a/appengine/swarming/elements/res/imp/botlist/bot-filters.html
+++ b/appengine/swarming/elements/res/imp/botlist/bot-filters.html
@@ -26,6 +26,8 @@
// outputs
columns: Array<String>, the columns that should be displayed.
+ dimensions: Array<String>, dimensions formatted like "dim:value", to be
+ used to filter server-side.
filter: Object, an object {filter:Function} where filter will take one param
(bot) and return a Boolean if it should be displayed given the
current filters.
@@ -45,6 +47,7 @@
<link rel="import" href="/res/imp/bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="/res/imp/bower_components/paper-input/paper-input.html">
+<link rel="import" href="bot-list-shared.html">
<dom-module id="bot-filters">
<template>
@@ -206,50 +209,51 @@
</template>
<script>
(function(){
- var FILTER_SEP = " | ";
+ var FILTER_SEP = ":";
// filterMap is a map of primary -> function. The function returns a
// boolean "does the bot (first arg) match the second argument". These
// functions will have "this" be the botlist, and will have access to all
// functions defined in bot-list and bot-list-shared.
var filterMap = {
- cores: function(bot, cores){
- var o = this._cores(bot);
+ android_devices: function(bot, num) {
+ var o = this._attribute(bot, "android_devices", "0");
+ return o.indexOf(num) !== -1;
+ },
+ cores: function(bot, cores) {
+ var o = this._attribute(bot, "cores");
return o.indexOf(cores) !== -1;
},
- cpu: function(bot, cpu){
- var o = this._dimension(bot, "cpu") || ["none"];
+ cpu: function(bot, cpu) {
+ var o = this._attribute(bot, "cpu");
return o.indexOf(cpu) !== -1;
},
- devices: function(bot, device){
- if (device === "none") {
- return this._devices(bot).length === 0;
- }
- // extract the deviceType, if it is not "unknown".
- device = this._unalias(device);
- var found = false;
- this._devices(bot).forEach(function(d) {
- if (this._deviceType(d) === device) {
- found = true;
- }
- }.bind(this));
- return found;
+ device_os: function(bot, os) {
+ var o = this._attribute(bot, "device_os", "none");
+ return o.indexOf(os) !== -1;
},
- gpu: function(bot, gpu){
- var o = this._dimension(bot, "gpu") || ["none"];
+ device_type: function(bot, dt) {
+ var o = this._attribute(bot, "device_type", "none");
+ return o.indexOf(this._unalias(dt)) !== -1;
+ },
+ disk_space: function(bot, space) {
+ return true;
+ },
+ gpu: function(bot, gpu) {
+ var o = this._attribute(bot, "gpu", "none");
return o.indexOf(this._unalias(gpu)) !== -1;
},
id: function(bot, id) {
- return bot.bot_id === id;
+ return true;
},
- os: function(bot, os){
- var o = this._dimension(bot, "os") || ["Unknown"];
+ os: function(bot, os) {
+ var o = this._attribute(bot, "os");
return o.indexOf(os) !== -1;
},
- pool: function(bot, pool){
- var o = this._dimension(bot, "pool") || ["Unknown"];
+ pool: function(bot, pool) {
+ var o = this._attribute(bot, "pool");
return o.indexOf(pool) !== -1;
},
- status: function(bot, status){
+ status: function(bot, status) {
if (status === "quarantined") {
return bot.quarantined;
} else if (status === "dead") {
@@ -302,6 +306,9 @@
Polymer({
is: "bot-filters",
+
+ behaviors: [SwarmingBehaviors.BotListBehavior],
+
properties: {
// input
primary_map: {
@@ -321,6 +328,11 @@
},
notify: true,
},
+ dimensions: {
+ type: Array,
+ computed: "_extractDimensions(DIMENSIONS.*,_filters.*)",
+ notify: true,
+ },
filter: {
type: Object,
computed: "_makeFilter(_filters.*)",
@@ -546,6 +558,19 @@
return item.substring(match.idx + match.part.length);
},
+ _extractDimensions: function() {
+ var dims = []
+ this._filters.forEach(function(f) {
+ var split = f.split(FILTER_SEP, 1)
+ var col = split[0];
+ if (this.DIMENSIONS.indexOf(col) !== -1) {
+ var rest = f.substring(col.length + FILTER_SEP.length);
jcgregorio 2016/08/08 20:54:32 Isn't rest = split[1]?
kjlubick 2016/08/09 12:07:21 In Java, yes. In Go, yes. In Javascript.... no.
jcgregorio 2016/08/09 13:26:13 "gpu:1234:5678".split(":",2) ["gpu", "1234"] So t
+ dims.push(col + FILTER_SEP + this._unalias(rest))
+ };
+ }.bind(this));
+ return dims;
+ }
+
});
})();
</script>

Powered by Google App Engine
This is Rietveld 408576698