Skip to content

Commit 7dc6ace

Browse files
Merge branch 'master' into fix-invitation-url
2 parents c9df920 + 3fe2e6f commit 7dc6ace

File tree

5 files changed

+197
-2
lines changed

5 files changed

+197
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ qx.Class.define("osparc.Application", {
7070
// trackers
7171
osparc.announcement.Tracker.getInstance().startTracker();
7272
osparc.WindowSizeTracker.getInstance().startTracker();
73+
osparc.ConsoleErrorTracker.getInstance().startTracker();
7374

7475
const webSocket = osparc.wrapper.WebSocket.getInstance();
7576
webSocket.addListener("connect", () => osparc.WatchDog.getInstance().setOnline(true));
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2023 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.ConsoleErrorTracker", {
19+
extend: qx.core.Object,
20+
type: "singleton",
21+
22+
construct: function() {
23+
this.base(arguments);
24+
25+
this.__errors = [];
26+
},
27+
28+
members: {
29+
__errors: null,
30+
31+
startTracker: function() {
32+
const originalConsoleError = console.error;
33+
34+
// Override console.error
35+
console.error = (...args) => {
36+
this.__errors.unshift({
37+
date: new Date(),
38+
error: args
39+
});
40+
if (this.__errors.length > 20) {
41+
this.__errors.length = 20;
42+
}
43+
44+
// Call the original console.error so the error still appears in the console
45+
originalConsoleError.apply(console, args);
46+
};
47+
},
48+
49+
getErrors: function() {
50+
return this.__errors;
51+
},
52+
}
53+
});

services/static-webserver/client/source/class/osparc/navigation/UserMenu.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ qx.Class.define("osparc.navigation.UserMenu", {
213213
if (osparc.data.Permissions.getInstance().isProductOwner()) {
214214
this.getChildControl("po-center");
215215
}
216+
if (osparc.data.Permissions.getInstance().isTester()) {
217+
this.getChildControl("tester-center");
218+
}
216219
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
217220
this.getChildControl("billing-center");
218221
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 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.tester.ConsoleErrors", {
19+
extend: osparc.po.BaseView,
20+
construct: function() {
21+
this.base(arguments);
22+
},
23+
24+
members: {
25+
_createChildControlImpl: function(id) {
26+
let control;
27+
switch (id) {
28+
case "filter-message": {
29+
control = new qx.ui.form.TextField().set({
30+
liveUpdate : true,
31+
placeholder: this.tr("Search in Message"),
32+
});
33+
this._add(control);
34+
break;
35+
}
36+
case "messages-table": {
37+
const tableModel = new qx.ui.table.model.Filtered();
38+
tableModel.setColumns([
39+
this.tr("Date"),
40+
this.tr("Message"),
41+
]);
42+
const custom = {
43+
tableColumnModel: function(obj) {
44+
return new qx.ui.table.columnmodel.Resize(obj);
45+
}
46+
};
47+
control = new qx.ui.table.Table(tableModel, custom).set({
48+
selectable: true,
49+
statusBarVisible: false,
50+
showCellFocusIndicator: false,
51+
forceLineHeight: false
52+
});
53+
control.getTableColumnModel().setDataCellRenderer(
54+
0,
55+
new qx.ui.table.cellrenderer.String().set({
56+
defaultCellStyle: "user-select: text"
57+
})
58+
);
59+
control.getTableColumnModel().setDataCellRenderer(
60+
1,
61+
new osparc.ui.table.cellrenderer.Html().set({
62+
defaultCellStyle: "user-select: text; text-wrap: wrap"
63+
})
64+
);
65+
control.setColumnWidth(0, 80);
66+
67+
// control.setDataRowRenderer(new osparc.ui.table.rowrenderer.ExpandSelection(control));
68+
this._add(control, {
69+
flex: 1
70+
});
71+
break;
72+
}
73+
case "error-viewer":
74+
control = new qx.ui.form.TextArea().set({
75+
autoSize: true,
76+
});
77+
this._add(control, {
78+
flex: 1
79+
});
80+
break;
81+
}
82+
return control || this.base(arguments, id);
83+
},
84+
85+
_buildLayout: function() {
86+
const filterMessage = this.getChildControl("filter-message");
87+
const table = this.getChildControl("messages-table");
88+
const errorViewer = this.getChildControl("error-viewer");
89+
90+
const model = table.getTableModel();
91+
filterMessage.addListener("changeValue", e => {
92+
const value = e.getData();
93+
model.resetHiddenRows();
94+
model.addNotRegex(value, "Message", true);
95+
model.applyFilters();
96+
});
97+
table.addListener("cellTap", e => {
98+
const selectedRow = e.getRow();
99+
const rowData = table.getTableModel().getRowData(selectedRow);
100+
errorViewer.setValue(JSON.stringify(rowData[1]));
101+
}, this);
102+
103+
this.__populateTable();
104+
},
105+
106+
__populateTable: function() {
107+
const consoleErrorTracker = osparc.ConsoleErrorTracker.getInstance();
108+
const errors = consoleErrorTracker.getErrors();
109+
const errorsArray = [];
110+
errors.forEach(msg => {
111+
errorsArray.push({
112+
date: msg.date,
113+
message: msg.error,
114+
});
115+
});
116+
errorsArray.sort((a, b) => {
117+
return new Date(b.date) - new Date(a.date); // newest first
118+
});
119+
const datas = [];
120+
errorsArray.forEach(entry => {
121+
const data = [
122+
new Date(entry.date).toLocaleTimeString(),
123+
entry.message,
124+
];
125+
datas.push(data);
126+
});
127+
this.getChildControl("messages-table").getTableModel().setData(datas);
128+
}
129+
}
130+
});

services/static-webserver/client/source/class/osparc/tester/TesterCenter.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ qx.Class.define("osparc.tester.TesterCenter", {
2727
this.addWidgetOnTopOfTheTabs(miniProfile);
2828

2929
this.__addSocketMessagesPage();
30+
this.__addConsoleErrorsPage();
3031
this.__addStaticsPage();
3132
},
3233

3334
members: {
3435
__addSocketMessagesPage: function() {
3536
const title = this.tr("Socket Messages");
3637
const iconSrc = "@FontAwesome5Solid/exchange-alt/22";
37-
const maintenance = new osparc.tester.WebSocketMessages();
38-
this.addTab(title, iconSrc, maintenance);
38+
const webSocketMessages = new osparc.tester.WebSocketMessages();
39+
this.addTab(title, iconSrc, webSocketMessages);
40+
},
41+
42+
__addConsoleErrorsPage: function() {
43+
const title = this.tr("Console Errors");
44+
const iconSrc = "@FontAwesome5Solid/times/22";
45+
const consoleErrors = new osparc.tester.ConsoleErrors();
46+
this.addTab(title, iconSrc, consoleErrors);
3947
},
4048

4149
__addStaticsPage: function() {

0 commit comments

Comments
 (0)