1
0
Fork 0

Add transmitter table view

Signed-off-by: Pierros Papadeas <pierros@papadeas.gr>
spacecruft
Pierros Papadeas 2020-07-09 19:25:50 +03:00
parent 67f229d2ed
commit ef1e315984
10 changed files with 141 additions and 11 deletions

View File

@ -7,6 +7,7 @@ BASE_URLPATTERNS = (
[
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^transmitters/$', views.transmitters_list, name='transmitters_list'),
url(r'^faq/$', views.faq, name='faq'),
url(r'^satellite/(?P<norad>[0-9]+)/$', views.satellite, name='satellite'),
url(r'^frames/(?P<norad>[0-9]+)/$', views.request_export, name='request_export_all'),

View File

@ -9,6 +9,7 @@ from django.contrib.sites.shortcuts import get_current_site
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.db import OperationalError
from django.db.models import Count
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
@ -31,7 +32,7 @@ def home(request):
:returns: base/home.html
"""
satellites = Satellite.objects.all()
satellites = Satellite.objects.annotate(transmitters_count=Count('transmitter_entries'))
transmitter_suggestions = TransmitterSuggestion.objects.count()
contributors = User.objects.filter(is_active=1).count()
cached_stats = cache.get('stats_transmitters')
@ -51,6 +52,16 @@ def home(request):
)
def transmitters_list(request):
"""View to render transmitters list page.
:returns: base/transmitters.html
"""
transmitters = Transmitter.objects.prefetch_related('satellite', 'downlink_mode')
return render(request, 'base/transmitters.html', {'transmitters': transmitters})
def robots(request):
"""robots.txt handler

View File

@ -270,14 +270,16 @@ CSP_DEFAULT_SRC = config(
'CSP_DEFAULT_SRC',
cast=lambda v: tuple(s.strip() for s in v.split(',')),
default="'self',"
'https://*.mapbox.com'
'https://*.mapbox.com,'
"'unsafe-inline'"
)
CSP_SCRIPT_SRC = config(
'CSP_SCRIPT_SRC',
cast=lambda v: tuple(s.strip() for s in v.split(',')),
default="'self',"
'https://*.google-analytics.com,'
"'unsafe-eval'"
"'unsafe-eval',"
"'unsafe-inline'"
)
CSP_IMG_SRC = config(
'CSP_IMG_SRC',

View File

@ -334,6 +334,13 @@ footer {
}
}
/* Transmitters List page
==================== */
#transmitters-table {
opacity: 0;
}
/* Statistics page
==================== */

View File

@ -0,0 +1,36 @@
function ppb_to_freq(freq, drift) {
var freq_obs = freq + ((freq * drift) / Math.pow(10,9));
return Math.round(freq_obs);
}
function format_freq(frequency) {
if (frequency == 'None' ){
return 'None';
} else if (frequency < 1000) {
// Frequency is in Hz range
return frequency.toFixed(3) + ' Hz';
} else if (frequency < 1000000) {
return (frequency/1000).toFixed(3) + ' kHz';
} else {
return (frequency/1000000).toFixed(3) + ' MHz';
}
}
$(document).ready(function() {
$('#transmitters-table').bootstrapTable('hideLoading');
$('#transmitters-table').css('opacity','1');
// Calculate the drifted frequencies
$('.drifted').each(function() {
var drifted = ppb_to_freq($(this).data('freq_or'),$(this).data('drift'));
$(this).html(drifted);
});
// Format all frequencies
$('.frequency').each(function() {
var to_format = $(this).html();
$(this).html(format_freq(to_format));
});
});

View File

@ -39,8 +39,9 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="{% active request 'home' %}"><a href="{% url 'home' %}">Home</a></li>
<li class="{% active request 'about' %}"><a href="{% url 'about' %}">About</a></li>
<li class="{% active request 'home' %}"><a href="{% url 'home' %}">Satellites</a></li>
<li class="{% active request 'transmitters_list' %}"><a href="{% url 'transmitters_list' %}">Transmitters</a></li>
<li class="{% active request 'stats' %}"><a href="{% url 'stats' %}">Statistics</a></li>
<li class="{% active request 'faq' %}"><a href="{% url 'faq' %}">FAQ</a></li>
<li><a href="https://community.libre.space/c/satnogs/" target="_blank">Community</a></li>

View File

@ -22,7 +22,7 @@
{{ statistics.transmitters }}
</p>
{% if transmitter_suggestions %}
<p class="statistics" title="transmitter_suggestions" data-toggle="tooltip">
<p class="statistics" title="transmitter suggestions" data-toggle="tooltip">
<img src="{% static 'img/transmitter_suggestions.png' %}">
{{ transmitter_suggestions }}
</p>
@ -53,12 +53,7 @@
<div class="satellite-names">{{ sat.names }}&nbsp;</div>
</div>
<div class="panel-footer">
{% with total=sat.transmitters.all.count %}
{{ total }} transmitter{{ total|pluralize }}
{% endwith %}
{% if request.user.is_superuser and sat.transmitter_suggestion_count %}
- <span class="glyphicon glyphicon-edit" title="Suggest edits"></span> {{ sat.transmitter_suggestion_count }}
{% endif %}
{{ sat.transmitters_count }} Transmitters
</div>
</a>
</div>

View File

@ -0,0 +1,67 @@
{% extends "base.html" %}
{% load staticfiles %}
{% block title %} - Transmitters List{% endblock %}
{% block css %}
<link rel="stylesheet" href="{% static 'lib/bootstrap-table/dist/bootstrap-table.min.css' %}">
{% endblock css %}
{% block content %}
<div class="row trans">
<table data-toggle="table"
data-sortable="true"
data-filter-control="true"
data-search="true"
data-show-columns="true"
data-show-columns-search="true"
id="transmitters-table">
<thead>
<tr>
<th data-visible="false">UUID</th>
<th data-sortable="true">Satellite</th>
<th data-sortable="true">Type</th>
<th data-sortable="true">Description</th>
<th data-sortable="true">Downlink</th>
<th data-sortable="true" data-visible="false">Downlink Drift</th>
<th data-sortable="true" data-visible="false">Uplink</th>
<th data-sortable="true" data-visible="false">Uplink Drift</th>
<th data-sortable="true" data-visible="false">Inverted</th>
<th data-sortable="true" data-filter-control="select">Mode</th>
<th data-sortable="true">Baud</th>
<th data-sortable="true">Service</th>
<th data-sortable="true">Status</th>
</tr>
</thead>
<tbody>
{% for trans in transmitters %}
<tr>
<td>{{ trans.uuid }}</td>
<td>
<a href="{% url 'satellite' norad=trans.satellite.norad_cat_id %}">
{{ trans.satellite }}</a>
</a>
</td>
<td>{{ trans.type }}</td>
<td>{{ trans.description }}</td>
<td class="frequency">{{ trans.downlink_low }}</td>
<td>{{ trans.downlink_drift }}</td>
<td class="frequency">{{ trans.uplink }}</td>
<td>{{ trans.uplink_drift }}</td>
<td>{{ trans.invert }}</td>
<td>{{ trans.downlink_mode }}</td>
<td>{{ trans.baud }}</td>
<td>{{ trans.service }}</td>
<td>{{ trans.status }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% block javascript %}
<script src="{% static 'lib/bootstrap-table/dist/bootstrap-table.min.js' %}"></script>
<script src="{% static 'js/transmitters.js' %}"></script>
{% endblock %}

5
package-lock.json generated
View File

@ -733,6 +733,11 @@
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.4.1.tgz",
"integrity": "sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA=="
},
"bootstrap-table": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/bootstrap-table/-/bootstrap-table-1.17.0.tgz",
"integrity": "sha512-WgfD/RhhEp6uVGxVGwCRMrSDxAIZcPKYQzajKavnCVDeH8gc7Dw9XMFHqPDPX2fBc8Smfd6+klcVUC3M1BLCNg=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View File

@ -16,6 +16,7 @@
},
"dependencies": {
"bootstrap": "^3.4.1",
"bootstrap-table": "^1.17.0",
"chart.js": "^2.8.0",
"dnt-helper": "github:schalkneethling/dnt-helper",
"gpredict.js": "github:kerel-fs/gpredict.js",
@ -27,6 +28,10 @@
"bootstrap/dist/css/bootstrap.min.css",
"bootstrap/dist/js/bootstrap.min.js",
"bootstrap/dist/fonts/*",
"bootstrap-table/dist/bootstrap-table.min.css",
"bootstrap-table/dist/bootstrap-table.min.js",
"bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.min.css",
"bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.min.js",
"chart.js/dist/Chart.min.js",
"dnt-helper/js/dnt-helper.js",
"gpredict.js/dist/gpredict.min.js",