Skip to content

Commit b2035cf

Browse files
committed
trashed and search workspaces
1 parent 7605f82 commit b2035cf

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
9999
__workspacesList: null,
100100
__foldersList: null,
101101
__loadingFolders: null,
102+
__loadingWorkspaces: null,
102103

103104
// overridden
104105
initResources: function() {
@@ -163,11 +164,40 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
163164
},
164165

165166
__reloadWorkspaces: function() {
167+
if (
168+
!osparc.auth.Manager.getInstance().isLoggedIn() ||
169+
!osparc.utils.DisabledPlugins.isFoldersEnabled() ||
170+
this.getCurrentContext() === "studiesAndFolders" ||
171+
this.__loadingWorkspaces
172+
) {
173+
return;
174+
}
175+
176+
let request = null;
177+
switch (this.getCurrentContext()) {
178+
case "search": {
179+
const filterData = this._searchBarFilter.getFilterData();
180+
const text = filterData.text ? encodeURIComponent(filterData.text) : "";
181+
request = osparc.store.Workspaces.getInstance().searchWorkspaces(text);
182+
break;
183+
}
184+
case "workspaces": {
185+
request = osparc.store.Workspaces.getInstance().fetchWorkspaces();
186+
break;
187+
}
188+
case "trash":
189+
request = osparc.store.Workspaces.getInstance().fetchTrashedWorkspaces();
190+
break;
191+
}
192+
193+
this.__loadingWorkspaces = true;
166194
this.__setWorkspacesToList([]);
167-
osparc.store.Workspaces.getInstance().fetchWorkspaces()
195+
request
168196
.then(workspaces => {
169197
this.__setWorkspacesToList(workspaces);
170-
});
198+
})
199+
.catch(console.error)
200+
.finally(() => this.__loadingWorkspaces = null);
171201
},
172202

173203
__reloadFolders: function() {
@@ -180,7 +210,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
180210
return;
181211
}
182212

183-
this.__loadingFolders = true;
184213
let request = null;
185214
switch (this.getCurrentContext()) {
186215
case "search": {
@@ -200,6 +229,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
200229
break;
201230
}
202231

232+
this.__loadingFolders = true;
203233
this.__setFoldersToList([]);
204234
request
205235
.then(folders => {
@@ -1032,10 +1062,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10321062

10331063
this._toolbar.show();
10341064
if (context === "search") {
1065+
this.__reloadWorkspaces();
10351066
this.__reloadFolders();
10361067
this.__reloadStudies();
10371068
} else if (context === "trash") {
1038-
// for now, studies only
1069+
this._searchBarFilter.resetFilters();
1070+
this.__reloadWorkspaces();
10391071
this.__reloadFolders();
10401072
this.__reloadStudies();
10411073
} else if (context === "workspaces") {

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,14 @@ qx.Class.define("osparc.store.Workspaces", {
6868
});
6969
},
7070

71-
fetchTrashedWorkspaces: function(orderBy = {
72-
field: "modified_at",
73-
direction: "desc"
74-
}) {
71+
fetchTrashedWorkspaces: function() {
7572
if (osparc.auth.Data.getInstance().isGuest()) {
7673
return new Promise(resolve => {
7774
resolve([]);
7875
});
7976
}
8077

81-
const curatedOrderBy = this.self().curateOrderBy(orderBy);
82-
const params = {
83-
url: {
84-
orderBy: JSON.stringify(curatedOrderBy),
85-
}
86-
};
87-
return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageTrashed")
78+
return osparc.data.Resources.getInstance().getAllPages("workspaces", {}, "getPageTrashed")
8879
.then(trashedWorkspacesData => {
8980
const workspaces = [];
9081
trashedWorkspacesData.forEach(workspaceData => {
@@ -95,24 +86,16 @@ qx.Class.define("osparc.store.Workspaces", {
9586
});
9687
},
9788

98-
searchWorkspaces: function(
99-
text,
100-
orderBy = {
101-
field: "modified_at",
102-
direction: "desc"
103-
},
104-
) {
89+
searchWorkspaces: function(text) {
10590
if (osparc.auth.Data.getInstance().isGuest()) {
10691
return new Promise(resolve => {
10792
resolve([]);
10893
});
10994
}
11095

111-
const curatedOrderBy = this.self().curateOrderBy(orderBy);
11296
const params = {
11397
url: {
11498
text,
115-
orderBy: JSON.stringify(curatedOrderBy),
11699
}
117100
};
118101
return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch")

0 commit comments

Comments
 (0)