diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPageFlex.js b/services/static-webserver/client/source/class/osparc/auth/LoginPageFlex.js deleted file mode 100644 index f367fa0e0b9e..000000000000 --- a/services/static-webserver/client/source/class/osparc/auth/LoginPageFlex.js +++ /dev/null @@ -1,50 +0,0 @@ -/* ************************************************************************ - - 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.auth.LoginPageFlex", { - extend: osparc.auth.LoginPage, - type: "abstract", - - properties: { - compactVersion: { - check: "Boolean", - init: false, - nullable: false, - event: "changeCompactVersion", - apply: "_reloadLayout" - } - }, - - members: { - // overridden - _buildLayout: function() { - this._reloadLayout(); - - setTimeout(() => this.__resized(), 100); - window.addEventListener("resize", () => this.__resized()); - }, - - __resized: function() { - const width = document.documentElement.clientWidth; - this.setCompactVersion(width < 2*(osparc.auth.core.BaseAuthPage.FORM_WIDTH + 50)); - }, - - _reloadLayout: function() { - throw new Error("Abstract method called!"); - } - } -}); diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPageOsparc.js b/services/static-webserver/client/source/class/osparc/auth/LoginPageOsparc.js index 4d693882cdc9..e5f7bff66e08 100644 --- a/services/static-webserver/client/source/class/osparc/auth/LoginPageOsparc.js +++ b/services/static-webserver/client/source/class/osparc/auth/LoginPageOsparc.js @@ -16,18 +16,24 @@ ************************************************************************ */ qx.Class.define("osparc.auth.LoginPageOsparc", { - extend: osparc.auth.LoginPage, - - members: { - // overridden - _buildLayout: function() { - const layout = new qx.ui.layout.HBox(); - this._setLayout(layout); - - const loginLayout = this._getMainLayout(); - this._add(loginLayout, { - flex: 1 - }); - } - } + extend: qx.ui.core.Widget, + + construct: function() { + this.base(arguments); + + const layout = new qx.ui.layout.HBox(); + this._setLayout(layout); + + const loginPage = new osparc.auth.LoginWithDecorators(); + loginPage.addListener("done", e => this.fireDataEvent("done", e.getData())); + const container = new qx.ui.container.Scroll(); + container.add(loginPage); + this._add(container, { + flex: 1 + }); + }, + + events: { + "done": "qx.event.type.Data", + }, }); diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPageS4L.js b/services/static-webserver/client/source/class/osparc/auth/LoginPageS4L.js index 1e7cf123b378..1ff204745d94 100644 --- a/services/static-webserver/client/source/class/osparc/auth/LoginPageS4L.js +++ b/services/static-webserver/client/source/class/osparc/auth/LoginPageS4L.js @@ -21,36 +21,17 @@ */ qx.Class.define("osparc.auth.LoginPageS4L", { - extend: osparc.auth.LoginPageFlex, + extend: osparc.auth.LoginPageSplit, - members: { - // overridden - _reloadLayout: function() { - const layout = new qx.ui.layout.HBox(); - this._setLayout(layout); - - this.setBackgroundColor("rgba(0, 20, 46, 1)"); + construct: function() { + this.base(arguments); - this._removeAll(); + this.setBackgroundColor("rgba(0, 20, 46, 1)"); + }, - const loginLayout = this._getMainLayout(); - if (this.isCompactVersion()) { - this._resetBackgroundImage(); - this._add(loginLayout, { - flex: 1 - }); - } else { - this.__setBackgroundImage(); - this._add(new qx.ui.core.Spacer(), { - width: "50%" - }); - this._add(loginLayout, { - width: "50%" - }); - } - }, - - __setBackgroundImage: function() { + members: { + // overridden + _getBackgroundImage: function() { let backgroundImage = ""; const defaultBG = `url(${osparc.product.Utils.getProductBackgroundUrl("Sim4Life-head-default.png")}), url(${osparc.product.Utils.getProductBackgroundUrl("clouds_11.png")})`; @@ -71,7 +52,7 @@ qx.Class.define("osparc.auth.LoginPageS4L", { backgroundImage = defaultBG; break; } - this._setBackgroundImage(backgroundImage); - } + return backgroundImage; + }, } }); diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPageSplit.js b/services/static-webserver/client/source/class/osparc/auth/LoginPageSplit.js new file mode 100644 index 000000000000..f1e11eddf313 --- /dev/null +++ b/services/static-webserver/client/source/class/osparc/auth/LoginPageSplit.js @@ -0,0 +1,126 @@ +/* ************************************************************************ + + 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.auth.LoginPageSplit", { + extend: qx.ui.core.Widget, + type: "abstract", + + construct: function() { + this.base(arguments); + + const layout = new qx.ui.layout.HBox(); + this._setLayout(layout); + + this.__rebuildLayout(); + + setTimeout(() => this.__resized(), 100); + window.addEventListener("resize", () => this.__resized()); + }, + + properties: { + compactVersion: { + check: "Boolean", + init: false, + nullable: false, + event: "changeCompactVersion", + apply: "__rebuildLayout" + } + }, + + events: { + "done": "qx.event.type.Data", + }, + + statics: { + COMPACT_WIDTH_BREAKPOINT: 2*(osparc.auth.core.BaseAuthPage.FORM_WIDTH + 50), + COMPACT_HEIGHT_BREAKPOINT: osparc.WindowSizeTracker.HEIGHT_BREAKPOINT * 1.1, + }, + + members: { + _getBackgroundImage: function() { + throw new Error("Abstract method called!"); + }, + + __resized: function() { + const width = document.documentElement.clientWidth; + const height = document.documentElement.clientHeight; + this.setCompactVersion( + (width < this.self().COMPACT_WIDTH_BREAKPOINT) || + (height < this.self().COMPACT_HEIGHT_BREAKPOINT) + ); + }, + + __rebuildLayout: function() { + this._removeAll(); + + const loginPage = new osparc.auth.LoginWithDecorators(); + loginPage.addListener("done", e => this.fireDataEvent("done", e.getData())); + const container = new qx.ui.container.Scroll(); + container.add(loginPage); + const hideableItems = loginPage.getChildControl("login-view").getHideableItems(); + if (this.isCompactVersion()) { + // no split-image + // just the login widget + this.__resetBackgroundImage(); + this._add(container, { + flex: 1 + }); + hideableItems.forEach(hideableItem => hideableItem.exclude()); + } else { + // split-image on the left + // the login widget on the right + this.___setBackgroundImage(); + this._add(new qx.ui.core.Spacer(), { + width: "50%" + }); + this._add(container, { + width: "50%" + }); + hideableItems.forEach(hideableItem => hideableItem.show()); + } + }, + + __setBackgroundImage: function(backgroundImage) { + if (osparc.product.Utils.getProductName().includes("s4l")) { + this.getContentElement().setStyles({ + "background-image": backgroundImage, + "background-repeat": "no-repeat", + "background-size": "65% auto, 80% auto", // auto width, 85% height + "background-position": "left bottom, left -440px bottom -230px" // left bottom + }); + } else { + this.getContentElement().setStyles({ + "background-image": backgroundImage, + "background-repeat": "no-repeat", + "background-size": "50% auto", // 50% of the view width + "background-position": "left 10% center" // left bottom + }); + } + }, + + __resetBackgroundImage: function() { + this.getContentElement().setStyles({ + "background-image": "" + }); + }, + + ___setBackgroundImage: function() { + const backgroundImage = this._getBackgroundImage(); + this.__setBackgroundImage(backgroundImage); + }, + } +}); diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPageTI.js b/services/static-webserver/client/source/class/osparc/auth/LoginPageTI.js index 622e94bfbbf4..a10d61194899 100644 --- a/services/static-webserver/client/source/class/osparc/auth/LoginPageTI.js +++ b/services/static-webserver/client/source/class/osparc/auth/LoginPageTI.js @@ -21,36 +21,13 @@ */ qx.Class.define("osparc.auth.LoginPageTI", { - extend: osparc.auth.LoginPageFlex, + extend: osparc.auth.LoginPageSplit, members: { // overridden - _reloadLayout: function() { - const layout = new qx.ui.layout.HBox(); - this._setLayout(layout); - - this._removeAll(); - - const loginLayout = this._getMainLayout(); - if (this.isCompactVersion()) { - this._resetBackgroundImage(); - this._add(loginLayout, { - flex: 1 - }); - } else { - this.__setBackgroundImage(); - this._add(new qx.ui.core.Spacer(), { - width: "50%" - }); - this._add(loginLayout, { - width: "50%" - }); - } - }, - - __setBackgroundImage: function() { + _getBackgroundImage: function() { const backgroundImage = "url(resource/osparc/tip_splitimage.png)"; - this._setBackgroundImage(backgroundImage); - } + return backgroundImage; + }, } }); diff --git a/services/static-webserver/client/source/class/osparc/auth/LoginPage.js b/services/static-webserver/client/source/class/osparc/auth/LoginWithDecorators.js similarity index 82% rename from services/static-webserver/client/source/class/osparc/auth/LoginPage.js rename to services/static-webserver/client/source/class/osparc/auth/LoginWithDecorators.js index a972fce24d64..65d778af81b5 100644 --- a/services/static-webserver/client/source/class/osparc/auth/LoginPage.js +++ b/services/static-webserver/client/source/class/osparc/auth/LoginWithDecorators.js @@ -12,17 +12,24 @@ Authors: * Pedro Crespo (pcrespov) + * Odei Maiz (odeimaiz) ************************************************************************ */ /** - * Main Authentication Page: - * A multi-page view that fills all page + * Main Authentication Page. A multi-page view that contains: + * - top-spacer + * - product logo + * - login stack (multi-page) + * - announcements (if any) + * - the login forms + * - disclaimer and extra widgets (if any) + * - bottom-spacer + * - footer */ -qx.Class.define("osparc.auth.LoginPage", { +qx.Class.define("osparc.auth.LoginWithDecorators", { extend: qx.ui.core.Widget, - type: "abstract", /* ***************************************************************************** @@ -32,7 +39,14 @@ qx.Class.define("osparc.auth.LoginPage", { construct: function() { this.base(arguments); - this._buildLayout(); + this._setLayout(new qx.ui.layout.VBox(10)); + + this.set({ + alignX: "center", + alignY: "middle" + }); + + this.__buildLayout(); }, events: { @@ -48,20 +62,9 @@ qx.Class.define("osparc.auth.LoginPage", { _createChildControlImpl: function(id) { let control; switch (id) { - case "main-layout": { - control = new qx.ui.container.Composite(new qx.ui.layout.VBox(10)).set({ - alignX: "center", - alignY: "middle" - }); - const scrollView = new qx.ui.container.Scroll(); - scrollView.add(control); - break; - } case "top-spacer": - control = new qx.ui.core.Spacer().set({ - minHeight: 50 - }); - this.getChildControl("main-layout").add(control, { + control = new qx.ui.core.Spacer(); + this._add(control, { flex: 1 }); break; @@ -82,7 +85,7 @@ qx.Class.define("osparc.auth.LoginPage", { }); } control.setFont("text-18"); - this.getChildControl("main-layout").add(control); + this._add(control); break; } case "science-text-image": @@ -93,28 +96,27 @@ qx.Class.define("osparc.auth.LoginPage", { alignX: "center", marginTop: -25 }); - this.getChildControl("main-layout").add(control); + this._add(control); break; case "pages-stack": control = new qx.ui.container.Stack().set({ allowGrowX: false, - alignX: "center" + alignX: "center", + minHeight: 165, }); - this.getChildControl("main-layout").add(control, { + this._add(control, { flex: 1 }); break; case "bottom-spacer": - control = new qx.ui.core.Spacer().set({ - minHeight: 50 - }); - this.getChildControl("main-layout").add(control, { + control = new qx.ui.core.Spacer(); + this._add(control, { flex: 1 }); break; case "footer": { control = this.__getVersionLink(); - this.getChildControl("main-layout").add(control); + this._add(control); break; } case "login-view": { @@ -160,36 +162,7 @@ qx.Class.define("osparc.auth.LoginPage", { return control || this.base(arguments, id); }, - _buildLayout: function() { - throw new Error("Abstract method called!"); - }, - - _setBackgroundImage: function(backgroundImage) { - if (osparc.product.Utils.getProductName().includes("s4l")) { - this.getContentElement().setStyles({ - "background-image": backgroundImage, - "background-repeat": "no-repeat", - "background-size": "65% auto, 80% auto", // auto width, 85% height - "background-position": "left bottom, left -440px bottom -230px" // left bottom - }); - } else { - this.getContentElement().setStyles({ - "background-image": backgroundImage, - "background-repeat": "no-repeat", - "background-size": "50% auto", // 50% of the view width - "background-position": "left 10% center" // left bottom - }); - } - }, - - _resetBackgroundImage: function() { - this.getContentElement().setStyles({ - "background-image": "" - }); - }, - - _getMainLayout: function() { - const mainLayout = this.getChildControl("main-layout"); + __buildLayout: function() { this.getChildControl("top-spacer"); const logo = this.getChildControl("logo-w-platform"); if (osparc.product.Utils.isS4LProduct() || osparc.product.Utils.isProduct("s4llite")) { @@ -202,7 +175,6 @@ qx.Class.define("osparc.auth.LoginPage", { this.__getLoginStack(); this.getChildControl("bottom-spacer"); this.getChildControl("footer"); - return mainLayout; }, __getLoginStack: function() { diff --git a/services/static-webserver/client/source/class/osparc/auth/core/BaseAuthPage.js b/services/static-webserver/client/source/class/osparc/auth/core/BaseAuthPage.js index 092c40fb26a4..8a1488b7e4da 100644 --- a/services/static-webserver/client/source/class/osparc/auth/core/BaseAuthPage.js +++ b/services/static-webserver/client/source/class/osparc/auth/core/BaseAuthPage.js @@ -72,13 +72,9 @@ qx.Class.define("osparc.auth.core.BaseAuthPage", { */ _form: null, - /** - * This method gets called upon construction and - * must be overriden in a subclass - * - * @signature function() - */ - _buildPage: null, + _buildPage: function() { + throw new Error("Abstract method called!"); + }, beautifyFormFields: function() { const formItems = this._form.getItems(); diff --git a/services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js b/services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js index fdbcebeaec2f..ea0324b06403 100644 --- a/services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js +++ b/services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js @@ -27,6 +27,12 @@ qx.Class.define("osparc.auth.ui.LoginView", { extend: osparc.auth.core.BaseAuthPage, + construct: function() { + this.__hideableItems = []; + + this.base(arguments); + }, + events: { "toRegister": "qx.event.type.Event", "toRequestAccount": "qx.event.type.Event", @@ -38,9 +44,16 @@ qx.Class.define("osparc.auth.ui.LoginView", { members: { __loginBtn: null, __loginAnnouncements: null, + __hideableItems: null, // overrides base _buildPage: function() { + this.__addAnnouncements(); + this.__addLoginForms(); + this.__addExtraWidgets(); + }, + + __addAnnouncements: function() { const announcementUIFactory = osparc.announcement.AnnouncementUIFactory.getInstance(); const addAnnouncements = () => { if (this.__loginAnnouncements) { @@ -54,8 +67,9 @@ qx.Class.define("osparc.auth.ui.LoginView", { } else { announcementUIFactory.addListenerOnce("changeAnnouncements", () => addAnnouncements()); } + }, - // form + __addLoginForms: function() { const email = new qx.ui.form.TextField().set({ required: true }); @@ -98,7 +112,7 @@ qx.Class.define("osparc.auth.ui.LoginView", { } createAccountBtn.addListener("execute", () => { if (window.location.hostname === "tip.itis.swiss") { - this.__openTIPITISSWISSPhaseOutDialog(); + this.__openTipItisPhaseOutDialog(); } else if (createAccountAction === "REGISTER") { this.fireEvent("toRegister"); } else if (createAccountAction === "REQUEST_ACCOUNT_FORM") { @@ -123,7 +137,9 @@ qx.Class.define("osparc.auth.ui.LoginView", { }); this.add(grp); + }, + __addExtraWidgets: function() { if (osparc.product.Utils.isProduct("tis") || osparc.product.Utils.isProduct("tiplite")) { let text = ""; if (osparc.product.Utils.isProduct("tiplite")) { @@ -144,10 +160,6 @@ qx.Class.define("osparc.auth.ui.LoginView", { disclaimer.getChildren()[1].setFont("text-12"); // description this.add(disclaimer); - this.add(new qx.ui.core.Spacer(), { - flex: 1 - }); - const poweredByLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({ alignX: "center", allowGrowX: false, @@ -158,17 +170,22 @@ qx.Class.define("osparc.auth.ui.LoginView", { poweredByLayout.add(label); const s4lLogo = new qx.ui.basic.Image("osparc/Sim4Life_full_logo_white.svg"); s4lLogo.set({ - width: osparc.auth.LoginPage.LOGO_WIDTH/2, - height: osparc.auth.LoginPage.LOGO_HEIGHT/2, + width: osparc.auth.LoginWithDecorators.LOGO_WIDTH/2, + height: osparc.auth.LoginWithDecorators.LOGO_HEIGHT/2, scale: true, alignX: "center" }); poweredByLayout.add(s4lLogo); this.add(poweredByLayout); + this.__hideableItems.push(poweredByLayout); } }, - __openTIPITISSWISSPhaseOutDialog: function() { + getHideableItems: function() { + return this.__hideableItems; + }, + + __openTipItisPhaseOutDialog: function() { const createAccountWindow = new osparc.ui.window.Dialog("Request Account").set({ maxWidth: 380 });