Skip to content

Commit ac6cb68

Browse files
committed
pageSize
1 parent 66775fc commit ac6cb68

File tree

1 file changed

+28
-8
lines changed
  • services/static-webserver/client/source/class/osparc/data

1 file changed

+28
-8
lines changed

services/static-webserver/client/source/class/osparc/data/StreamTask.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,33 @@ qx.Class.define("osparc.data.StreamTask", {
3838
streamHref: {
3939
check: "String",
4040
nullable: false,
41+
init: null,
42+
},
43+
44+
end: {
45+
check: "Boolean",
46+
nullable: false,
47+
init: false,
48+
},
49+
50+
pageSize: {
51+
check: "Number",
52+
nullable: false,
53+
// init: 20,
54+
init: 2,
4155
},
4256
},
4357

4458
members: {
4559
_startPolling: function() {
46-
this.__fetchStream();
60+
this.fetchStream();
4761
},
4862

49-
__fetchStream: function() {
63+
fetchStream: function() {
5064
if (!this.isDone()) {
5165
const streamPath = osparc.data.PollTask.extractPathname(this.getStreamHref());
52-
fetch(streamPath)
66+
const url = `${streamPath}?limit=${this.getPageSize()}`;
67+
fetch(url)
5368
.then(resp => {
5469
if (resp.status === 200) {
5570
return resp.json();
@@ -64,11 +79,16 @@ qx.Class.define("osparc.data.StreamTask", {
6479
throw streamData["error"];
6580
}
6681
if ("data" in streamData && streamData["data"]) {
67-
const data = streamData["data"];
68-
this.fireDataEvent("streamReceived", data);
69-
if ("end" in data && data["end"] === false) {
70-
setTimeout(() => this.__fetchStream(), this.getPollInterval());
71-
} else {
82+
const items = streamData["data"]["items"] || [];
83+
const end = streamData["data"]["end"] || false;
84+
if (items.length === 0 && end === false) {
85+
// nothing to stream yet, try again later
86+
setTimeout(() => this.fetchStream(), this.getPollInterval());
87+
return;
88+
}
89+
this.fireDataEvent("streamReceived", items);
90+
if (end) {
91+
this.setEnd(true);
7292
this.setDone(true);
7393
}
7494
return;

0 commit comments

Comments
 (0)