Skip to content

Commit 3c45641

Browse files
committed
static
1 parent b531bb5 commit 3c45641

File tree

1 file changed

+45
-43
lines changed
  • services/static-webserver/client/source/class/osparc/store

1 file changed

+45
-43
lines changed

services/static-webserver/client/source/class/osparc/store/Data.js

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,49 @@ qx.Class.define("osparc.store.Data", {
3535
"fileCopied": "qx.event.type.Data",
3636
},
3737

38+
statics: {
39+
getAllItems: async function(locationId, path, cursor, allItems = []) {
40+
if (allItems.length >= 10000) {
41+
const msg = qx.locale.Manager.tr("Oops... more than 10.000 items to be listed here. Maybe it's time to make a folder :).");
42+
osparc.FlashMessenger.logAs(msg, "WARNING");
43+
return allItems;
44+
}
45+
46+
const params = {
47+
url: {
48+
locationId,
49+
}
50+
};
51+
if (path) {
52+
params["url"]["path"] = path;
53+
}
54+
if (cursor) {
55+
params["url"]["cursor"] = cursor;
56+
}
57+
let pagResp = null;
58+
if (path) {
59+
pagResp = await osparc.data.Resources.fetch("storagePaths", cursor ? "getPathsPage" : "getPaths", params);
60+
} else {
61+
pagResp = await osparc.data.Resources.fetch("storagePaths", cursor ? "getDatasetsPage" : "getDatasets", params);
62+
}
63+
64+
let nextCursor = null;
65+
if (pagResp) {
66+
if (pagResp["items"]) {
67+
allItems.push(...pagResp["items"]);
68+
}
69+
if (pagResp["next_page"]) {
70+
nextCursor = pagResp["next_page"];
71+
}
72+
}
73+
74+
if (nextCursor) {
75+
return this.getAllItems(locationId, path, nextCursor, allItems);
76+
}
77+
return allItems;
78+
},
79+
},
80+
3881
members: {
3982
__locationsCached: null,
4083
__datasetsByLocationCached: null,
@@ -99,7 +142,7 @@ qx.Class.define("osparc.store.Data", {
99142
}
100143

101144
try {
102-
const allItems = await this.__getAllItems(locationId);
145+
const allItems = await this.self().getAllItems(locationId);
103146
this.__datasetsByLocationCached[locationId] = allItems;
104147
data["items"] = allItems;
105148
return data;
@@ -116,55 +159,14 @@ qx.Class.define("osparc.store.Data", {
116159
}
117160

118161
try {
119-
const allItems = await this.__getAllItems(locationId, path);
162+
const allItems = await this.self().getAllItems(locationId, path);
120163
return allItems;
121164
} catch (err) {
122165
console.error(err);
123166
return [];
124167
}
125168
},
126169

127-
__getAllItems: async function(locationId, path, cursor, allItems = []) {
128-
if (allItems.length >= 10000) {
129-
const msg = qx.locale.Manager.tr("Oops... more than 10.000 items to be listed here. Maybe it's time to make a folder :).");
130-
osparc.FlashMessenger.logAs(msg, "WARNING");
131-
return allItems;
132-
}
133-
134-
const params = {
135-
url: {
136-
locationId,
137-
}
138-
};
139-
if (path) {
140-
params["url"]["path"] = path;
141-
}
142-
if (cursor) {
143-
params["url"]["cursor"] = cursor;
144-
}
145-
let pagResp = null;
146-
if (path) {
147-
pagResp = await osparc.data.Resources.fetch("storagePaths", cursor ? "getPathsPage" : "getPaths", params);
148-
} else {
149-
pagResp = await osparc.data.Resources.fetch("storagePaths", cursor ? "getDatasetsPage" : "getDatasets", params);
150-
}
151-
152-
let nextCursor = null;
153-
if (pagResp) {
154-
if (pagResp["items"]) {
155-
allItems.push(...pagResp["items"]);
156-
}
157-
if (pagResp["next_page"]) {
158-
nextCursor = pagResp["next_page"];
159-
}
160-
}
161-
162-
if (nextCursor) {
163-
return this.__getAllItems(locationId, path, nextCursor, allItems);
164-
}
165-
return allItems;
166-
},
167-
168170
getPresignedLink: function(download = true, locationId, fileUuid, fileSize) {
169171
return new Promise((resolve, reject) => {
170172
if (download && !osparc.data.Permissions.getInstance().canDo("study.node.data.pull", true)) {

0 commit comments

Comments
 (0)