formatting to js standard
This commit is contained in:
parent
57cddee3fd
commit
6975167a77
@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* Any functionality required for the admin app
|
|
||||||
*/
|
|
||||||
|
|
||||||
require('./../bootstrap');
|
|
||||||
require('eonasdan-bootstrap-datetimepicker');
|
|
||||||
|
|
||||||
require('./sidebar');
|
|
||||||
|
|
||||||
// Import the mapping function
|
|
||||||
window.phpvms.map = require('../maps/index');
|
|
@ -1,90 +0,0 @@
|
|||||||
|
|
||||||
const jquery = require('jquery');
|
|
||||||
|
|
||||||
const getStorage = function (key) {
|
|
||||||
const st = window.localStorage.getItem(key);
|
|
||||||
|
|
||||||
console.log('storage: ', key, st);
|
|
||||||
if (_.isNil(st)) {
|
|
||||||
return {
|
|
||||||
"menu": [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.parse(st);
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveStorage = function (key, obj) {
|
|
||||||
console.log('save: ', key, obj);
|
|
||||||
window.localStorage.setItem(key, JSON.stringify(obj));
|
|
||||||
};
|
|
||||||
|
|
||||||
const addItem = function (obj, item) {
|
|
||||||
|
|
||||||
if (_.isNil(obj)) {
|
|
||||||
obj = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = _.indexOf(obj, item);
|
|
||||||
if (index === -1) {
|
|
||||||
obj.push(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeItem = function (obj, item) {
|
|
||||||
|
|
||||||
if (_.isNil(obj)) {
|
|
||||||
obj = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = _.indexOf(obj, item);
|
|
||||||
if (index !== -1) {
|
|
||||||
console.log("removing", item);
|
|
||||||
obj.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
jquery(document).ready(function () {
|
|
||||||
|
|
||||||
$(".select2").select2();
|
|
||||||
|
|
||||||
let storage = getStorage("phpvms.admin");
|
|
||||||
|
|
||||||
// see what menu items should be open
|
|
||||||
for (let idx = 0; idx < storage.menu.length; idx++) {
|
|
||||||
const id = storage.menu[idx];
|
|
||||||
const elem = jquery(".collapse#" + id);
|
|
||||||
elem.addClass("in").trigger("show.bs.collapse");
|
|
||||||
|
|
||||||
const caret = jquery("a." + id + " b");
|
|
||||||
caret.addClass("pe-7s-angle-down");
|
|
||||||
caret.removeClass("pe-7s-angle-right");
|
|
||||||
}
|
|
||||||
|
|
||||||
jquery(".collapse").on("hide.bs.collapse", function () {
|
|
||||||
console.log('hiding');
|
|
||||||
const id = jquery(this).attr('id');
|
|
||||||
const elem = jquery("a." + id + " b");
|
|
||||||
elem.removeClass("pe-7s-angle-down");
|
|
||||||
elem.addClass("pe-7s-angle-right");
|
|
||||||
|
|
||||||
removeItem(storage.menu, id);
|
|
||||||
saveStorage("phpvms.admin", storage);
|
|
||||||
});
|
|
||||||
|
|
||||||
jquery(".collapse").on("show.bs.collapse", function () {
|
|
||||||
console.log('showing');
|
|
||||||
const id = jquery(this).attr('id');
|
|
||||||
const caret = jquery("a." + id + " b");
|
|
||||||
caret.addClass("pe-7s-angle-down");
|
|
||||||
caret.removeClass("pe-7s-angle-right");
|
|
||||||
|
|
||||||
addItem(storage.menu, id);
|
|
||||||
saveStorage("phpvms.admin", storage);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
42
resources/js/bootstrap.js
vendored
42
resources/js/bootstrap.js
vendored
@ -2,40 +2,38 @@
|
|||||||
* Bootstrap any Javascript libraries required
|
* Bootstrap any Javascript libraries required
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window._ = require('lodash');
|
window._ = require('lodash')
|
||||||
window.Popper = require('popper.js').default;
|
window.Popper = require('popper.js').default
|
||||||
window.$ = window.jquery = require('jquery');
|
window.$ = window.jquery = require('jquery')
|
||||||
window.select2 = require('select2');
|
window.select2 = require('select2')
|
||||||
window.pjax = require('pjax');
|
window.pjax = require('pjax')
|
||||||
window.axios = require('axios');
|
window.axios = require('axios')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for phpVMS specific functions
|
* Container for phpVMS specific functions
|
||||||
*/
|
*/
|
||||||
window.phpvms = {
|
window.phpvms = {}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure Axios with both the csrf token and the API key
|
* Configure Axios with both the csrf token and the API key
|
||||||
*/
|
*/
|
||||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
|
||||||
const token = document.head.querySelector('meta[name="csrf-token"]');
|
const token = document.head.querySelector('meta[name="csrf-token"]')
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content
|
||||||
window.jquery.ajaxSetup({
|
window.jquery.ajaxSetup({
|
||||||
'X-CSRF-TOKEN': token.content
|
'X-CSRF-TOKEN': token.content
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token')
|
||||||
}
|
}
|
||||||
|
|
||||||
const api_key = document.head.querySelector('meta[name="api-key"]');
|
const api_key = document.head.querySelector('meta[name="api-key"]')
|
||||||
if(api_key) {
|
if (api_key) {
|
||||||
window.axios.defaults.headers.common['x-api-key'] = api_key.content;
|
window.axios.defaults.headers.common['x-api-key'] = api_key.content
|
||||||
window.PHPVMS_USER_API_KEY = api_key.content;
|
window.PHPVMS_USER_API_KEY = api_key.content
|
||||||
} else {
|
} else {
|
||||||
window.PHPVMS_USER_API_KEY = false;
|
window.PHPVMS_USER_API_KEY = false
|
||||||
console.error('API Key not found!');
|
console.error('API Key not found!')
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
const _ = require('lodash')
|
||||||
|
const leaflet = require('leaflet')
|
||||||
|
|
||||||
const _ = require('lodash');
|
import draw_base_map from './base_map'
|
||||||
const leaflet = require('leaflet');
|
|
||||||
|
|
||||||
import draw_base_map from './base_map';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a map with the airspace, etc around a given set of coords
|
* Render a map with the airspace, etc around a given set of coords
|
||||||
@ -10,24 +9,24 @@ import draw_base_map from './base_map';
|
|||||||
* @param opts
|
* @param opts
|
||||||
*/
|
*/
|
||||||
export default (opts) => {
|
export default (opts) => {
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
overlay_elem: '',
|
overlay_elem: '',
|
||||||
lat: 0,
|
lat: 0,
|
||||||
lon: 0,
|
lon: 0,
|
||||||
zoom: 12,
|
zoom: 12,
|
||||||
layers: [],
|
layers: [],
|
||||||
set_marker: false,
|
set_marker: false,
|
||||||
});
|
})
|
||||||
|
|
||||||
let map = draw_base_map(opts);
|
let map = draw_base_map(opts)
|
||||||
const coords = [opts.lat, opts.lon];
|
const coords = [opts.lat, opts.lon]
|
||||||
console.log('Applying coords', coords);
|
console.log('Applying coords', coords)
|
||||||
|
|
||||||
map.setView(coords, opts.zoom);
|
map.setView(coords, opts.zoom)
|
||||||
if (opts.set_marker === true) {
|
if (opts.set_marker === true) {
|
||||||
leaflet.marker(coords).addTo(map);
|
leaflet.marker(coords).addTo(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map
|
||||||
};
|
};
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash')
|
||||||
const leaflet = require('leaflet');
|
const leaflet = require('leaflet')
|
||||||
|
|
||||||
export default (opts) => {
|
export default (opts) => {
|
||||||
|
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
center: [29.98139, -95.33374],
|
center: [29.98139, -95.33374],
|
||||||
zoom: 5,
|
zoom: 5,
|
||||||
maxZoom: 10,
|
maxZoom: 10,
|
||||||
layers: [],
|
layers: [],
|
||||||
set_marker: false,
|
set_marker: false,
|
||||||
});
|
})
|
||||||
|
|
||||||
let feature_groups = [];
|
let feature_groups = []
|
||||||
/*var openaip_airspace_labels = new leaflet.TileLayer.WMS(
|
/*var openaip_airspace_labels = new leaflet.TileLayer.WMS(
|
||||||
"http://{s}.tile.maps.openaip.net/geowebcache/service/wms", {
|
"http://{s}.tile.maps.openaip.net/geowebcache/service/wms", {
|
||||||
maxZoom: 14,
|
maxZoom: 14,
|
||||||
minZoom: 12,
|
minZoom: 12,
|
||||||
layers: 'openaip_approved_airspaces_labels',
|
layers: 'openaip_approved_airspaces_labels',
|
||||||
tileSize: 1024,
|
tileSize: 1024,
|
||||||
detectRetina: true,
|
detectRetina: true,
|
||||||
subdomains: '12',
|
subdomains: '12',
|
||||||
format: 'image/png',
|
format: 'image/png',
|
||||||
transparent: true
|
transparent: true
|
||||||
});
|
});
|
||||||
|
|
||||||
openaip_airspace_labels.addTo(map);*/
|
openaip_airspace_labels.addTo(map);*/
|
||||||
|
|
||||||
const opencyclemap_phys_osm = new leaflet.TileLayer(
|
const opencyclemap_phys_osm = new leaflet.TileLayer(
|
||||||
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=f09a38fa87514de4890fc96e7fe8ecb1', {
|
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=f09a38fa87514de4890fc96e7fe8ecb1', {
|
||||||
maxZoom: 14,
|
maxZoom: 14,
|
||||||
minZoom: 4,
|
minZoom: 4,
|
||||||
format: 'image/png',
|
format: 'image/png',
|
||||||
transparent: true
|
transparent: true
|
||||||
});
|
})
|
||||||
|
|
||||||
feature_groups.push(opencyclemap_phys_osm);
|
feature_groups.push(opencyclemap_phys_osm)
|
||||||
|
|
||||||
/*const openaip_cached_basemap = new leaflet.TileLayer("http://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.png", {
|
/*const openaip_cached_basemap = new leaflet.TileLayer("http://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.png", {
|
||||||
maxZoom: 14,
|
maxZoom: 14,
|
||||||
minZoom: 4,
|
minZoom: 4,
|
||||||
tms: true,
|
tms: true,
|
||||||
detectRetina: true,
|
detectRetina: true,
|
||||||
subdomains: '12',
|
subdomains: '12',
|
||||||
format: 'image/png',
|
format: 'image/png',
|
||||||
transparent: true
|
transparent: true
|
||||||
});
|
});
|
||||||
|
|
||||||
feature_groups.push(openaip_cached_basemap);
|
feature_groups.push(openaip_cached_basemap);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const openaip_basemap_phys_osm = leaflet.featureGroup(feature_groups);
|
const openaip_basemap_phys_osm = leaflet.featureGroup(feature_groups)
|
||||||
|
|
||||||
let map = leaflet.map('map', {
|
let map = leaflet.map('map', {
|
||||||
layers: [openaip_basemap_phys_osm],
|
layers: [openaip_basemap_phys_osm],
|
||||||
center: opts.center,
|
center: opts.center,
|
||||||
zoom: opts.zoom,
|
zoom: opts.zoom,
|
||||||
scrollWheelZoom: false,
|
scrollWheelZoom: false,
|
||||||
});
|
})
|
||||||
|
|
||||||
const attrib = leaflet.control.attribution({position: 'bottomleft'});
|
const attrib = leaflet.control.attribution({position: 'bottomleft'})
|
||||||
attrib.addAttribution("<a href=\"https://www.thunderforest.com\" target=\"_blank\" style=\"\">Thunderforest</a>");
|
attrib.addAttribution('<a href="https://www.thunderforest.com" target="_blank" style="">Thunderforest</a>')
|
||||||
attrib.addAttribution("<a href=\"https://www.openaip.net\" target=\"_blank\" style=\"\">openAIP</a>");
|
attrib.addAttribution('<a href="https://www.openaip.net" target="_blank" style="">openAIP</a>')
|
||||||
attrib.addAttribution("<a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\" style=\"\">OpenStreetMap</a> contributors");
|
attrib.addAttribution('<a href="https://www.openstreetmap.org/copyright" target="_blank" style="">OpenStreetMap</a> contributors')
|
||||||
attrib.addAttribution("<a href=\"https://www.openweathermap.org\" target=\"_blank\" style=\"\">OpenWeatherMap</a>");
|
attrib.addAttribution('<a href="https://www.openweathermap.org" target="_blank" style="">OpenWeatherMap</a>')
|
||||||
|
|
||||||
attrib.addTo(map);
|
attrib.addTo(map)
|
||||||
|
|
||||||
return map;
|
return map
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export let
|
export let
|
||||||
PLAN_ROUTE_COLOR = '#36b123',
|
PLAN_ROUTE_COLOR = '#36b123',
|
||||||
ACTUAL_ROUTE_COLOR = '#172aea';
|
ACTUAL_ROUTE_COLOR = '#172aea'
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
* All of the functionality required for maps
|
* All of the functionality required for maps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.L = require('leaflet');
|
window.L = require('leaflet')
|
||||||
require('Leaflet.Geodesic');
|
require('Leaflet.Geodesic')
|
||||||
require('leaflet-rotatedmarker');
|
require('leaflet-rotatedmarker')
|
||||||
|
|
||||||
import render_airspace_map from './airspace_map';
|
import render_airspace_map from './airspace_map'
|
||||||
import render_live_map from './live_map';
|
import render_live_map from './live_map'
|
||||||
import render_route_map from './route_map';
|
import render_route_map from './route_map'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
render_airspace_map,
|
render_airspace_map,
|
||||||
render_live_map,
|
render_live_map,
|
||||||
render_route_map,
|
render_route_map,
|
||||||
};
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
const _ = require('lodash')
|
||||||
|
const leaflet = require('leaflet')
|
||||||
|
|
||||||
const _ = require('lodash');
|
import draw_base_map from './base_map'
|
||||||
const leaflet = require('leaflet');
|
import { ACTUAL_ROUTE_COLOR } from './config'
|
||||||
|
|
||||||
import draw_base_map from './base_map';
|
|
||||||
import {ACTUAL_ROUTE_COLOR} from './config';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the live map
|
* Render the live map
|
||||||
@ -12,113 +11,113 @@ import {ACTUAL_ROUTE_COLOR} from './config';
|
|||||||
*/
|
*/
|
||||||
export default (opts) => {
|
export default (opts) => {
|
||||||
|
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
update_uri: '/api/acars',
|
update_uri: '/api/acars',
|
||||||
pirep_uri: '/api/pireps/{id}/acars',
|
pirep_uri: '/api/pireps/{id}/acars',
|
||||||
positions: null,
|
positions: null,
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
aircraft_icon: '/assets/img/acars/aircraft.png',
|
aircraft_icon: '/assets/img/acars/aircraft.png',
|
||||||
});
|
})
|
||||||
|
|
||||||
const map = draw_base_map(opts);
|
const map = draw_base_map(opts)
|
||||||
const aircraftIcon = leaflet.icon({
|
const aircraftIcon = leaflet.icon({
|
||||||
iconUrl: opts.aircraft_icon,
|
iconUrl: opts.aircraft_icon,
|
||||||
iconSize: [42, 42],
|
iconSize: [42, 42],
|
||||||
iconAnchor: [21, 21],
|
iconAnchor: [21, 21],
|
||||||
});
|
})
|
||||||
|
|
||||||
let layerFlights = null;
|
let layerFlights = null
|
||||||
let layerSelFlight = null;
|
let layerSelFlight = null
|
||||||
let layerSelFlightFeature = null;
|
let layerSelFlightFeature = null
|
||||||
let layerSelFlightLayer = null;
|
let layerSelFlightLayer = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When a flight is clicked on, show the path, etc for that flight
|
||||||
|
* @param feature
|
||||||
|
* @param layer
|
||||||
|
*/
|
||||||
|
const onFlightClick = (feature, layer) => {
|
||||||
|
|
||||||
|
const uri = opts.pirep_uri.replace('{id}', feature.properties.pirep_id)
|
||||||
|
|
||||||
|
const flight_route = $.ajax({
|
||||||
|
url: uri,
|
||||||
|
dataType: 'json',
|
||||||
|
error: console.log
|
||||||
|
})
|
||||||
|
|
||||||
|
$.when(flight_route).done((routeJson) => {
|
||||||
|
if (layerSelFlight !== null) {
|
||||||
|
map.removeLayer(layerSelFlight)
|
||||||
|
}
|
||||||
|
|
||||||
|
layerSelFlight = leaflet.geodesic([], {
|
||||||
|
weight: 7,
|
||||||
|
opacity: 0.9,
|
||||||
|
color: ACTUAL_ROUTE_COLOR,
|
||||||
|
wrap: false,
|
||||||
|
}).addTo(map)
|
||||||
|
|
||||||
|
layerSelFlight.geoJson(routeJson.line)
|
||||||
|
|
||||||
|
layerSelFlightFeature = feature
|
||||||
|
layerSelFlightLayer = layer
|
||||||
|
//map.fitBounds(layerSelFlight.getBounds());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateMap = () => {
|
||||||
|
|
||||||
|
console.log('reloading flights from acars...')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a flight is clicked on, show the path, etc for that flight
|
* AJAX UPDATE
|
||||||
* @param feature
|
|
||||||
* @param layer
|
|
||||||
*/
|
*/
|
||||||
const onFlightClick = (feature, layer) => {
|
|
||||||
|
|
||||||
const uri = opts.pirep_uri.replace('{id}', feature.properties.pirep_id);
|
let flights = $.ajax({
|
||||||
|
url: opts.update_uri,
|
||||||
|
dataType: 'json',
|
||||||
|
error: console.log
|
||||||
|
})
|
||||||
|
|
||||||
const flight_route = $.ajax({
|
$.when(flights).done(function (flightGeoJson) {
|
||||||
url: uri,
|
|
||||||
dataType: "json",
|
|
||||||
error: console.log
|
|
||||||
});
|
|
||||||
|
|
||||||
$.when(flight_route).done((routeJson) => {
|
if (layerFlights !== null) {
|
||||||
if (layerSelFlight !== null) {
|
layerFlights.clearLayers()
|
||||||
map.removeLayer(layerSelFlight);
|
}
|
||||||
|
|
||||||
|
layerFlights = leaflet.geoJSON(flightGeoJson, {
|
||||||
|
onEachFeature: (feature, layer) => {
|
||||||
|
|
||||||
|
layer.on({
|
||||||
|
click: (e) => {
|
||||||
|
onFlightClick(feature, layer)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
layerSelFlight = leaflet.geodesic([], {
|
let popup_html = ''
|
||||||
weight: 7,
|
if (feature.properties && feature.properties.popup) {
|
||||||
opacity: 0.9,
|
popup_html += feature.properties.popup
|
||||||
color: ACTUAL_ROUTE_COLOR,
|
}
|
||||||
wrap: false,
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
layerSelFlight.geoJson(routeJson.line);
|
layer.bindPopup(popup_html)
|
||||||
|
},
|
||||||
|
pointToLayer: function (feature, latlon) {
|
||||||
|
return leaflet.marker(latlon, {
|
||||||
|
icon: aircraftIcon,
|
||||||
|
rotationAngle: feature.properties.heading
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
layerSelFlightFeature = feature;
|
layerFlights.addTo(map)
|
||||||
layerSelFlightLayer = layer;
|
|
||||||
//map.fitBounds(layerSelFlight.getBounds());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateMap = () => {
|
if (layerSelFlight !== null) {
|
||||||
|
onFlightClick(layerSelFlightFeature, layerSelFlightLayer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
console.log('reloading flights from acars...');
|
updateMap()
|
||||||
|
setInterval(updateMap, 10000)
|
||||||
/**
|
|
||||||
* AJAX UPDATE
|
|
||||||
*/
|
|
||||||
|
|
||||||
let flights = $.ajax({
|
|
||||||
url: opts.update_uri,
|
|
||||||
dataType: "json",
|
|
||||||
error: console.log
|
|
||||||
});
|
|
||||||
|
|
||||||
$.when(flights).done(function (flightGeoJson) {
|
|
||||||
|
|
||||||
if (layerFlights !== null) {
|
|
||||||
layerFlights.clearLayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
layerFlights = leaflet.geoJSON(flightGeoJson, {
|
|
||||||
onEachFeature: (feature, layer) => {
|
|
||||||
|
|
||||||
layer.on({
|
|
||||||
click: (e) => {
|
|
||||||
onFlightClick(feature, layer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let popup_html = "";
|
|
||||||
if (feature.properties && feature.properties.popup) {
|
|
||||||
popup_html += feature.properties.popup;
|
|
||||||
}
|
|
||||||
|
|
||||||
layer.bindPopup(popup_html);
|
|
||||||
},
|
|
||||||
pointToLayer: function (feature, latlon) {
|
|
||||||
return leaflet.marker(latlon, {
|
|
||||||
icon: aircraftIcon,
|
|
||||||
rotationAngle: feature.properties.heading
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
layerFlights.addTo(map);
|
|
||||||
|
|
||||||
if (layerSelFlight !== null) {
|
|
||||||
onFlightClick(layerSelFlightFeature, layerSelFlightLayer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
updateMap();
|
|
||||||
setInterval(updateMap, 10000);
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash')
|
||||||
const leaflet = require('leaflet');
|
const leaflet = require('leaflet')
|
||||||
|
|
||||||
import draw_base_map from './base_map';
|
import draw_base_map from './base_map'
|
||||||
import {ACTUAL_ROUTE_COLOR, PLAN_ROUTE_COLOR} from './config';
|
import { ACTUAL_ROUTE_COLOR, PLAN_ROUTE_COLOR } from './config'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show some popup text when a feature is clicked on
|
* Show some popup text when a feature is clicked on
|
||||||
@ -10,13 +10,13 @@ import {ACTUAL_ROUTE_COLOR, PLAN_ROUTE_COLOR} from './config';
|
|||||||
* @param layer
|
* @param layer
|
||||||
*/
|
*/
|
||||||
export const onFeaturePointClick = (feature, layer) => {
|
export const onFeaturePointClick = (feature, layer) => {
|
||||||
let popup_html = "";
|
let popup_html = ''
|
||||||
if (feature.properties && feature.properties.popup) {
|
if (feature.properties && feature.properties.popup) {
|
||||||
popup_html += feature.properties.popup;
|
popup_html += feature.properties.popup
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.bindPopup(popup_html);
|
layer.bindPopup(popup_html)
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show each point as a marker
|
* Show each point as a marker
|
||||||
@ -25,15 +25,15 @@ export const onFeaturePointClick = (feature, layer) => {
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export const pointToLayer = (feature, latlng) => {
|
export const pointToLayer = (feature, latlng) => {
|
||||||
return leaflet.circleMarker(latlng, {
|
return leaflet.circleMarker(latlng, {
|
||||||
radius: 12,
|
radius: 12,
|
||||||
fillColor: "#ff7800",
|
fillColor: '#ff7800',
|
||||||
color: "#000",
|
color: '#000',
|
||||||
weight: 1,
|
weight: 1,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
fillOpacity: 0.8
|
fillOpacity: 0.8
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -42,82 +42,82 @@ export const pointToLayer = (feature, latlng) => {
|
|||||||
*/
|
*/
|
||||||
export default (opts) => {
|
export default (opts) => {
|
||||||
|
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
route_points: null,
|
route_points: null,
|
||||||
planned_route_line: null,
|
planned_route_line: null,
|
||||||
actual_route_points: null,
|
actual_route_points: null,
|
||||||
actual_route_line: null,
|
actual_route_line: null,
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
});
|
})
|
||||||
|
|
||||||
console.log(opts);
|
console.log(opts)
|
||||||
|
|
||||||
let map = draw_base_map(opts);
|
let map = draw_base_map(opts)
|
||||||
|
|
||||||
|
let geodesicLayer = leaflet.geodesic([], {
|
||||||
|
weight: 7,
|
||||||
|
opacity: 0.9,
|
||||||
|
color: PLAN_ROUTE_COLOR,
|
||||||
|
steps: 50,
|
||||||
|
wrap: false,
|
||||||
|
}).addTo(map)
|
||||||
|
|
||||||
|
geodesicLayer.geoJson(opts.planned_route_line)
|
||||||
|
|
||||||
|
try {
|
||||||
|
map.fitBounds(geodesicLayer.getBounds())
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the route points after
|
||||||
|
if (opts.route_points !== null) {
|
||||||
|
let route_points = leaflet.geoJSON(opts.route_points, {
|
||||||
|
onEachFeature: onFeaturePointClick,
|
||||||
|
pointToLayer: pointToLayer,
|
||||||
|
style: {
|
||||||
|
'color': PLAN_ROUTE_COLOR,
|
||||||
|
'weight': 5,
|
||||||
|
'opacity': 0.65,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
route_points.addTo(map)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw the actual route
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (opts.actual_route_line !== null && opts.actual_route_line.features.length > 0) {
|
||||||
let geodesicLayer = leaflet.geodesic([], {
|
let geodesicLayer = leaflet.geodesic([], {
|
||||||
weight: 7,
|
weight: 7,
|
||||||
opacity: 0.9,
|
opacity: 0.9,
|
||||||
color: PLAN_ROUTE_COLOR,
|
color: ACTUAL_ROUTE_COLOR,
|
||||||
steps: 50,
|
steps: 50,
|
||||||
wrap: false,
|
wrap: false,
|
||||||
}).addTo(map);
|
}).addTo(map)
|
||||||
|
|
||||||
geodesicLayer.geoJson(opts.planned_route_line);
|
geodesicLayer.geoJson(opts.actual_route_line)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
map.fitBounds(geodesicLayer.getBounds());
|
map.fitBounds(geodesicLayer.getBounds())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the route points after
|
if (opts.actual_route_points !== null && opts.actual_route_points.features.length > 0) {
|
||||||
if (opts.route_points !== null) {
|
let route_points = leaflet.geoJSON(opts.actual_route_points, {
|
||||||
let route_points = leaflet.geoJSON(opts.route_points, {
|
onEachFeature: onFeaturePointClick,
|
||||||
onEachFeature: onFeaturePointClick,
|
pointToLayer: pointToLayer,
|
||||||
pointToLayer: pointToLayer,
|
style: {
|
||||||
style: {
|
'color': ACTUAL_ROUTE_COLOR,
|
||||||
"color": PLAN_ROUTE_COLOR,
|
'weight': 5,
|
||||||
"weight": 5,
|
'opacity': 0.65,
|
||||||
"opacity": 0.65,
|
},
|
||||||
},
|
})
|
||||||
});
|
|
||||||
|
|
||||||
route_points.addTo(map);
|
route_points.addTo(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* draw the actual route
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (opts.actual_route_line !== null && opts.actual_route_line.features.length > 0) {
|
|
||||||
let geodesicLayer = leaflet.geodesic([], {
|
|
||||||
weight: 7,
|
|
||||||
opacity: 0.9,
|
|
||||||
color: ACTUAL_ROUTE_COLOR,
|
|
||||||
steps: 50,
|
|
||||||
wrap: false,
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
geodesicLayer.geoJson(opts.actual_route_line);
|
|
||||||
|
|
||||||
try {
|
|
||||||
map.fitBounds(geodesicLayer.getBounds());
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.actual_route_points !== null && opts.actual_route_points.features.length > 0) {
|
|
||||||
let route_points = leaflet.geoJSON(opts.actual_route_points, {
|
|
||||||
onEachFeature: onFeaturePointClick,
|
|
||||||
pointToLayer: pointToLayer,
|
|
||||||
style: {
|
|
||||||
"color": ACTUAL_ROUTE_COLOR,
|
|
||||||
"weight": 5,
|
|
||||||
"opacity": 0.65,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
route_points.addTo(map);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
194
webpack.mix.js
194
webpack.mix.js
@ -2,155 +2,151 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
const mix = require('laravel-mix');
|
const mix = require('laravel-mix')
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack')
|
||||||
|
|
||||||
mix.webpackConfig({
|
mix.webpackConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ProvidePlugin({
|
new webpack.ProvidePlugin({
|
||||||
$: "jquery",
|
$: 'jquery',
|
||||||
jQuery: "jquery"
|
jQuery: 'jquery'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GENERAL FILES
|
* GENERAL FILES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/fonts/');
|
mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/fonts/')
|
||||||
mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/admin/fonts/');
|
mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/admin/fonts/')
|
||||||
mix.copy('node_modules/icheck/icheck.js', 'public/assets/admin/js/');
|
mix.copy('node_modules/icheck/icheck.js', 'public/assets/admin/js/')
|
||||||
mix.copy('node_modules/x-editable/dist/bootstrap3-editable/js/*', 'public/assets/admin/js/');
|
mix.copy('node_modules/x-editable/dist/bootstrap3-editable/js/*', 'public/assets/admin/js/')
|
||||||
mix.copy('node_modules/x-editable/dist/bootstrap3-editable/img/*', 'public/assets/admin/img/');
|
mix.copy('node_modules/x-editable/dist/bootstrap3-editable/img/*', 'public/assets/admin/img/')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ADMIN REQUIRED FILES
|
* ADMIN REQUIRED FILES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mix.sass('public/assets/admin/vendor/sass/paper-dashboard.scss',
|
mix.sass('public/assets/admin/vendor/sass/paper-dashboard.scss',
|
||||||
'public/assets/admin/vendor/paper-dashboard.css')
|
'public/assets/admin/vendor/paper-dashboard.css')
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
|
||||||
mix.styles([
|
mix.styles([
|
||||||
'node_modules/bootstrap3/dist/css/bootstrap.css',
|
'node_modules/bootstrap3/dist/css/bootstrap.css',
|
||||||
'public/assets/admin/vendor/animate.css',
|
'public/assets/admin/vendor/animate.css',
|
||||||
'node_modules/select2/dist/css/select2.css',
|
'node_modules/select2/dist/css/select2.css',
|
||||||
'node_modules/leaflet/dist/leaflet.css',
|
'node_modules/leaflet/dist/leaflet.css',
|
||||||
'node_modules/icheck/skins/square/blue.css',
|
'node_modules/icheck/skins/square/blue.css',
|
||||||
'node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css',
|
'node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css',
|
||||||
'public/assets/admin/vendor/paper-dashboard.css',
|
'public/assets/admin/vendor/paper-dashboard.css',
|
||||||
'node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css',
|
'node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css',
|
||||||
], 'public/assets/admin/css/vendor.min.css').version()
|
], 'public/assets/admin/css/vendor.min.css').version()
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
|
||||||
mix.scripts([
|
mix.scripts([
|
||||||
'node_modules/lodash/lodash.js',
|
'node_modules/lodash/lodash.js',
|
||||||
'node_modules/moment/moment.js',
|
'node_modules/moment/moment.js',
|
||||||
'node_modules/axios/dist/axios.js',
|
'node_modules/axios/dist/axios.js',
|
||||||
'node_modules/bootstrap3/dist/js/bootstrap.js',
|
'node_modules/bootstrap3/dist/js/bootstrap.js',
|
||||||
'node_modules/bootstrap3/js/collapse.js',
|
'node_modules/bootstrap3/js/collapse.js',
|
||||||
'node_modules/bootstrap3/js/transition.js',
|
'node_modules/bootstrap3/js/transition.js',
|
||||||
'node_modules/popper.js/dist/umd/popper.js',
|
'node_modules/popper.js/dist/umd/popper.js',
|
||||||
'node_modules/popper.js/dist/umd/popper-utils.js',
|
'node_modules/popper.js/dist/umd/popper-utils.js',
|
||||||
'node_modules/select2/dist/js/select2.js',
|
'node_modules/select2/dist/js/select2.js',
|
||||||
'node_modules/leaflet/dist/leaflet.js',
|
'node_modules/leaflet/dist/leaflet.js',
|
||||||
'node_modules/icheck/icheck.js',
|
'node_modules/icheck/icheck.js',
|
||||||
'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js',
|
'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js',
|
||||||
'node_modules/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js',
|
'node_modules/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js',
|
||||||
'node_modules/jquery-pjax/jquery.pjax.js',
|
'node_modules/jquery-pjax/jquery.pjax.js',
|
||||||
], 'public/assets/admin/js/vendor.js');
|
], 'public/assets/admin/js/vendor.js')
|
||||||
|
|
||||||
mix.copy('node_modules/icheck/skins/square/blue*.png', 'public/assets/admin/css');
|
mix.copy('node_modules/icheck/skins/square/blue*.png', 'public/assets/admin/css')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SYSTEM REQUIRED AND GLOBAL VENDOR FILES
|
* SYSTEM REQUIRED AND GLOBAL VENDOR FILES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mix.copy('node_modules/jquery/dist/jquery.js', 'public/assets/system/js/');
|
mix.copy('node_modules/jquery/dist/jquery.js', 'public/assets/system/js/')
|
||||||
mix.copy('node_modules/flag-icon-css/flags/', 'public/assets/system/flags/');
|
mix.copy('node_modules/flag-icon-css/flags/', 'public/assets/system/flags/')
|
||||||
|
|
||||||
mix.autoload({
|
mix.autoload({
|
||||||
'jquery': ['jQuery', '$'],
|
'jquery': ['jQuery', '$'],
|
||||||
});
|
})
|
||||||
|
|
||||||
mix.scripts([
|
mix.scripts([
|
||||||
'node_modules/lodash/lodash.js',
|
'node_modules/lodash/lodash.js',
|
||||||
'node_modules/axios/dist/axios.js',
|
'node_modules/axios/dist/axios.js',
|
||||||
'node_modules/jquery/dist/jquery.js',
|
'node_modules/jquery/dist/jquery.js',
|
||||||
'node_modules/bootstrap3/dist/js/bootstrap.js',
|
'node_modules/bootstrap3/dist/js/bootstrap.js',
|
||||||
'node_modules/popper.js/dist/umd/popper.js',
|
'node_modules/popper.js/dist/umd/popper.js',
|
||||||
'node_modules/popper.js/dist/umd/popper-utils.js',
|
'node_modules/popper.js/dist/umd/popper-utils.js',
|
||||||
'node_modules/select2/dist/js/select2.js',
|
'node_modules/select2/dist/js/select2.js',
|
||||||
'node_modules/leaflet/dist/leaflet.js',
|
'node_modules/leaflet/dist/leaflet.js',
|
||||||
'node_modules/pjax/pjax.js',
|
'node_modules/pjax/pjax.js',
|
||||||
'node_modules/leaflet-rotatedmarker/leaflet.rotatedMarker.js',
|
'node_modules/leaflet-rotatedmarker/leaflet.rotatedMarker.js',
|
||||||
'node_modules/Leaflet.Geodesic/Leaflet.Geodesic.js',
|
'node_modules/Leaflet.Geodesic/Leaflet.Geodesic.js',
|
||||||
], 'public/assets/system/js/vendor.js');
|
], 'public/assets/system/js/vendor.js')
|
||||||
|
|
||||||
mix.styles([
|
mix.styles([
|
||||||
'node_modules/select2/dist/css/select2.css',
|
'node_modules/select2/dist/css/select2.css',
|
||||||
'node_modules/leaflet/dist/leaflet.css',
|
'node_modules/leaflet/dist/leaflet.css',
|
||||||
'node_modules/flag-icon-css/css/flag-icon.css',
|
'node_modules/flag-icon-css/css/flag-icon.css',
|
||||||
'public/assets/admin/vendor/pe-icon-7-stroke.css',
|
'public/assets/admin/vendor/pe-icon-7-stroke.css',
|
||||||
], 'public/assets/system/css/vendor.min.css')
|
], 'public/assets/system/css/vendor.min.css')
|
||||||
.options({
|
.options({
|
||||||
compressed: true
|
compressed: true
|
||||||
})
|
})
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INSTALLER VENDOR FILES
|
* INSTALLER VENDOR FILES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mix.styles([
|
mix.styles([
|
||||||
'node_modules/select2/dist/css/select2.css',
|
'node_modules/select2/dist/css/select2.css',
|
||||||
'node_modules/flag-icon-css/css/flag-icon.css',
|
'node_modules/flag-icon-css/css/flag-icon.css',
|
||||||
], 'public/assets/system/css/installer.css')
|
], 'public/assets/system/css/installer.css')
|
||||||
.options({
|
.options({
|
||||||
processCssUrls: false,
|
processCssUrls: false,
|
||||||
compressed: true
|
compressed: true
|
||||||
})
|
})
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
|
||||||
mix.scripts([
|
mix.scripts([
|
||||||
'node_modules/lodash/lodash.js',
|
'node_modules/lodash/lodash.js',
|
||||||
'node_modules/jquery/dist/jquery.js',
|
'node_modules/jquery/dist/jquery.js',
|
||||||
'node_modules/pjax/pjax.js',
|
'node_modules/pjax/pjax.js',
|
||||||
'node_modules/select2/dist/js/select2.js',
|
'node_modules/select2/dist/js/select2.js',
|
||||||
], 'public/assets/system/js/installer-vendor.js');
|
], 'public/assets/system/js/installer-vendor.js')
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DEFAULT SKIN FRONTEND FILES
|
* DEFAULT SKIN FRONTEND FILES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mix.sass('public/assets/frontend/sass/now-ui-kit.scss',
|
mix.sass('public/assets/frontend/sass/now-ui-kit.scss',
|
||||||
'public/assets/frontend/css/now-ui-kit.css')
|
'public/assets/frontend/css/now-ui-kit.css')
|
||||||
.options({
|
.options({
|
||||||
processCssUrls: false,
|
processCssUrls: false,
|
||||||
compressed: true
|
compressed: true
|
||||||
})
|
})
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
|
||||||
|
|
||||||
// These should go into the separate vendor.js file
|
// These should go into the separate vendor.js file
|
||||||
const extract = [
|
const extract = [
|
||||||
'lodash',
|
'lodash',
|
||||||
'popper.js',
|
'popper.js',
|
||||||
'jquery',
|
'jquery',
|
||||||
'select2',
|
'select2',
|
||||||
'pjax',
|
'pjax',
|
||||||
'leaflet',
|
'leaflet',
|
||||||
'Leaflet.Geodesic',
|
'Leaflet.Geodesic',
|
||||||
'leaflet-rotatedmarker'
|
'leaflet-rotatedmarker'
|
||||||
];
|
]
|
||||||
|
|
||||||
mix.js('resources/js/frontend/app.js', 'public/js/frontend')
|
mix.js('resources/js/frontend/app.js', 'public/js/frontend')
|
||||||
.extract(extract);
|
.extract(extract)
|
||||||
|
|
||||||
|
//mix.js('resources/js/admin/app.js', 'public/js/admin')
|
||||||
mix.js('resources/js/admin/app.js', 'public/js/admin');
|
|
||||||
|
Loading…
Reference in New Issue
Block a user