Skip to content

Commit 5164d46

Browse files
authored
⚗️ [Frontend] Integrate the 3rd party Appointment Booking tool (#8391)
1 parent e04c848 commit 5164d46

File tree

5 files changed

+128
-11
lines changed

5 files changed

+128
-11
lines changed

services/static-webserver/client/source/class/osparc/support/Conversation.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ qx.Class.define("osparc.support.Conversation", {
5858
SYSTEM_MESSAGE_TYPE: {
5959
ASK_A_QUESTION: "askAQuestion",
6060
BOOK_A_CALL: "bookACall",
61+
BOOK_A_CALL_3RD: "bookACall3rd",
6162
ESCALATE_TO_SUPPORT: "escalateToSupport",
6263
REPORT_OEC: "reportOEC",
6364
FOLLOW_UP: "followUp",
@@ -287,7 +288,7 @@ qx.Class.define("osparc.support.Conversation", {
287288
},
288289

289290
addSystemMessage: function(type) {
290-
type = type || "askAQuestion";
291+
type = type || osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.ASK_A_QUESTION;
291292

292293
const now = new Date();
293294
const systemMessage = {
@@ -317,8 +318,8 @@ qx.Class.define("osparc.support.Conversation", {
317318
if (msg) {
318319
systemMessage["content"] = msg;
319320
systemMessage["systemMessageType"] = type;
321+
this.addMessage(systemMessage);
320322
}
321-
this.addMessage(systemMessage);
322323
},
323324

324325
addMessage: function(message) {

services/static-webserver/client/source/class/osparc/support/ConversationPage.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,23 @@ qx.Class.define("osparc.support.ConversationPage", {
148148
this.getChildControl("buttons-layout").addAt(control, 4);
149149
break;
150150
}
151+
case "main-stack":
152+
control = new qx.ui.container.Stack();
153+
this._add(control, {
154+
flex: 1
155+
});
156+
break;
157+
case "conversation-container":
158+
control = new qx.ui.container.Scroll();
159+
this.getChildControl("main-stack").add(control);
160+
break;
151161
case "conversation-content":
152162
control = new osparc.support.Conversation();
153-
const scroll = new qx.ui.container.Scroll();
154-
scroll.add(control);
155-
this._add(scroll, {
156-
flex: 1,
157-
});
163+
this.getChildControl("conversation-container").add(control);
164+
break;
165+
case "book-a-call-iframe":
166+
control = new osparc.wrapper.BookACallIframe();
167+
this.getChildControl("main-stack").add(control);
158168
break;
159169
}
160170
return control || this.base(arguments, id);
@@ -167,13 +177,21 @@ qx.Class.define("osparc.support.ConversationPage", {
167177
const title = this.getChildControl("conversation-title");
168178
const conversationContent = this.getChildControl("conversation-content");
169179
conversationContent.clearAllMessages();
180+
const conversationContainer = this.getChildControl("conversation-container");
181+
this.getChildControl("main-stack").setSelection([conversationContainer]);
170182
switch (type) {
171183
case osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.ASK_A_QUESTION:
172184
title.setValue(this.tr("Ask a Question"));
173185
break;
174186
case osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL:
175187
title.setValue(this.tr("Book a Call"));
176188
break;
189+
case osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL_3RD: {
190+
title.setValue(this.tr("Book a Call 3rd"));
191+
const bookACallIframe = this.getChildControl("book-a-call-iframe");
192+
this.getChildControl("main-stack").setSelection([bookACallIframe]);
193+
break;
194+
}
177195
case osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.ESCALATE_TO_SUPPORT:
178196
title.setValue(this.tr("Ask a Question"));
179197
break;

services/static-webserver/client/source/class/osparc/support/ConversationsPage.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ qx.Class.define("osparc.support.ConversationsPage", {
2727
this.getChildControl("conversations-list");
2828
this.getChildControl("ask-a-question-button");
2929
this.getChildControl("book-a-call-button");
30+
if (osparc.utils.Utils.isDevelopmentPlatform()) {
31+
this.getChildControl("book-a-call-button-3rd");
32+
}
3033
},
3134

3235
events: {
@@ -63,7 +66,7 @@ qx.Class.define("osparc.support.ConversationsPage", {
6366
allowGrowX: false,
6467
center: true,
6568
});
66-
control.addListener("execute", () => this.fireDataEvent("createConversation", "askAQuestion"), this);
69+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.ASK_A_QUESTION), this);
6770
this.getChildControl("buttons-layout").add(control);
6871
break;
6972
case "book-a-call-button":
@@ -72,7 +75,16 @@ qx.Class.define("osparc.support.ConversationsPage", {
7275
allowGrowX: false,
7376
center: true,
7477
});
75-
control.addListener("execute", () => this.fireDataEvent("createConversation", "bookACall"), this);
78+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL), this);
79+
this.getChildControl("buttons-layout").add(control);
80+
break;
81+
case "book-a-call-button-3rd":
82+
control = new qx.ui.form.Button(this.tr("Book a Call 3rd"), "@FontAwesome5Solid/phone/14").set({
83+
appearance: "strong-button",
84+
allowGrowX: false,
85+
center: true,
86+
});
87+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL_3RD), this);
7688
this.getChildControl("buttons-layout").add(control);
7789
break;
7890
}

services/static-webserver/client/source/class/osparc/support/HomePage.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ qx.Class.define("osparc.support.HomePage", {
3131
if (osparc.store.Groups.getInstance().isSupportEnabled()) {
3232
this.getChildControl("ask-a-question-button");
3333
this.getChildControl("book-a-call-button");
34+
if (osparc.utils.Utils.isDevelopmentPlatform()) {
35+
this.getChildControl("book-a-call-button-3rd");
36+
}
3437
}
3538
this.__populateButtons();
3639
},
@@ -82,7 +85,7 @@ qx.Class.define("osparc.support.HomePage", {
8285
center: true,
8386
width: 183,
8487
});
85-
control.addListener("execute", () => this.fireDataEvent("createConversation", "askAQuestion"));
88+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.ASK_A_QUESTION));
8689
this.getChildControl("conversation-buttons-layout").add(control, { flex: 1 });
8790
break;
8891
case "book-a-call-button":
@@ -92,7 +95,17 @@ qx.Class.define("osparc.support.HomePage", {
9295
center: true,
9396
width: 183,
9497
});
95-
control.addListener("execute", () => this.fireDataEvent("createConversation", "bookACall"));
98+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL));
99+
this.getChildControl("conversation-buttons-layout").add(control, { flex: 1 });
100+
break;
101+
case "book-a-call-button-3rd":
102+
control = new qx.ui.form.Button(this.tr("Book a Call 3rd"), "@FontAwesome5Solid/phone/16").set({
103+
gap: 8,
104+
appearance: "strong-button",
105+
center: true,
106+
width: 183,
107+
});
108+
control.addListener("execute", () => this.fireDataEvent("createConversation", osparc.support.Conversation.SYSTEM_MESSAGE_TYPE.BOOK_A_CALL_3RD));
96109
this.getChildControl("conversation-buttons-layout").add(control, { flex: 1 });
97110
break;
98111
case "learning-box":
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.setAppearance("iframe-no-border");
48+
49+
// not only once, every time there is a load (e.g. when navigating in the iframe)
50+
this.addListener("load", () => this.__updateStyles(), this);
51+
},
52+
53+
statics: {
54+
SERVICE_URL: "http://localhost:8000/booking",
55+
},
56+
57+
members: {
58+
__updateStyles: function() {
59+
const colorManager = qx.theme.manager.Color.getInstance();
60+
const iframe = this.getContentElement().getDomElement();
61+
const theme = {
62+
'--bs-body-bg': colorManager.resolve("background-main-1"),
63+
'--osparc-text-color': colorManager.resolve("text"),
64+
'--osparc-primary': colorManager.resolve("product-color"),
65+
};
66+
const url = new URL(this.self().SERVICE_URL);
67+
iframe.contentWindow.postMessage({
68+
type: 'osparc-theme',
69+
theme
70+
}, url.origin); // targetOrigin = iframe origin
71+
},
72+
}
73+
});

0 commit comments

Comments
 (0)