Skip to content

Commit a3b8340

Browse files
authored
🎨 [Frontend] Folder & Workspaces: Missing features I (#6317)
1 parent e28d3bd commit a3b8340

21 files changed

+554
-353
lines changed

services/static-webserver/client/source/class/osparc/About.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,6 @@ qx.Class.define("osparc.About", {
184184
const label = lib.name || "unknown-library";
185185
const version = lib.version || "-";
186186
const url = lib.url || null;
187-
const thumbnail = lib.thumbnail || null;
188-
189-
if (thumbnail) {
190-
const image = new qx.ui.basic.Image(thumbnail).set({
191-
height: 30,
192-
maxWidth: this.self().MAX_WIDTH - 2*this.self().PADDING,
193-
scale: true,
194-
toolTipText: label + (version === "-" ? "" : (" " + version))
195-
});
196-
image.getContentElement().setStyles({
197-
"object-fit": "contain",
198-
"object-position": "left"
199-
});
200-
if (url) {
201-
image.set({
202-
cursor: "pointer"
203-
});
204-
image.addListener("tap", () => window.open(url));
205-
}
206-
return [image];
207-
}
208187

209188
let entryLabel;
210189
if (url) {

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,12 @@ qx.Class.define("osparc.dashboard.ContainerHeader", {
109109
const workspace = osparc.store.Workspaces.getWorkspace(workspaceId);
110110
rootButton = new qx.ui.form.Button(workspace.getName(), osparc.store.Workspaces.iconPath());
111111
}
112-
rootButton.addListener("execute", () => this.set({
113-
currentWorkspaceId: workspaceId,
114-
currentFolderId: null,
115-
}));
116112
} else {
117113
rootButton = new qx.ui.form.Button(this.tr("My Workspace"), "@FontAwesome5Solid/home/14");
118-
rootButton.addListener("execute", () => this.set({
119-
currentWorkspaceId: null,
120-
currentFolderId: null,
121-
}));
122114
}
115+
rootButton.addListener("execute", () => this.set({
116+
currentFolderId: null,
117+
}));
123118
return rootButton;
124119
},
125120

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
5858
apply: "__applyFolder"
5959
},
6060

61+
workspaceId: {
62+
check: "Number",
63+
nullable: true,
64+
apply: "__applyWorkspaceId"
65+
},
66+
6167
folderId: {
6268
check: "Number",
6369
nullable: false
@@ -87,8 +93,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
8793
let control;
8894
switch (id) {
8995
case "icon": {
90-
control = new qx.ui.basic.Image().set({
91-
source: "@FontAwesome5Solid/folder/26",
96+
control = new osparc.dashboard.FolderWithSharedIcon().set({
9297
anonymous: true,
9398
height: 40,
9499
padding: 5
@@ -136,6 +141,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
136141
this.set({
137142
cardKey: "folder-" + folder.getFolderId()
138143
});
144+
folder.bind("workspaceId", this, "workspaceId");
139145
folder.bind("folderId", this, "folderId");
140146
folder.bind("parentId", this, "parentFolderId");
141147
folder.bind("name", this, "title");
@@ -144,6 +150,22 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
144150
this.__addMenuButton();
145151
},
146152

153+
__applyWorkspaceId: function(workspaceId) {
154+
const workspace = osparc.store.Workspaces.getWorkspace(workspaceId);
155+
const accessRights = workspace ? workspace.getAccessRights() : {};
156+
if (accessRights && Object.keys(accessRights).length) {
157+
const shareIcon = this.getChildControl("icon").getChildControl("shared-icon");
158+
// if it's not shared don't show the share icon
159+
shareIcon.addListener("changeSource", e => {
160+
const newSource = e.getData();
161+
shareIcon.set({
162+
visibility: newSource.includes(osparc.dashboard.CardBase.SHARE_ICON) ? "hidden" : "visible"
163+
});
164+
});
165+
osparc.dashboard.CardBase.populateShareIcon(shareIcon, accessRights);
166+
}
167+
},
168+
147169
__applyTitle: function(value) {
148170
const label = this.getChildControl("title");
149171
label.setValue(value);
@@ -172,7 +194,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
172194
moveToFolderButton.addListener("execute", () => this.fireDataEvent("moveFolderToFolderRequested", this.getFolderId()), this);
173195
menu.add(moveToFolderButton);
174196

175-
const moveToWorkspaceButton = new qx.ui.menu.Button(this.tr("Move to Workspace..."), "");
197+
const moveToWorkspaceButton = new qx.ui.menu.Button(this.tr("Move to Workspace..."), osparc.store.Workspaces.iconPath(14));
176198
moveToWorkspaceButton.addListener("execute", () => this.fireDataEvent("moveFolderToWorkspaceRequested", this.getFolderId()), this);
177199
menu.add(moveToWorkspaceButton);
178200

@@ -199,7 +221,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
199221
label: folder.getName(),
200222
});
201223
const title = this.tr("Edit Folder");
202-
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 150);
224+
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 120);
203225
folderEditor.addListener("updateFolder", () => {
204226
const newName = folderEditor.getLabel();
205227
const updateData = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ 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, 150);
83+
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 120);
8484
folderEditor.addListener("createFolder", () => {
8585
const name = folderEditor.getLabel();
8686
this.fireDataEvent("createFolder", {

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

Lines changed: 0 additions & 41 deletions
This file was deleted.

services/static-webserver/client/source/class/osparc/dashboard/WorkspaceWithSharedIcon.js renamed to services/static-webserver/client/source/class/osparc/dashboard/FolderWithSharedIcon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
************************************************************************ */
1717

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

2121
construct: function() {

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

Lines changed: 30 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ qx.Class.define("osparc.dashboard.FoldersTree", {
2020

2121
construct: function(currentWorkspaceId) {
2222
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);
26-
const root = qx.data.marshal.Json.createModel(rootFolder, true);
27-
this.__fetchChildren(root);
2823

29-
this.base(arguments, root, "label", "children");
24+
const workspace = osparc.store.Workspaces.getWorkspace(this.__currentWorkspaceId);
25+
const workspaceLabel = workspace ? workspace.getName() : "My Workspace";
26+
const rootData = {
27+
label: workspaceLabel,
28+
folderId: null,
29+
children: [],
30+
loaded: true,
31+
};
32+
const root = qx.data.marshal.Json.createModel(rootData, true);
33+
this.__populateFolder(root);
3034

31-
this.set({
32-
openMode: "dbltap",
33-
decorator: "no-border",
34-
font: "text-14",
35-
showLeafs: true,
36-
paddingLeft: -10,
37-
});
35+
this.base(arguments, root, "label", "children");
3836

3937
this.__initTree();
4038
},
@@ -43,94 +41,48 @@ qx.Class.define("osparc.dashboard.FoldersTree", {
4341
"selectionChanged": "qx.event.type.Event" // tap
4442
},
4543

46-
statics: {
47-
createNewEntry: function(label, folderId) {
48-
return {
49-
label,
50-
folderId,
51-
children: [
52-
this.self().getLoadingData()
53-
],
54-
loaded: false,
55-
};
56-
},
57-
58-
getLoadingData: function() {
59-
return {
60-
folderId: -1,
61-
label: "Loading...",
62-
children: [],
63-
icon: "@FontAwesome5Solid/circle-notch/12",
64-
loaded: false,
65-
};
66-
},
67-
68-
addLoadingChild: function(parentModel) {
69-
const loadingModel = qx.data.marshal.Json.createModel(this.self().getLoadingData(), true);
70-
parentModel.getChildren().append(loadingModel);
71-
},
72-
73-
removeLoadingChild: function(parent) {
74-
for (let i = parent.getChildren().getLength() - 1; i >= 0; i--) {
75-
if (parent.getChildren().toArray()[i].getLabel() === "Loading...") {
76-
parent.getChildren().splice(i, 1);
77-
}
78-
}
79-
}
80-
},
81-
8244
members: {
8345
__currentWorkspaceId:null,
8446

8547
__initTree: function() {
8648
const that = this;
8749
this.setDelegate({
88-
createItem: () => new osparc.dashboard.FolderTreeItem(),
8950
bindItem: (c, item, id) => {
9051
c.bindDefaultProperties(item, id);
91-
c.bindProperty("folderId", "model", null, item, id);
9252
c.bindProperty("", "open", {
93-
converter(value, _, __, target) {
53+
converter(value, model, source, target) {
9454
const isOpen = target.isOpen();
9555
if (isOpen && !value.getLoaded()) {
56+
value.setLoaded(true);
9657
// eslint-disable-next-line no-underscore-dangle
97-
that.__fetchChildren(value);
58+
that.__populateFolder(value);
9859
}
9960
return isOpen;
100-
}
61+
},
10162
}, item, id);
10263
},
10364
configureItem: item => {
104-
item.addListener("tap", () => this.fireDataEvent("selectionChanged", item.getModel()), this);
65+
item.addListener("tap", () => this.fireDataEvent("selectionChanged", item.getModel().getFolderId()), this);
10566
},
106-
sorter: (a, b) => {
107-
const aLabel = a.getLabel();
108-
if (aLabel === -1) {
109-
return 1;
110-
}
111-
const bLabel = b.getLabel();
112-
if (bLabel === -1) {
113-
return -1;
114-
}
115-
return aLabel - bLabel;
116-
}
11767
});
11868
},
11969

120-
__fetchChildren: function(parentModel) {
121-
parentModel.setLoaded(true);
122-
123-
const folderId = parentModel.getFolderId ? parentModel.getFolderId() : parentModel.getModel();
124-
osparc.store.Folders.getInstance().fetchFolders(folderId, this.__currentWorkspaceId)
70+
__populateFolder: function(parent) {
71+
osparc.store.Folders.getInstance().fetchFolders(parent.getFolderId(), this.__currentWorkspaceId)
12572
.then(folders => {
126-
this.self().removeLoadingChild(parentModel);
73+
parent.getChildren().removeAll();
12774
folders.forEach(folder => {
128-
const folderData = this.self().createNewEntry(folder.getName(), folder.getFolderId());
129-
const folderModel = qx.data.marshal.Json.createModel(folderData, true);
130-
parentModel.getChildren().append(folderModel);
75+
const folderData = {
76+
label: folder.getName(),
77+
folderId: folder.getFolderId(),
78+
loaded: false,
79+
children: [{
80+
label: "Loading...",
81+
}]
82+
};
83+
parent.getChildren().push(qx.data.marshal.Json.createModel(folderData, true));
13184
});
132-
})
133-
.catch(console.error);
134-
}
85+
});
86+
},
13587
}
13688
});

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ qx.Class.define("osparc.dashboard.MoveResourceToWorkspace", {
3333
moveButton.setEnabled(false)
3434
workspacesTree.addListener("selectionChanged", e => {
3535
const workspaceId = e.getData();
36-
moveButton.setEnabled(this.__currentWorkspaceId !== workspaceId);
37-
this.__selectedWorkspaceId = workspaceId;
36+
if (this.__currentWorkspaceId !== workspaceId && workspaceId !== -1) {
37+
moveButton.setEnabled(true);
38+
this.__selectedWorkspaceId = workspaceId;
39+
} else {
40+
moveButton.setEnabled(false);
41+
}
3842
});
3943
moveButton.addListener("execute", () => {
4044
this.fireDataEvent("moveToWorkspace", this.__selectedWorkspaceId);
@@ -48,6 +52,7 @@ qx.Class.define("osparc.dashboard.MoveResourceToWorkspace", {
4852

4953
members: {
5054
__currentWorkspaceId: null,
55+
__selectedWorkspaceId: null,
5156

5257
_createChildControlImpl: function(id) {
5358
let control;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
157157
osparc.store.Workspaces.fetchWorkspaces()
158158
.then(workspaces => {
159159
workspaces.forEach(workspace => {
160-
const workspaceButton = new qx.ui.toolbar.RadioButton(workspace.getName(), osparc.store.Workspaces.iconPath(22));
160+
const workspaceButton = new qx.ui.toolbar.RadioButton(null, osparc.store.Workspaces.iconPath(22));
161+
workspace.bind("name", workspaceButton, "label");
161162
workspaceButton.workspaceId = workspace.getWorkspaceId();
162163
this.__workspaceButtons.push(workspaceButton);
163164
workspaceButton.set({

0 commit comments

Comments
 (0)