| Index: appengine/swarming/elements/res/imp/tasklist/task-list-data.html
|
| diff --git a/appengine/swarming/elements/res/imp/tasklist/task-list-data.html b/appengine/swarming/elements/res/imp/tasklist/task-list-data.html
|
| index f4899eb910575ab220fa6f3c045c5835cec57e2c..1f1ef7cfa8399496747cc80d37a4e260c45ce7aa 100644
|
| --- a/appengine/swarming/elements/res/imp/tasklist/task-list-data.html
|
| +++ b/appengine/swarming/elements/res/imp/tasklist/task-list-data.html
|
| @@ -42,6 +42,8 @@
|
|
|
| <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html">
|
|
|
| +<link rel="import" href="/res/imp/common/common-aliases.html">
|
| +
|
| <dom-module id="task-list-data">
|
| <template>
|
| <iron-ajax id="tasklist"
|
| @@ -52,7 +54,22 @@
|
| last-response="{{_list}}"
|
| loading="{{_busy1}}">
|
| </iron-ajax>
|
| - <!-- TODO(kjlubick): Make more requests (like all tags) -->
|
| +
|
| + <iron-ajax id="tags"
|
| + url="/_ah/api/swarming/v1/tasks/tags"
|
| + headers="[[auth_headers]]"
|
| + handle-as="json"
|
| + last-response="{{_tags}}"
|
| + loading="{{_busy2}}">
|
| + </iron-ajax>
|
| +
|
| + <iron-ajax id="dimensions"
|
| + url="/_ah/api/swarming/v1/bots/dimensions"
|
| + headers="[[auth_headers]]"
|
| + handle-as="json"
|
| + last-response="{{_dimensions}}"
|
| + loading="{{_busy3}}">
|
| + </iron-ajax>
|
|
|
| </template>
|
| <script>
|
| @@ -60,7 +77,10 @@
|
| Polymer({
|
| is: 'task-list-data',
|
|
|
| - behaviors: [SwarmingBehaviors.SwarmingBehavior],
|
| + behaviors: [
|
| + SwarmingBehaviors.SwarmingBehavior,
|
| + SwarmingBehaviors.Aliases,
|
| + ],
|
|
|
| properties: {
|
| // inputs
|
| @@ -72,24 +92,115 @@
|
| type: Object,
|
| },
|
|
|
| - //outputs
|
| + // outputs
|
| busy: {
|
| type: Boolean,
|
| - computed: "_or(_busy1)",
|
| + computed: "_or(_busy1,_busy2,_busy3)",
|
| + notify: true,
|
| + },
|
| + primary_map: {
|
| + type: Object,
|
| + computed: "_primaryMap(_tags,_dimensions,_list)",
|
| + notify: true,
|
| + },
|
| + primary_arr: {
|
| + type: Array,
|
| + computed: "_primaryArr(primary_map)",
|
| notify: true,
|
| },
|
| tasks: {
|
| type: Array,
|
| computed: "_tasks(_list)",
|
| notify: true,
|
| + },
|
| +
|
| + // private
|
| + _dimensions: {
|
| + type: Object,
|
| }
|
| },
|
| +
|
| signIn: function(){
|
| // Auto on iron-ajax means to automatically re-make the request if
|
| // the url or the query params change. Auto does not trigger if the
|
| // [auth] headers change, so we wait until the user is signed in
|
| // before making any requests.
|
| this.$.tasklist.auto = true;
|
| + this.$.tags.auto = true;
|
| + this.$.dimensions.auto = true;
|
| + },
|
| +
|
| + _primaryArr: function(map) {
|
| + var arr = Object.keys(map);
|
| + arr.sort();
|
| + return arr;
|
| + },
|
| +
|
| + _primaryMap: function(tags, dims) {
|
| + tags = (tags && tags.tasks_tags) || [];
|
| + dims = (dims && dims.bots_dimensions) || [];
|
| + // TODO(kjlubick)
|
| + // Take fleet task_tags, add in dimensions from fleet, and tags from tasks.
|
| + var pMap = {};
|
| + tags.forEach(function(t) {
|
| + var values = t.value || [];
|
| + pMap[t.key] = values.filter(function(v) {
|
| + return v;
|
| + });
|
| + });
|
| +
|
| + // augment existing tags with aliased dimensions
|
| + dims.forEach(function(d) {
|
| + var vals = d.value;
|
| + if (pMap[d.key]) {
|
| + var existing = pMap[d.key];
|
| + existing.forEach(function(d) {
|
| + if (vals.indexOf(d) === -1) {
|
| + vals.push(d);
|
| + }
|
| + });
|
| + }
|
| + if (this.DIMENSIONS_WITH_ALIASES.indexOf(d.key) === -1) {
|
| + // value is an array of all seen values for the dimension d.key
|
| + pMap[d.key] = vals;
|
| + } else if (d.key === "gpu") {
|
| + var gpus = [];
|
| + vals.forEach(function(g){
|
| + var alias = this._gpuAlias(g);
|
| + if (alias !== "unknown") {
|
| + gpus.push(this._applyAlias(g, alias));
|
| + } else {
|
| + gpus.push(g);
|
| + }
|
| + }.bind(this));
|
| + pMap["gpu"] = gpus;
|
| + } else if (d.key === "device_type") {
|
| + var devs = [];
|
| + d.value.forEach(function(dt){
|
| + var alias = this._androidAlias(dt);
|
| + if (alias !== "unknown") {
|
| + devs.push(this._applyAlias(dt, alias));
|
| + } else {
|
| + devs.push(dt);
|
| + }
|
| + }.bind(this));
|
| + pMap["device_type"] = devs;
|
| + } else {
|
| + console.log("Unknown alias type: ", d);
|
| + }
|
| + }.bind(this));
|
| +
|
| + // Add some options that might not show up.
|
| + pMap["android_devices"].push("0");
|
| + pMap["device_os"].push("none");
|
| + pMap["device_type"].push("none");
|
| + pMap["user"].push("none");
|
| +
|
| + // Custom filter options
|
| + pMap["name"] = [];
|
| + pMap["state"] = ["RUNNING", "PENDING", "EXPIRED", "TIMED_OUT", "BOT_DIED", "CANCELED", "COMPLETED", "Going", "Not Going", "Exceptional", "Done", "Abandoned"];
|
| +
|
| + return pMap;
|
| },
|
|
|
| _tasks: function() {
|
| @@ -97,6 +208,16 @@
|
| return [];
|
| }
|
| // Do any preprocessing here
|
| + this._list.items.forEach(function(t) {
|
| + var tagMap = {};
|
| + t.tags.forEach(function(tag) {
|
| + var split = tag.split(":", 1)
|
| + var key = split[0];
|
| + var rest = tag.substring(key.length + 1);
|
| + tagMap[key] = rest;
|
| + });
|
| + t.tagMap = tagMap;
|
| + });
|
| return this._list.items;
|
| }
|
| });
|
|
|