Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [Frontend] Connect folders to backend #6151

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
52e0500
update folder keys
odeimaiz Aug 8, 2024
d19af2f
add new resources
odeimaiz Aug 8, 2024
9bfbc2d
folders in main Store
odeimaiz Aug 8, 2024
9a3b549
list folders
odeimaiz Aug 8, 2024
0727bb7
working post
odeimaiz Aug 8, 2024
cf3af7f
not needed
odeimaiz Aug 8, 2024
f2f16e9
delete working
odeimaiz Aug 8, 2024
2c0383e
update folder
odeimaiz Aug 8, 2024
1025dee
reload after put
odeimaiz Aug 8, 2024
d729b90
make folders optional
matusdrobuliak66 Aug 8, 2024
b9cf440
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 8, 2024
dc27a0a
review @sanderegg
matusdrobuliak66 Aug 8, 2024
bea85b2
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 8, 2024
80138fa
separate calls for folders
odeimaiz Aug 8, 2024
56b8d19
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 8, 2024
9e065df
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 8, 2024
078d435
minor
odeimaiz Aug 8, 2024
933af0e
default one week
odeimaiz Aug 8, 2024
dd18f2e
minor
odeimaiz Aug 8, 2024
3dea9ef
minor
odeimaiz Aug 8, 2024
cf7b14c
refactoring
odeimaiz Aug 8, 2024
1bcb8ed
moveToFolder
odeimaiz Aug 8, 2024
d2f5774
minor
odeimaiz Aug 8, 2024
5ee7437
minor
odeimaiz Aug 8, 2024
fb2a070
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 9, 2024
fddf7c3
reset list in reloadResources
odeimaiz Aug 9, 2024
08365b5
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 12, 2024
b9cca23
reload resources after folder change
odeimaiz Aug 12, 2024
5ac5a92
minor
odeimaiz Aug 12, 2024
eb87795
navigate
odeimaiz Aug 12, 2024
4dfa215
disable Share folder
odeimaiz Aug 12, 2024
02ad9cb
disableShare
odeimaiz Aug 12, 2024
f2422f0
isFoldersEnabled
odeimaiz Aug 12, 2024
df804c8
Move To Folder Menu Button
odeimaiz Aug 12, 2024
ade3b29
populate tree
odeimaiz Aug 12, 2024
8ec5b2f
build tree
odeimaiz Aug 12, 2024
683f77f
__moveStudyToFolder
odeimaiz Aug 12, 2024
0001b5d
minors
odeimaiz Aug 13, 2024
7da278b
not there yet
odeimaiz Aug 13, 2024
0967b08
simplify
odeimaiz Aug 13, 2024
bd485f3
minor
odeimaiz Aug 13, 2024
82cc213
loaded property
odeimaiz Aug 13, 2024
48dafdc
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 13, 2024
ec7c1db
minor
odeimaiz Aug 13, 2024
d42d0d8
remove moved card
odeimaiz Aug 13, 2024
be93d65
move to folder working
odeimaiz Aug 13, 2024
993f5de
review @pcrespov
matusdrobuliak66 Aug 13, 2024
ff821ff
review @pcrespov
matusdrobuliak66 Aug 13, 2024
3796b70
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 13, 2024
fb284ea
improvements
matusdrobuliak66 Aug 13, 2024
d08a5cd
fix open api specs
matusdrobuliak66 Aug 13, 2024
87f1346
adding test
matusdrobuliak66 Aug 13, 2024
0c7c64b
review @pcrespov
matusdrobuliak66 Aug 13, 2024
61bdf2c
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 13, 2024
39243c7
small progress
odeimaiz Aug 13, 2024
8a18da4
adding order by to folders
matusdrobuliak66 Aug 13, 2024
d8a72db
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 14, 2024
d0b19cd
adding pagination to folders
matusdrobuliak66 Aug 14, 2024
402548d
adding pagination tests
matusdrobuliak66 Aug 14, 2024
e8e2a1f
add filter by product name
matusdrobuliak66 Aug 14, 2024
0fa36a8
add WEBSERVER_FOLDERS env var
matusdrobuliak66 Aug 14, 2024
ba2efa4
fix test
matusdrobuliak66 Aug 14, 2024
3e76b73
Merge branch 'master' into enable-disable-folders
matusdrobuliak66 Aug 14, 2024
2c0a860
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 14, 2024
bb44772
Merge branch 'enable-disable-folders' of github.com:matusdrobuliak66/…
odeimaiz Aug 14, 2024
9fddeb9
Merge branch 'feature/connect-folders-backend' of github.com:odeimaiz…
odeimaiz Aug 14, 2024
a441f66
minors
odeimaiz Aug 14, 2024
cf2cd9e
add todos
odeimaiz Aug 14, 2024
05dd372
owner property
odeimaiz Aug 14, 2024
5a2acf2
paginated getFOlders response
odeimaiz Aug 14, 2024
0da307a
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 14, 2024
a9f14cb
bad merge
odeimaiz Aug 14, 2024
2bde953
minor
odeimaiz Aug 14, 2024
bd8d83b
minor
odeimaiz Aug 14, 2024
71ee948
postFolder and catch
odeimaiz Aug 14, 2024
a63c863
minor
odeimaiz Aug 14, 2024
9a87eca
folderId can be null
odeimaiz Aug 14, 2024
27398f4
minor
odeimaiz Aug 14, 2024
ceb2844
renaming
odeimaiz Aug 14, 2024
b85d541
minor
odeimaiz Aug 14, 2024
5790927
refactoring
odeimaiz Aug 14, 2024
97ea9f0
small win
odeimaiz Aug 14, 2024
e54a4a8
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 15, 2024
26348b4
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 15, 2024
a27add9
Merge branch 'master' into feature/connect-folders-backend
odeimaiz Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {

events: {
"folderSelected": "qx.event.type.Data",
"folderUpdated": "qx.event.type.Data",
"deleteFolderRequested": "qx.event.type.Data"
},

Expand Down Expand Up @@ -148,9 +149,9 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
__applyFolder: function(folder) {
this.getChildControl("icon");
this.set({
cardKey: "folder-" + folder.getId()
cardKey: "folder-" + folder.getFolderId()
});
folder.bind("id", this, "folderId");
folder.bind("folderId", this, "folderId");
folder.bind("parentId", this, "parentFolderId");
folder.bind("name", this, "title");
folder.bind("description", this, "description");
Expand Down Expand Up @@ -198,18 +199,18 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
folderEditor.addListener("updateFolder", () => {
const newName = folderEditor.getLabel();
const newDescription = folderEditor.getDescription();
const promises = [];
if (newName !== folder.getName()) {
promises.push(osparc.data.model.Folder.patchFolder(this.getFolderId(), "name", newName));
}
if (newDescription !== folder.getDescription()) {
promises.push(osparc.data.model.Folder.patchFolder(this.getFolderId(), "description", newDescription));
}
Promise.all(promises)
.then(() => folder.set({
name: newName,
description: newDescription
}))
const updateData = {
"name": newName,
"description": newDescription
};
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
.then(() => {
folder.set({
name: newName,
description: newDescription
});
this.fireDataEvent("folderUpdated", folder.getFolderId());
})
.catch(err => console.error(err));
win.close();
});
Expand Down Expand Up @@ -260,10 +261,15 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
},

__openShareWith: function() {
const title = this.tr("Share Folder");
const permissionsView = new osparc.share.CollaboratorsFolder(this.getFolder());
osparc.ui.window.Window.popUpInWindow(permissionsView, title);
permissionsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getFolder().getAccessRights()), this);
const disableShare = true;
if (disableShare) {
osparc.FlashMessenger.getInstance().logAs(this.tr("Not yet implemented"), "WARNING");
} else {
const title = this.tr("Share Folder");
const permissionsView = new osparc.share.CollaboratorsFolder(this.getFolder());
osparc.ui.window.Window.popUpInWindow(permissionsView, title);
permissionsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getFolder().getAccessRights()), this);
}
},

