Add ACARS live time/coords/default zoom into admin settings
This commit is contained in:
parent
a63a784dec
commit
da0a7cbe81
@ -122,6 +122,35 @@ class CreateSettingsTable extends Migration
|
||||
'description' => 'The units for temperature',
|
||||
]);
|
||||
|
||||
/**
|
||||
* ACARS Settings
|
||||
*/
|
||||
|
||||
$this->addSetting('acars.live_time', [
|
||||
'name' => 'Live Time',
|
||||
'group' => 'acars',
|
||||
'value' => 12,
|
||||
'type' => 'int',
|
||||
'description' => 'Age of flights to show on the map in hours. '
|
||||
.'Set to 0 to show only all in-progress flights',
|
||||
]);
|
||||
|
||||
$this->addSetting('acars.center_coords', [
|
||||
'name' => 'Center Coords',
|
||||
'group' => 'acars',
|
||||
'value' => '30.1945,-97.6699',
|
||||
'type' => 'text',
|
||||
'description' => 'Where to center the map; enter as LAT,LON',
|
||||
]);
|
||||
|
||||
$this->addSetting('acars.default_zoom', [
|
||||
'name' => 'Default Zoom',
|
||||
'group' => 'acars',
|
||||
'value' => 5,
|
||||
'type' => 'int',
|
||||
'description' => 'Initial zoom level on the map',
|
||||
]);
|
||||
|
||||
/**
|
||||
* BIDS
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ use App\Models\Acars;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Pirep;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class AcarsRepository
|
||||
@ -51,14 +52,21 @@ class AcarsRepository extends Repository
|
||||
/**
|
||||
* Get all of the PIREPS that are in-progress, and then
|
||||
* get the latest update for those flights
|
||||
* @param int $live_time Age in hours of the oldest flights to show
|
||||
* @return Pirep
|
||||
*/
|
||||
public function getPositions()
|
||||
public function getPositions($live_time = 0)
|
||||
{
|
||||
return Pirep::with(['airline', 'position', 'aircraft'])
|
||||
->where(['state' => PirepState::IN_PROGRESS])
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
$q = Pirep::with(['airline', 'position', 'aircraft'])
|
||||
->where(['state' => PirepState::IN_PROGRESS]);
|
||||
|
||||
if($live_time !== null && $live_time > 0) {
|
||||
$st = Carbon::now('UTC')->subHours($live_time);
|
||||
$q = $q->whereDate('created_at', '>=', $st);
|
||||
}
|
||||
|
||||
$q = $q->orderBy('created_at', 'desc');
|
||||
return $q->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,13 +25,20 @@ class LiveMap extends Widget
|
||||
$geoSvc = app(GeoService::class);
|
||||
$acarsRepo = app(AcarsRepository::class);
|
||||
|
||||
$pireps = $acarsRepo->getPositions();
|
||||
$pireps = $acarsRepo->getPositions(setting('acars.live_time', 0));
|
||||
$positions = $geoSvc->getFeatureForLiveFlights($pireps);
|
||||
|
||||
$center_coords = setting('acars.center_coords', '0,0');
|
||||
$center_coords = array_map(function($c) {
|
||||
return (float) trim($c);
|
||||
}, explode(',', $center_coords));
|
||||
|
||||
return view('widgets.live_map', [
|
||||
'config' => $this->config,
|
||||
'pireps' => $pireps,
|
||||
'positions' => $positions,
|
||||
'config' => $this->config,
|
||||
'pireps' => $pireps,
|
||||
'positions' => $positions,
|
||||
'center' => $center_coords,
|
||||
'zoom' => setting('acars.default_zoom', 5),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
30
composer.lock
generated
30
composer.lock
generated
@ -1448,16 +1448,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.6.20",
|
||||
"version": "v5.6.22",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c"
|
||||
"reference": "637fd797a6dde8d24a9f07da77e375ec251c5d24"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c",
|
||||
"reference": "3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/637fd797a6dde8d24a9f07da77e375ec251c5d24",
|
||||
"reference": "637fd797a6dde8d24a9f07da77e375ec251c5d24",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1583,20 +1583,20 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2018-05-02T15:22:18+00:00"
|
||||
"time": "2018-05-15T13:34:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravelcollective/html",
|
||||
"version": "v5.6.7",
|
||||
"version": "v5.6.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LaravelCollective/html.git",
|
||||
"reference": "38f2c6ff0d3dfc497175a5cff5e24b3937f6e2c9"
|
||||
"reference": "42c0854e00d6bb3346883d122b444fbf15a13ecb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/38f2c6ff0d3dfc497175a5cff5e24b3937f6e2c9",
|
||||
"reference": "38f2c6ff0d3dfc497175a5cff5e24b3937f6e2c9",
|
||||
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/42c0854e00d6bb3346883d122b444fbf15a13ecb",
|
||||
"reference": "42c0854e00d6bb3346883d122b444fbf15a13ecb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1651,7 +1651,7 @@
|
||||
],
|
||||
"description": "HTML and Form Builders for the Laravel Framework",
|
||||
"homepage": "https://laravelcollective.com",
|
||||
"time": "2018-04-26T16:09:18+00:00"
|
||||
"time": "2018-05-10T17:15:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/csv",
|
||||
@ -1722,16 +1722,16 @@
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "1.0.44",
|
||||
"version": "1.0.45",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "168dbe519737221dc87d17385cde33073881fd02"
|
||||
"reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/168dbe519737221dc87d17385cde33073881fd02",
|
||||
"reference": "168dbe519737221dc87d17385cde33073881fd02",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a99f94e63b512d75f851b181afcdf0ee9ebef7e6",
|
||||
"reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1802,7 +1802,7 @@
|
||||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2018-04-06T09:58:14+00:00"
|
||||
"time": "2018-05-07T08:44:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/geotools",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,8 +1,8 @@
|
||||
{
|
||||
"/assets/frontend/js/app.js": "/assets/frontend/js/app.js?id=c30de31f825160aacbb4",
|
||||
"/assets/frontend/js/app.js": "/assets/frontend/js/app.js?id=b83a392b6c373e164576",
|
||||
"/assets/frontend/css/now-ui-kit.css": "/assets/frontend/css/now-ui-kit.css?id=b0a0f05b94a4486db4f2",
|
||||
"/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=cc80aec3cf1646f83d8d",
|
||||
"/assets/admin/js/app.js": "/assets/admin/js/app.js?id=fd7aff514485e548f4bc",
|
||||
"/assets/admin/js/app.js": "/assets/admin/js/app.js?id=1f2917a3a9f172f3cdad",
|
||||
"/assets/installer/js/app.js": "/assets/installer/js/app.js?id=3a51850509367b06cd1f",
|
||||
"/assets/fonts/glyphicons-halflings-regular.woff2": "/assets/fonts/glyphicons-halflings-regular.woff2?id=349344e92fb16221dd56",
|
||||
"/assets/admin/fonts/glyphicons-halflings-regular.woff2": "/assets/admin/fonts/glyphicons-halflings-regular.woff2?id=349344e92fb16221dd56",
|
||||
|
@ -15,6 +15,8 @@ import { ACTUAL_ROUTE_COLOR } from './config'
|
||||
export default (opts) => {
|
||||
|
||||
opts = Object.assign({
|
||||
center: [29.98139, -95.33374],
|
||||
zoom: 5,
|
||||
update_uri: '/api/acars',
|
||||
pirep_uri: '/api/pireps/{id}',
|
||||
pirep_link_uri: '/pireps/{id}',
|
||||
|
@ -110,11 +110,13 @@ and being mindful of the rivets bindings
|
||||
@section('scripts')
|
||||
<script>
|
||||
phpvms.map.render_live_map({
|
||||
'update_uri': '{!! url('/api/acars') !!}',
|
||||
'pirep_uri': '{!! url('/api/pireps/{id}') !!}',
|
||||
'pirep_link_uri': '{!! url('/pireps/{id}') !!}',
|
||||
'aircraft_icon': '{!! public_asset('/assets/img/acars/aircraft.png') !!}',
|
||||
'units': '{{ setting('units.distance') }}',
|
||||
center: ['{{ $center[0] }}', '{{ $center[1] }}'],
|
||||
zoom: '{{ $zoom }}',
|
||||
update_uri: '{!! url('/api/acars') !!}',
|
||||
pirep_uri: '{!! url('/api/pireps/{id}') !!}',
|
||||
pirep_link_uri: '{!! url('/pireps/{id}') !!}',
|
||||
aircraft_icon: '{!! public_asset('/assets/img/acars/aircraft.png') !!}',
|
||||
units: '{{ setting('units.distance') }}',
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user