Skip to content

Commit d37fd52

Browse files
committed
search and trashed workspaces
1 parent 15ad214 commit d37fd52

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,15 @@ qx.Class.define("osparc.data.Resources", {
314314
method: "GET",
315315
url: statics.API + "/folders?workspace_id={workspaceId}&folder_id={folderId}&offset={offset}&limit={limit}&order_by={orderBy}"
316316
},
317+
getOne: {
318+
method: "GET",
319+
url: statics.API + "/folders/{folderId}"
320+
},
317321
getPageSearch: {
318322
useCache: false,
319323
method: "GET",
320324
url: statics.API + "/folders:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}"
321325
},
322-
getOne: {
323-
method: "GET",
324-
url: statics.API + "/folders/{folderId}"
325-
},
326326
getPageTrashed: {
327327
useCache: false,
328328
method: "GET",
@@ -364,6 +364,16 @@ qx.Class.define("osparc.data.Resources", {
364364
method: "GET",
365365
url: statics.API + "/workspaces/{workspaceId}"
366366
},
367+
getPageSearch: {
368+
useCache: false,
369+
method: "GET",
370+
url: statics.API + "/workspaces:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}"
371+
},
372+
getPageTrashed: {
373+
useCache: false,
374+
method: "GET",
375+
url: statics.API + "/workspaces?filters={%22trashed%22:%22true%22}&offset={offset}&limit={limit}&order_by={orderBy}"
376+
},
367377
post: {
368378
method: "POST",
369379
url: statics.API + "/workspaces"

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

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

71+
fetchTrashedWorkspaces: function(orderBy = {
72+
field: "modified_at",
73+
direction: "desc"
74+
}) {
75+
if (osparc.auth.Data.getInstance().isGuest()) {
76+
return new Promise(resolve => {
77+
resolve([]);
78+
});
79+
}
80+
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")
88+
.then(trashedWorkspacesData => {
89+
const workspaces = [];
90+
trashedWorkspacesData.forEach(workspaceData => {
91+
const workspace = this.__addToCache(workspaceData);
92+
workspaces.push(workspace);
93+
});
94+
return workspaces;
95+
});
96+
},
97+
98+
searchWorkspaces: function(
99+
text,
100+
orderBy = {
101+
field: "modified_at",
102+
direction: "desc"
103+
},
104+
) {
105+
if (osparc.auth.Data.getInstance().isGuest()) {
106+
return new Promise(resolve => {
107+
resolve([]);
108+
});
109+
}
110+
111+
const curatedOrderBy = this.self().curateOrderBy(orderBy);
112+
const params = {
113+
url: {
114+
text,
115+
orderBy: JSON.stringify(curatedOrderBy),
116+
}
117+
};
118+
return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch")
119+
.then(workspacesData => {
120+
const workspaces = [];
121+
workspacesData.forEach(workspaceData => {
122+
const workspace = this.__addToCache(workspaceData);
123+
workspaces.push(workspace);
124+
});
125+
return workspaces;
126+
});
127+
},
128+
71129
postWorkspace: function(newWorkspaceData) {
72130
const params = {
73131
data: newWorkspaceData

0 commit comments

Comments
 (0)