Skip to content

Commit cd3e76b

Browse files
committed
list templates
1 parent 1e7df57 commit cd3e76b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
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
@@ -276,8 +276,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
276276
return;
277277
}
278278

279-
const studies = resp["data"];
280-
this.__addStudiesToList(studies);
279+
if (["templates", "public"].includes(this.getCurrentContext())) {
280+
const templates = resp["data"];
281+
templates.forEach(template => template["resourceType"] = "template");
282+
this.__addResourcesToList(templates);
283+
} else {
284+
const studies = resp["data"];
285+
studies.forEach(study => study["resourceType"] = "study");
286+
this.__addResourcesToList(studies);
287+
}
281288
if (this._resourcesContainer.getFlatList()) {
282289
this._resourcesContainer.getFlatList().nextRequest = resp["_links"]["next"];
283290
}
@@ -333,17 +340,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
333340
this._reloadCards();
334341
},
335342

336-
__addStudiesToList: function(studiesList) {
337-
studiesList.forEach(study => study["resourceType"] = "study");
338-
studiesList.forEach(study => {
343+
__addResourcesToList: function(resourcesList) {
344+
resourcesList.forEach(study => {
339345
const idx = this._resourcesList.findIndex(std => std["uuid"] === study["uuid"]);
340346
if (idx === -1) {
341347
this._resourcesList.push(study);
342348
}
343349
});
344350
this.__reloadNewCards();
345351

346-
studiesList.forEach(study => {
352+
resourcesList.forEach(study => {
347353
const state = study["state"];
348354
if (state && "locked" in state && state["locked"]["value"] && state["locked"]["status"] === "CLOSING") {
349355
// websocket might have already notified that the state was closed.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ qx.Class.define("osparc.store.Templates", {
2424

2525
fetchTemplatesPaginated: function(params, options) {
2626
return osparc.data.Resources.fetch("templates", "getPage", params, options)
27-
.then(templates => {
27+
.then(resp => {
28+
const templates = resp.data;
2829
// add them to the list
2930
if (this.__templates) {
3031
templates.forEach(template => {
@@ -36,7 +37,7 @@ qx.Class.define("osparc.store.Templates", {
3637
}
3738
});
3839
}
39-
return templates;
40+
return resp;
4041
})
4142
.catch(err => osparc.FlashMessenger.logError(err));
4243
},

0 commit comments

Comments
 (0)