Skip to content

Commit 67dd452

Browse files
committed
fetchTemplatesPaginated
1 parent f82d620 commit 67dd452

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
164164
__reloadWorkspaces: function() {
165165
if (
166166
!osparc.auth.Manager.getInstance().isLoggedIn() ||
167-
this.getCurrentContext() === "studiesAndFolders" ||
167+
["studiesAndFolders", "templates", "public"].includes(this.getCurrentContext()) ||
168168
this.__loadingWorkspaces
169169
) {
170170
return;
@@ -208,7 +208,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
208208
__reloadFolders: function() {
209209
if (
210210
!osparc.auth.Manager.getInstance().isLoggedIn() ||
211-
this.getCurrentContext() === "workspaces" ||
211+
["workspaces", "templates", "public"].includes(this.getCurrentContext()) ||
212212
this.__loadingFolders
213213
) {
214214
return;
@@ -818,14 +818,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
818818

819819
let request = null;
820820
switch (this.getCurrentContext()) {
821-
case "trash":
822-
request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options);
821+
case "studiesAndFolders":
822+
request = osparc.data.Resources.fetch("studies", "getPage", params, options);
823823
break;
824824
case "search":
825825
request = osparc.data.Resources.fetch("studies", "getPageSearch", params, options);
826826
break;
827-
case "studiesAndFolders":
828-
request = osparc.data.Resources.fetch("studies", "getPage", params, options);
827+
case "templates":
828+
request = osparc.store.Templates.fetchTemplatesPaginated(params, options);
829+
break;
830+
case "public":
831+
request = osparc.store.Templates.fetchTemplatesPaginated(params, options);
832+
break;
833+
case "trash":
834+
request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options);
829835
break;
830836
}
831837
return request;

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ qx.Class.define("osparc.store.Templates", {
2222
__templates: null,
2323
__templatesPromisesCached: null,
2424

25+
fetchTemplatesPaginated: function(params, options) {
26+
return osparc.data.Resources.fetch("templates", "getPage", params, options)
27+
.then(templates => {
28+
// add them to the list
29+
if (this.__templates) {
30+
templates.forEach(template => {
31+
const index = this.__templates.findIndex(t => t.uuid === template.uuid);
32+
if (index === -1) {
33+
this.__templates.push(template);
34+
} else {
35+
this.__templates[index] = template;
36+
}
37+
});
38+
}
39+
return templates;
40+
})
41+
.catch(err => osparc.FlashMessenger.logError(err));
42+
},
43+
2544
__fetchAllTemplates: function() {
2645
return this.__templatesPromisesCached = osparc.data.Resources.getInstance().getAllPages("templates")
2746
.then(templates => {

0 commit comments

Comments
 (0)