Skip to content

[OKRS24-192] Signal Detail Added a list of signals with the same base signal #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/signals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ def example_url(self):
example_url = self.links.filter(link_type="example_url").first()
return example_url.url if example_url else None

@property
def same_base_signals(self):
"""
Returns the signals that have the same base signal.
"""
return self.base.base_for.all() if self.base else None

class Meta:
unique_together = ['name', 'source']
ordering: list[str] = ["modified"]
Expand Down
74 changes: 74 additions & 0 deletions src/templates/signals/signal_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,80 @@ <h5>About this signal</h5>
</div>
</div>
</section>
{% if signal.base %}
<h5>Signals with same base</h5>
<section class="section">
<div class="row">
<div class="card">
<div class="card-body">
<table class="table table-borderless table-hover">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Active</th>
<th scope="col">Data Source</th>
<th scope="col">Description</th>
<th scope="col">Pathogen/Disease Area</th>
<th scope="col">Base Signal</th>
<th scope="col">Last Updated</th>
</tr>
</thead>
<tbody>
{% for signal in signal.same_base_signals %}
<tr classs="clickable-table-row">
<td onClick="location.href='{% url 'signal' pk=signal.id %}';" class="clickable-table-cell">{{ signal.display_name }}</td>
{% if signal.active == True %}
<td><i class="bi bi-circle-fill" style="color:green;" ></i></td>
{% else %}
<td><i class="bi bi-circle-fill" style="color:red;" ></i></td>
{% endif %}
<td>{{ signal.source.data_source }}</td>
<td>{{ signal.description }}</td>
<td>
{% for pathogen in signal.pathogen.all %}
<span class="badge rounded-pill bg-dark">{{ pathogen|title }}</span>
{% endfor %}
</td>
<td>
{% if signal.base %}
<a href="{% url 'signal' pk=signal.base.id %}">{{ signal.display_name }}</a>
{% else %}
--/--
{% endif %}
</td>
<td>
{% if signal.last_updated %}
{{ signal.last_updated|date:"Y-m-d" }}
{% else %}
--/--
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</section>
{% endif %}
{% if signal.example_url != '' %}
<h5>Response Example</h5>
<section class="section">
<div class="row">
<div class="card">
<div class="card-body">
<div class="row margin-top-1rem">
<p>Example URL:</p>
<span>{{ signal.example_url }}</span>
<button type="button" class="btn btn-primary margin-top-1rem" id="show-response">Show response</button>
<pre class="margin-top-1rem"><code id="example-response" class="hidden"></code></pre>
</div>
</div>
</div>
</div>
</section>
{% endif %}
{% include "signals/data_visualization_export.html"%}
<h5>Related links</h5>
<section class="section">
Expand Down
Loading