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

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

Issue 2408743002: Move elements/ to ui/ (Closed)
Patch Set: rebase again Created 4 years, 2 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
deleted file mode 100644
index be6962a32707c75ecc40ec761379c352e127cdb5..0000000000000000000000000000000000000000
--- a/appengine/swarming/elements/res/imp/botlist/bot-filters.html
+++ /dev/null
@@ -1,302 +0,0 @@
-<!--
- Copyright 2016 The LUCI Authors. All rights reserved.
- Use of this source code is governed under the Apache License, Version 2.0
- that can be found in the LICENSE file.
-
- This in an HTML Import-able file that contains the definition
- of the following elements:
-
- <bot-filters>
-
- This element allows the user to pick which columns they want to see on the bot
- list and which filters should be applied.
-
- Usage:
-
- <bot-filters></bot-filters>
-
- Properties:
- // inputs
- dimensions: Array<String>, of all valid dimensions.
- primary_map: Object, a mapping of primary keys to secondary items.
- The primary keys are things that can be columns or sorted by. The
- primary values (aka the secondary items) are things that can be filtered
- on. Primary consists of dimensions and state. Secondary contains the
- values primary things can be.
- primary_arr: Array<String>, the display order of the primary keys.
-
- // outputs
- columns: Array<String>, the columns that should be displayed.
- query_params: Object, The query params that will filter the query
- server-side. This can have dimensions:Array<String>, quarantined:String
- and is_dead: String. For example:
- {
- "dimensions": ["pool:Skia", "device_type:Sprout"],
- "quarantined": "FALSE", // optional
- "is_dead": "TRUE", // optional
- }
- For a full list of dimensions in the fleet, see the API call:
- https://[swarming_url]/_ah/api/swarming/v1/bots/dimensions
- 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.
- verbose: Boolean, if the data displayed should be verbose.
-
- Methods:
- None.
-
- Events:
- None.
--->
-
-<link rel="import" href="/res/imp/bower_components/iron-a11y-keys/iron-a11y-keys.html">
-<link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="/res/imp/bower_components/iron-icons/iron-icons.html">
-<link rel="import" href="/res/imp/bower_components/iron-selector/iron-selector.html">
-<link rel="import" href="/res/imp/bower_components/paper-checkbox/paper-checkbox.html">
-<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="/res/imp/common/url-param.html">
-<link rel="import" href="/res/imp/common/query-column-filter-behavior.html">
-
-
-<link rel="import" href="bot-list-shared-behavior.html">
-
-<dom-module id="bot-filters">
- <template>
- <style is="custom-style" include="iron-flex iron-flex-alignment iron-positioning query-column-filter-style">
-
- </style>
-
- <url-param name="f"
- value="{{_filters}}"
- default_values="[]"
- multi>
- </url-param>
- <url-param name="c"
- value="{{columns}}"
- default_values='["id","os","task","status"]'
- multi>
- </url-param>
- <url-param name="q"
- value="{{_query}}"
- default_value="">
- </url-param>
- <url-param name="v"
- value="{{verbose}}">
- </url-param>
- <url-param name="l"
- default_value="100"
- value="{{_limit}}">
- </url-param>
-
- <div class="container horizontal layout">
- <!--
- A common pattern below is to do something like
- checked="[[_columnState(col,columns.*)]]"
- The last argument here allows this value to change if anything in the
- columns array is added or removed. Arrays are weird in Polymer and this is
- the best way to listen to those changes.
- -->
-
- <div class="narrow-down-selector">
- <div>
- <iron-a11y-keys target="[[_filter_input]]" keys="enter" on-keys-pressed="_manuallyAddFilter"></iron-a11y-keys>
- <paper-input id="filter"
- label="Search columns and filters or supply a filter and press enter"
- placeholder="gpu nvidia pool:Chrome"
- value="{{_query::input}}">
- </paper-input>
- </div>
-
- <div class="selector side-by-side"
- title="This shows all bot dimension names and other interesting bot properties. Mark the check box to add as a column. Select the row to see filter options.">
- <iron-selector attr-for-selected="label" selected="{{_primarySelected}}">
- <template is="dom-repeat" items="[[_primaryItems]]" as="item">
- <div class="selectable item horizontal layout" label="[[item]]">
- <!-- No line break here to avoid awkward spaces-->
- <span>[[_beforeBold(item,_query)]]<span class="bold">[[_bold(item,_query)]]</span>[[_afterBold(item,_query)]]</span>
- <span class="flex"></span>
- <paper-checkbox
- noink
- disabled$="[[_cantToggleColumn(item)]]"
- checked="[[_columnState(item,columns.*)]]"
- on-change="_toggleColumn">
- </paper-checkbox>
- </div>
- </template>
- </iron-selector>
- </div>
-
- <div class="selector side-by-side"
- title="These are all options (if any) that the bot list can be filtered on.">
- <template is="dom-repeat" id="secondaryList"
- items="[[_secondaryItems]]" as="item">
- <div class="item horizontal layout" label="[[item]]">
- <!-- No line break here to avoid awkward spaces-->
- <span>[[_beforeBold(item,_query)]]<span class="bold">[[_bold(item,_query)]]</span>[[_afterBold(item,_query)]]</span>
- <span class="flex"></span>
- <iron-icon
- class="icons"
- icon="icons:arrow-forward"
- hidden="[[_cantAddFilter(_primarySelected,item,_filters.*)]]"
- on-tap="_addFilter">
- </iron-icon>
- </div>
- </template>
- </div>
-
- <div class="selector side-by-side"
- title="These filters are AND'd together and applied to all bots in
-the fleet.">
- <template is="dom-repeat" items="[[_filters]]" as="fil">
- <div class="item horizontal layout" label="[[fil]]">
- <span>[[fil]]</span>
- <span class="flex"></span>
- <iron-icon
- class="icons"
- icon="icons:remove-circle-outline"
- hidden="[[_cantRemoveFilter(fil,_filters.*)]]"
- on-tap="_removeFilter">
- </iron-icon>
- </div>
- </template>
- </div>
-
- <div class="side-by-side">
- <paper-checkbox checked="{{verbose}}">Verbose Entries</paper-checkbox>
- <paper-input id="_limit"
- label="Limit Results"
- auto-validate
- min="0"
- max="1000"
- pattern="[0-9]+"
- value="{{_limit}}">
- </paper-input>
- </div>
- </div>
-
- </div>
-
- </template>
- <script>
- (function(){
- // See query-column-filter for more documentation on these properties.
- var filterMap = {
- disk_space: function(bot, space) {
- return true;
- },
- id: function(bot, id) {
- return true;
- },
- status: function(bot, status) {
- if (status === "quarantined") {
- return bot.quarantined;
- } else if (status === "dead") {
- return bot.is_dead;
- } else {
- // Status must be "alive".
- return !bot.quarantined && !bot.is_dead;
- }
- },
- task: function(bot, task) {
- if (task === "idle") {
- return this._taskId(bot) === "idle";
- }
- // Task must be "busy".
- return this._taskId(bot) !== "idle";
- }
- };
-
- Polymer({
- is: "bot-filters",
-
- behaviors: [
- SwarmingBehaviors.BotListBehavior,
- SwarmingBehaviors.QueryColumnFilter,
- ],
-
- properties: {
- // url-param doesn't like columns to be defined in query_column-filter,
- // so we define it here.
- columns: {
- type: Array,
- notify: true,
- },
- query_params: {
- type: Object,
- computed: "_extractQueryParams(dimensions.*,_filters.*, _limit)",
- notify: true,
- },
- verbose: {
- type: Boolean,
- notify: true,
- },
-
- _filter_input: {
- type: Object,
- value: function() {
- return this.$.filter;
- }
- },
-
- // for QueryColumnFilter
- _filterMap: {
- type: Object,
- value: function() {
- var base = this._commonFilters();
- for (var attr in filterMap) {
- base[attr] = filterMap[attr];
- }
- return base;
- },
- }
- },
-
- _cantToggleColumn: function(col) {
- // Don't allow the id column to be removed, as the bot list is basically
- // meaningless without it.
- return !col || col === "id" ;
- },
-
- _extractQueryParams: function() {
- var params = {};
- var dims = [];
- this._filters.forEach(function(f) {
- var split = f.split(this.FILTER_SEP, 1)
- var col = split[0];
- if (this.dimensions.indexOf(col) !== -1) {
- var rest = f.substring(col.length + this.FILTER_SEP.length);
- dims.push(col + this.FILTER_SEP + swarming.alias.unapply(rest))
- } else if (col === "status") {
- var rest = f.substring(col.length + this.FILTER_SEP.length);
- if (rest === "alive") {
- params["is_dead"] = ["FALSE"];
- params["quarantined"] = ["FALSE"];
- } else if (rest === "quarantined") {
- params["quarantined"] = ["TRUE"];
- } else if (rest === "dead") {
- params["is_dead"] = ["TRUE"];
- }
- }
- }.bind(this));
- params["dimensions"] = dims;
- var lim = parseInt(this._limit);
- if (Number.isInteger(lim)) {
- // Clamp the limit
- lim = Math.max(lim, 1);
- lim = Math.min(1000, lim);
- params["limit"] = [lim];
- // not !== because limit could be a string, e.g. "900"
- if (this._limit != lim) {
- this.set("_limit", lim);
- }
- }
- return params;
- }
-
- });
- })();
- </script>
-</dom-module>
« no previous file with comments | « appengine/swarming/elements/res/imp/botlist/DESIGN.md ('k') | appengine/swarming/elements/res/imp/botlist/bot-list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698