Skip to content

Commit ce3685c

Browse files
committed
downloadPaths
1 parent d100209 commit ce3685c

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,44 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
143143

144144
__retrieveURLAndDownloadSelected: function() {
145145
if (this.isMultiSelect()) {
146-
this.__selection.forEach(selection => {
147-
if (selection && osparc.file.FilesTree.isFile(selection)) {
148-
this.__retrieveURLAndDownloadFile(selection);
149-
}
150-
});
146+
if (this.__selection.length === 1 && osparc.file.FilesTree.isFile(this.__selection[0])) {
147+
this.__retrieveURLAndDownloadFile(this.__selection[0]);
148+
} else if (this.__selection.length > 1) {
149+
const paths = this.__selection.map(item => item.getPath());
150+
this.__retrieveURLAndDownloadPaths(paths);
151+
}
151152
} else if (this.__selection.length) {
152153
const selection = this.__selection[0];
153-
if (selection && osparc.file.FilesTree.isFile(selection)) {
154-
this.__retrieveURLAndDownloadFile(selection);
154+
if (selection) {
155+
if (osparc.file.FilesTree.isFile(selection)) {
156+
this.__retrieveURLAndDownloadFile(selection);
157+
} else {
158+
const paths = [selection.getPath()];
159+
this.__retrieveURLAndDownloadPaths(paths);
160+
}
155161
}
156162
}
157163
},
158164

159165
__retrieveURLAndDownloadFile: function(file) {
160166
const fileId = file.getFileId();
161167
const locationId = file.getLocation();
162-
osparc.utils.Utils.retrieveURLAndDownload(locationId, fileId)
168+
osparc.utils.Utils.downloadPaths(locationId, fileId)
163169
.then(data => {
164170
if (data) {
165171
osparc.DownloadLinkTracker.getInstance().downloadLinkUnattended(data.link, data.fileName);
166172
}
167173
});
168174
},
169175

176+
__retrieveURLAndDownloadPaths: function(paths) {
177+
const locationId = 0;
178+
osparc.store.Data.getInstance().retrieveURLAndDownload(locationId, paths)
179+
.then(data => {
180+
console.log("data", data);
181+
});
182+
},
183+
170184
__deleteSelected: function() {
171185
const toBeDeleted = [];
172186
let isFolderSelected = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ qx.Class.define("osparc.store.Data", {
234234
return true;
235235
},
236236

237-
downloadFiles: function(paths) {
237+
downloadPaths: function(paths) {
238238
if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) {
239239
return null;
240240
}

0 commit comments

Comments
 (0)