__deleteStudyRequested: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ qx.Class.define("osparc.dashboard.FolderHeader", {
} else {
folderButton = new qx.ui.form.Button(this.tr("Home"), "@FontAwesome5Solid/home/14");
}
folderButton.addListener("execute", () => this.fireDataEvent("changeCurrentFolderId", folder ? folder.getId() : null), this);
folderButton.addListener("execute", () => this.fireDataEvent("changeCurrentFolderId", folder ? folder.getFolderId() : null), this);
folderButton.set({
backgroundColor: "transparent",
textColor: "text",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* ************************************************************************

osparc - the simcore frontend

https://osparc.io

Copyright:
2024 IT'IS Foundation, https://itis.swiss

License:
MIT: https://opensource.org/licenses/MIT

Authors:
* Odei Maiz (odeimaiz)

************************************************************************ */

qx.Class.define("osparc.dashboard.FolderTreeItem", {
extend: qx.ui.tree.VirtualTreeItem,

members: {
_addWidgets: function() {
this.addSpacer();
// this.addOpenButton();
const openButton = this.getChildControl("open");
openButton.addListener("changeOpen", () => {
console.log("changeOpen", this);
}, this);
openButton.addListener("changeVisibility", e => {
// console.log("changeVisibility", this.getLabel() + e.getData(), this);
openButton.show();
}, this);
this._add(openButton);
this.addIcon();
const label = this.getChildControl("label");
this._add(label, {
flex: 1
});
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* ************************************************************************

osparc - the simcore frontend

https://osparc.io

Copyright:
2024 IT'IS Foundation, https://itis.swiss

License:
MIT: https://opensource.org/licenses/MIT

Authors:
* Odei Maiz (odeimaiz)

************************************************************************ */

qx.Class.define("osparc.dashboard.FoldersTree", {
extend: qx.ui.tree.VirtualTree,

construct: function() {
const rootFolder = this.self().createNewEntry(null);
const root = qx.data.marshal.Json.createModel(rootFolder, true);
this.__fetchChildren(root);

this.base(arguments, root, "label", "children");

this.set({
openMode: "dbltap",
decorator: "no-border",
font: "text-14",
showLeafs: true,
paddingLeft: -10,
});

this.__initTree();
},

events: {
"selectionChanged": "qx.event.type.Event" // tap
},

statics: {
createNewEntry: function(folder) {
return {
folderId: folder ? folder.getFolderId() : null,
label: folder ? folder.getName() : "Home",
children: [
this.self().getLoadingData()
],
loaded: false,
};
},

getLoadingData: function() {
return {
folderId: -1,
label: "Loading...",
children: [],
icon: "@FontAwesome5Solid/circle-notch/12",
loaded: false,
};
},

addLoadingChild: function(parentModel) {
const loadingModel = qx.data.marshal.Json.createModel(this.self().getLoadingData(), true);
parentModel.getChildren().append(loadingModel);
},

removeLoadingChild: function(parent) {
for (let i = parent.getChildren().getLength() - 1; i >= 0; i--) {
if (parent.getChildren().toArray()[i].getLabel() === "Loading...") {
parent.getChildren().splice(i, 1);
}
}
}
},

members: {
__initTree: function() {
const that = this;
this.setDelegate({
createItem: () => new osparc.dashboard.FolderTreeItem(),
bindItem: (c, item, id) => {
c.bindDefaultProperties(item, id);
c.bindProperty("folderId", "model", null, item, id);
c.bindProperty("", "open", {
converter(value, _, __, target) {
const isOpen = target.isOpen();
if (isOpen && !value.getLoaded()) {
// eslint-disable-next-line no-underscore-dangle
that.__fetchChildren(value);
}
return isOpen;
}
}, item, id);
},
configureItem: item => {
item.addListener("tap", () => this.fireDataEvent("selectionChanged", item.getModel()), this);
},
sorter: (a, b) => {
const aLabel = a.getLabel();
if (aLabel === -1) {
return 1;
}
const bLabel = b.getLabel();
if (bLabel === -1) {
return -1;
}
return aLabel - bLabel;
}
});
},

__fetchChildren: function(parentModel) {
parentModel.setLoaded(true);

const folderId = parentModel.getFolderId ? parentModel.getFolderId() : parentModel.getModel();
osparc.store.Folders.getInstance().fetchFolders(folderId)
.then(folders => {
this.self().removeLoadingChild(parentModel);
folders.forEach(folder => {
const folderData = this.self().createNewEntry(folder);
const folderModel = qx.data.marshal.Json.createModel(folderData, true);
parentModel.getChildren().append(folderModel);
});
})
.catch(console.error);
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* ************************************************************************

osparc - the simcore frontend

https://osparc.io

Copyright:
2024 IT'IS Foundation, https://itis.swiss

License:
MIT: https://opensource.org/licenses/MIT

Authors:
* Odei Maiz (odeimaiz)

************************************************************************ */

qx.Class.define("osparc.dashboard.MoveStudyToFolder", {
extend: qx.ui.core.Widget,

construct: function(studyData, currentFolderId) {
this.base(arguments);

this.__studyData = studyData;
this.__currentFolderId = currentFolderId;

this._setLayout(new qx.ui.layout.VBox(10));

this.getChildControl("current-folder");
const foldersTree = this.getChildControl("folders-tree");
this.getChildControl("cancel-btn");
const moveButton = this.getChildControl("move-btn");

moveButton.setEnabled(false)
foldersTree.addListener("selectionChanged", e => {
const folderId = e.getData();
moveButton.setEnabled(this.__currentFolderId !== folderId);
moveButton.addListenerOnce("execute", () => this.fireDataEvent("moveToFolder", folderId));
});
},

events: {
"cancel": "qx.event.type.Event",
"moveToFolder": "qx.event.type.Data"
},

members: {
__studyData: null,
__currentFolderId: null,

_createChildControlImpl: function(id) {
let control;
switch (id) {
case "current-folder": {
const folder = osparc.store.Folders.getInstance().getFolder(this.__currentFolderId);
const currentFolderName = folder ? folder["name"] : "Home";
control = new qx.ui.basic.Label(this.tr("Current location: ") + currentFolderName);
this._add(control);
break;
}
case "folders-tree":
control = new osparc.dashboard.FoldersTree();
this._add(control);
break;
case "buttons-layout":
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
alignX: "right"
}));
this._add(control);
break;
case "cancel-btn": {
const buttons = this.getChildControl("buttons-layout");
control = new qx.ui.form.Button(this.tr("Cancel")).set({
appearance: "form-button-text"
});
control.addListener("execute", () => this.fireEvent("cancel"), this);
buttons.add(control);
break;
}
case "move-btn": {
const buttons = this.getChildControl("buttons-layout");
control = new qx.ui.form.Button(this.tr("Move")).set({
appearance: "form-button"
});
buttons.add(control);
break;
}
}
return control || this.base(arguments, id);
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
resourcesContainer.addListener("tagClicked", e => this._searchBarFilter.addTagActiveFilter(e.getData()));
resourcesContainer.addListener("emptyStudyClicked", e => this._deleteResourceRequested(e.getData()));
resourcesContainer.addListener("folderSelected", e => this._folderSelected(e.getData()));
resourcesContainer.addListener("folderUpdated", e => this._folderUpdated(e.getData()));
resourcesContainer.addListener("deleteFolderRequested", e => this._deleteFolderRequested(e.getData()));
this._addToLayout(resourcesContainer);
},
Expand Down Expand Up @@ -451,6 +452,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
throw new Error("Abstract method called!");
},

_folderUpdated: function(folderId) {
throw new Error("Abstract method called!");
},

_deleteFolderRequested: function(folderId) {
throw new Error("Abstract method called!");
},
Expand Down
Loading
Loading