1
0
Fork 0
satnogs-db/db/static/js/transmitters.js

128 lines
3.9 KiB
JavaScript
Raw Normal View History

/* global renderTransmittersChart */
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_string) {
var frequency = Number(frequency_string);
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
if (isNaN(frequency) || frequency == ''){
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';
}
}
/* eslint-enable no-unused-vars */
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
/* eslint new-cap: "off" */
$(document).ready(function() {
// Calculate the drifted frequencies
$('.drifted').each(function() {
var drifted = ppb_to_freq($(this).data('freq_or'),$(this).data('drift'));
$(this).html(drifted);
});
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
// Format all frequencies
$('.frequency').each(function() {
var to_format = $(this).html();
$(this).html(format_freq(to_format));
});
$('#transmitters').DataTable( {
// the dom field controls the layout and visibility of datatable items
// and is not intuitive at all. Without layout we have dom: 'Bftrilp'
// https://datatables.net/reference/option/dom
dom: '<"row"<"d-none d-md-block col-md-6"B><"col-sm-12 col-md-6"f>>' +
'<"row"<"col-sm-12"tr>>' +
'<"row"<"col-sm-12 col-xl-3 align-self-center"i><"col-sm-12 col-md-6 col-xl-3 align-self-center"l><"col-sm-12 col-md-6 col-xl-6"p>>',
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
buttons: [
'colvis'
],
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.childRow,
type: 'column'
}
},
columnDefs: [
{
className: 'control',
orderable: false,
targets: 0
},
{
type: 'natural',
targets: [5, 6, 7, 8, 11]
}
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
],
language: {
search: 'Filter:',
buttons: {
colvis: 'Columns',
}
},
order: [ 1, 'asc' ],
pageLength: 25
} );
// Handle deep linking of tabbed panes
let url = location.href.replace(/\/$/, '');
history.replaceState(null, null, url);
if (location.hash) {
const hash = url.split('#');
$('#tabs a[href="#' + hash[1] + '"]').tab('show');
url = location.href.replace(/\/#/, '#');
history.replaceState(null, null, url);
setTimeout(() => {
$(window).scrollTop(0);
}, 400);
}
$('a[data-toggle="tab"]').on('click', function () {
let newUrl;
const hash = $(this).attr('href');
if (hash == '#list') {
newUrl = url.split('#')[0];
} else {
newUrl = url.split('#')[0] + hash;
}
history.replaceState(null, null, newUrl);
});
Promise.all([
fetch('/api/transmitters/?format=json')
.then((response) => response.json()),
fetch('/api/satellites/?format=json')
.then((response) => response.json()),
]).then((responses) => {
const transmittersChart = renderTransmittersChart({
el: document.querySelector('#transmitters-chart-container'),
transmitters: responses[0],
satellites_list: responses[1],
});
transmittersChart.zoom(
434.5,
438.5
);
document.querySelector('#zoom-all').addEventListener('click', () => {
transmittersChart.zoom(0,30000);
});
document.querySelector('#zoom-vhf').addEventListener('click', () => {
transmittersChart.zoom(143,147);
});
document.querySelector('#zoom-uhf').addEventListener('click', () => {
transmittersChart.zoom(434.5,438.5);
});
});
New SatNOGS DB user interface Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far: * Updated dependencies to latest 2.x django * Updated to Bootstrap 4 * New home screen to display most recent satellite entries, most recent data, and contributors * Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size * Adopted AdminLTE 3.x framework atop Bootstrap 4 * Created reusable cards for satellite and transmitters * Cards and Modals are organized into subdirectories for template includes and base templates, respectively * New stats display widgets using BS4 and AdminLTE 3 * Satellite search is redesigned and now accessible from any page of the site * Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view * Focus on all UI scaling down to mobile devices * New model created for Operator (/ Owner): name, names, description, website * Added django-countries for support of CountryField * Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime * Transmitter suggestions can now be approved in the UI by superusers * Satellite entries can now be edited in the UI by users with the change satellite permission * Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size * Other cleanup and changes that I'm missing for sure. Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
} );