From ff3d88001e5749323ea9ef9d16e3681d44c41fb6 Mon Sep 17 00:00:00 2001 From: Corey Shields Date: Thu, 30 Jul 2020 18:47:22 -0400 Subject: [PATCH] Refacter transmitter_card fields and kaitai struct decoder info Removes the field.html include - and the frequent inclusion of that in the transmitter cards. Fix a bug in satellite.js where input not recognized as an integer Add gitlab links to the version info Removes the manually-entered kaitai struct field from view (will need removed from db in a later change) - replacing with a procedurally generated list of fields from the class imported through satnogsdecoders. Fixes #385 Signed-off-by: Corey Shields --- db/base/models.py | 13 +++ db/static/js/satellite.js | 3 +- db/templates/base.html | 4 +- db/templates/base/satellite.html | 58 +++++++------ .../includes/cards/transmitter_card.html | 84 ++++++++----------- db/templates/includes/field.html | 20 ----- 6 files changed, 84 insertions(+), 98 deletions(-) delete mode 100644 db/templates/includes/field.html diff --git a/db/base/models.py b/db/base/models.py index 16a2437..733a4ca 100644 --- a/db/base/models.py +++ b/db/base/models.py @@ -4,6 +4,7 @@ from os import path from uuid import uuid4 import h5py +import satnogsdecoders from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ValidationError @@ -488,6 +489,18 @@ class Telemetry(models.Model): def __str__(self): return self.name + def get_kaitai_fields(self): + """Return an empty-value dict of fields for this kaitai.io struct + Beware the overuse of "decoder" in satnogsdecoders and "decoder" the + field above in this Telemetry model""" + results = {} + try: + decoder_class = getattr(satnogsdecoders.decoder, self.decoder.capitalize()) + results = satnogsdecoders.decoder.get_fields(decoder_class, empty=True) + except AttributeError: + pass + return results + @python_2_unicode_compatible class DemodData(models.Model): diff --git a/db/static/js/satellite.js b/db/static/js/satellite.js index b5db463..6395d61 100644 --- a/db/static/js/satellite.js +++ b/db/static/js/satellite.js @@ -81,7 +81,8 @@ function freq_to_ppb(freq_obs, freq) { } } -function format_freq(frequency) { +function format_freq(freq) { + var frequency = +freq; if (frequency < 1000) { // Frequency is in Hz range return frequency.toFixed(3) + ' Hz'; diff --git a/db/templates/base.html b/db/templates/base.html index 490e2d2..7403fd8 100644 --- a/db/templates/base.html +++ b/db/templates/base.html @@ -161,9 +161,9 @@