feat: Refactor series tag consistency modal with improved UI and analysis functionality
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,18 +1,26 @@
|
|||||||
{% load django_htmx %}
|
{% load django_htmx %}
|
||||||
<div id="series-tag-consistency-panel" class="d-flex flex-column gap-2">
|
<div id="series-tag-consistency-panel">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Series Tag Consistency</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body d-flex flex-column gap-3">
|
||||||
<div class="d-flex flex-wrap gap-2 align-items-center">
|
<div class="d-flex flex-wrap gap-2 align-items-center">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-outline-info btn-sm"
|
class="btn btn-outline-info btn-sm"
|
||||||
hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}?analyze=1"
|
hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}?analyze=1"
|
||||||
hx-target="#series-tag-consistency-panel"
|
hx-target="#series-tag-consistency-panel"
|
||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
Analyze tag consistency
|
Re-run analysis
|
||||||
</button>
|
</button>
|
||||||
{% if analyze_requested %}
|
{% if analyze_requested %}
|
||||||
<span class="small text-muted">Scanned {{ image_count }} image{{ image_count|pluralize }}</span>
|
<span class="small text-muted">Scanned {{ image_count }} image{{ image_count|pluralize }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="tag-consistency-split-result"></div>
|
||||||
|
|
||||||
{% if analyze_requested %}
|
{% if analyze_requested %}
|
||||||
<div class="small d-flex flex-wrap gap-2">
|
<div class="small d-flex flex-wrap gap-2">
|
||||||
<span class="badge text-bg-success">Same: {{ same_tags|length }}</span>
|
<span class="badge text-bg-success">Same: {{ same_tags|length }}</span>
|
||||||
@@ -20,6 +28,11 @@
|
|||||||
<span class="badge text-bg-secondary">Missing in some: {{ partial_tags|length }}</span>
|
<span class="badge text-bg-secondary">Missing in some: {{ partial_tags|length }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="tag-consistency-filter-{{ series.pk }}" class="form-label form-label-sm mb-1">Filter tags</label>
|
||||||
|
<input id="tag-consistency-filter-{{ series.pk }}" type="text" class="form-control form-control-sm" placeholder="Type to filter by tag name or value">
|
||||||
|
</div>
|
||||||
|
|
||||||
<details class="styled-detail" open>
|
<details class="styled-detail" open>
|
||||||
<summary>Different tags (highlighted)</summary>
|
<summary>Different tags (highlighted)</summary>
|
||||||
<div class="table-responsive mt-2">
|
<div class="table-responsive mt-2">
|
||||||
@@ -29,18 +42,34 @@
|
|||||||
<th>Tag</th>
|
<th>Tag</th>
|
||||||
<th>Unique values</th>
|
<th>Unique values</th>
|
||||||
<th>Sample values</th>
|
<th>Sample values</th>
|
||||||
|
<th>Split</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for row in different_tags %}
|
{% for row in different_tags %}
|
||||||
<tr class="table-warning">
|
<tr class="table-warning" data-filter-row="1">
|
||||||
<td>{{ row.tag_name }}</td>
|
<td>{{ row.tag_name }}</td>
|
||||||
<td>{{ row.unique_count }}</td>
|
<td>{{ row.unique_count }}</td>
|
||||||
<td>{{ row.sample_values|join:", " }}</td>
|
<td>{{ row.sample_values|join:", " }}</td>
|
||||||
|
<td>
|
||||||
|
{% if can_split %}
|
||||||
|
<form method="post"
|
||||||
|
action="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-post="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-target="#tag-consistency-split-result"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="dicom_tag" value="{{ row.tag_name }}">
|
||||||
|
<button type="submit" class="btn btn-outline-warning btn-sm">Split</button>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted small">No split access</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="text-muted">No tags vary across all images.</td>
|
<td colspan="4" class="text-muted">No tags vary across all images.</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -56,17 +85,33 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Tag</th>
|
<th>Tag</th>
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
|
<th>Split</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for row in same_tags %}
|
{% for row in same_tags %}
|
||||||
<tr class="table-success">
|
<tr class="table-success" data-filter-row="1">
|
||||||
<td>{{ row.tag_name }}</td>
|
<td>{{ row.tag_name }}</td>
|
||||||
<td>{{ row.sample_values.0 }}</td>
|
<td>{{ row.sample_values.0 }}</td>
|
||||||
|
<td>
|
||||||
|
{% if can_split %}
|
||||||
|
<form method="post"
|
||||||
|
action="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-post="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-target="#tag-consistency-split-result"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="dicom_tag" value="{{ row.tag_name }}">
|
||||||
|
<button type="submit" class="btn btn-outline-warning btn-sm">Split</button>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted small">No split access</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="text-muted">No uniform tags found across all images.</td>
|
<td colspan="3" class="text-muted">No uniform tags found across all images.</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -83,18 +128,34 @@
|
|||||||
<th>Tag</th>
|
<th>Tag</th>
|
||||||
<th>Present in</th>
|
<th>Present in</th>
|
||||||
<th>Unique values</th>
|
<th>Unique values</th>
|
||||||
|
<th>Split</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for row in partial_tags %}
|
{% for row in partial_tags %}
|
||||||
<tr class="table-secondary">
|
<tr class="table-secondary" data-filter-row="1">
|
||||||
<td>{{ row.tag_name }}</td>
|
<td>{{ row.tag_name }}</td>
|
||||||
<td>{{ row.present_count }}/{{ image_count }}</td>
|
<td>{{ row.present_count }}/{{ image_count }}</td>
|
||||||
<td>{{ row.unique_count }}</td>
|
<td>{{ row.unique_count }}</td>
|
||||||
|
<td>
|
||||||
|
{% if can_split %}
|
||||||
|
<form method="post"
|
||||||
|
action="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-post="{% url 'atlas:series_split_by_tag' pk=series.pk %}"
|
||||||
|
hx-target="#tag-consistency-split-result"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="dicom_tag" value="{{ row.tag_name }}">
|
||||||
|
<button type="submit" class="btn btn-outline-warning btn-sm">Split</button>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted small">No split access</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="text-muted">All scanned tags were present in every image.</td>
|
<td colspan="4" class="text-muted">All scanned tags were present in every image.</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -105,3 +166,29 @@
|
|||||||
<p class="small text-muted mb-0">Run analysis to quickly highlight tags that are the same or different across the series.</p>
|
<p class="small text-muted mb-0">Run analysis to quickly highlight tags that are the same or different across the series.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
const filterInput = document.getElementById("tag-consistency-filter-{{ series.pk }}");
|
||||||
|
if (!filterInput) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = document.querySelectorAll("#series-tag-consistency-panel tr[data-filter-row='1']");
|
||||||
|
|
||||||
|
function applyFilter() {
|
||||||
|
const query = filterInput.value.trim().toLowerCase();
|
||||||
|
rows.forEach((row) => {
|
||||||
|
const text = row.textContent.toLowerCase();
|
||||||
|
row.style.display = text.includes(query) ? "" : "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
filterInput.addEventListener("input", applyFilter);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -195,11 +195,14 @@
|
|||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
<span class="text-muted small">Loading split controls…</span>
|
<span class="text-muted small">Loading split controls…</span>
|
||||||
</div>
|
</div>
|
||||||
<div hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}"
|
<button class="btn btn-outline-info btn-sm"
|
||||||
hx-trigger="load"
|
hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}?analyze=1"
|
||||||
hx-swap="outerHTML">
|
hx-target="#series-tag-consistency-modal .modal-content"
|
||||||
<span class="text-muted small">Loading tag analysis controls...</span>
|
hx-swap="innerHTML"
|
||||||
</div>
|
data-bs-toggle="modal"
|
||||||
|
data-bs-target="#series-tag-consistency-modal">
|
||||||
|
Analyze tag consistency
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -244,6 +247,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="series-tag-consistency-modal" class="modal modal-blur fade" tabindex="-1">
|
||||||
|
<div class="modal-dialog modal-dialog-centered modal-xl" style="max-width: 1200px;">
|
||||||
|
<div class="modal-content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|||||||
@@ -3702,6 +3702,7 @@ def series_tag_consistency(request, pk):
|
|||||||
"""
|
"""
|
||||||
series = get_object_or_404(Series, pk=pk)
|
series = get_object_or_404(Series, pk=pk)
|
||||||
analyze_requested = request.GET.get("analyze") == "1"
|
analyze_requested = request.GET.get("analyze") == "1"
|
||||||
|
can_split = series.check_user_can_edit(request.user)
|
||||||
|
|
||||||
same_tags = []
|
same_tags = []
|
||||||
different_tags = []
|
different_tags = []
|
||||||
@@ -3755,6 +3756,7 @@ def series_tag_consistency(request, pk):
|
|||||||
{
|
{
|
||||||
"series": series,
|
"series": series,
|
||||||
"analyze_requested": analyze_requested,
|
"analyze_requested": analyze_requested,
|
||||||
|
"can_split": can_split,
|
||||||
"image_count": image_count,
|
"image_count": image_count,
|
||||||
"same_tags": same_tags,
|
"same_tags": same_tags,
|
||||||
"different_tags": different_tags,
|
"different_tags": different_tags,
|
||||||
|
|||||||
Reference in New Issue
Block a user