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

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

Issue 2227803002: Mirror filters and sort preferences to url-params (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@use-dimensions
Patch Set: Make limit a visible option 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-list.html
diff --git a/appengine/swarming/elements/res/imp/botlist/bot-list.html b/appengine/swarming/elements/res/imp/botlist/bot-list.html
index 9522227e3afd73e250fbedadaa4bf236473379bf..23137a04167cd8f8ce1b27ab44a11f1232b400bc 100644
--- a/appengine/swarming/elements/res/imp/botlist/bot-list.html
+++ b/appengine/swarming/elements/res/imp/botlist/bot-list.html
@@ -26,6 +26,7 @@
<link rel="import" href="/res/imp/common/sort-toggle.html">
<link rel="import" href="/res/imp/common/swarming-app.html">
+<link rel="import" href="/res/imp/common/url-param.html">
<link rel="import" href="bot-filters.html">
<link rel="import" href="bot-list-data.html">
@@ -75,6 +76,11 @@
}
</style>
+ <url-param name="sort"
+ value="{{_sortstr}}"
+ default_value="id:asc">
+ </url-param>
+
<swarming-app
auth_headers="{{_auth_headers}}"
signed_in="{{_signed_in}}"
@@ -93,21 +99,24 @@
primary_arr="[[_primary_arr]]"
columns="{{_columns}}"
- dimensions="{{_dimensions}}"
+ query_params="{{_query_params}}"
filter="{{_filter}}"
verbose="{{_verbose}}">
</bot-filters>
<bot-list-summary
+ columns="[[_columns]]"
fleet="[[_fleet]]"
- filtered_bots="[[_filteredSortedBots]]">
+ filtered_bots="[[_filteredSortedBots]]"
+ sort="[[_sortstr]]"
+ verbose="[[_verbose]]">
</bot-list-summary>
</div>
<bot-list-data
auth_headers="[[_auth_headers]]"
- dimensions="[[_dimensions]]"
+ query_params="[[_query_params]]"
bots="{{_bots}}"
busy="{{_busy}}"
@@ -272,7 +281,7 @@
disk_space: function(bot) {
var aliased = [];
bot.disks.forEach(function(disk){
- var alias = swarming.humanBytes(disk.mb, swarming.MB);
+ var alias = sk.human.bytes(disk.mb, swarming.MB);
aliased.push(this._applyAlias(disk.mb, disk.id + " "+ alias));
}.bind(this));
if (this._verbose) {
@@ -323,7 +332,7 @@
// If a bot is both dead and quarantined, show the deadness over the
// quarentinedness.
if (bot.is_dead) {
- return "Dead. Last seen " + swarming.diffDate(bot.last_seen_ts) +
+ return "Dead. Last seen " + sk.human.diffDate(bot.last_seen_ts) +
" ago";
}
if (bot.quarantined) {
@@ -411,12 +420,14 @@
// _sort is an Object {name:String, direction:String}.
_sort: {
type: Object,
- value: function() {
- return {
- name: "id",
- direction: "asc",
- };
- }
+ computed: "_makeObject(_sortstr)",
+ },
+
+ // We can't (easily) stick an object in query params, so we use
+ // a serialized string of key:dir and stick that in the query params.
+ // This is deserialized (into _sort) for easier use
+ _sortstr: {
+ type: String,
},
_verbose: {
@@ -487,6 +498,21 @@
return this._columns.indexOf(col) === -1;
},
+ _makeObject: function(sortstr){
+ if (!sortstr) {
+ return undefined;
+ }
+ var pieces = sortstr.split(":");
+ if (pieces.length != 2) {
+ // fail safe
+ return {name: "id", direction:"desc"};
+ }
+ return {
+ name: pieces[0],
+ direction: pieces[1],
+ }
+ },
+
_reRender: function(filter, sort) {
this.$.bot_table.render();
},
@@ -516,8 +542,8 @@
if (!(e && e.detail && e.detail.name)) {
return;
}
- // should trigger __filterAndSort
- this.set("_sort", e.detail);
+ // should trigger the computation of _sort and __filterAndSort
+ this.set("_sortstr", e.detail.name +":"+e.detail.direction);
},
// _stripSpecial removes the special columns and sorts the remaining

Powered by Google App Engine
This is Rietveld 408576698