|
| 1 | +/* ************************************************************************ |
| 2 | +
|
| 3 | + osparc - the simcore frontend |
| 4 | +
|
| 5 | + https://osparc.io |
| 6 | +
|
| 7 | + Copyright: |
| 8 | + 2025 IT'IS Foundation, https://itis.swiss |
| 9 | +
|
| 10 | + License: |
| 11 | + MIT: https://opensource.org/licenses/MIT |
| 12 | +
|
| 13 | + Authors: |
| 14 | + * Odei Maiz (odeimaiz) |
| 15 | +
|
| 16 | +************************************************************************ */ |
| 17 | + |
| 18 | +qx.Class.define("osparc.wrapper.BookACallIframe", { |
| 19 | + extend: qx.ui.embed.Iframe, |
| 20 | + |
| 21 | + construct: function() { |
| 22 | + // Build base URL |
| 23 | + let url = osparc.wrapper.BookACallIframe.SERVICE_URL; |
| 24 | + |
| 25 | + const params = []; |
| 26 | + const myAuthData = osparc.auth.Data.getInstance(); |
| 27 | + const firstName = myAuthData.getFirstName(); |
| 28 | + if (firstName) { |
| 29 | + params.push("first_name=" + encodeURIComponent(firstName)); |
| 30 | + } |
| 31 | + const lastName = myAuthData.getLastName(); |
| 32 | + if (lastName) { |
| 33 | + params.push("last_name=" + encodeURIComponent(lastName)); |
| 34 | + } |
| 35 | + const email = myAuthData.getEmail(); |
| 36 | + if (email) { |
| 37 | + params.push("email=" + encodeURIComponent(email)); |
| 38 | + } |
| 39 | + |
| 40 | + if (params.length > 0) { |
| 41 | + url += "?" + params.join("&"); |
| 42 | + } |
| 43 | + |
| 44 | + // Call parent constructor |
| 45 | + this.base(arguments, url); |
| 46 | + |
| 47 | + this.addListener("load", () => this.__updateStyles(), this); |
| 48 | + }, |
| 49 | + |
| 50 | + statics: { |
| 51 | + SERVICE_URL: "http://localhost:8000/booking", |
| 52 | + }, |
| 53 | + |
| 54 | + members: { |
| 55 | + __updateStyles: function() { |
| 56 | + const colorManager = qx.theme.manager.Color.getInstance(); |
| 57 | + const iframe = this.getContentElement().getDomElement(); |
| 58 | + const theme = { |
| 59 | + '--bs-body-bg': colorManager.resolve("background-main-1"), |
| 60 | + '--osparc-primary': '"red"', |
| 61 | + '--osparc-secondary': '"green"', |
| 62 | + '--osparc-text': '"black"' |
| 63 | + }; |
| 64 | + iframe.contentWindow.postMessage({ |
| 65 | + type: 'osparc-theme', |
| 66 | + theme |
| 67 | + }, "http://localhost:8000"); // targetOrigin = iframe origin |
| 68 | + }, |
| 69 | + } |
| 70 | +}); |
0 commit comments