Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [Frontend] Logger UX improvements #6222

Merged
merged 30 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d428430
wrap text
odeimaiz Aug 22, 2024
fbe9d95
git pushMerge remote-tracking branch 'upstream/master' into ux/logger
odeimaiz Aug 22, 2024
382232d
minor
odeimaiz Aug 22, 2024
6fb561c
Merge branch 'master' into ux/logger
odeimaiz Aug 26, 2024
f8d7bae
Merge branch 'ux/logger' of github.com:odeimaiz/osparc-simcore into u…
odeimaiz Aug 26, 2024
c15d541
set height of the entire row and its children
odeimaiz Aug 26, 2024
be87c56
minor fix
odeimaiz Aug 26, 2024
fc75efc
dummy data
odeimaiz Aug 26, 2024
8ad8359
setDataRowRenderer
odeimaiz Aug 26, 2024
c772c26
minor
odeimaiz Aug 26, 2024
2ce78a6
follow up comments
odeimaiz Aug 26, 2024
03c0549
Merge branch 'master' into ux/logger
odeimaiz Aug 27, 2024
cbafeef
switch lock behaviour
odeimaiz Aug 27, 2024
aff479e
live logs
odeimaiz Aug 27, 2024
6f026bf
Copy Selected log to clipboard
odeimaiz Aug 27, 2024
c711a46
printRow
odeimaiz Aug 27, 2024
987d0e2
minor
odeimaiz Aug 27, 2024
0e505e2
minor
odeimaiz Aug 27, 2024
a8dc09a
asdf
odeimaiz Aug 27, 2024
28c8822
wire requestOpenLogger
odeimaiz Aug 27, 2024
0694104
minor
odeimaiz Aug 27, 2024
63c728d
minor
odeimaiz Aug 27, 2024
85273df
filterByNode
odeimaiz Aug 27, 2024
7372ca1
__openLoggerTab
odeimaiz Aug 27, 2024
3ac0277
getFilteredRows
odeimaiz Aug 27, 2024
5711e34
Merge branch 'master' into ux/logger
odeimaiz Aug 27, 2024
cfbd367
remove dummy logs
odeimaiz Aug 28, 2024
f712cec
Merge branch 'master' into ux/logger
odeimaiz Aug 28, 2024
ef9cad7
Merge branch 'master' into ux/logger
odeimaiz Aug 28, 2024
3598021
Merge branch 'master' into ux/logger
odeimaiz Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
__workbenchUI: null,
__workbenchUIConnected: null,
__iframePage: null,
__loggerPage: null,
__loggerView: null,
__currentNodeId: null,
__startAppButton: null,
Expand Down Expand Up @@ -440,9 +441,9 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
tabViewMain.add(iframePage);

const loggerView = this.__loggerView = new osparc.widget.logger.LoggerView();
const logsPage = this.__logsPage = this.__createTabPage("@FontAwesome5Solid/file-alt", this.tr("Logger"), loggerView);
osparc.utils.Utils.setIdToWidget(logsPage.getChildControl("button"), "loggerTabButton");
tabViewMain.add(logsPage);
const loggerPage = this.__loggerPage = this.__createTabPage("@FontAwesome5Solid/file-alt", this.tr("Logger"), loggerView);
osparc.utils.Utils.setIdToWidget(loggerPage.getChildControl("button"), "loggerTabButton");
tabViewMain.add(loggerPage);

this.__addTopBarSpacer(topBar);

Expand Down Expand Up @@ -590,6 +591,11 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
const edgeId = e.getData();
this.__removeEdge(edgeId);
}, this);
workbenchUI.addListener("requestOpenLogger", e => {
const nodeId = e.getData();
this.__loggerView.filterByNode(nodeId);
this.__openLoggerTab();
}, this);
}

const workbench = this.getStudy().getWorkbench();
Expand Down Expand Up @@ -707,6 +713,11 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
}
},

__openLoggerTab: function() {
const tabViewMain = this.getChildControl("main-panel-tabs");
tabViewMain.setSelection([this.__loggerPage]);
},

