Skip to content

Commit eb89050

Browse files
committed
cleanup
1 parent a80b336 commit eb89050

File tree

5 files changed

+21
-60
lines changed

5 files changed

+21
-60
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,10 +1190,6 @@ qx.Class.define("osparc.data.Resources", {
11901190
copy: {
11911191
method: "PUT",
11921192
url: statics.API + "/storage/locations/{toLoc}/files/{fileName}?extra_location={fromLoc}&extra_source={fileUuid}"
1193-
},
1194-
delete: {
1195-
method: "DELETE",
1196-
url: statics.API + "/storage/locations/{locationId}/files/{fileUuid}"
11971193
}
11981194
}
11991195
},

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,27 +208,10 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
208208
},
209209

210210
__doDeleteSelected: function(toBeDeleted) {
211-
let request = null;
212211
if (toBeDeleted.length === 0) {
213212
osparc.FlashMessenger.logAs(this.tr("Nothing to delete"), "ERROR");
214213
return;
215-
} else if (toBeDeleted.length === 1) {
216-
const selection = toBeDeleted[0];
217-
if (selection) {
218-
if (osparc.file.FilesTree.isFile(selection)) {
219-
request = this.__deleteItem(selection.getFileId(), selection.getLocation());
220-
} else {
221-
request = this.__deleteItem(selection.getPath(), selection.getLocation());
222-
}
223-
request
224-
.then(datas => {
225-
if (datas.length) {
226-
this.fireDataEvent("fileDeleted", datas[0]);
227-
osparc.FlashMessenger.logAs(this.tr("Items successfully deleted"), "INFO");
228-
}
229-
});
230-
}
231-
} else if (toBeDeleted.length > 1) {
214+
} else if (toBeDeleted.length > 0) {
232215
const paths = toBeDeleted.map(item => item.getPath());
233216
const dataStore = osparc.store.Data.getInstance();
234217
const fetchPromise = dataStore.deleteFiles(paths);
@@ -243,14 +226,5 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
243226
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files deletion")));
244227
}
245228
},
246-
247-
__deleteItem: function(itemId, locationId) {
248-
if (locationId !== 0 && locationId !== "0") {
249-
osparc.FlashMessenger.logAs(this.tr("Externally managed items cannot be deleted"));
250-
return null;
251-
}
252-
const dataStore = osparc.store.Data.getInstance();
253-
return dataStore.deleteFile(locationId, itemId);
254-
},
255229
}
256230
});

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ qx.Class.define("osparc.file.FolderViewer", {
179179

180180
__applyFolder: function() {
181181
this.getChildControl("selected-file-layout").resetSelection();
182-
}
182+
},
183+
184+
resetSelection: function() {
185+
const folderContent = this.getChildControl("folder-content");
186+
folderContent.resetSelection();
187+
188+
const selectedFileLayout = this.getChildControl("selected-file-layout");
189+
selectedFileLayout.resetSelection();
190+
},
183191
}
184192
});

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,17 @@ qx.Class.define("osparc.file.TreeFolderView", {
137137
},
138138

139139
pathsDeleted: function(paths) {
140-
console.log("pathsDeleted", paths);
141-
const folderContent = this.getChildControl("folder-viewer").getChildControl("folder-content");
142-
folderContent.resetSelection();
140+
this.getChildControl("folder-viewer").resetSelection();
141+
142+
const folderTree = this.getChildControl("folder-tree");
143+
const selectedFolder = folderTree.getSelectedItem();
144+
const children = selectedFolder.getChildren();
145+
paths.forEach(path => {
146+
const found = children.toArray().find(child => child.getPath() === path);
147+
if (found) {
148+
children.remove(found);
149+
}
150+
});
143151
},
144152

145153
openPath: async function(pathParts) {

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -234,31 +234,6 @@ qx.Class.define("osparc.store.Data", {
234234
return true;
235235
},
236236

237-
// if folder path is provided as fileUuid, it can also be deleted
238-
deleteFile: function(locationId, fileUuid) {
239-
if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) {
240-
return null;
241-
}
242-
243-
// Deletes File
244-
const params = {
245-
url: {
246-
locationId,
247-
fileUuid: encodeURIComponent(fileUuid)
248-
}
249-
};
250-
return osparc.data.Resources.fetch("storageFiles", "delete", params)
251-
.then(files => {
252-
const data = {
253-
data: files,
254-
locationId: locationId,
255-
fileUuid: fileUuid
256-
};
257-
return data;
258-
})
259-
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful file deletion")));
260-
},
261-
262237
deleteFiles: function(paths) {
263238
if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) {
264239
return null;

0 commit comments

Comments
 (0)