Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Frontend] Fix: duplicated /folders call #6587

Merged
merged 14 commits into from
Oct 24, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
this._reloadCards();
},

_viewByChanged: function(viewMode) {
_viewModeChanged: function(viewMode) {
this._resourcesContainer.setMode(viewMode);
this._reloadCards();

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
check: ["grid", "list"],
init: "grid",
nullable: false,
event: "changeMode",
apply: "__reloadCards"
event: "changeMode"
},

groupBy: {
Expand Down Expand Up @@ -277,10 +276,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
this._removeAll();
},

__reloadCards: function(mode) {
this.reloadCards();
},

__addFoldersContainer: function() {
// add foldersContainer dynamically
[
Expand All @@ -301,7 +296,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
});
},

reloadCards: function(resourceType) {
__rebuildLayout: function(resourceType) {
this.__cleanAll();
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
this.__addFoldersContainer();
Expand All @@ -326,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));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
__workspaceHeader: null,
__workspacesList: null,
__foldersList: null,
__loadingFolders: null,

// overridden
initResources: function() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -283,6 +287,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {

__resetStudiesList: function() {
this._resourcesList = [];
// It will remove the study cards
this._reloadCards();
},

Expand Down Expand Up @@ -693,7 +698,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
invalidateStudies: function() {
osparc.store.Store.getInstance().invalidate("studies");
this.__resetStudiesList();
this._resourcesContainer.getFlatList().nextRequest = null;
if (this._resourcesContainer.getFlatList()) {
this._resourcesContainer.getFlatList().nextRequest = null;
}

},

__addNewStudyButtons: function() {
Expand Down Expand Up @@ -1233,6 +1241,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
} else {
this._resourcesList[index] = studyData;
}
// it will render the studies in the right order
this._reloadCards();
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading