Skip to content

Commit 81958f3

Browse files
authored
✨ [Frontend] Templates and Public Projects in Study Browser (#7676)
1 parent 67c3d67 commit 81958f3

File tree

17 files changed

+230
-103
lines changed

17 files changed

+230
-103
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Widget containing a TabView including:
2020
* - StudyBrowser
21-
* - TemplateBrowser
21+
* - TutorialBrowser
2222
* - AppBrowser
2323
* - DataBrowser
2424
*
@@ -82,16 +82,16 @@ qx.Class.define("osparc.dashboard.Dashboard", {
8282

8383
members: {
8484
__studyBrowser: null,
85-
__templateBrowser: null,
85+
__tutorialBrowser: null,
8686
__appBrowser: null,
8787
__dataBrowser: null,
8888

8989
getStudyBrowser: function() {
9090
return this.__studyBrowser;
9191
},
9292

93-
getTemplateBrowser: function() {
94-
return this.__templateBrowser;
93+
getTutorialBrowser: function() {
94+
return this.__tutorialBrowser;
9595
},
9696

9797
getAppBrowser: function() {
@@ -104,23 +104,17 @@ qx.Class.define("osparc.dashboard.Dashboard", {
104104
const tabs = [{
105105
id: "studiesTab",
106106
buttonId: "studiesTabBtn",
107-
label: osparc.product.Utils.getStudyAlias({
108-
plural: true,
109-
allUpperCase: true
110-
}),
107+
label: this.tr("PROJECTS"),
111108
icon: "@FontAwesome5Solid/file/"+tabIconSize,
112109
buildLayout: this.__createStudyBrowser
113110
}];
114111
if (permissions.canDo("dashboard.templates.read")) {
115112
tabs.push({
116113
id: "templatesTab",
117114
buttonId: "templatesTabBtn",
118-
label: osparc.product.Utils.getTemplateAlias({
119-
plural: true,
120-
allUpperCase: true
121-
}),
115+
label: this.tr("TUTORIALS"),
122116
icon: "@FontAwesome5Solid/copy/"+tabIconSize,
123-
buildLayout: this.__createTemplateBrowser
117+
buildLayout: this.__createTutorialBrowser
124118
});
125119
}
126120
if (permissions.canDo("dashboard.services.read")) {
@@ -228,8 +222,8 @@ qx.Class.define("osparc.dashboard.Dashboard", {
228222
return studiesView;
229223
},
230224

231-
__createTemplateBrowser: function() {
232-
const templatesView = this.__templateBrowser = new osparc.dashboard.TemplateBrowser();
225+
__createTutorialBrowser: function() {
226+
const templatesView = this.__tutorialBrowser = new osparc.dashboard.TutorialBrowser();
233227
return templatesView;
234228
},
235229

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
232232
}
233233

234234
if (permissions.canDo("dashboard.services.read")) {
235-
const servicesButton = this.self().createMenuButton("@FontAwesome5Solid/cog/16", this.tr("Services..."));
235+
const servicesButton = this.self().createMenuButton("@FontAwesome5Solid/cog/16", this.tr("Apps..."));
236236
servicesButton.addListener("execute", () => this.fireDataEvent("changeTab", "appsTab"), this);
237237
moreMenu.add(servicesButton);
238238
}

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
2929
this.__tagButtons = [];
3030
this.__appTypeButtons = [];
3131

32-
this._setLayout(new qx.ui.layout.VBox(15));
32+
this._setLayout(new qx.ui.layout.VBox(10));
3333
this.__buildLayout();
3434
},
3535

3636
events: {
37+
"templatesContext": "qx.event.type.Event",
38+
"publicContext": "qx.event.type.Event",
3739
"trashContext": "qx.event.type.Event",
3840
"changeTab": "qx.event.type.Data",
3941
"trashStudyRequested": "qx.event.type.Data",
@@ -46,6 +48,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
4648
members: {
4749
__resourceType: null,
4850
__workspacesAndFoldersTree: null,
51+
__templatesButton: null,
52+
__publicProjectsButton: null,
4953
__trashButton: null,
5054
__sharedWithButtons: null,
5155
__tagButtons: null,
@@ -56,6 +60,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
5660
switch (this.__resourceType) {
5761
case "study": {
5862
this._add(this.__createWorkspacesAndFoldersTree());
63+
this._add(this.__createTemplates());
64+
this._add(this.__createPublicProjects());
5965
this._add(this.__createTrashBin());
6066
this._add(filtersSpacer);
6167
const scrollView = new qx.ui.container.Scroll();
@@ -90,6 +96,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
9096
});
9197
this.__workspacesAndFoldersTree.contextChanged(context);
9298

99+
this.__templatesButton.setValue(context === "templates");
100+
this.__publicProjectsButton.setValue(context === "public");
93101
this.__trashButton.setValue(context === "trash");
94102
},
95103

@@ -116,6 +124,40 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
116124
},
117125
/* /WORKSPACES AND FOLDERS */
118126

127+
__createTemplates: function() {
128+
const templatesButton = this.__templatesButton = new qx.ui.toolbar.RadioButton().set({
129+
value: false,
130+
appearance: "filter-toggle-button",
131+
label: this.tr("Templates"),
132+
icon: "@FontAwesome5Solid/copy/16",
133+
paddingLeft: 10, // align it with the context
134+
});
135+
templatesButton.addListener("changeValue", e => {
136+
const templatesEnabled = e.getData();
137+
if (templatesEnabled) {
138+
this.fireEvent("templatesContext");
139+
}
140+
});
141+
return templatesButton;
142+
},
143+
144+
__createPublicProjects: function() {
145+
const publicProjectsButton = this.__publicProjectsButton = new qx.ui.toolbar.RadioButton().set({
146+
value: false,
147+
appearance: "filter-toggle-button",
148+
label: this.tr("Public Projects"),
149+
icon: "@FontAwesome5Solid/globe/16",
150+
paddingLeft: 10, // align it with the context
151+
});
152+
publicProjectsButton.addListener("changeValue", e => {
153+
const templatesEnabled = e.getData();
154+
if (templatesEnabled) {
155+
this.fireEvent("publicContext");
156+
}
157+
});
158+
return publicProjectsButton;
159+
},
160+
119161
/* TRASH BIN */
120162
__createTrashBin: function() {
121163
const trashButton = this.__trashButton = new qx.ui.toolbar.RadioButton().set({

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

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
3434

3535
if (resourceType === "study") {
3636
const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.CardContainer();
37+
this.__workspacesContainer.exclude();
3738
this._add(workspacesContainer);
3839

3940
const foldersContainer = this.__foldersContainer = new osparc.dashboard.CardContainer();
41+
this.__foldersContainer.exclude();
4042
this._add(foldersContainer);
4143
}
4244

@@ -294,26 +296,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
294296
this.__groupedContainersList = [];
295297
},
296298

297-
__addFoldersContainer: function() {
298-
// add foldersContainer dynamically
299-
[
300-
"addChildWidget",
301-
"removeChildWidget"
302-
].forEach(ev => {
303-
this.__foldersContainer.addListener(ev, () => {
304-
const children = this.__foldersContainer.getChildren();
305-
if (children.length && !children.includes(this.__foldersContainer)) {
306-
this._addAt(this.__foldersContainer, 0);
307-
return;
308-
}
309-
if (children.length === 0 && children.includes(this.__foldersContainer)) {
310-
this._remove(this.__foldersContainer);
311-
return;
312-
}
313-
})
314-
});
315-
},
316-
317299
__rebuildLayout: function(resourceType) {
318300
this.__cleanAll();
319301
if (this.getGroupBy()) {
@@ -386,6 +368,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
386368
reloadWorkspaces: function() {
387369
if (this.__workspacesContainer) {
388370
this.__workspacesContainer.removeAll();
371+
this.__workspacesContainer.exclude();
389372
}
390373
let workspacesCards = [];
391374
this.__workspacesList.forEach(workspaceData => workspacesCards.push(this.__workspaceToCard(workspaceData)));
@@ -394,11 +377,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
394377

395378
addNewWorkspaceCard: function(newWorkspaceCard) {
396379
this.__workspacesContainer.addAt(newWorkspaceCard, 0);
380+
this.__workspacesContainer.show();
397381
},
398382

399383
__workspaceToCard: function(workspaceData) {
400384
const card = this.__createWorkspaceCard(workspaceData);
401385
this.__workspacesContainer.add(card);
386+
this.__workspacesContainer.show();
402387
return card;
403388
},
404389

@@ -423,6 +408,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
423408
reloadFolders: function() {
424409
if (this.__foldersContainer) {
425410
this.__foldersContainer.removeAll();
411+
this.__foldersContainer.exclude();
426412
}
427413
let folderCards = [];
428414
this.__foldersList.forEach(folderData => folderCards.push(this.__folderToCard(folderData)));
@@ -431,11 +417,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
431417

432418
addNewFolderCard: function(newFolderCard) {
433419
this.__foldersContainer.addAt(newFolderCard, 0);
420+
this.__foldersContainer.show();
434421
},
435422

436423
__folderToCard: function(folderData) {
437424
const card = this.__createFolderCard(folderData);
438425
this.__foldersContainer.add(card);
426+
this.__foldersContainer.show();
439427
return card;
440428
},
441429

0 commit comments

Comments
 (0)