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

Unified Diff: appengine/swarming/elements/res/imp/common/pageable-data.html

Issue 2375963003: Move bot-list and task-list to use pageable-data (Closed) Base URL: git@github.com:luci/luci-py@limit-tasks
Patch Set: rename 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/common/pageable-data.html
diff --git a/appengine/swarming/elements/res/imp/common/pageable-data.html b/appengine/swarming/elements/res/imp/common/pageable-data.html
index 392c754e564faf9722ecc961a00642d313a98ef4..48356aa5466e5b56a40a80eb981cc6ddfeb60319 100644
--- a/appengine/swarming/elements/res/imp/common/pageable-data.html
+++ b/appengine/swarming/elements/res/imp/common/pageable-data.html
@@ -34,8 +34,9 @@
clear(): Reset the element, emptying output. page() will not work until
a call to load() has been made.
- load(url, headers, pageSize): Initialize the element and make a call to
- the server for the first batch of data.
+ load(url, headers, [pageSize]): Initialize the element and make a call to
+ the server for the first batch of data. If [pageSize] is omitted, the
+ server default (or those specified in the url) will be used
page(): Must be called after a call to load(). Fetch the next batch of
data from the server.
@@ -108,6 +109,7 @@
clear: function() {
this.set("output", []);
this._cursor = null;
+ this._url = "";
},
load: function(url, headers, pageSize) {
@@ -119,7 +121,8 @@
}
this._url = url;
this._headers = headers;
- this._page_size = pageSize || 50;
+ this._page_size = pageSize;
+ this._cursor = null;
this.page();
},
@@ -133,14 +136,19 @@
}
this.set("busy", true);
- var url = this._url + "&limit=" + this._page_size;
+ var url = this._url;
+ if (this._page_size) {
+ url += "&limit=" + this._page_size;
+ }
if (this._cursor) {
url += "&cursor=" + this._cursor;
}
sk.request("GET", url, "", this._headers).then(JSON.parse).then(function(json){
var vals = this.parse(json);
- if (!this.output) {
+ // !this._cursor means this is our first load and we should empty the
+ // array
+ if (!this._cursor || !this.output) {
this.set("output", vals);
} else {
this.push("output", ...vals);

Powered by Google App Engine
This is Rietveld 408576698