From e59b2a5558e3cc87dda9f7e9eade8ed3a90826a9 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 23 Oct 2024 16:38:24 +0200 Subject: [PATCH 01/10] comments --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index bc22291e7bc..c640508f0fc 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -283,6 +283,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __resetStudiesList: function() { this._resourcesList = []; + this._resourcesContainer.getFlatList().nextRequest = null; + + // It will remove the study cards this._reloadCards(); }, @@ -693,7 +696,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { invalidateStudies: function() { osparc.store.Store.getInstance().invalidate("studies"); this.__resetStudiesList(); - this._resourcesContainer.getFlatList().nextRequest = null; }, __addNewStudyButtons: function() { @@ -1233,6 +1235,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } else { this._resourcesList[index] = studyData; } + // it will render the studies in the right order this._reloadCards(); }, From d7510e1a5fb49f1f19587dcef0a2ebbe7de671e1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 23 Oct 2024 17:03:04 +0200 Subject: [PATCH 02/10] don't print twice --- .../source/class/osparc/dashboard/ResourceBrowserBase.js | 6 +++--- .../class/osparc/dashboard/ResourceContainerManager.js | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index 9082c3a5c2b..fd70f5c4a49 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -290,7 +290,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this._reloadCards(); }, - _viewByChanged: function(viewMode) { + _viewModeChanged: function(viewMode) { this._resourcesContainer.setMode(viewMode); this._reloadCards(); @@ -343,10 +343,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { _addViewModeButton: function() { const gridBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/th/14", this.tr("Grid view"), "left"); - gridBtn.addListener("execute", () => this._viewByChanged("grid")); + gridBtn.addListener("execute", () => this._viewModeChanged("grid")); const listBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/bars/14", this.tr("List view"), "right"); - listBtn.addListener("execute", () => this._viewByChanged("list")); + listBtn.addListener("execute", () => this._viewModeChanged("list")); const viewModeLayout = this.__viewModeLayout; const radioGroup = new qx.ui.form.RadioGroup(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index f0d854b2222..56e69bd8c48 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -59,8 +59,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { check: ["grid", "list"], init: "grid", nullable: false, - event: "changeMode", - apply: "__reloadCards" + event: "changeMode" }, groupBy: { @@ -277,10 +276,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this._removeAll(); }, - __reloadCards: function(mode) { - this.reloadCards(); - }, - __addFoldersContainer: function() { // add foldersContainer dynamically [ From 076c35bd4e417d11606f8ee7e5421b9a92a794ce Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 23 Oct 2024 17:18:12 +0200 Subject: [PATCH 03/10] minor --- .../class/osparc/dashboard/ResourceContainerManager.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 56e69bd8c48..df41744539d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -296,7 +296,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }); }, - reloadCards: function(resourceType) { + __rebuildLayout: function(resourceType) { this.__cleanAll(); if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { this.__addFoldersContainer(); @@ -321,8 +321,12 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }); this._add(this.__nonGroupedContainer); } + }, - let cards = []; + reloadCards: function(resourceType) { + this.__rebuildLayout(resourceType); + + const cards = []; this.__resourcesList.forEach(resourceData => { Array.prototype.push.apply(cards, this.__resourceToCards(resourceData)); }); From 3b2038e14ebccac77c9b38c278790f89c31a3e80 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 23 Oct 2024 17:38:57 +0200 Subject: [PATCH 04/10] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c640508f0fc..57511385a56 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -283,7 +283,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __resetStudiesList: function() { this._resourcesList = []; - this._resourcesContainer.getFlatList().nextRequest = null; + if (this._resourcesContainer.getFlatList()) { + this._resourcesContainer.getFlatList().nextRequest = null; + } // It will remove the study cards this._reloadCards(); From d17032ba0d6b26056448260cd4142a6f745a03db Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 10:32:24 +0200 Subject: [PATCH 05/10] pages, chunks of 10 --- .../client/source/class/osparc/data/Resources.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 3c2d4d500f6..9d591c0d1ee 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -1370,7 +1370,7 @@ qx.Class.define("osparc.data.Resources", { params["url"] = {}; } params["url"]["offset"] = offset; - params["url"]["limit"] = 20; + params["url"]["limit"] = 10; const endpoint = "getPage"; const options = { resolveWResponse: true From 5baf7d11d68eb922e843ad45569e48383ea4954d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 10:59:27 +0200 Subject: [PATCH 06/10] loadingFolders variable --- .../class/osparc/dashboard/StudyBrowser.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 57511385a56..4f735d21b4b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -104,6 +104,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __workspaceHeader: null, __workspacesList: null, __foldersList: null, + __loadingFolders: null, // overridden initResources: function() { @@ -170,23 +171,26 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __reloadFolders: function() { - if (!osparc.auth.Manager.getInstance().isLoggedIn()) { + if ( + !osparc.auth.Manager.getInstance().isLoggedIn() || + !osparc.utils.DisabledPlugins.isFoldersEnabled() || + this.__loadingFolders) { return; } - - if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - const folderId = this.getCurrentFolderId(); - const workspaceId = this.getCurrentWorkspaceId(); - if (workspaceId === -1 || workspaceId === -2) { - return; - } - this.__setFoldersToList([]); - osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()) - .then(folders => { - this.__setFoldersToList(folders); - }) - .catch(console.error); + const workspaceId = this.getCurrentWorkspaceId(); + if (workspaceId === -1 || workspaceId === -2) { + return; } + + this.__loadingFolders = true; + this.__setFoldersToList([]); + const folderId = this.getCurrentFolderId(); + osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()) + .then(folders => { + this.__setFoldersToList(folders); + }) + .catch(console.error) + .finally(() => this.__loadingFolders = null); }, __reloadStudies: function() { From c1c34ee10e802cfa5ed271bb818d22a81eb88f11 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 11:12:15 +0200 Subject: [PATCH 07/10] undo --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 4f735d21b4b..7870c236721 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -287,10 +287,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __resetStudiesList: function() { this._resourcesList = []; - if (this._resourcesContainer.getFlatList()) { - this._resourcesContainer.getFlatList().nextRequest = null; - } - // It will remove the study cards this._reloadCards(); }, @@ -702,6 +698,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { invalidateStudies: function() { osparc.store.Store.getInstance().invalidate("studies"); this.__resetStudiesList(); + if (this._resourcesContainer.getFlatList()) { + this._resourcesContainer.getFlatList().nextRequest = null; + } + }, __addNewStudyButtons: function() { From 9041c730dca4bfa5842b788b293b8a765c0a4570 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 11:13:24 +0200 Subject: [PATCH 08/10] eslint --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 1 - 1 file changed, 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 7870c236721..f3490323417 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -701,7 +701,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (this._resourcesContainer.getFlatList()) { this._resourcesContainer.getFlatList().nextRequest = null; } - }, __addNewStudyButtons: function() { From 2580032e73d0a1c26ca038fef55d20a71fb936df Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 11:17:09 +0200 Subject: [PATCH 09/10] protected -> private --- .../class/osparc/dashboard/ResourceBrowserBase.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index fd70f5c4a49..9334861f11c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -282,7 +282,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this._addToLayout(resourcesContainer); }, - _groupByChanged: function(groupBy) { + __groupByChanged: function(groupBy) { // if cards are grouped they need to be in grid mode this._resourcesContainer.setMode("grid"); this.__viewModeLayout.setVisibility(groupBy ? "excluded" : "visible"); @@ -290,7 +290,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this._reloadCards(); }, - _viewModeChanged: function(viewMode) { + __viewModeChanged: function(viewMode) { this._resourcesContainer.setMode(viewMode); this._reloadCards(); @@ -314,14 +314,14 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const dontGroup = new qx.ui.menu.RadioButton(this.tr("None")); osparc.utils.Utils.setIdToWidget(dontGroup, "groupByNone"); - dontGroup.addListener("execute", () => this._groupByChanged(null)); + dontGroup.addListener("execute", () => this.__groupByChanged(null)); groupByMenu.add(dontGroup); groupOptions.add(dontGroup); if (this._resourceType === "template") { const tagByGroup = new qx.ui.menu.RadioButton(this.tr("Tags")); - tagByGroup.addListener("execute", () => this._groupByChanged("tags")); + tagByGroup.addListener("execute", () => this.__groupByChanged("tags")); groupByMenu.add(tagByGroup); groupOptions.add(tagByGroup); if ( @@ -334,7 +334,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { } const groupByShared = new qx.ui.menu.RadioButton(this.tr("Shared with")); - groupByShared.addListener("execute", () => this._groupByChanged("shared")); + groupByShared.addListener("execute", () => this.__groupByChanged("shared")); groupByMenu.add(groupByShared); groupOptions.add(groupByShared); @@ -343,10 +343,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { _addViewModeButton: function() { const gridBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/th/14", this.tr("Grid view"), "left"); - gridBtn.addListener("execute", () => this._viewModeChanged("grid")); + gridBtn.addListener("execute", () => this.__viewModeChanged("grid")); const listBtn = this.self().createToolbarRadioButton(null, "@FontAwesome5Solid/bars/14", this.tr("List view"), "right"); - listBtn.addListener("execute", () => this._viewModeChanged("list")); + listBtn.addListener("execute", () => this.__viewModeChanged("list")); const viewModeLayout = this.__viewModeLayout; const radioGroup = new qx.ui.form.RadioGroup(); From d6f2c9cf462176036b187ccb08d7cd1423390df9 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 11:30:30 +0200 Subject: [PATCH 10/10] set fetching to false when context changes --- .../source/class/osparc/dashboard/StudyBrowser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index f3490323417..165b2dff7e0 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -194,11 +194,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __reloadStudies: function() { - if (this._loadingResourcesBtn.isFetching() || !osparc.auth.Manager.getInstance().isLoggedIn()) { - return; - } const workspaceId = this.getCurrentWorkspaceId(); - if (workspaceId === -1) { // shared workspace listing + if ( + !osparc.auth.Manager.getInstance().isLoggedIn() || + workspaceId === -1 || // listing workspaces + this._loadingResourcesBtn.isFetching() + ) { return; } @@ -945,6 +946,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return; } + this._loadingResourcesBtn.setFetching(false); this.resetSelection(); this.setMultiSelection(false); this.set({