Convert live acars map into a widget
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Models\Pirep;
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Services\GeoService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
32
app/Widgets/LiveMap.php
Normal file
32
app/Widgets/LiveMap.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Widgets;
|
||||
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Services\GeoService;
|
||||
|
||||
class LiveMap extends BaseWidget
|
||||
{
|
||||
protected $config = [
|
||||
'height' => '800px',
|
||||
'width' => '100%',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$geoSvc = app(GeoService::class);
|
||||
$acarsRepo = app(AcarsRepository::class);
|
||||
|
||||
$pireps = $acarsRepo->getPositions();
|
||||
$positions = $geoSvc->getFeatureForLiveFlights($pireps);
|
||||
|
||||
return $this->view('widgets.live_map', [
|
||||
'config' => $this->config,
|
||||
'pireps' => $pireps,
|
||||
'positions' => $positions,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
@section('title', 'live map')
|
||||
@section('content')
|
||||
@include('layouts.default.acars.map')
|
||||
<div class="clearfix" style="padding-top: 25px"></div>
|
||||
@include('layouts.default.acars.table')
|
||||
{{ Widget::liveMap() }}
|
||||
@endsection
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">flight map</h3>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="box-body">
|
||||
<div id="map" style="width: 100%; height: 800px"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
phpvms.render_live_map({
|
||||
'update_uri': '{!! url('/api/acars') !!}',
|
||||
'pirep_uri': '{!! url('/api/pireps/{id}/acars/geojson') !!}',
|
||||
'aircraft_icon': '{!! public_asset('/assets/img/acars/aircraft.png') !!}',
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -1,17 +0,0 @@
|
||||
<div id="flights_table" class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">flights</h3>
|
||||
<table class="table">
|
||||
@foreach($pireps as $pirep)
|
||||
<tr>
|
||||
<td>{!! $pirep->ident !!}</td>
|
||||
<td>{!! $pirep->dpt_airport_id !!}</td>
|
||||
<td>{!! $pirep->arr_airport_id !!}</td>
|
||||
<td>
|
||||
{!! PirepStatus::label($pirep->status); !!}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
41
resources/views/layouts/default/widgets/live_map.blade.php
Normal file
41
resources/views/layouts/default/widgets/live_map.blade.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">flight map</h3>
|
||||
<div class="box-body">
|
||||
<div id="map" style="width: {!! $config['width'] !!}; height: {!! $config['height'] !!}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix" style="padding-top: 25px"></div>
|
||||
|
||||
<div id="flights_table" class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">flights</h3>
|
||||
@if(!filled($pireps))
|
||||
<div class="text-center">There are no flights</div>
|
||||
@endif
|
||||
<table class="table">
|
||||
@foreach($pireps as $pirep)
|
||||
<tr>
|
||||
<td>{!! $pirep->ident !!}</td>
|
||||
<td>{!! $pirep->dpt_airport_id !!}</td>
|
||||
<td>{!! $pirep->arr_airport_id !!}</td>
|
||||
<td>
|
||||
{!! PirepStatus::label($pirep->status); !!}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
phpvms.render_live_map({
|
||||
'update_uri': '{!! url('/api/acars') !!}',
|
||||
'pirep_uri': '{!! url('/api/pireps/{id}/acars/geojson') !!}',
|
||||
'aircraft_icon': '{!! public_asset('/assets/img/acars/aircraft.png') !!}',
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user