Skip to content

Commit a620fd8

Browse files
committed
SVG button renderer
1 parent 9142541 commit a620fd8

File tree

3 files changed

+72
-55
lines changed

3 files changed

+72
-55
lines changed

services/static-webserver/client/source/class/osparc/jobs/JobsTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ qx.Class.define("osparc.jobs.JobsTable", {
3636

3737
Object.values(this.self().COLS).forEach(col => columnModel.setColumnWidth(col.column, col.width));
3838

39-
const fontButtonRenderer = new osparc.ui.table.cellrenderer.FontButtonRenderer();
39+
const fontButtonRenderer = new osparc.ui.table.cellrenderer.SVGButtonRenderer();
4040
columnModel.setDataCellRenderer(this.self().COLS.INFO.column, fontButtonRenderer);
4141
},
4242

services/static-webserver/client/source/class/osparc/ui/table/cellrenderer/FontButtonRenderer.js

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2035 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.table.cellrenderer.SVGButtonRenderer", {
19+
extend: osparc.ui.table.cellrenderer.Html,
20+
21+
construct: function(id, icon) {
22+
this.base(arguments);
23+
},
24+
25+
properties: {
26+
clickAction: {
27+
check: "String",
28+
nullable: false,
29+
init: "clickAction",
30+
},
31+
32+
svgIcon: {
33+
check: "String",
34+
nullable: false,
35+
init: "osparc/offline.svg", // Default icon
36+
},
37+
},
38+
39+
members: {
40+
// Override
41+
_getContentHtml: function(cellInfo) {
42+
const clickAction = this.getClickAction();
43+
const iconPath = this.getSvgIcon();
44+
const resMgr = qx.util.ResourceManager.getInstance();
45+
const iconUrl = resMgr.toUri(iconPath); // Resolves to the correct URL of the asset
46+
47+
// Button styling
48+
const buttonStyle = "background:none; border:none; padding:0; cursor:pointer; height:32px; width:32px; display:flex; align-items:center; justify-content:center;";
49+
const imgStyle = "height:24px; width:24px;"; // Ensuring it fits nicely
50+
51+
// Return the button with the image
52+
return `
53+
<button style="${buttonStyle}" data-action="${clickAction}" data-row="${cellInfo.row}" title="View">
54+
<img src="${iconUrl}" style="${imgStyle}" alt="icon" />
55+
</button>
56+
`;
57+
},
58+
59+
/*
60+
// Helper method to get the correct FontAwesome icon as inline SVG
61+
_getFontAwesomeSvg: function(iconClass) {
62+
const iconMap = {
63+
"fa-cog": '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="24" height="24"><path d="M487.8 317.6l-53.7-31.1c7.3-17.7 11.6-36.9 11.6-56.5 0-19.7-4.3-38.8-11.6-56.5l53.7-31.1c10.7-6.1 13.5-19.8 7.4-30.4l-41.5-71.6c-6.1-10.7-19.8-13.5-30.4-7.4l-53.7 31.1c-17.7-13.1-37.1-23.6-58.4-30.5l-8.5-55.2c-2.2-14.2-15.4-24.3-29.8-24.3h-57.8c-14.4 0-27.6 10.1-29.8 24.3l-8.5 55.2c-21.3 6.9-40.7 17.4-58.4 30.5l-53.7-31.1c-10.7-6.1-24.3-3.3-30.4 7.4l-41.5 71.6c-6.1 10.7-3.3 24.3 7.4 30.4l53.7 31.1c-7.3 17.7-11.6 36.9-11.6 56.5 0 19.7 4.3 38.8 11.6 56.5l-53.7 31.1c-10.7 6.1-13.5 19.8-7.4 30.4l41.5 71.6c6.1 10.7 19.8 13.5 30.4 7.4l53.7-31.1c17.7 13.1 37.1 23.6 58.4 30.5l8.5 55.2c2.2 14.2 15.4 24.3 29.8 24.3h57.8c14.4 0 27.6-10.1 29.8-24.3l8.5-55.2c21.3-6.9 40.7-17.4 58.4-30.5l53.7 31.1c10.7 6.1 24.3 3.3 30.4-7.4l41.5-71.6c6.1-10.7 3.3-24.3-7.4-30.4z"/></svg>',
64+
// Add more icons as needed...
65+
};
66+
67+
return iconMap[iconClass] || iconMap["fa-cog"]; // Default to "fa-cog" if iconClass is not found
68+
}
69+
*/
70+
}
71+
});

0 commit comments

Comments
 (0)