Skip to content

Commit cacf6fd

Browse files
committed
getItemsByLocationAndPath
1 parent 27a690e commit cacf6fd

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ qx.Class.define("osparc.dashboard.DataBrowser", {
113113
foldersTree.populateTree()
114114
.then(datasetPromises => {
115115
Promise.all(datasetPromises)
116-
.then(() => foldersTree.requestDatasetFiles(locationId, datasetId))
116+
.then(() => foldersTree.requestPathItems(locationId, datasetId))
117117
.then(() => openSameFolder());
118118
})
119119
.catch(err => console.error(err));

services/static-webserver/client/source/class/osparc/file/FilePicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ qx.Class.define("osparc.file.FilePicker", {
576576
}, this);
577577
folderViewer.addListener("requestDatasetFiles", e => {
578578
const data = e.getData();
579-
filesTree.requestDatasetFiles(data.locationId, data.datasetId);
579+
filesTree.requestPathItems(data.locationId, data.datasetId);
580580
}, this);
581581

582582
const selectBtn = this.__selectButton = new qx.ui.form.Button(this.tr("Select")).set({

services/static-webserver/client/source/class/osparc/file/FilesTree.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ qx.Class.define("osparc.file.FilesTree", {
151151
this.self().addLoadingChild(studyModel);
152152

153153
const dataStore = osparc.store.Data.getInstance();
154-
return dataStore.getItemsByLocationAndDataset("0", studyId)
154+
const locationId = 0;
155+
const path = studyId;
156+
return dataStore.getItemsByLocationAndPath(locationId, path)
155157
.then(items => {
156158
if (items.length && "project_name" in items[0]) {
157159
this.__resetTree(items[0]["project_name"]);
@@ -212,6 +214,22 @@ qx.Class.define("osparc.file.FilesTree", {
212214
this.__populateLocations();
213215
},
214216

217+
requestPathItems: function(locationId, datasetId) {
218+
if (this.__datasets.has(datasetId)) {
219+
return null;
220+
}
221+
222+
const dataStore = osparc.store.Data.getInstance();
223+
const path = datasetId;
224+
return dataStore.getItemsByLocationAndPath(locationId, path)
225+
.then(items => {
226+
const parentModel = this.__getDatasetModel(locationId, datasetId);
227+
if (parentModel) {
228+
this.__itemsToParentModel(locationId, datasetId, items);
229+
}
230+
});
231+
},
232+
215233
__resetChecks: function() {
216234
this.__locations = new Set();
217235
this.__datasets = new Set();
@@ -254,7 +272,7 @@ qx.Class.define("osparc.file.FilesTree", {
254272
item.setLoaded(true);
255273
const locationId = item.getLocation();
256274
const datasetId = item.getPath();
257-
this.requestDatasetFiles(locationId, datasetId);
275+
this.requestPathItems(locationId, datasetId);
258276
}
259277
}, this);
260278
item.addListener("dbltap", () => this.__itemSelected(), this);
@@ -372,21 +390,6 @@ qx.Class.define("osparc.file.FilesTree", {
372390
});
373391
},
374392

375-
requestDatasetFiles: function(locationId, datasetId) {
376-
if (this.__datasets.has(datasetId)) {
377-
return null;
378-
}
379-
380-
const dataStore = osparc.store.Data.getInstance();
381-
return dataStore.getItemsByLocationAndDataset(locationId, datasetId)
382-
.then(items => {
383-
const parentModel = this.__getDatasetModel(locationId, datasetId);
384-
if (parentModel) {
385-
this.__itemsToParentModel(locationId, datasetId, items);
386-
}
387-
});
388-
},
389-
390393
__getLocationModel: function(locationId) {
391394
const rootModel = this.getModel();
392395
const locationModels = rootModel.getChildren();
@@ -492,7 +495,7 @@ qx.Class.define("osparc.file.FilesTree", {
492495
if (openThis) {
493496
const datasetId = openThis.getItemId();
494497
this.openNodeAndParents(openThis);
495-
this.requestDatasetFiles(locationId, datasetId);
498+
this.requestPathItems(locationId, datasetId);
496499
}
497500
},
498501

services/static-webserver/client/source/class/osparc/file/TreeFolderView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ qx.Class.define("osparc.file.TreeFolderView", {
109109

110110
folderViewer.addListener("requestDatasetFiles", e => {
111111
const data = e.getData();
112-
folderTree.requestDatasetFiles(data.locationId, data.datasetId);
112+
folderTree.requestPathItems(data.locationId, data.datasetId);
113113
}, this);
114114
},
115115

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ qx.Class.define("osparc.store.Data", {
120120
});
121121
},
122122

123-
getItemsByLocationAndDataset: function(locationId, datasetId) {
123+
getItemsByLocationAndPath: function(locationId, path) {
124124
return new Promise((resolve, reject) => {
125125
// Get list of file meta data
126126
if (locationId === 1 && !osparc.data.Permissions.getInstance().canDo("storage.datcore.read")) {
@@ -129,8 +129,8 @@ qx.Class.define("osparc.store.Data", {
129129

130130
const params = {
131131
url: {
132-
locationId: locationId,
133-
path: datasetId
132+
locationId,
133+
path,
134134
}
135135
};
136136
osparc.data.Resources.fetch("storagePaths", "getPaths", params)

0 commit comments

Comments
 (0)