Skip to content

Commit b4006b9

Browse files
🎨 [Frontend] UX Enh: Starting osparc (#7987)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 383c511 commit b4006b9

File tree

5 files changed

+72
-21
lines changed

5 files changed

+72
-21
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ qx.Class.define("osparc.dashboard.AppBrowser", {
4242
}
4343
this._resourcesInitialized = true;
4444

45+
this._showLoadingPage(this.tr("Loading Apps..."));
4546
this._resourcesList = [];
4647
Promise.all([
4748
osparc.store.Services.getServicesLatest(),
@@ -63,19 +64,21 @@ qx.Class.define("osparc.dashboard.AppBrowser", {
6364

6465
this.getChildControl("resources-layout");
6566
this.reloadResources();
66-
this._hideLoadingPage();
6767
});
6868
},
6969

7070
reloadResources: function(useCache = true) {
71-
this.__loadServices();
72-
this.__loadHypertools(useCache);
71+
Promise.all([
72+
this.__loadServices(),
73+
this.__loadHypertools(useCache),
74+
])
75+
.finally(() => this._hideLoadingPage());
7376
},
7477

7578
__loadServices: function() {
7679
const excludeFrontend = true;
7780
const excludeDeprecated = true
78-
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
81+
return osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
7982
.then(servicesList => {
8083
servicesList.forEach(service => service["resourceType"] = "service");
8184
this._resourcesList.push(...servicesList.filter(service => service !== null));
@@ -84,7 +87,7 @@ qx.Class.define("osparc.dashboard.AppBrowser", {
8487
},
8588

8689
__loadHypertools: function(useCache = true) {
87-
osparc.store.Templates.getHypertools(useCache)
90+
return osparc.store.Templates.getHypertools(useCache)
8891
.then(hypertoolsList => {
8992
hypertoolsList.forEach(hypertool => hypertool["resourceType"] = "hypertool");
9093
this._resourcesList.push(...hypertoolsList.filter(hypertool => hypertool !== null));
@@ -126,6 +129,8 @@ qx.Class.define("osparc.dashboard.AppBrowser", {
126129
this._populateCardMenu(card);
127130
});
128131
osparc.filter.UIFilterController.dispatch("searchBarFilter");
132+
133+
this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this._resourceType);
129134
},
130135

131136
__itemClicked: function(card) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ qx.Class.define("osparc.dashboard.Dashboard", {
209209
selectedTab.resourceBrowser.initResources();
210210
} else {
211211
const initTab = () => {
212-
selectedTab.resourceBrowser.initResources()
212+
selectedTab.resourceBrowser.initResources();
213213
this.removeListener("preResourcesLoaded", initTab);
214214
};
215215
this.addListener("preResourcesLoaded", initTab, this);

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
4242
this._add(foldersContainer);
4343
}
4444

45+
const noResourcesFound = this.__noResourcesFound = new qx.ui.basic.Label("No resources found").set({
46+
visibility: "excluded",
47+
font: "text-14"
48+
});
49+
noResourcesFound.exclude();
50+
this._add(noResourcesFound);
51+
4552
const nonGroupedContainer = this.__nonGroupedContainer = this.__createFlatList();
4653
this._add(nonGroupedContainer);
4754

@@ -128,9 +135,38 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
128135
__groupedContainersList: null,
129136
__foldersContainer: null,
130137
__workspacesContainer: null,
138+
__noResourcesFound: null,
131139
__nonGroupedContainer: null,
132140
__groupedContainers: null,
133141

142+
evaluateNoResourcesFoundLabel: function(cards, context) {
143+
if (this.__noResourcesFound) {
144+
let text = null;
145+
switch (context) {
146+
case "studiesAndFolders":
147+
case "search":
148+
text = this.tr("No Projects found");
149+
break;
150+
case "templates":
151+
text = this.tr("No Templates found");
152+
break;
153+
case "public":
154+
text = this.tr("No Public Projects found");
155+
break;
156+
case "template":
157+
text = this.tr("No Tutorials found");
158+
break;
159+
case "service":
160+
text = this.tr("No Apps found");
161+
break;
162+
}
163+
this.__noResourcesFound.set({
164+
value: text,
165+
visibility: text && cards.length === 0 ? "visible" : "excluded",
166+
});
167+
}
168+
},
169+
134170
addNonResourceCard: function(card) {
135171
if (osparc.dashboard.CardContainer.isValidCard(card)) {
136172
let groupContainer = null;

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
9595
__foldersList: null,
9696
__loadingFolders: null,
9797
__loadingWorkspaces: null,
98-
__dragWidget: null,
9998

10099
// overridden
101100
initResources: function() {
@@ -104,6 +103,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
104103
}
105104
this._resourcesInitialized = true;
106105

106+
this._showLoadingPage(this.tr("Loading Projects..."));
107107
this._resourcesList = [];
108108
this.__getActiveStudy()
109109
.then(() => {
@@ -118,8 +118,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
118118
} else {
119119
this.reloadResources();
120120
}
121-
// "Starting..." page
122-
this._hideLoadingPage();
123121

124122
// since all the resources (templates, users, orgs...) were already loaded, notifications can be built
125123
osparc.data.Resources.get("notifications")
@@ -150,10 +148,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
150148
osparc.data.Permissions.getInstance().canDo("studies.user.read") &&
151149
osparc.auth.Manager.getInstance().isLoggedIn()
152150
) {
153-
this.__reloadFolders();
154-
this.__reloadStudies();
151+
Promise.all([
152+
this.__reloadFolders(),
153+
this.__reloadStudies(),
154+
])
155+
.finally(() => this._hideLoadingPage());
155156
} else {
156157
this.__resetStudiesList();
158+
this._hideLoadingPage();
157159
}
158160
},
159161

@@ -235,7 +237,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
235237

236238
this.__loadingFolders = true;
237239
this.__setFoldersToList([]);
238-
request
240+
return request
239241
.then(folders => {
240242
this.__setFoldersToList(folders);
241243
if (this.getCurrentContext() === "trash") {
@@ -267,7 +269,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
267269

268270
this._loadingResourcesBtn.setFetching(true);
269271
this._loadingResourcesBtn.setVisibility("visible");
270-
this.__getNextStudiesRequest()
272+
this._resourcesContainer.evaluateNoResourcesFoundLabel([]);
273+
return this.__getNextStudiesRequest()
271274
.then(resp => {
272275
// Context might have been changed while waiting for the response.
273276
// The new call is on the way, therefore this response can be ignored.
@@ -341,7 +344,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
341344
if (this._resourcesContainer.getFlatList()) {
342345
this._loadingResourcesBtn.setVisibility(this._resourcesContainer.getFlatList().nextRequest === null ? "excluded" : "visible");
343346
}
344-
this._moreResourcesRequired();
347+
// delay the next request to avoid flooding the server
348+
setTimeout(() => this._moreResourcesRequired(), 100);
345349
});
346350
},
347351

@@ -415,6 +419,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
415419
this._resourcesContainer.addNonResourceCard(loadMoreBtn);
416420

417421
osparc.filter.UIFilterController.dispatch("searchBarFilter");
422+
423+
this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this.getCurrentContext());
418424
},
419425

420426
__reloadNewCards: function() {
@@ -423,6 +429,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
423429
this.__configureStudyCards(cards);
424430

425431
osparc.filter.UIFilterController.dispatch("searchBarFilter");
432+
433+
this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this.getCurrentContext());
426434
},
427435

428436
// WORKSPACES

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
3434
}
3535
this._resourcesInitialized = true;
3636

37+
this._showLoadingPage(this.tr("Loading Tutorials..."));
3738
osparc.store.Templates.getTutorials()
3839
.then(() => {
3940
this._resourcesList = [];
4041
this.getChildControl("resources-layout");
4142
this.reloadResources();
4243
this.__attachEventHandlers();
43-
this._hideLoadingPage();
4444
});
4545
},
4646

4747
reloadResources: function(useCache = true) {
4848
if (osparc.data.Permissions.getInstance().canDo("studies.templates.read")) {
49-
this.__reloadTutorials(useCache);
49+
this.__reloadTutorials(useCache)
50+
.finally(() => this._hideLoadingPage());
5051
} else {
5152
this.__setResourcesToList([]);
53+
this._hideLoadingPage();
5254
}
5355
},
5456

@@ -65,8 +67,6 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
6567
},
6668

6769
__tutorialStateReceived: function(templateId, state, errors) {
68-
osparc.store.Templates.getTutorials()
69-
// OM follow here
7070
const idx = this._resourcesList.findIndex(study => study["uuid"] === templateId);
7171
if (idx > -1) {
7272
this._resourcesList[idx]["state"] = state;
@@ -83,9 +83,9 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
8383
__reloadTutorials: function(useCache) {
8484
this.__tasksToCards();
8585

86-
osparc.store.Templates.getTutorials(useCache)
87-
.then(tutorials => this.__setResourcesToList(tutorials))
88-
.catch(() => this.__setResourcesToList([]));
86+
return osparc.store.Templates.getTutorials(useCache)
87+
.then(tutorials => this.__setResourcesToList(tutorials))
88+
.catch(() => this.__setResourcesToList([]));
8989
},
9090

9191
_updateTutorialData: function(templateData) {
@@ -116,6 +116,8 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
116116
});
117117
this.__evaluateUpdateAllButton();
118118
osparc.filter.UIFilterController.dispatch("searchBarFilter");
119+
120+
this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this._resourceType);
119121
},
120122

121123
__itemClicked: function(card) {

0 commit comments

Comments
 (0)