Skip to content

Commit 6bfab60

Browse files
authored
🐛 [Frontend] Fix: duplicated /folders call (#6587)
1 parent 5569079 commit 6bfab60

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
282282
this._addToLayout(resourcesContainer);
283283
},
284284

285-
_groupByChanged: function(groupBy) {
285+
__groupByChanged: function(groupBy) {
286286
// if cards are grouped they need to be in grid mode
287287
this._resourcesContainer.setMode("grid");
288288
this.__viewModeLayout.setVisibility(groupBy ? "excluded" : "visible");
289289
this._resourcesContainer.setGroupBy(groupBy);
290290
this._reloadCards();
291291
},
292292

293-
_viewByChanged: function(viewMode) {
293+
__viewModeChanged: function(viewMode) {
294294
this._resourcesContainer.setMode(viewMode);
295295
this._reloadCards();
296296

@@ -314,14 +314,14 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
314314

315315
const dontGroup = new qx.ui.menu.RadioButton(this.tr("None"));
316316
osparc.utils.Utils.setIdToWidget(dontGroup, "groupByNone");
317-
dontGroup.addListener("execute", () => this._groupByChanged(null));
317+
dontGroup.addListener("execute", () => this.__groupByChanged(null));
318318

319319
groupByMenu.add(dontGroup);
320320
groupOptions.add(dontGroup);
321321

322322
if (this._resourceType === "template") {
323323
const tagByGroup = new qx.ui.menu.RadioButton(this.tr("Tags"));
324-
tagByGroup.addListener("execute", () => this._groupByChanged("tags"));
324+
tagByGroup.addListener("execute", () => this.__groupByChanged("tags"));
325325
groupByMenu.add(tagByGroup);
326326
groupOptions.add(tagByGroup);
327327
if (
@@ -334,7 +334,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
334334
}
335335

336336
const groupByShared = new qx.ui.menu.RadioButton(this.tr("Shared with"));
337-
groupByShared.addListener("execute", () => this._groupByChanged("shared"));
337+
groupByShared.addListener("execute", () => this.__groupByChanged("shared"));
338338
groupByMenu.add(groupByShared);
339339
groupOptions.add(groupByShared);
340340

@@ -343,10 +343,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
343343

344344
_addViewModeButton: function() {
345345
const gridBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/th/14", this.tr("Grid view"), "left");
346-
gridBtn.addListener("execute", () => this._viewByChanged("grid"));
346+
gridBtn.addListener("execute", () => this.__viewModeChanged("grid"));
347347

348348
const listBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/bars/14", this.tr("List view"), "right");
349-
listBtn.addListener("execute", () => this._viewByChanged("list"));
349+
listBtn.addListener("execute", () => this.__viewModeChanged("list"));
350350

351351
const viewModeLayout = this.__viewModeLayout;
352352
const radioGroup = new qx.ui.form.RadioGroup();

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
5959
check: ["grid", "list"],
6060
init: "grid",
6161
nullable: false,
62-
event: "changeMode",
63-
apply: "__reloadCards"
62+
event: "changeMode"
6463
},
6564

6665
groupBy: {
@@ -277,10 +276,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
277276
this._removeAll();
278277
},
279278

280-
__reloadCards: function(mode) {
281-
this.reloadCards();
282-
},
283-
284279
__addFoldersContainer: function() {
285280
// add foldersContainer dynamically
286281
[
@@ -301,7 +296,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
301296
});
302297
},
303298

304-
reloadCards: function(resourceType) {
299+
__rebuildLayout: function(resourceType) {
305300
this.__cleanAll();
306301
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
307302
this.__addFoldersContainer();
@@ -326,8 +321,12 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
326321
});
327322
this._add(this.__nonGroupedContainer);
328323
}
324+
},
329325

330-
let cards = [];
326+
reloadCards: function(resourceType) {
327+
this.__rebuildLayout(resourceType);
328+
329+
const cards = [];
331330
this.__resourcesList.forEach(resourceData => {
332331
Array.prototype.push.apply(cards, this.__resourceToCards(resourceData));
333332
});

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

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
104104
__workspaceHeader: null,
105105
__workspacesList: null,
106106
__foldersList: null,
107+
__loadingFolders: null,
107108

108109
// overridden
109110
initResources: function() {
@@ -170,31 +171,35 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
170171
},
171172

172173
__reloadFolders: function() {
173-
if (!osparc.auth.Manager.getInstance().isLoggedIn()) {
174+
if (
175+
!osparc.auth.Manager.getInstance().isLoggedIn() ||
176+
!osparc.utils.DisabledPlugins.isFoldersEnabled() ||
177+
this.__loadingFolders) {
174178
return;
175179
}
176-
177-
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
178-
const folderId = this.getCurrentFolderId();
179-
const workspaceId = this.getCurrentWorkspaceId();
180-
if (workspaceId === -1 || workspaceId === -2) {
181-
return;
182-
}
183-
this.__setFoldersToList([]);
184-
osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy())
185-
.then(folders => {
186-
this.__setFoldersToList(folders);
187-
})
188-
.catch(console.error);
180+
const workspaceId = this.getCurrentWorkspaceId();
181+
if (workspaceId === -1 || workspaceId === -2) {
182+
return;
189183
}
184+
185+
this.__loadingFolders = true;
186+
this.__setFoldersToList([]);
187+
const folderId = this.getCurrentFolderId();
188+
osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy())
189+
.then(folders => {
190+
this.__setFoldersToList(folders);
191+
})
192+
.catch(console.error)
193+
.finally(() => this.__loadingFolders = null);
190194
},
191195

192196
__reloadStudies: function() {
193-
if (this._loadingResourcesBtn.isFetching() || !osparc.auth.Manager.getInstance().isLoggedIn()) {
194-
return;
195-
}
196197
const workspaceId = this.getCurrentWorkspaceId();
197-
if (workspaceId === -1) { // shared workspace listing
198+
if (
199+
!osparc.auth.Manager.getInstance().isLoggedIn() ||
200+
workspaceId === -1 || // listing workspaces
201+
this._loadingResourcesBtn.isFetching()
202+
) {
198203
return;
199204
}
200205

@@ -283,6 +288,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
283288

284289
__resetStudiesList: function() {
285290
this._resourcesList = [];
291+
// It will remove the study cards
286292
this._reloadCards();
287293
},
288294

@@ -693,7 +699,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
693699
invalidateStudies: function() {
694700
osparc.store.Store.getInstance().invalidate("studies");
695701
this.__resetStudiesList();
696-
this._resourcesContainer.getFlatList().nextRequest = null;
702+
if (this._resourcesContainer.getFlatList()) {
703+
this._resourcesContainer.getFlatList().nextRequest = null;
704+
}
697705
},
698706

699707
__addNewStudyButtons: function() {
@@ -938,6 +946,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
938946
return;
939947
}
940948

949+
this._loadingResourcesBtn.setFetching(false);
941950
this.resetSelection();
942951
this.setMultiSelection(false);
943952
this.set({
@@ -1233,6 +1242,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
12331242
} else {
12341243
this._resourcesList[index] = studyData;
12351244
}
1245+
// it will render the studies in the right order
12361246
this._reloadCards();
12371247
},
12381248

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ qx.Class.define("osparc.data.Resources", {
13701370
params["url"] = {};
13711371
}
13721372
params["url"]["offset"] = offset;
1373-
params["url"]["limit"] = 20;
1373+
params["url"]["limit"] = 10;
13741374
const endpoint = "getPage";
13751375
const options = {
13761376
resolveWResponse: true

0 commit comments

Comments
 (0)