Skip to content

Commit 2b253f8

Browse files
committed
renaming
1 parent d2bb386 commit 2b253f8

File tree

2 files changed

+49
-24
lines changed

2 files changed

+49
-24
lines changed

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

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,13 @@ qx.Class.define("osparc.file.FilesTree", {
152152
this.self().addLoadingChild(studyModel);
153153

154154
const dataStore = osparc.store.Data.getInstance();
155-
return dataStore.getPathByLocationAndDataset("0", studyId)
156-
.then(data => {
157-
const {
158-
items
159-
} = data;
160-
155+
return dataStore.getItemsByLocationAndDataset("0", studyId)
156+
.then(items => {
161157
if (items.length && "project_name" in items[0]) {
162158
this.__resetTree(items[0]["project_name"]);
163159
}
164160
studyModel = this.getModel();
165-
this.__filesToDataset("0", studyId, items, studyModel);
161+
this.__itemsToDataset("0", studyId, items, studyModel);
166162

167163
// select study item
168164
this.setSelection(new qx.data.Array([studyModel]));
@@ -382,12 +378,12 @@ qx.Class.define("osparc.file.FilesTree", {
382378
}
383379

384380
const dataStore = osparc.store.Data.getInstance();
385-
return dataStore.getPathByLocationAndDataset(locationId, datasetId)
386-
.then(data => {
387-
const {
388-
items
389-
} = data;
390-
this.__filesToDataset(locationId, datasetId, items);
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+
}
391387
});
392388
},
393389

@@ -415,6 +411,39 @@ qx.Class.define("osparc.file.FilesTree", {
415411
return null;
416412
},
417413

414+
__itemsToParentModel(locationId, datasetId, items, model) {
415+
if (this.__datasets.has(datasetId)) {
416+
return;
417+
}
418+
419+
const datasetModel = model ? model : this.__getDatasetModel(locationId, datasetId);
420+
if (datasetModel) {
421+
datasetModel.getChildren().removeAll();
422+
if (items.length) {
423+
const locationData = osparc.data.Converters.fromDSMToVirtualTreeModel(locationId, datasetId, items);
424+
const datasetData = locationData[0].children;
425+
datasetData[0].children.forEach(data => {
426+
this.self().attachPathLabel(datasetModel.getPathLabel(), data);
427+
const filesModel = qx.data.marshal.Json.createModel(data, true);
428+
datasetModel.getChildren().append(filesModel);
429+
});
430+
}
431+
// sort files
432+
osparc.data.Converters.sortModelByLabel(datasetModel);
433+
434+
this.__rerender(datasetModel);
435+
436+
this.__datasets.add(datasetId);
437+
this.fireEvent("filesAddedToTree");
438+
}
439+
440+
this.__filesReceived(locationId, datasetId, items);
441+
},
442+
443+
__getPathModel: function(locationId, path) {
444+
445+
},
446+
418447
__itemsToNode: function(files) {
419448
const currentModel = this.getModel();
420449
this.self().removeLoadingChild(currentModel);
@@ -467,7 +496,7 @@ qx.Class.define("osparc.file.FilesTree", {
467496
}
468497
},
469498

470-
__filesToDataset: function(locationId, datasetId, files, model) {
499+
__itemsToDataset: function(locationId, datasetId, files, model) {
471500
if (this.__datasets.has(datasetId)) {
472501
return;
473502
}

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

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

123-
getPathByLocationAndDataset: function(locationId, datasetId) {
124-
const data = {
125-
locationId,
126-
datasetId,
127-
items: []
128-
};
123+
getItemsByLocationAndDataset: function(locationId, datasetId) {
129124
return new Promise((resolve, reject) => {
130125
// Get list of file meta data
131126
if (locationId === 1 && !osparc.data.Permissions.getInstance().canDo("storage.datcore.read")) {
132-
reject(data);
127+
reject([]);
133128
}
134129

135130
const params = {
@@ -141,13 +136,14 @@ qx.Class.define("osparc.store.Data", {
141136
osparc.data.Resources.fetch("storagePaths", "getPaths", params)
142137
.then(pagResp => {
143138
if (pagResp["items"] && pagResp["items"].length>0) {
144-
data.items = pagResp["items"];
139+
resolve(pagResp["items"]);
140+
} else {
141+
resolve([]);
145142
}
146-
resolve(data);
147143
})
148144
.catch(err => {
149145
console.error(err);
150-
reject(data);
146+
reject([]);
151147
});
152148
});
153149
},

0 commit comments

Comments
 (0)