Skip to content

Commit 82a2b81

Browse files
committed
Home page populated
1 parent 2566e47 commit 82a2b81

File tree

2 files changed

+124
-48
lines changed

2 files changed

+124
-48
lines changed

services/static-webserver/client/source/class/osparc/store/Support.js

Lines changed: 105 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -167,73 +167,138 @@ qx.Class.define("osparc.store.Support", {
167167
return manualButtons;
168168
},
169169

170-
addSupportButtonsToMenu: function(menu) {
170+
__getIssueInfos: function() {
171+
const issuesInfos = [];
171172
const issues = osparc.store.VendorInfo.getIssues();
172-
const supports = osparc.store.VendorInfo.getSupports();
173173
issues.forEach(issueInfo => {
174-
const label = issueInfo["label"];
175-
const issueButton = new qx.ui.menu.Button(label, "@FontAwesome5Solid/comments/14");
176-
issueButton.getChildControl("label").set({
177-
rich: true
174+
issuesInfos.push({
175+
label: issueInfo["label"],
176+
icon: "@FontAwesome5Solid/comments/14",
177+
callback: () => {
178+
const issueConfirmationWindow = new osparc.ui.window.Dialog(issueInfo["label"] + " " + qx.locale.Manager.tr("Information"), null,
179+
qx.locale.Manager.tr("To create an issue, you must have an account and be already logged-in.")
180+
);
181+
const continueBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Continue"), "@FontAwesome5Solid/external-link-alt/14");
182+
continueBtn.addListener("execute", () => {
183+
window.open(issueInfo["new_url"]);
184+
issueConfirmationWindow.close();
185+
}, this);
186+
const loginBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Log in in ") + label, "@FontAwesome5Solid/external-link-alt/14");
187+
loginBtn.addListener("execute", () => window.open(issueInfo["login_url"]), this);
188+
issueConfirmationWindow.addButton(continueBtn);
189+
issueConfirmationWindow.addButton(loginBtn);
190+
issueConfirmationWindow.addCancelButton();
191+
issueConfirmationWindow.open();
192+
},
178193
});
179-
issueButton.addListener("execute", () => {
180-
const issueConfirmationWindow = new osparc.ui.window.Dialog(label + " " + qx.locale.Manager.tr("Information"), null,
181-
qx.locale.Manager.tr("To create an issue, you must have an account and be already logged-in.")
182-
);
183-
const contBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Continue"), "@FontAwesome5Solid/external-link-alt/14");
184-
contBtn.addListener("execute", () => {
185-
window.open(issueInfo["new_url"]);
186-
issueConfirmationWindow.close();
187-
}, this);
188-
const loginBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Log in in ") + label, "@FontAwesome5Solid/external-link-alt/14");
189-
loginBtn.addListener("execute", () => window.open(issueInfo["login_url"]), this);
190-
issueConfirmationWindow.addButton(contBtn);
191-
issueConfirmationWindow.addButton(loginBtn);
192-
issueConfirmationWindow.addCancelButton();
193-
issueConfirmationWindow.open();
194-
}, this);
195-
menu.add(issueButton);
196194
});
195+
return issuesInfos;
196+
},
197197

198-
if (issues.length && supports.length) {
199-
menu.addSeparator();
200-
}
201-
198+
__getSupportInfos: function() {
199+
const supportInfos = [];
200+
const supports = osparc.store.VendorInfo.getSupports();
202201
supports.forEach(supportInfo => {
203-
const supportBtn = new qx.ui.menu.Button(supportInfo["label"]);
204-
supportBtn.getChildControl("label").set({
205-
rich: true
206-
});
202+
const label = supportInfo["label"];
207203
let icon = null;
208-
let cb = null;
204+
let callback = null;
209205
switch (supportInfo["kind"]) {
210206
case "web":
211207
icon = "@FontAwesome5Solid/link/14";
212-
cb = () => window.open(supportInfo["url"]);
208+
callback = () => window.open(supportInfo["url"]);
213209
break;
214210
case "forum":
215211
icon = "@FontAwesome5Solid/comments/14";
216-
cb = () => window.open(supportInfo["url"]);
212+
callback = () => window.open(supportInfo["url"]);
217213
break;
218214
case "email":
219215
icon = "@FontAwesome5Solid/envelope/14";
220-
cb = () => this.__openSendEmailFeedbackDialog(supportInfo["email"]);
216+
callback = () => this.__openSendEmailFeedbackDialog(supportInfo["email"]);
221217
break;
222218
}
223-
supportBtn.setIcon(icon);
224-
supportBtn.addListener("execute", () => cb(), this);
219+
supportInfos.push({
220+
label,
221+
icon,
222+
callback,
223+
});
224+
});
225+
return supportInfos;
226+
},
227+
228+
addSupportButtonsToMenu: function(menu) {
229+
const issuesInfos = this.__getIssueInfos();
230+
issuesInfos.forEach(issueInfo => {
231+
const issueButton = new qx.ui.menu.Button(issueInfo.label, issueInfo.icon);
232+
issueButton.getChildControl("label").set({
233+
rich: true
234+
});
235+
issueButton.addListener("execute", issueInfo.callback, this);
236+
menu.add(issueButton);
237+
});
238+
239+
const supportInfos = this.__getSupportInfos();
240+
if (issuesInfos.length && supportInfos.length) {
241+
menu.addSeparator();
242+
}
243+
244+
supportInfos.forEach(supportInfo => {
245+
const supportBtn = new qx.ui.menu.Button(supportInfo.label, supportInfo.icon);
246+
supportBtn.getChildControl("label").set({
247+
rich: true
248+
});
249+
supportBtn.addListener("execute", supportInfo.callback, this);
225250
menu.add(supportBtn);
226251
});
227252
},
228253

229-
addReleaseNotesToMenu: function(menu) {
254+
getSupportButtons: function() {
255+
const buttons = [];
256+
const issuesInfos = this.__getIssueInfos();
257+
issuesInfos.forEach(issueInfo => {
258+
const issueButton = new qx.ui.form.Button(issueInfo.label, issueInfo.icon);
259+
issueButton.getChildControl("label").set({
260+
rich: true
261+
});
262+
issueButton.addListener("execute", issueInfo.callback, this);
263+
buttons.push(issueButton);
264+
});
265+
266+
const supportInfos = this.__getSupportInfos();
267+
supportInfos.forEach(supportInfo => {
268+
const supportBtn = new qx.ui.form.Button(supportInfo.label, supportInfo.icon);
269+
supportBtn.getChildControl("label").set({
270+
rich: true
271+
});
272+
supportBtn.addListener("execute", supportInfo.callback, this);
273+
buttons.push(supportBtn);
274+
});
275+
return buttons;
276+
},
277+
278+
__getReleaseInfo: function() {
230279
const releaseTag = osparc.utils.Utils.getReleaseTag();
231280
const releaseLink = osparc.utils.Utils.getReleaseLink();
232-
const releaseBtn = new qx.ui.menu.Button(qx.locale.Manager.tr("What's new in") + " " + releaseTag, "@FontAwesome5Solid/bullhorn/14");
233-
releaseBtn.addListener("execute", () => window.open(releaseLink), this);
281+
return {
282+
label: qx.locale.Manager.tr("What's new in") + " " + releaseTag,
283+
icon: "@FontAwesome5Solid/bullhorn/14",
284+
callback: () => { window.open(releaseLink); },
285+
};
286+
},
287+
288+
addReleaseNotesToMenu: function(menu) {
289+
const releaseInfo = this.__getReleaseInfo();
290+
const releaseBtn = new qx.ui.menu.Button(releaseInfo.label, releaseInfo.icon);
291+
releaseBtn.addListener("execute", releaseInfo.callback, this);
234292
menu.add(releaseBtn);
235293
},
236294

295+
getReleaseNotesButton: function() {
296+
const releaseInfo = this.__getReleaseInfo();
297+
const releaseBtn = new qx.ui.form.Button(releaseInfo.label, releaseInfo.icon);
298+
releaseBtn.addListener("execute", releaseInfo.callback, this);
299+
return releaseBtn;
300+
},
301+
237302
mailToLink: function(email, subject, centered = true) {
238303
const color = qx.theme.manager.Color.getInstance().resolve("text");
239304
let textLink = `<a href="mailto:${email}?subject=${subject}" style='color: ${color}' target='_blank'>${email}</a>`;

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ qx.Class.define("osparc.support.HomePage", {
2424

2525
this._setLayout(new qx.ui.layout.VBox(15));
2626

27+
this.set({
28+
padding: 5,
29+
});
30+
2731
this.getChildControl("conversations-intro-text");
2832

2933
this.__populateButtons();
@@ -36,13 +40,14 @@ qx.Class.define("osparc.support.HomePage", {
3640
case "conversations-intro-text": {
3741
control = new qx.ui.basic.Label().set({
3842
rich: true,
39-
font: "text-14",
43+
font: "text-16",
4044
});
4145
const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser();
46+
const userName = osparc.auth.Data.getInstance().getUserName();
4247
control.set({
4348
value: isSupportUser ?
44-
this.tr("Hello Support User!") :
45-
this.tr("Hello User!"),
49+
userName + ", " + this.tr("thanks for being here!<br>Let's help every user feel supported.") :
50+
this.tr("Hi there 👋<br>How can we help?"),
4651
});
4752
this._add(control);
4853
break;
@@ -61,11 +66,17 @@ qx.Class.define("osparc.support.HomePage", {
6166
this._add(guidedToursButton);
6267

6368
const manualButtons = osparc.store.Support.getManualButtons();
64-
if (manualButtons) {
65-
manualButtons.forEach(manualButton => {
66-
this._add(manualButton);
67-
});
68-
}
69+
manualButtons.forEach(manualButton => {
70+
this._add(manualButton);
71+
});
72+
73+
const supportButtons = osparc.store.Support.getSupportButtons();
74+
supportButtons.forEach(supportButton => {
75+
this._add(supportButton);
76+
});
77+
78+
const releaseNotesButton = osparc.store.Support.getReleaseNotesButton();
79+
this._add(releaseNotesButton);
6980
},
7081
}
7182
});

0 commit comments

Comments
 (0)