From 3df604ab8b2348a6b6a3a96ad72dc18f753c4f77 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 12 Apr 2024 15:44:13 +0200 Subject: [PATCH 1/2] probe-file UI --- .../source/class/osparc/workbench/NodeUI.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js b/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js index 22c293b2463..c7e55086dac 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js +++ b/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js @@ -68,7 +68,8 @@ qx.Class.define("osparc.workbench.NodeUI", { statics: { NODE_WIDTH: 180, - NODE_HEIGHT: 80 + NODE_HEIGHT: 80, + FILE_NODE_WIDTH: 120, }, events: { @@ -371,7 +372,7 @@ qx.Class.define("osparc.workbench.NodeUI", { }, __turnIntoFileUI: function() { - const width = 120; + const width = this.self().FILE_NODE_WIDTH; this.__setNodeUIWidth(width); const chipContainer = this.getChildControl("chips"); @@ -496,8 +497,31 @@ qx.Class.define("osparc.workbench.NodeUI", { converter: outputs => { if (portKey in outputs && "value" in outputs[portKey]) { const val = outputs[portKey]["value"]; - if (Array.isArray(val)) { + if (this.getNode().getMetaData()["key"].includes("probe/array")) { return "[" + val.join(",") + "]"; + } else if (this.getNode().getMetaData()["key"].includes("probe/file")) { + const download = true; + const locationId = val.store; + const fileId = val.path; + const filename = val.filename || osparc.file.FilePicker.getFilenameFromPath(val); + label.set({ + font: "text-12", + rich: true + }); + osparc.store.Data.getInstance().getPresignedLink(download, locationId, fileId) + .then(presignedLinkData => { + if ("resp" in presignedLinkData && presignedLinkData.resp) { + const linkColor = qx.theme.manager.Color.getInstance().resolve("text"); + const downloadLink = `${filename}`; + label.set({ + value: downloadLink, + cursor: "pointer", + font: "link-label-12", + rich: true + }); + } + }); + return filename; } return String(val); } From 06f98fd041ce513861e59c178a8a2ed84ec4de83 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 12 Apr 2024 15:57:25 +0200 Subject: [PATCH 2/2] Replace by LinkLabel --- .../source/class/osparc/workbench/NodeUI.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js b/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js index c7e55086dac..e9221359214 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js +++ b/services/static-webserver/client/source/class/osparc/workbench/NodeUI.js @@ -487,6 +487,24 @@ qx.Class.define("osparc.workbench.NodeUI", { }, __setProbeValue: function(label) { + const replaceByLinkLabel = val => { + const download = true; + const locationId = val.store; + const fileId = val.path; + osparc.store.Data.getInstance().getPresignedLink(download, locationId, fileId) + .then(presignedLinkData => { + if ("resp" in presignedLinkData && presignedLinkData.resp) { + const filename = val.filename || osparc.file.FilePicker.getFilenameFromPath(val); + const linkLabel = new osparc.ui.basic.LinkLabel(filename, presignedLinkData.resp.link).set({ + font: "link-label-12" + }); + const chipContainer = this.getChildControl("chips"); + chipContainer.remove(label); + chipContainer.add(linkLabel); + } + }); + } + const link = this.getNode().getLink("in_1"); if (link && "nodeUuid" in link) { const inputNodeId = link["nodeUuid"]; @@ -500,27 +518,12 @@ qx.Class.define("osparc.workbench.NodeUI", { if (this.getNode().getMetaData()["key"].includes("probe/array")) { return "[" + val.join(",") + "]"; } else if (this.getNode().getMetaData()["key"].includes("probe/file")) { - const download = true; - const locationId = val.store; - const fileId = val.path; const filename = val.filename || osparc.file.FilePicker.getFilenameFromPath(val); label.set({ font: "text-12", rich: true }); - osparc.store.Data.getInstance().getPresignedLink(download, locationId, fileId) - .then(presignedLinkData => { - if ("resp" in presignedLinkData && presignedLinkData.resp) { - const linkColor = qx.theme.manager.Color.getInstance().resolve("text"); - const downloadLink = `${filename}`; - label.set({ - value: downloadLink, - cursor: "pointer", - font: "link-label-12", - rich: true - }); - } - }); + replaceByLinkLabel(val); return filename; } return String(val);