__applyMaximized: function(maximized) {
this.getBlocker().setStyles({
display: maximized ? "none" : "block"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ qx.Class.define("osparc.desktop.organizations.ServicesList", {
item.addListener("openMoreInfo", e => {
const serviceKey = e.getData()["key"];
const serviceVersion = e.getData()["version"];
osparc.store.Store.getInstance().getService(serviceKey, serviceVersion)
osparc.store.Store.getService(serviceKey, serviceVersion)
.then(serviceData => {
if (serviceData) {
serviceData["resourceType"] = "service";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ qx.Class.define("osparc.info.StudyMedium", {
width: 25,
height: 25,
icon: "@FontAwesome5Solid/ellipsis-v/14",
focusable: false
focusable: false,
allowGrowY: false
});

const moreInfoButton = this.__getMoreInfoMenuButton();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* ************************************************************************

osparc - the simcore frontend

https://osparc.io

Copyright:
2024 IT'IS Foundation, https://itis.swiss

License:
MIT: https://opensource.org/licenses/MIT

Authors:
* Odei Maiz (odeimaiz)

************************************************************************ */

qx.Class.define("osparc.ui.table.rowrenderer.ExtendSelection", {
extend: qx.ui.table.rowrenderer.Default,

members: {
// overridden
updateDataRowElement : function(rowInfo, rowElem) {
this.base(arguments, rowInfo, rowElem);

const messageCellPos = 2;
// extend collapse row
const style = rowElem.style;
if (rowInfo.selected) {
let messageDiv = rowElem.children.item(messageCellPos)
if (rowElem.children.item(messageCellPos).children.length) {
messageDiv = rowElem.children.item(messageCellPos).children.item(0);
}
const extendedHeight = messageDiv.getBoundingClientRect().height + "px";
style.height = extendedHeight;
Array.from(rowElem.children).forEach(child => child.style.height = extendedHeight);
} else {
style.height = "19px";
}
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ qx.Class.define("osparc.widget.logger.LoggerModel", {
return this.__rawData;
},

getFilteredRows: function() {
return this.__filteredData;
},

addRows: function(newRows) {
newRows.forEach(newRow => {
const levelColor = this.self().getLevelColor(newRow.logLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
50: "ERROR" // CRITICAL
},

printRow: function(rowData) {
return `${rowData.timeStamp} ${this.self().logLevel2Str(rowData.logLevel)} ${rowData.nodeId} ${rowData.label}: ${rowData.msg}`;
},

logLevel2Str: function(logLevel) {
const pairFound = Object.entries(this.LOG_LEVELS).find(pair => pair[1] === logLevel);
if (pairFound && pairFound.length) {
Expand Down Expand Up @@ -177,7 +181,7 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
});
control.bind("value", this, "lockLogs");
control.bind("value", control, "icon", {
converter: val => val ? "@FontAwesome5Solid/lock/14" : "@FontAwesome5Solid/lock-open/14"
converter: val => val ? "@FontAwesome5Solid/lock-open/14" : "@FontAwesome5Solid/lock/14"
});
const toolbar = this.getChildControl("toolbar");
toolbar.add(control);
Expand All @@ -194,6 +198,16 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
toolbar.add(control);
break;
}
case "copy-selected-to-clipboard": {
const toolbar = this.getChildControl("toolbar");
control = new qx.ui.form.Button().set({
icon: "@FontAwesome5Solid/file/14",
toolTipText: this.tr("Copy Selected log to clipboard"),
appearance: "toolbar-button"
});
toolbar.add(control);
break;
}
case "download-logs-button": {
const toolbar = this.getChildControl("toolbar");
control = new qx.ui.form.Button().set({
Expand All @@ -213,9 +227,7 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
const toolbar = this.getChildControl("toolbar");

const pinNode = this.getChildControl("pin-node");
pinNode.addListener("changeValue", e => {
this.__currentNodeClicked(e.getData());
}, this);
pinNode.addListener("changeValue", e => this.__pinChanged(e.getData()), this);

const textFilterField = this.__textFilterField = this.getChildControl("filter-text");
textFilterField.addListener("changeValue", this.__applyFilters, this);
Expand All @@ -233,6 +245,10 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
copyToClipboardButton.addListener("execute", () => this.__copyLogsToClipboard(), this);
toolbar.add(copyToClipboardButton);

const copySelectedToClipboardButton = this.getChildControl("copy-selected-to-clipboard");
copySelectedToClipboardButton.addListener("execute", () => this.__copySelectedLogToClipboard(), this);
toolbar.add(copySelectedToClipboardButton);

const downloadButton = this.getChildControl("download-logs-button");
downloadButton.addListener("execute", () => this.downloadLogs(), this);
toolbar.add(downloadButton);
Expand All @@ -256,29 +272,37 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
showCellFocusIndicator: false,
forceLineHeight: false
});
// alwaysUpdateCells
osparc.utils.Utils.setIdToWidget(table, "logsViewer");
const colModel = table.getTableColumnModel();
colModel.setDataCellRenderer(this.self().POS.TIMESTAMP, new osparc.ui.table.cellrenderer.Html().set({
defaultCellStyle: "user-select: text"
}));
colModel.setDataCellRenderer(this.self().POS.ORIGIN, new qx.ui.table.cellrenderer.Html());
colModel.setDataCellRenderer(this.self().POS.MESSAGE, new osparc.ui.table.cellrenderer.Html().set({
defaultCellStyle: "user-select: text"
defaultCellStyle: "user-select: text; text-wrap: wrap"
}));
let resizeBehavior = colModel.getBehavior();
resizeBehavior.setWidth(this.self().POS.TIMESTAMP, 80);
resizeBehavior.setWidth(this.self().POS.ORIGIN, 100);

table.setDataRowRenderer(new osparc.ui.table.rowrenderer.ExtendSelection(table));

this.__applyFilters();

return table;
},

filterByNode: function(nodeId) {
this.setCurrentNodeId(nodeId);
this.getChildControl("pin-node").setValue(true);
},

__currentNodeIdChanged: function() {
this.getChildControl("pin-node").setValue(false);
},

__currentNodeClicked: function(checked) {
__pinChanged: function(checked) {
if (checked) {
const currentNodeId = this.getCurrentNodeId();
this.__nodeSelected(currentNodeId);
Expand All @@ -294,8 +318,8 @@ qx.Class.define("osparc.widget.logger.LoggerView", {

__getLogsString: function() {
let logs = "";
this.__loggerModel.getRows().forEach(row => {
logs += `${row.timeStamp} ${this.self().logLevel2Str(row.logLevel)} ${row.nodeId} ${row.label}: ${row.msg} \n`;
this.__loggerModel.getFilteredRows().forEach(rowData => {
logs += this.self().printRow(rowData) + "\n";
});
return logs;
},
Expand All @@ -304,6 +328,14 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
osparc.utils.Utils.copyTextToClipboard(this.__getLogsString());
},

__copySelectedLogToClipboard: function() {
const sel = this.__loggerTable.getSelectionModel().getAnchorSelectionIndex();
if (sel > -1) {
const rowData = this.__loggerModel.getRowData(sel);
osparc.utils.Utils.copyTextToClipboard(this.self().printRow(rowData));
}
},

downloadLogs: function() {
const logs = this.__getLogsString();
osparc.utils.Utils.downloadContent("data:text/plain;charset=utf-8," + logs, "logs.log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ qx.Class.define("osparc.workbench.NodeUI", {
},

events: {
"updateNodeDecorator": "qx.event.type.Event"
"updateNodeDecorator": "qx.event.type.Event",
"requestOpenLogger": "qx.event.type.Event",
},

members: {
Expand Down Expand Up @@ -146,6 +147,20 @@ qx.Class.define("osparc.workbench.NodeUI", {
}
const nodeStatus = new osparc.ui.basic.NodeStatusUI(this.getNode());
control.add(nodeStatus);
const statusLabel = nodeStatus.getChildControl("label");
const requestOpenLogger = () => this.fireEvent("requestOpenLogger");
const evaluateLabel = () => {
const failed = statusLabel.getValue() === "Failed";
statusLabel.setCursor(failed ? "pointer" : "auto");
if (nodeStatus.hasListener("tap")) {
nodeStatus.removeListener("tap", requestOpenLogger);
}
if (failed) {
nodeStatus.addListener("tap", requestOpenLogger);
}
};
evaluateLabel();
statusLabel.addListener("changeValue", evaluateLabel);
this.add(control, {
row: 0,
column: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
"removeNode": "qx.event.type.Data",
"removeNodes": "qx.event.type.Data",
"removeEdge": "qx.event.type.Data",
"changeSelectedNode": "qx.event.type.Data"
"changeSelectedNode": "qx.event.type.Data",
"requestOpenLogger": "qx.event.type.Data",
},

properties: {
Expand Down Expand Up @@ -492,6 +493,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {

__addNodeListeners: function(nodeUI) {
nodeUI.addListener("updateNodeDecorator", () => this.__updateNodeUIPos(nodeUI), this);
nodeUI.addListener("requestOpenLogger", () => this.fireDataEvent("requestOpenLogger", nodeUI.getNodeId()), this);

nodeUI.addListener("nodeMovingStart", () => {
this.__selectNode(nodeUI);
Expand Down
Loading