Switch from jshint to eslint
parent
95452b616f
commit
ea892fd51a
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true,
|
||||||
|
"jquery": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"curly": [
|
||||||
|
"error",
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"one-var-declaration-per-line": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"new-cap": "error"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
language: python
|
language: python
|
||||||
|
dist: trusty
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
install:
|
install:
|
||||||
- pip install flake8
|
- pip install flake8
|
||||||
- npm install -g jshint
|
- npm install -g eslint
|
||||||
script:
|
script:
|
||||||
- flake8 .
|
- flake8 .
|
||||||
- jshint .
|
- eslint 'db/static/js/*.js'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* global d3 Backbone moment _ */
|
||||||
// D3 visualisation
|
// D3 visualisation
|
||||||
|
|
||||||
d3.lineChart = function(telemetry_key, unit) {
|
d3.lineChart = function(telemetry_key, unit) {
|
||||||
|
@ -10,9 +11,9 @@ d3.lineChart = function(telemetry_key, unit) {
|
||||||
var svg;
|
var svg;
|
||||||
|
|
||||||
// Define the div for the tooltip
|
// Define the div for the tooltip
|
||||||
var div = d3.select("body").append("div")
|
var div = d3.select('body').append('div')
|
||||||
.attr("class", "chart-tooltip")
|
.attr('class', 'chart-tooltip')
|
||||||
.style("opacity", 0);
|
.style('opacity', 0);
|
||||||
|
|
||||||
function render(selection) {
|
function render(selection) {
|
||||||
selection.each(function(_data) {
|
selection.each(function(_data) {
|
||||||
|
@ -21,7 +22,7 @@ d3.lineChart = function(telemetry_key, unit) {
|
||||||
|
|
||||||
|
|
||||||
var x1 = d3.scale.ordinal()
|
var x1 = d3.scale.ordinal()
|
||||||
.domain(_data.map(function(d, i){
|
.domain(_data.map(function(d){
|
||||||
return parseDate(d.telemetry.observation_datetime);
|
return parseDate(d.telemetry.observation_datetime);
|
||||||
}))
|
}))
|
||||||
.rangePoints([0, chartW]);
|
.rangePoints([0, chartW]);
|
||||||
|
@ -31,13 +32,13 @@ d3.lineChart = function(telemetry_key, unit) {
|
||||||
switch(_data.length) {
|
switch(_data.length) {
|
||||||
case 1:
|
case 1:
|
||||||
y1 = d3.scale.linear()
|
y1 = d3.scale.linear()
|
||||||
.domain([0, d3.max(_data, function(d, i){ return +d.telemetry.damod_data[telemetry_key]; })])
|
.domain([0, d3.max(_data, function(d){ return +d.telemetry.damod_data[telemetry_key]; })])
|
||||||
.range([chartH, 0])
|
.range([chartH, 0])
|
||||||
.nice(4);
|
.nice(4);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
y1 = d3.scale.linear()
|
y1 = d3.scale.linear()
|
||||||
.domain(d3.extent(_data, function(d, i){ return +d.telemetry.damod_data[telemetry_key]; }))
|
.domain(d3.extent(_data, function(d){ return +d.telemetry.damod_data[telemetry_key]; }))
|
||||||
.range([chartH, 0])
|
.range([chartH, 0])
|
||||||
.nice(4);
|
.nice(4);
|
||||||
}
|
}
|
||||||
|
@ -74,47 +75,47 @@ d3.lineChart = function(telemetry_key, unit) {
|
||||||
.transition()
|
.transition()
|
||||||
.call(yAxis);
|
.call(yAxis);
|
||||||
|
|
||||||
svg.selectAll(".x-axis-group.axis text") // select all the text elements for the xaxis
|
svg.selectAll('.x-axis-group.axis text') // select all the text elements for the xaxis
|
||||||
.attr("transform", function(d) {
|
.attr('transform', function() {
|
||||||
return "translate(-50,50)rotate(-45)";
|
return 'translate(-50,50)rotate(-45)';
|
||||||
});
|
});
|
||||||
|
|
||||||
// Axis labels
|
// Axis labels
|
||||||
svg.append("text")
|
svg.append('text')
|
||||||
.attr("transform", "translate(" + (chartW + config.margin.right + 18) + " ," + (chartH + 10) + ")")
|
.attr('transform', 'translate(' + (chartW + config.margin.right + 18) + ' ,' + (chartH + 10) + ')')
|
||||||
.style("text-anchor", "middle")
|
.style('text-anchor', 'middle')
|
||||||
.text("Observation Datetime");
|
.text('Observation Datetime');
|
||||||
|
|
||||||
svg.append("text")
|
svg.append('text')
|
||||||
.attr("transform", "rotate(-90)")
|
.attr('transform', 'rotate(-90)')
|
||||||
.attr("y", 40)
|
.attr('y', 40)
|
||||||
.attr("x", 0 - (chartH / 2))
|
.attr('x', 0 - (chartH / 2))
|
||||||
.attr("dy", "1em")
|
.attr('dy', '1em')
|
||||||
.style("text-anchor", "middle")
|
.style('text-anchor', 'middle')
|
||||||
.text("Value (" + unit + ")");
|
.text('Value (' + unit + ')');
|
||||||
|
|
||||||
switch(_data.length) {
|
switch(_data.length) {
|
||||||
case 1:
|
case 1:
|
||||||
// Add the scatterplot
|
// Add the scatterplot
|
||||||
svg.selectAll("dot")
|
svg.selectAll('dot')
|
||||||
.data(_data)
|
.data(_data)
|
||||||
.enter().append("circle")
|
.enter().append('circle')
|
||||||
.attr("r", 4)
|
.attr('r', 4)
|
||||||
.attr("cx", function(d, i) { return chartW / 2 + config.margin.left; })
|
.attr('cx', function() { return chartW / 2 + config.margin.left; })
|
||||||
.attr("cy", function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; })
|
.attr('cy', function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; })
|
||||||
.attr("class", "circle")
|
.attr('class', 'circle')
|
||||||
.on("mouseover", function(d) {
|
.on('mouseover', function(d) {
|
||||||
div.transition()
|
div.transition()
|
||||||
.duration(200)
|
.duration(200)
|
||||||
.style("opacity", 1);
|
.style('opacity', 1);
|
||||||
div.html(d.telemetry.damod_data[telemetry_key] + ' (' + unit + ')')
|
div.html(d.telemetry.damod_data[telemetry_key] + ' (' + unit + ')')
|
||||||
.style("left", (d3.event.pageX) + "px")
|
.style('left', (d3.event.pageX) + 'px')
|
||||||
.style("top", (d3.event.pageY - 26) + "px");
|
.style('top', (d3.event.pageY - 26) + 'px');
|
||||||
})
|
})
|
||||||
.on("mouseout", function(d) {
|
.on('mouseout', function() {
|
||||||
div.transition()
|
div.transition()
|
||||||
.duration(500)
|
.duration(500)
|
||||||
.style("opacity", 0);
|
.style('opacity', 0);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -126,30 +127,30 @@ d3.lineChart = function(telemetry_key, unit) {
|
||||||
.y(function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; });
|
.y(function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; });
|
||||||
|
|
||||||
// Add the valueline path
|
// Add the valueline path
|
||||||
svg.append("path")
|
svg.append('path')
|
||||||
.attr("class", "line")
|
.attr('class', 'line')
|
||||||
.attr("d", valueline(_data));
|
.attr('d', valueline(_data));
|
||||||
|
|
||||||
// Add the scatterplot
|
// Add the scatterplot
|
||||||
svg.selectAll("dot")
|
svg.selectAll('dot')
|
||||||
.data(_data)
|
.data(_data)
|
||||||
.enter().append("circle")
|
.enter().append('circle')
|
||||||
.attr("r", 4)
|
.attr('r', 4)
|
||||||
.attr("cx", function(d, i) { return xInterval*i + config.margin.left; })
|
.attr('cx', function(d, i) { return xInterval*i + config.margin.left; })
|
||||||
.attr("cy", function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; })
|
.attr('cy', function(d) { return y1(d.telemetry.damod_data[telemetry_key]) + config.margin.top; })
|
||||||
.attr("class", "circle")
|
.attr('class', 'circle')
|
||||||
.on("mouseover", function(d) {
|
.on('mouseover', function(d) {
|
||||||
div.transition()
|
div.transition()
|
||||||
.duration(200)
|
.duration(200)
|
||||||
.style("opacity", 1);
|
.style('opacity', 1);
|
||||||
div.html(d.telemetry.damod_data[telemetry_key] + ' (' + unit + ')')
|
div.html(d.telemetry.damod_data[telemetry_key] + ' (' + unit + ')')
|
||||||
.style("left", (d3.event.pageX) + "px")
|
.style('left', (d3.event.pageX) + 'px')
|
||||||
.style("top", (d3.event.pageY - 26) + "px");
|
.style('top', (d3.event.pageY - 26) + 'px');
|
||||||
})
|
})
|
||||||
.on("mouseout", function(d) {
|
.on('mouseout', function() {
|
||||||
div.transition()
|
div.transition()
|
||||||
.duration(500)
|
.duration(500)
|
||||||
.style("opacity", 0);
|
.style('opacity', 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,12 +186,12 @@ if (has_telemetry_data) {
|
||||||
|
|
||||||
// Backbone Models
|
// Backbone Models
|
||||||
|
|
||||||
var TelemetryData = Backbone.Model.extend({});
|
Backbone.Model.extend({});
|
||||||
|
|
||||||
// Backbone Collections
|
// Backbone Collections
|
||||||
|
|
||||||
var TelemetryCollection = Backbone.Collection.extend({
|
var TelemetryCollection = Backbone.Collection.extend({
|
||||||
url:"/api/telemetry/?satellite=" + satelliteId
|
url:'/api/telemetry/?satellite=' + satelliteId
|
||||||
});
|
});
|
||||||
|
|
||||||
var TelemetryDescriptors = TelemetryCollection.extend({
|
var TelemetryDescriptors = TelemetryCollection.extend({
|
||||||
|
@ -206,7 +207,7 @@ if (has_telemetry_data) {
|
||||||
return( collection.get('telemetry').observation_datetime );
|
return( collection.get('telemetry').observation_datetime );
|
||||||
},
|
},
|
||||||
byDate: function (start_date, end_date) {
|
byDate: function (start_date, end_date) {
|
||||||
filtered = this.filter(function (model) {
|
var filtered = this.filter(function (model) {
|
||||||
var date = parseDateFilter(model.get('telemetry').observation_datetime);
|
var date = parseDateFilter(model.get('telemetry').observation_datetime);
|
||||||
return ( date >= start_date && date <= end_date );
|
return ( date >= start_date && date <= end_date );
|
||||||
});
|
});
|
||||||
|
@ -217,7 +218,7 @@ if (has_telemetry_data) {
|
||||||
// Backbone Views
|
// Backbone Views
|
||||||
|
|
||||||
var TelemetryDescriptorsView = Backbone.View.extend({
|
var TelemetryDescriptorsView = Backbone.View.extend({
|
||||||
el: "#telemetry-descriptors",
|
el: '#telemetry-descriptors',
|
||||||
template: _.template($('#telemetryDescriptorsTemplate').html()),
|
template: _.template($('#telemetryDescriptorsTemplate').html()),
|
||||||
initialize: function(){
|
initialize: function(){
|
||||||
this.listenTo(this.collection, 'add reset change remove', this.renderItem);
|
this.listenTo(this.collection, 'add reset change remove', this.renderItem);
|
||||||
|
@ -230,7 +231,7 @@ if (has_telemetry_data) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var TelemetryChartView = Backbone.View.extend({
|
var TelemetryChartView = Backbone.View.extend({
|
||||||
el: ".chart",
|
el: '.chart',
|
||||||
chart: null,
|
chart: null,
|
||||||
chartSelection: null,
|
chartSelection: null,
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
@ -238,10 +239,10 @@ if (has_telemetry_data) {
|
||||||
this.updateDates(moment().subtract(7, 'days').format('YYYY/MM/DD'), moment().format('YYYY/MM/DD'));
|
this.updateDates(moment().subtract(7, 'days').format('YYYY/MM/DD'), moment().format('YYYY/MM/DD'));
|
||||||
this.renderPlaceholder();
|
this.renderPlaceholder();
|
||||||
this.collection.on('update filter', this.render, this);
|
this.collection.on('update filter', this.render, this);
|
||||||
chart = d3.lineChart();
|
d3.lineChart();
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
"click .telemetry-key": "updateKey",
|
'click .telemetry-key': 'updateKey',
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.collection.length > 0) {
|
if (this.collection.length > 0) {
|
||||||
|
@ -258,12 +259,12 @@ if (has_telemetry_data) {
|
||||||
},
|
},
|
||||||
renderPlaceholder: function() {
|
renderPlaceholder: function() {
|
||||||
$('#telemetry-descriptors').hide();
|
$('#telemetry-descriptors').hide();
|
||||||
$('#data-available').html("<p>There is no data available for the selected dates.</p>");
|
$('#data-available').html('<p>There is no data available for the selected dates.</p>');
|
||||||
d3.select('svg').remove();
|
d3.select('svg').remove();
|
||||||
},
|
},
|
||||||
updateKey: function(e){
|
updateKey: function(e){
|
||||||
d3.select('svg').remove();
|
d3.select('svg').remove();
|
||||||
this.chartSelection.call(d3.lineChart($(e.currentTarget).data("key"), $(e.currentTarget).data("unit")));
|
this.chartSelection.call(d3.lineChart($(e.currentTarget).data('key'), $(e.currentTarget).data('unit')));
|
||||||
var active = $(e.currentTarget);
|
var active = $(e.currentTarget);
|
||||||
active.addClass('active');
|
active.addClass('active');
|
||||||
$('li').not(active).removeClass('active');
|
$('li').not(active).removeClass('active');
|
||||||
|
@ -276,7 +277,7 @@ if (has_telemetry_data) {
|
||||||
|
|
||||||
// Fetch data and render views
|
// Fetch data and render views
|
||||||
|
|
||||||
var telemetryDescriptorsView = new TelemetryDescriptorsView({ collection: new TelemetryDescriptors() });
|
new TelemetryDescriptorsView({ collection: new TelemetryDescriptors() });
|
||||||
var telemetryValues = new TelemetryValues();
|
var telemetryValues = new TelemetryValues();
|
||||||
var telemetryChartView = new TelemetryChartView({collection: telemetryValues});
|
var telemetryChartView = new TelemetryChartView({collection: telemetryValues});
|
||||||
|
|
||||||
|
@ -286,13 +287,13 @@ if (has_telemetry_data) {
|
||||||
format: 'YYYY/MM/DD'
|
format: 'YYYY/MM/DD'
|
||||||
},
|
},
|
||||||
dateLimit: {
|
dateLimit: {
|
||||||
"days": 60
|
'days': 60
|
||||||
},
|
},
|
||||||
autoApply: true,
|
autoApply: true,
|
||||||
startDate: moment().subtract(7, 'days').format('YYYY/MM/DD'),
|
startDate: moment().subtract(7, 'days').format('YYYY/MM/DD'),
|
||||||
endDate: moment().format('YYYY/MM/DD'),
|
endDate: moment().format('YYYY/MM/DD'),
|
||||||
},
|
},
|
||||||
function(start, end, label) {
|
function(start, end) {
|
||||||
telemetryChartView.updateDates(start.format('YYYYMMDD'), end.format('YYYYMMDD'));
|
telemetryChartView.updateDates(start.format('YYYYMMDD'), end.format('YYYYMMDD'));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var t = $('input');
|
var t = $('input');
|
||||||
t.bind('propertychange keyup input paste', function(event) {
|
t.bind('propertychange keyup input paste', function() {
|
||||||
var term = t.val().toLowerCase();
|
var term = t.val().toLowerCase();
|
||||||
if (term !== '') {
|
if (term !== '') {
|
||||||
$('.satellite-group-item').hide();
|
$('.satellite-group-item').hide();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/*global L */
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -17,16 +19,16 @@ $(document).ready(function() {
|
||||||
var geojson = {
|
var geojson = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [{
|
features: [{
|
||||||
"type": "Feature",
|
'type': 'Feature',
|
||||||
"geometry": {
|
'geometry': {
|
||||||
"type": "Point",
|
'type': 'Point',
|
||||||
"coordinates": [lon, lat]
|
'coordinates': [lon, lat]
|
||||||
},
|
},
|
||||||
"properties": {
|
'properties': {
|
||||||
"icon": {
|
'icon': {
|
||||||
"iconUrl": "/static/img/satellite-marker.png",
|
'iconUrl': '/static/img/satellite-marker.png',
|
||||||
"iconSize": [32, 32],
|
'iconSize': [32, 32],
|
||||||
"iconAnchor": [16, 16],
|
'iconAnchor': [16, 16],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
$.getJSON( "/statistics/", function( data ) {
|
/* global Chart */
|
||||||
|
|
||||||
var i, r, g, b, a;
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$.getJSON('/statistics/', function( data ) {
|
||||||
|
|
||||||
|
var i;
|
||||||
|
var r;
|
||||||
|
var g;
|
||||||
|
var b;
|
||||||
|
var a;
|
||||||
// Create colors for Mode Chart
|
// Create colors for Mode Chart
|
||||||
var mode_colors = [];
|
var mode_colors = [];
|
||||||
for (i = 0; i < data.mode_label.length; i++) {
|
for (i = 0; i < data.mode_label.length; i++) {
|
||||||
|
@ -8,7 +16,7 @@ $.getJSON( "/statistics/", function( data ) {
|
||||||
b = Math.floor(0.3 * 255);
|
b = Math.floor(0.3 * 255);
|
||||||
g = Math.floor(data.mode_data[i]* 10);
|
g = Math.floor(data.mode_data[i]* 10);
|
||||||
a = 0.5;
|
a = 0.5;
|
||||||
color = "rgba(" + r + "," + g + "," + b + "," + a + ")";
|
var color = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
|
||||||
mode_colors.push(color);
|
mode_colors.push(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +27,7 @@ $.getJSON( "/statistics/", function( data ) {
|
||||||
g = Math.floor(data.band_data[i]);
|
g = Math.floor(data.band_data[i]);
|
||||||
r = Math.floor(data.band_data[i]);
|
r = Math.floor(data.band_data[i]);
|
||||||
a = 0.5;
|
a = 0.5;
|
||||||
color = "rgba(" + r + "," + g + "," + b + "," + a + ")";
|
color = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
|
||||||
band_colors.push(color);
|
band_colors.push(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +38,8 @@ $.getJSON( "/statistics/", function( data ) {
|
||||||
Chart.defaults.global.title.fontColor= '#444';
|
Chart.defaults.global.title.fontColor= '#444';
|
||||||
|
|
||||||
//Mode Chart
|
//Mode Chart
|
||||||
var mode_c = document.getElementById("modes");
|
var mode_c = document.getElementById('modes');
|
||||||
var modeChart = new Chart(mode_c, {
|
new Chart(mode_c, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: data.mode_label,
|
labels: data.mode_label,
|
||||||
|
@ -49,8 +57,8 @@ $.getJSON( "/statistics/", function( data ) {
|
||||||
});
|
});
|
||||||
|
|
||||||
//Band Chart
|
//Band Chart
|
||||||
var band_c = document.getElementById("bands");
|
var band_c = document.getElementById('bands');
|
||||||
var bandChart = new Chart(band_c, {
|
new Chart(band_c, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: data.band_label,
|
labels: data.band_label,
|
||||||
|
@ -72,3 +80,4 @@ $.getJSON( "/statistics/", function( data ) {
|
||||||
$('#stats-transmitters').html(data.transmitters);
|
$('#stats-transmitters').html(data.transmitters);
|
||||||
$('#stats-satellites').html(data.total_satellites);
|
$('#stats-satellites').html(data.total_satellites);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue