Skip to content

Commit 4d70330

Browse files
✨ [Frontend] Workspaces: Connect to backend (#6304)
Co-authored-by: matusdrobuliak66 <[email protected]> Co-authored-by: matusdrobuliak66 <[email protected]>
1 parent 99de33d commit 4d70330

26 files changed

+778
-466
lines changed

services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ qx.Class.define("osparc.auth.ui.LoginView", {
9999
this.fireEvent("toRegister");
100100
} else if (createAccountAction === "REQUEST_ACCOUNT_FORM") {
101101
this.fireEvent("toRequestAccount");
102-
} else if (createAccountAction === "REQUEST_ACCOUNT_FORM") {
102+
} else if (createAccountAction === "REQUEST_ACCOUNT_INSTRUCTIONS") {
103103
osparc.store.Support.openInvitationRequiredDialog();
104104
}
105105
createAccountBtn.setEnabled(true);

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

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
4545
events: {
4646
"folderSelected": "qx.event.type.Data",
4747
"folderUpdated": "qx.event.type.Data",
48+
"moveFolderToFolderRequested": "qx.event.type.Data",
49+
"moveFolderToWorkspaceRequested": "qx.event.type.Data",
4850
"deleteFolderRequested": "qx.event.type.Data"
4951
},
5052

@@ -73,12 +75,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
7375
apply: "__applyTitle"
7476
},
7577

76-
description: {
77-
check: "String",
78-
nullable: true,
79-
apply: "__applyDescription"
80-
},
81-
8278
lastModified: {
8379
check: "Date",
8480
nullable: true,
@@ -143,7 +139,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
143139
folder.bind("folderId", this, "folderId");
144140
folder.bind("parentId", this, "parentFolderId");
145141
folder.bind("name", this, "title");
146-
folder.bind("description", this, "description");
147142
folder.bind("lastModified", this, "lastModified");
148143

149144
this.__addMenuButton();
@@ -152,11 +147,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
152147
__applyTitle: function(value) {
153148
const label = this.getChildControl("title");
154149
label.setValue(value);
155-
this.__updateTooltip();
156-
},
157-
158-
__applyDescription: function() {
159-
this.__updateTooltip();
160150
},
161151

162152
__applyLastModified: function(value) {
@@ -175,58 +165,59 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
175165
});
176166

177167
const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12");
178-
editButton.addListener("execute", () => {
179-
const folder = this.getFolder();
180-
const newFolder = false;
181-
const folderEditor = new osparc.editor.FolderEditor(newFolder).set({
182-
label: folder.getName(),
183-
description: folder.getDescription()
184-
});
185-
const title = this.tr("Edit Folder");
186-
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 200);
187-
folderEditor.addListener("updateFolder", () => {
188-
const newName = folderEditor.getLabel();
189-
const newDescription = folderEditor.getDescription();
190-
const updateData = {
191-
"name": newName,
192-
"description": newDescription
193-
};
194-
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
195-
.then(() => {
196-
folder.set({
197-
name: newName,
198-
description: newDescription
199-
});
200-
this.fireDataEvent("folderUpdated", folder.getFolderId());
201-
})
202-
.catch(err => console.error(err));
203-
win.close();
204-
});
205-
folderEditor.addListener("cancel", () => win.close());
206-
});
168+
editButton.addListener("execute", () => this.__editFolder(), this);
207169
menu.add(editButton);
208170

171+
const moveToFolderButton = new qx.ui.menu.Button(this.tr("Move to Folder..."), "@FontAwesome5Solid/folder/12");
172+
moveToFolderButton.addListener("execute", () => this.fireDataEvent("moveFolderToFolderRequested", this.getFolderId()), this);
173+
menu.add(moveToFolderButton);
174+
175+
const moveToWorkspaceButton = new qx.ui.menu.Button(this.tr("Move to Workspace..."), "");
176+
moveToWorkspaceButton.addListener("execute", () => this.fireDataEvent("moveFolderToWorkspaceRequested", this.getFolderId()), this);
177+
menu.add(moveToWorkspaceButton);
178+
179+
menu.addSeparator();
180+
209181
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
210182
deleteButton.addListener("execute", () => this.__deleteStudyRequested(), this);
211183
menu.add(deleteButton);
212184

213185
menuButton.setMenu(menu);
214186
},
215187

