Skip to content

Commit

Permalink
✨ New apps/prodcuts: sim4life desktop and sim4life desktop academia (I…
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Oct 26, 2023
1 parent 9538a3a commit b1279da
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 110 deletions.
2 changes: 1 addition & 1 deletion services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ services:
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.healthcheck.interval=2000ms
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.healthcheck.timeout=1000ms
- traefik.http.middlewares.${SWARM_STACK_NAME}_static_webserver_retry.retry.attempts=2
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.rule=hostregexp(`{host:.+}`) && (Path(`/osparc`,`/s4l`,`/s4llite`,`/s4lacad`,`/tis`,`/transpiled`,`/resource`) || PathPrefix(`/osparc/`,`/s4l/`,`/s4llite/`,`/s4lacad/`,`/tis/`,`/transpiled/`,`/resource/`))
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.rule=hostregexp(`{host:.+}`) && (Path(`/osparc`,`/s4l`,`/s4llite`,`/s4lacad`,`/s4ldesktop`,`/s4ldesktopacad`,`/tis`,`/transpiled`,`/resource`) || PathPrefix(`/osparc/`,`/s4l/`,`/s4llite/`,`/s4lacad/`,`/s4ldesktop/`,`/s4ldesktopacad/`,`/tis/`,`/transpiled/`,`/resource/`))
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.service=${SWARM_STACK_NAME}_static_webserver
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.entrypoints=http
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.priority=2
Expand Down
2 changes: 1 addition & 1 deletion services/static-webserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Used for static content serving.

In the future will fully serve all static content. Currently the `webserver` is still serving the following routes:

- `/` resolves to one of the three index.html pages inside the 4 products (osparc, tis, s4l, s4llite, s4lacad)
- `/` resolves to one of the three index.html pages inside the 4 products (osparc, tis, s4l, s4llite, s4lacad, s4ldesktop, s4ldesktopacad)
- `/static-frontend-data.json` contains information required by the fronted
36 changes: 34 additions & 2 deletions services/static-webserver/client/compile.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"class": "osparc.Application",
"theme": "osparc.theme.products.s4l.ThemeDark",
"name": "s4llite",
"title": "S4L lite",
"title": "Sim4Life lite",
"include": [
"iconfont.material.Load",
"iconfont.fontawesome5.Load",
Expand All @@ -72,7 +72,7 @@
"class": "osparc.Application",
"theme": "osparc.theme.products.s4l.ThemeDark",
"name": "s4lacad",
"title": "S4L Academic",
"title": "Sim4Life Academic",
"include": [
"iconfont.material.Load",
"iconfont.fontawesome5.Load",
Expand All @@ -84,6 +84,38 @@
"addTimestampsToUrls": true,
"bootPath": "source/boot"
},
{
"class": "osparc.Application",
"theme": "osparc.theme.products.s4l.ThemeDark",
"name": "s4ldesktop",
"title": "Sim4Life Desktop",
"include": [
"iconfont.material.Load",
"iconfont.fontawesome5.Load",
"osparc.theme.products.s4l.ThemeLight"
],
"environment": {
"product.name": "s4ldesktop"
},
"addTimestampsToUrls": true,
"bootPath": "source/boot"
},
{
"class": "osparc.Application",
"theme": "osparc.theme.products.s4l.ThemeDark",
"name": "s4ldesktopacad",
"title": "Sim4Life Desktop Academia",
"include": [
"iconfont.material.Load",
"iconfont.fontawesome5.Load",
"osparc.theme.products.s4l.ThemeLight"
],
"environment": {
"product.name": "s4ldesktopacad"
},
"addTimestampsToUrls": true,
"bootPath": "source/boot"
},
{
"class": "osparc.Application",
"theme": "osparc.theme.products.tis.ThemeDark",
Expand Down
32 changes: 18 additions & 14 deletions services/static-webserver/client/source/class/osparc/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ qx.Class.define("osparc.Application", {
members: {
__current: null,
__mainPage: null,
__openViewAfterLogin: null,

/**
* This method contains the initial application code and gets called
Expand Down Expand Up @@ -122,7 +121,6 @@ qx.Class.define("osparc.Application", {
},

__rerouteNav: function(urlFragment) {
this.__openViewAfterLogin = null;
const page = urlFragment.nav[0];
switch (page) {
case "study": {
Expand Down Expand Up @@ -178,15 +176,6 @@ qx.Class.define("osparc.Application", {
}
break;
}
case "wallets": {
// Route: /#/wallets
this.__openViewAfterLogin = "wallets";
osparc.utils.Utils.cookie.deleteCookie("user");
osparc.auth.Manager.getInstance().validateToken()
.then(() => this.__loadMainPage())
.catch(() => this.__loadLoginPage());
break;
}
case "error": {
// Route: /#/error/?message={errorMessage}&status_code={statusCode}
if (urlFragment.params && urlFragment.params.message) {
Expand Down Expand Up @@ -321,7 +310,7 @@ qx.Class.define("osparc.Application", {
case "s4llite":
case "s4lacad":
case "s4ldesktop":
case "s4lacaddesktop":
case "s4ldesktopacad":
view = new osparc.auth.LoginPageS4L();
this.__loadView(view);
break;
Expand All @@ -346,6 +335,15 @@ qx.Class.define("osparc.Application", {
// Invalidate the entire cache
osparc.store.Store.getInstance().invalidateEntireCache();
await this.__preloadCalls();

const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
if (osparc.product.Utils.shouldHaveWalletsEnabled() && !walletsEnabled) {
const infoLabel = this.tr("Credits information is not ready.<br>Please contact us by email:<br>");
const supportEmail = osparc.store.VendorInfo.getInstance().getSupportEmail();
osparc.FlashMessenger.getInstance().logAs(infoLabel + supportEmail, "ERROR");
this.logout();
}

const profile = await osparc.data.Resources.getOne("profile");
if (profile) {
this.__connectWebSocket();
Expand Down Expand Up @@ -393,7 +391,13 @@ qx.Class.define("osparc.Application", {
osparc.store.Store.getInstance().setCurrentStudyId(studyId);
}

const mainPage = this.__mainPage = new osparc.desktop.MainPage(this.__openViewAfterLogin);
let mainPage = null;
if (osparc.product.Utils.getProductName().includes("s4ldesktop")) {
mainPage = new osparc.desktop.MainPageDesktop();
} else {
mainPage = new osparc.desktop.MainPage();
}
this.__mainPage = mainPage;
this.__loadView(mainPage);
}
},
Expand Down Expand Up @@ -442,7 +446,7 @@ qx.Class.define("osparc.Application", {
osparc.MaintenanceTracker.getInstance().stopTracker();
osparc.announcement.Tracker.getInstance().stopTracker();
osparc.auth.Manager.getInstance().logout();
if (this.__mainPage) {
if ("closeEditor" in this.__mainPage) {
this.__mainPage.closeEditor();
}
osparc.utils.Utils.closeHangingWindows();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ qx.Class.define("osparc.auth.LoginPage", {
osparc.product.Utils.isProduct("s4l") ||
osparc.product.Utils.isProduct("s4lacad") ||
osparc.product.Utils.isProduct("s4ldesktop") ||
osparc.product.Utils.isProduct("s4ldektopacad")
osparc.product.Utils.isProduct("s4ldesktopacad")
)
) {
requestAccount = this.getChildControl("request-account");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ qx.Class.define("osparc.auth.LoginPageS4L", {
backgroundImage = "url(resource/osparc/s4llite_splitimage.png)";
break;
case "s4lacad":
case "s4lacaddesktop":
backgroundImage = "url(resource/osparc/s4lacad_splitimage.png)";
break;
case "s4ldesktop":
backgroundImage = "url(resource/osparc/s4ldesktop_splitimage.png)";
break;
case "s4ldesktopacad":
backgroundImage = "url(resource/osparc/s4ldesktopacad_splitimage.png)";
break;
case "s4l":
default:
backgroundImage = "url(resource/osparc/s4l_splitimage.png)";
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {

if (
osparc.product.Utils.isProduct("s4lacad") ||
osparc.product.Utils.isProduct("s4ldektopacad")
osparc.product.Utils.isProduct("s4ldesktopacad")
) {
const university = new qx.ui.form.TextField();
doubleSpaced.push(university);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ qx.Class.define("osparc.desktop.MainPage", {

this._add(osparc.notification.RibbonNotifications.getInstance());

const navBar = this.__navBar = this.__createNavigationBar();
const navBar = this.__navBar = new osparc.navigation.NavigationBar();
navBar.populateLayout();
navBar.addListener("backToDashboardPressed", () => this.__backToDashboardPressed(), this);
navBar.addListener("downloadStudyLogs", () => this.__downloadStudyLogs(), this);
this._add(navBar);

// Some resources request before building the main stack
Expand Down Expand Up @@ -90,13 +93,6 @@ qx.Class.define("osparc.desktop.MainPage", {
__loadingPage: null,
__studyEditor: null,

__createNavigationBar: function() {
const navBar = new osparc.navigation.NavigationBar();
navBar.addListener("backToDashboardPressed", () => this.__backToDashboardPressed(), this);
navBar.addListener("downloadStudyLogs", () => this.__downloadStudyLogs(), this);
return navBar;
},

__backToDashboardPressed: function() {
if (!osparc.data.Permissions.getInstance().canDo("studies.user.create", true)) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* ************************************************************************
osparc - the simcore frontend
https://osparc.io
Copyright:
2023 IT'IS Foundation, https://itis.swiss
License:
MIT: https://opensource.org/licenses/MIT
Authors:
* Odei Maiz (odeimaiz)
************************************************************************ */

qx.Class.define("osparc.desktop.MainPageDesktop", {
extend: qx.ui.core.Widget,

construct: function() {
this.base(arguments);

this._setLayout(new qx.ui.layout.VBox(null, null, "separator-vertical"));

this._add(osparc.notification.RibbonNotifications.getInstance());

const navBar = new osparc.navigation.NavigationBar();
navBar.populateLayout()
.then(() => {
// exclude some items from the navigation bar
navBar.getChildControl("dashboard-label").exclude();
navBar.getChildControl("dashboard-button").exclude();
navBar.getChildControl("notifications-button").exclude();
navBar.getChildControl("help").exclude();

// exclude all the menu entries except "log-out" from user menu
const userMenuButton = navBar.getChildControl("user-menu");
const userMenu = userMenuButton.getMenu();
// eslint-disable-next-line no-underscore-dangle
const userMenuEntries = userMenu._getCreatedChildControls();
Object.entries(userMenuEntries).forEach(([id, userMenuEntry]) => {
if (!["mini-profile-view", "log-out"].includes(id)) {
userMenuEntry.exclude();
}
});
// exclude also the separators
userMenu.getChildren().forEach(child => {
if (child.classname === "qx.ui.menu.Separator") {
child.exclude();
}
});
});
this._add(navBar);

osparc.MaintenanceTracker.getInstance().startTracker();

const store = osparc.store.Store.getInstance();
const preloadPromises = [];
const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
if (walletsEnabled) {
preloadPromises.push(store.reloadCreditPrice());
preloadPromises.push(store.reloadWallets());
}
preloadPromises.push(store.getAllClassifiers(true));
preloadPromises.push(store.getTags());
Promise.all(preloadPromises)
.then(() => {
const desktopCenter = new osparc.desktop.credits.DesktopCenter();
this._add(desktopCenter, {
flex: 1
});
});
}
});

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {
paddingLeft: 10
});

const tabViews = this.__tabsView = new qx.ui.tabview.TabView().set({
const tabViews = this._tabsView = new qx.ui.tabview.TabView().set({
barPosition: "left",
contentPadding: 0
});
Expand Down Expand Up @@ -83,7 +83,7 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {
},

members: {
__tabsView: null,
_tabsView: null,
__overviewPage: null,
__walletsPage: null,
__buyCreditsPage: null,
Expand Down Expand Up @@ -219,7 +219,7 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {

__openPage: function(page) {
if (page) {
this.__tabsView.setSelection([page]);
this._tabsView.setSelection([page]);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ************************************************************************
osparc - the simcore frontend
https://osparc.io
Copyright:
2023 IT'IS Foundation, https://itis.swiss
License:
MIT: https://opensource.org/licenses/MIT
Authors:
* Odei Maiz (odeimaiz)
************************************************************************ */

/**
* A mix between the Billing Center and My Account
*/

qx.Class.define("osparc.desktop.credits.DesktopCenter", {
extend: osparc.desktop.credits.BillingCenter,

construct: function() {
this.base(arguments);

this.set({
backgroundColor: "background-main-2"
});

const page = new osparc.desktop.credits.ProfilePage();
page.showLabelOnTab();
const profilePos = 2; // 0: Miniview, 1: Summary
this._tabsView.addAt(page, profilePos);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsWindow", {
orgsWindow.center();
orgsWindow.open();
return orgsWindow;
},

evaluateOrganizationsButton: function(btn) {
if (!osparc.data.Permissions.getInstance().canDo("user.organizations.create")) {
btn.exclude();
return;
}
osparc.data.Resources.get("organizations")
.then(resp => {
const orgs = resp["organizations"];
if (orgs.length) {
btn.show();
}
});
}
},

Expand Down
Loading

0 comments on commit b1279da

Please sign in to comment.