Skip to content

Commit d2cfad6

Browse files
odeimaizpcrespov
andcommitted
🐛 Bugfix: FP extractLabelFromLink + Announcement Validator (#4414)
Co-authored-by: Pedro Crespo-Valero <[email protected]>
1 parent ad20e4b commit d2cfad6

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ qx.Class.define("osparc.AnnouncementTracker", {
8787
if (
8888
this.getStart() &&
8989
this.getEnd() &&
90-
this.getStart() > now &&
90+
now > this.getStart() &&
9191
now < this.getEnd()
9292
) {
9393
return true;

services/static-webserver/client/source/class/osparc/file/FilePicker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ qx.Class.define("osparc.file.FilePicker", {
8585
getOutputLabel: function(outputs) {
8686
const outFileValue = osparc.file.FilePicker.getOutput(outputs);
8787
if (outFileValue) {
88-
if ("label" in outFileValue) {
88+
if ("label" in outFileValue && outFileValue["label"]) {
8989
return outFileValue.label;
9090
}
91-
if ("path" in outFileValue) {
91+
if ("path" in outFileValue && outFileValue["path"]) {
9292
return this.self().getFilenameFromPath(outFileValue);
9393
}
94-
if ("downloadLink" in outFileValue) {
94+
if ("downloadLink" in outFileValue && outFileValue["downloadLink"]) {
9595
return osparc.file.FileDownloadLink.extractLabelFromLink(outFileValue["downloadLink"]);
9696
}
9797
}

services/web/server/src/simcore_service_webserver/studies_dispatcher/_projects.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88
import json
99
import logging
10+
from pathlib import Path
1011
from typing import NamedTuple
1112

1213
from aiohttp import web
@@ -47,21 +48,26 @@ def _generate_nodeids(project_id: ProjectID) -> tuple[NodeID, NodeID]:
4748
return file_picker_id, viewer_id
4849

4950

50-
def _create_file_picker(download_link: str):
51+
def _create_file_picker(download_link: str, output_label: str | None):
52+
# NOTE: Label is used here to display in the file-picker and
53+
# also to name the file in case it is downloaded
54+
55+
data = {}
56+
data["downloadLink"] = url = parse_obj_as(AnyUrl, download_link)
57+
if output_label:
58+
data["label"] = Path(output_label).name
59+
elif url.path:
60+
data["label"] = Path(url.path).name
61+
output = DownloadLink.parse_obj(data)
62+
5163
output_id = "outFile"
5264
node = Node(
5365
key=_FILE_PICKER_KEY,
5466
version=_FILE_PICKER_VERSION,
5567
label="File Picker",
5668
inputs={},
5769
inputNodes=[],
58-
outputs={
59-
# NOTE: Empty label checked with @odeimaiz
60-
output_id: DownloadLink(
61-
downloadLink=parse_obj_as(AnyUrl, download_link),
62-
label="",
63-
)
64-
},
70+
outputs={output_id: output},
6571
progress=0,
6672
)
6773
return node, output_id
@@ -138,8 +144,9 @@ def _create_project_with_filepicker_and_service(
138144
download_link: HttpUrl,
139145
viewer_info: ViewerInfo,
140146
) -> Project:
141-
142-
file_picker, file_picker_output_id = _create_file_picker(download_link)
147+
file_picker, file_picker_output_id = _create_file_picker(
148+
download_link, output_label=None
149+
)
143150

144151
viewer_service = Node(
145152
key=viewer_info.key,
@@ -335,7 +342,9 @@ async def get_or_create_project_with_file(
335342
project_uuid=project_uid,
336343
):
337344
# nodes
338-
file_picker, _ = _create_file_picker(file_params.download_link)
345+
file_picker, _ = _create_file_picker(
346+
file_params.download_link, output_label=file_params.file_name
347+
)
339348

340349
# project
341350
project = _create_project(

0 commit comments

Comments
 (0)