216-
__updateTooltip: function() {
217-
const toolTipText = this.getTitle() + (this.getDescription() ? "<br>" + this.getDescription() : "");
218-
this.set({
219-
toolTipText
220-
})
221-
},
222-
223188
__itemSelected: function(newVal) {
224189
if (newVal) {
225190
this.fireDataEvent("folderSelected", this.getFolderId());
226191
}
227192
this.setValue(false);
228193
},
229194

195+
__editFolder: function() {
196+
const folder = this.getFolder();
197+
const newFolder = false;
198+
const folderEditor = new osparc.editor.FolderEditor(newFolder).set({
199+
label: folder.getName(),
200+
});
201+
const title = this.tr("Edit Folder");
202+
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 150);
203+
folderEditor.addListener("updateFolder", () => {
204+
const newName = folderEditor.getLabel();
205+
const updateData = {
206+
"name": newName,
207+
};
208+
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
209+
.then(() => {
210+
folder.set({
211+
name: newName,
212+
});
213+
this.fireDataEvent("folderUpdated", folder.getFolderId());
214+
})
215+
.catch(err => console.error(err));
216+
win.close();
217+
});
218+
folderEditor.addListener("cancel", () => win.close());
219+
},
220+
230221
__deleteStudyRequested: function() {
231222
const msg = this.tr("Are you sure you want to delete") + " <b>" + this.getTitle() + "</b>?";
232223
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,11 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", {
8080
const newFolder = true;
8181
const folderEditor = new osparc.editor.FolderEditor(newFolder);
8282
const title = this.tr("New Folder");
83-
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 200);
83+
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 150);
8484
folderEditor.addListener("createFolder", () => {
8585
const name = folderEditor.getLabel();
86-
const description = folderEditor.getDescription();
8786
this.fireDataEvent("createFolder", {
8887
name,
89-
description
9088
});
9189
win.close();
9290
});

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
qx.Class.define("osparc.dashboard.FoldersTree", {
1919
extend: qx.ui.tree.VirtualTree,
2020

21-
construct: function() {
22-
const rootFolder = this.self().createNewEntry(null);
21+
construct: function(currentWorkspaceId) {
22+
this.__currentWorkspaceId = currentWorkspaceId;
23+
const workspace = osparc.store.Workspaces.getWorkspace(currentWorkspaceId);
24+
const rootLabel = workspace ? workspace.getName() : "My Workspace";
25+
const rootFolder = this.self().createNewEntry(rootLabel, null);
2326
const root = qx.data.marshal.Json.createModel(rootFolder, true);
2427
this.__fetchChildren(root);
2528

@@ -41,10 +44,10 @@ qx.Class.define("osparc.dashboard.FoldersTree", {
4144
},
4245

4346
statics: {
44-
createNewEntry: function(folder) {
47+
createNewEntry: function(label, folderId) {
4548
return {
46-
folderId: folder ? folder.getFolderId() : null,
47-
label: folder ? folder.getName() : "Home",
49+
label,
50+
folderId,
4851
children: [
4952
this.self().getLoadingData()
5053
],
@@ -77,6 +80,8 @@ qx.Class.define("osparc.dashboard.FoldersTree", {
7780
},
7881

7982
members: {
83+
__currentWorkspaceId:null,
84+
8085
__initTree: function() {
8186
const that = this;
8287
this.setDelegate({
@@ -116,11 +121,11 @@ qx.Class.define("osparc.dashboard.FoldersTree", {
116121
parentModel.setLoaded(true);
117122

118123
const folderId = parentModel.getFolderId ? parentModel.getFolderId() : parentModel.getModel();
119-
osparc.store.Folders.getInstance().fetchFolders(folderId)
124+
osparc.store.Folders.getInstance().fetchFolders(folderId, this.__currentWorkspaceId)
120125
.then(folders => {
121126
this.self().removeLoadingChild(parentModel);
122127
folders.forEach(folder => {
123-
const folderData = this.self().createNewEntry(folder);
128+
const folderData = this.self().createNewEntry(folder.getName(), folder.getFolderId());
124129
const folderModel = qx.data.marshal.Json.createModel(folderData, true);
125130
parentModel.getChildren().append(folderModel);
126131
});

services/static-webserver/client/source/class/osparc/dashboard/MoveStudyToFolder.js renamed to services/static-webserver/client/source/class/osparc/dashboard/MoveResourceToFolder.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
1616
************************************************************************ */
1717

18-
qx.Class.define("osparc.dashboard.MoveStudyToFolder", {
18+
qx.Class.define("osparc.dashboard.MoveResourceToFolder", {
1919
extend: qx.ui.core.Widget,
2020

21-
construct: function(studyData, currentFolderId) {
21+
construct: function(currentFolderId, currentWorkspaceId) {
2222
this.base(arguments);
2323

24-
this.__studyData = studyData;
2524
this.__currentFolderId = currentFolderId;
25+
this.__currentWorkspaceId = currentWorkspaceId;
2626

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

@@ -35,7 +35,10 @@ qx.Class.define("osparc.dashboard.MoveStudyToFolder", {
3535
foldersTree.addListener("selectionChanged", e => {
3636
const folderId = e.getData();
3737
moveButton.setEnabled(this.__currentFolderId !== folderId);
38-
moveButton.addListenerOnce("execute", () => this.fireDataEvent("moveToFolder", folderId));
38+
this.__selectedFolderId = folderId;
39+
});
40+
moveButton.addListener("execute", () => {
41+
this.fireDataEvent("moveToFolder", this.__selectedFolderId);
3942
});
4043
},
4144

@@ -45,7 +48,6 @@ qx.Class.define("osparc.dashboard.MoveStudyToFolder", {
4548
},
4649

4750
members: {
48-
__studyData: null,
4951
__currentFolderId: null,
5052

5153
_createChildControlImpl: function(id) {
@@ -59,7 +61,7 @@ qx.Class.define("osparc.dashboard.MoveStudyToFolder", {
5961
break;
6062
}
6163
case "folders-tree":
62-
control = new osparc.dashboard.FoldersTree();
64+
control = new osparc.dashboard.FoldersTree(this.__currentWorkspaceId);
6365
this._add(control);
6466
break;
6567
case "buttons-layout":
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.dashboard.MoveResourceToWorkspace", {
19+
extend: qx.ui.core.Widget,
20+
21+
construct: function(currentWorkspaceId) {
22+
this.base(arguments);
23+
24+
this.__currentWorkspaceId = currentWorkspaceId;
25+
26+
this._setLayout(new qx.ui.layout.VBox(10));
27+
28+
this.getChildControl("current-workspace");
29+
const workspacesTree = this.getChildControl("workspaces-tree");
30+
this.getChildControl("cancel-btn");
31+
const moveButton = this.getChildControl("move-btn");
32+
33+
moveButton.setEnabled(false)
34+
workspacesTree.addListener("selectionChanged", e => {
35+
const workspaceId = e.getData();
36+
moveButton.setEnabled(this.__currentWorkspaceId !== workspaceId);
37+
this.__selectedWorkspaceId = workspaceId;
38+
});
39+
moveButton.addListener("execute", () => {
40+
this.fireDataEvent("moveToWorkspace", this.__selectedWorkspaceId);
41+
}, this);
42+
},
43+
44+
events: {
45+
"cancel": "qx.event.type.Event",
46+
"moveToWorkspace": "qx.event.type.Data"
47+
},
48+
49+
members: {
50+
__currentWorkspaceId: null,
51+
52+
_createChildControlImpl: function(id) {
53+
let control;
54+
switch (id) {
55+
case "current-workspace": {
56+
const workspace = osparc.store.Workspaces.getWorkspace(this.__currentWorkspaceId);
57+
const currentWorkspaceName = workspace ? workspace.getName() : "My Workspace";
58+
control = new qx.ui.basic.Label(this.tr("Current location: ") + currentWorkspaceName);
59+
this._add(control);
60+
break;
61+
}
62+
case "workspaces-tree":
63+
control = new osparc.dashboard.WorkspacesTree();
64+
this._add(control);
65+
break;
66+
case "buttons-layout":
67+
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
68+
alignX: "right"
69+
}));
70+
this._add(control);
71+
break;
72+
case "cancel-btn": {
73+
const buttons = this.getChildControl("buttons-layout");
74+
control = new qx.ui.form.Button(this.tr("Cancel")).set({
75+
appearance: "form-button-text"
76+
});
77+
control.addListener("execute", () => this.fireEvent("cancel"), this);
78+
buttons.add(control);
79+
break;
80+
}
81+
case "move-btn": {
82+
const buttons = this.getChildControl("buttons-layout");
83+
control = new qx.ui.form.Button(this.tr("Move")).set({
84+
appearance: "form-button"
85+
});
86+
buttons.add(control);
87+
break;
88+
}
89+
}
90+
return control || this.base(arguments, id);
91+
}
92+
}
93+
});

0 commit comments

Comments
 (0)