Skip to content

Commit e55362e

Browse files
committed
FlashMessageOEC
1 parent 5aca687 commit e55362e

File tree

2 files changed

+85
-7
lines changed

2 files changed

+85
-7
lines changed

services/static-webserver/client/source/class/osparc/FlashMessenger.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ qx.Class.define("osparc.FlashMessenger", {
8686
console.error(error);
8787
}
8888
const msg = this.extractMessage(error, defaultMessage);
89-
const flashMessage = this.getInstance().logAs(msg, "ERROR", duration);
89+
let flashMessage = null;
9090
if (error && error["supportId"]) {
91-
flashMessage.addWidget(this.__createCopyOECWidget(msg, error["supportId"]));
92-
flashMessage.setDuration(flashMessage.getDuration()*2);
91+
flashMessage = new osparc.ui.message.FlashMessageOEC(msg, duration, error["supportId"]);
92+
this.getInstance().addFlashMessage(flashMessage);
93+
} else {
94+
flashMessage = this.getInstance().logAs(msg, "ERROR", duration);
9395
}
9496
return flashMessage;
9597
},
@@ -142,14 +144,15 @@ qx.Class.define("osparc.FlashMessenger", {
142144

143145
log: function(logMessage) {
144146
const message = this.self().extractMessage(logMessage);
145-
146147
const level = logMessage.level.toUpperCase(); // "DEBUG", "INFO", "WARNING", "ERROR"
147-
148148
const flashMessage = new osparc.ui.message.FlashMessage(message, level, logMessage.duration);
149+
this.addFlashMessage(flashMessage);
150+
return flashMessage;
151+
},
152+
153+
addFlashMessage: function(flashMessage) {
149154
flashMessage.addListener("closeMessage", () => this.removeMessage(flashMessage), this);
150155
this.__messages.push(flashMessage);
151-
152-
return flashMessage;
153156
},
154157

155158
/**
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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.ui.message.FlashMessageOEC", {
19+
extend: osparc.ui.message.FlashMessage,
20+
21+
/**
22+
* Constructor for the FlashMessage.
23+
*
24+
* @param {String} message Message that the user will read.
25+
* @param {Number} duration
26+
* @param {String} supportId
27+
*/
28+
construct: function(message, duration, supportId) {
29+
this.base(arguments, message, "ERROR", duration*2);
30+
31+
const oecAtom = this.getChildControl("oec-atom");
32+
this.bind("supportId", oecAtom, "label");
33+
this.setSupportId(supportId);
34+
},
35+
36+
properties: {
37+
supportId: {
38+
check: "String",
39+
nullable: true,
40+
event: "changeSupportId",
41+
},
42+
},
43+
44+
members: {
45+
_createChildControlImpl: function(id) {
46+
let control;
47+
switch (id) {
48+
case "oec-atom":
49+
control = new qx.ui.basic.Atom().set({
50+
icon: "@FontAwesome5Solid/copy/10",
51+
iconPosition: "right",
52+
gap: 8,
53+
cursor: "pointer",
54+
alignX: "center",
55+
allowGrowX: false,
56+
});
57+
control.addListener("tap", () => {
58+
const currentStudy = osparc.store.Store.getInstance().getCurrentStudy();
59+
const dataToClipboard = {
60+
message: this.getMessage(),
61+
supportId: this.getSupportId(),
62+
timestamp: new Date().toString(),
63+
url: window.location.href,
64+
releaseTag: osparc.utils.Utils.getReleaseTag(),
65+
studyId: currentStudy ? currentStudy.getUuid() : "",
66+
}
67+
osparc.utils.Utils.copyTextToClipboard(osparc.utils.Utils.prettifyJson(dataToClipboard));
68+
});
69+
this.addWidget(control);
70+
break;
71+
}
72+
return control || this.base(arguments, id);
73+
},
74+
}
75+
});

0 commit comments

Comments
 (0)