Skip to content

Commit b3e7da7

Browse files
committed
Only show iviewer for externalInfo images. Otherwise show Fileset download links
1 parent 5a19f1c commit b3e7da7

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

idr_gallery/templates/idr_gallery/archived_image.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
</style>
1212
<body>
1313
<h1>Image Archived</h1>
14-
<h2>Name: {{ image.name }}</h2>
14+
<h2>Study: {{ idr_study }}</h2>
15+
<h2>Image Name: {{ image.name }}</h2>
1516
<h3>ID: {{ image.id }}</h3>
1617
<p>This image is archived and cannot be viewed.</p>
1718

@@ -22,5 +23,17 @@ <h3>ID: {{ image.id }}</h3>
2223
<li>Download URL: <a href="{{ download_url }}">{{ download_url }}</a></li>
2324
<li>BIA NGFF ID: {{ bia_ngff_id }}</li>
2425
</ul>
26+
27+
<h3>Image Files</h3>
28+
{% if fileset %}
29+
<h2>Fileset ID: {{ fileset.id }}</h2>
30+
<ul>
31+
{% for file in fileset.file_urls %}
32+
<li><a href="{{ file.url }}">{{ file.path }}</a></li>
33+
{% endfor %}
34+
</ul>
35+
{% else %}
36+
<p>No associated fileset.</p>
37+
{% endif %}
2538
</body>
2639
</html>

idr_gallery/views.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def api_thumbnails(request, conn=None, **kwargs):
473473
@render_response()
474474
def image_viewer(request, iid, conn=None, **kwargs):
475475
"""
476-
Check if image is archived before returning iviewer response
476+
Check if image is OME-Zarr (externalInfo) before returning iviewer response
477477
"""
478478
image = conn.getObject("Image", iid)
479479

@@ -482,8 +482,8 @@ def image_viewer(request, iid, conn=None, **kwargs):
482482
if image is None:
483483
raise Http404("Image with ID %s not found" % iid)
484484

485-
if not image.archived:
486-
return iviewer_index(request, iid, conn=conn, **kwargs)
485+
# if not image.archived:
486+
# return iviewer_index(request, iid, conn=conn, **kwargs)
487487

488488
ext_info = image.getDetails().externalInfo
489489
if ext_info is not None:
@@ -511,8 +511,8 @@ def image_viewer(request, iid, conn=None, **kwargs):
511511
# "mkngff" data is at https://uk1s3.embassy.ebi.ac.uk/bia-integrator-data/pages/idr_ngff_data.html
512512
bia_ngff_id = img_path.split(BIA_URL, 1)[-1].split("/", 1)[0]
513513

514-
515-
return {
514+
rsp_json = {
515+
"idr_study": idrid_name,
516516
"template": "idr_gallery/archived_image.html",
517517
"image": {
518518
"id": image.id,
@@ -524,3 +524,18 @@ def image_viewer(request, iid, conn=None, **kwargs):
524524
"download_url": download_url,
525525
"bia_ngff_id": bia_ngff_id,
526526
}
527+
if image.fileset is not None:
528+
paths = image.getImportedImageFilePaths()
529+
file_urls = []
530+
for path in paths["client_paths"]:
531+
if idrid_name in path:
532+
file_path = path.split(idrid_name, 1)[-1]
533+
file_urls.append({"url": f"{download_url}{file_path}", "path": file_path})
534+
fileset_id = image.fileset.id.val
535+
rsp_json["fileset"] = {
536+
"id": fileset_id,
537+
"client_paths": paths["client_paths"],
538+
"file_urls": file_urls,
539+
}
540+
541+
return rsp_json

0 commit comments

Comments
 (0)