From 5ce337c7c4288b2223ed930361a237393d695029 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 16 May 2026 22:02:50 +0100 Subject: [PATCH] feat(series): Enhance series truncation with options for removing empty DICOMs and downsampling pixel data --- atlas/templates/atlas/case_display_block.html | 123 +++++++- .../atlas/partials/truncate_result.html | 19 +- atlas/templates/atlas/series_viewer.html | 270 ++++++++++++++---- atlas/views.py | 60 +++- 4 files changed, 406 insertions(+), 66 deletions(-) diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index 617c8fd5..58755e1a 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -2,24 +2,40 @@ {% partialdef case-series %} {% for series in case.get_ordered_series %} - + Series {{ forloop.counter }}:
- + {{series.get_block}}
- - - - Popup - +
+ + + + + Page + + + + Popup + + +
{% endfor %} @@ -162,6 +178,57 @@ border: 1px solid rgba(0,0,0,0.06); text-align: left; } + + /* Enhanced series block with interactive features */ + .series-block-interactive { + transition: all 0.2s ease; + cursor: pointer; + } + + .series-block-interactive:hover { + box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15); + border-color: rgba(13, 110, 253, 0.3); + } + + .series-block-actions { + display: flex; + flex-wrap: wrap; + gap: 0.25rem; + margin-top: 0.5rem; + } + + .series-block-actions .btn { + padding: 0.25rem 0.5rem; + font-size: 0.75rem; + } + + .series-block-actions .btn-xs { + min-width: auto; + } + + /* Also support dark theme when site sets a theme attribute/class */ + .atlas[data-bs-theme="dark"] .series-block, + [data-bs-theme="dark"] .series-block, + body[data-bs-theme="dark"] .series-block, + body.bg-dark .series-block, + .bg-dark .series-block, + .dark .series-block, + .theme-dark .series-block { + background: #071018 !important; + border-color: rgba(255,255,255,0.03) !important; + color: #e6eef8 !important; + } + + .atlas[data-bs-theme="dark"] .series-block-interactive:hover, + [data-bs-theme="dark"] .series-block-interactive:hover, + body[data-bs-theme="dark"] .series-block-interactive:hover, + body.bg-dark .series-block-interactive:hover, + .bg-dark .series-block-interactive:hover, + .dark .series-block-interactive:hover, + .theme-dark .series-block-interactive:hover { + border-color: rgba(158, 197, 255, 0.3) !important; + box-shadow: 0 2px 8px rgba(158, 197, 255, 0.1) !important; + } /* Also support dark theme when site sets a theme attribute/class */ .atlas[data-bs-theme="dark"] .series-block, [data-bs-theme="dark"] .series-block, @@ -1272,6 +1339,36 @@ } })(); + // Series viewer button handler: open series in viewer or navigate to series page + (function initSeriesViewerButtons() { + if (window.__seriesViewerButtonsBound) return; + window.__seriesViewerButtonsBound = true; + + document.querySelectorAll('.series-open-viewer-btn').forEach(btn => { + btn.addEventListener('click', function(e) { + e.preventDefault(); + const seriesId = this.getAttribute('data-series-id'); + if (!seriesId) { + alert('Series ID not found'); + return; + } + + // Focus the viewer details element to open it + const viewerDetails = document.getElementById('dicom-viewer-details'); + if (viewerDetails && !viewerDetails.hasAttribute('open')) { + viewerDetails.setAttribute('open', 'open'); + // Trigger the toggle event to ensure viewer initializes + viewerDetails.dispatchEvent(new Event('toggle', { bubbles: true })); + } + + // Note: Direct series loading will be implemented via API in the future. + // For now, this just opens and focuses the viewer. + // When the series page viewer API is available, we can load the specific series here: + // window.loadSeriesInViewer(seriesId); + }); + }); + })(); + }); diff --git a/atlas/templates/atlas/partials/truncate_result.html b/atlas/templates/atlas/partials/truncate_result.html index 2b774c49..c236d996 100644 --- a/atlas/templates/atlas/partials/truncate_result.html +++ b/atlas/templates/atlas/partials/truncate_result.html @@ -1,6 +1,17 @@
Truncate complete. -
Removed {{ images_removed|length }} images from series {{ series.pk }}.
+
+
Removed {{ images_removed|length }} images from series {{ series.pk }}.
+ {% if images_downsampled %} +
Downsampled {{ images_downsampled|length }} images (pixel data reduced by 50%).
+ {% endif %} + {% if remove_empty_dicoms %} +
✓ Empty DICOM removal applied
+ {% endif %} + {% if downsample_pixels %} +
✓ Pixel downsampling applied (original hash preserved)
+ {% endif %} +
{% if images_removed %}
@@ -8,3 +19,9 @@
{{ images_removed|join:", " }}
{% endif %} +{% if images_downsampled %} +
+ Show downsampled image IDs +
{{ images_downsampled|join:", " }}
+
+{% endif %} diff --git a/atlas/templates/atlas/series_viewer.html b/atlas/templates/atlas/series_viewer.html index 62312e9b..ae42753c 100755 --- a/atlas/templates/atlas/series_viewer.html +++ b/atlas/templates/atlas/series_viewer.html @@ -30,7 +30,11 @@
{% with image_url_array_and_count=series.get_image_url_array_and_count %} -
+
{% endwith %}
@@ -202,39 +206,15 @@ data-bs-target="#series-tag-consistency-modal"> Analyze tag consistency + {% if can_edit %} + + {% endif %}
- - - - {% if can_edit %} -
-
Truncate series
-
-

Limit the series to the selected bounds (the rest of the images will be deleted). This action is irreversible on site.

-
Warning: If you have reordered the series this may remove the wrong images.
-
- -
- - -
-
-
- -
- - -
-
-
- - -
-
-
-
- {% endif %} @@ -252,11 +232,216 @@ + + {% if can_edit %} + + {% endif %} +