Skip to content

Commit

Permalink
Updated Signal Sets list view
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrotsko committed Dec 21, 2024
1 parent 6db9b16 commit fdc2dd8
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 191 deletions.
31 changes: 29 additions & 2 deletions src/signal_sets/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from typing import Any, Dict
import json

from django.conf import settings
from django.db.models.query import QuerySet
Expand Down Expand Up @@ -58,17 +59,37 @@ def get_url_params(self):
url_params_str = f"{url_params_str}&{param_name}={param_value}"
return url_params_dict, url_params_str

def get_related_signals(self):
related_signals = []
for signal_set in self.get_queryset():
for signal in signal_set.signals.all():
related_signals.append(
{
"id": signal.id,
"display_name": signal.display_name,
"name": signal.name,
"signal_set": signal_set.id,
"signal_set_name": signal_set.name,
"endpoint": signal_set.endpoint,
"source": signal.source.name,
"time_type": signal.time_type,
"description": signal.description
}
)
return related_signals

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
url_params_dict, url_params_str = self.get_url_params()
context["url_params_dict"] = url_params_dict
context["url_params_str"] = url_params_str
context['epivis_url'] = settings.EPIVIS_URL
context["epivis_url"] = settings.EPIVIS_URL
context["form"] = SignalSetFilterForm(initial=url_params_dict)
context["filter"] = SignalSetFilter(
self.request.GET, queryset=self.get_queryset()
)
context["signal_sets"] = self.get_queryset()
context["related_signals"] = json.dumps(self.get_related_signals())
context["available_geographies"] = Geography.objects.all()
return context

Expand Down Expand Up @@ -96,6 +117,12 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
.distinct()
.order_by()
)
context["time_type"] = self.object.signals.all().values_list("time_type", flat=True).distinct().order_by().first()
context["time_type"] = (
self.object.signals.all()
.values_list("time_type", flat=True)
.distinct()
.order_by()
.first()
)

return context
8 changes: 8 additions & 0 deletions src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<!-- Select2 css -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />

<!-- Data Table -->
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/cr-2.0.4/fc-5.0.4/fh-4.0.1/kt-2.12.1/r-3.0.3/rg-1.5.1/rr-1.5.0/sc-2.4.3/sp-2.3.3/sl-2.1.0/datatables.min.css">

<link rel="stylesheet" href="https://cdn.datatables.net/plug-ins/1.10.13/features/mark.js/datatables.mark.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
Expand Down Expand Up @@ -312,6 +317,9 @@ <h5 class="modal-title" id="selectedSignalsModalLabel">Selected signals</h5>

</script>

<!-- Data Table -->



<!--<script src="{% static 'js/back_to_top.js' %}"></script> -->
</body>
Expand Down
Loading

0 comments on commit fdc2dd8

Please sign in to comment.