Add AirspaceMap widget; airport overview page

This commit is contained in:
Nabeel Shahzad 2018-03-27 11:40:37 -05:00
parent 5cbb480f6e
commit 504b33ba2a
9 changed files with 160 additions and 5 deletions

View File

@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers\Frontend;
use App\Interfaces\Controller;
use App\Models\User;
use App\Repositories\AirportRepository;
use App\Repositories\FlightRepository;
use Flash;
use Illuminate\Database\QueryException;
use Request;
/**
* Class HomeController
* @package App\Http\Controllers\Frontend
*/
class AirportController extends Controller
{
private $airportRepo,
$flightRepo;
public function __construct(
AirportRepository $airportRepo,
FlightRepository $flightRepo
) {
$this->airportRepo = $airportRepo;
$this->flightRepo = $flightRepo;
}
/**
* Show the airport
*/
public function show($id, Request $request)
{
$id = strtoupper($id);
$airport = $this->airportRepo->find($id);
if (empty($airport)) {
Flash::error('Airport not found!');
return redirect(route('frontend.dashboard.index'));
}
$inbound_flights = $this->flightRepo->findWhere([
'arr_airport_id' => $id,
])->all();
$outbound_flights = $this->flightRepo->findWhere([
'dpt_airport_id' => $id,
])->all();
return view('airports.show', [
'airport' => $airport,
'inbound_flights' => $inbound_flights,
'outbound_flights' => $outbound_flights,
]);
}
}

View File

@ -9,6 +9,7 @@ use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria;
use App\Repositories\FlightRepository;
use App\Services\GeoService;
use Flash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Log;
@ -132,7 +133,6 @@ class FlightController extends Controller
$flight = $this->flightRepo->find($id);
if (empty($flight)) {
Flash::error('Flight not found!');
return redirect(route('frontend.dashboard.index'));
}

View File

@ -25,6 +25,8 @@ Route::group([
], function () {
Route::resource('dashboard', 'DashboardController');
Route::get('airports/{id}', 'AirportController@show')->name('airports.show');
Route::get('flights/bids', 'FlightController@bids')->name('flights.bids');
Route::get('flights/search', 'FlightController@search')->name('flights.search');
Route::resource('flights', 'FlightController');

View File

@ -0,0 +1,29 @@
<?php
namespace App\Widgets;
use App\Interfaces\Widget;
/**
* Show the live map in a view
* @package App\Widgets
*/
class AirspaceMap extends Widget
{
protected $config = [
'height' => '800px',
'width' => '100%',
'lat' => 0,
'lon' => 0,
];
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function run()
{
return view('widgets.airspace_map', [
'config' => $this->config,
]);
}
}

View File

@ -2,6 +2,13 @@
*
*/
.mini-splash {
padding: 30px 0;
text-align: center;
color: #9A9A9A;
font-weight: 300;
}
.font-large {
font-size: 20px;
}

View File

@ -16,10 +16,7 @@
<tr>
<td>
<a href="{{ route('admin.flights.edit', [$flight->id]) }}">
{{ $flight->airline->code }}{{ $flight->flight_number }}
@if($flight->route_code)
(C: {{ $flight->route_code }} L: {{ $flight->route_leg }})
@endif
{{$flight->ident}}
</a>
</td>
<td>{{ $flight->dpt_airport->icao }}</td>

View File

@ -0,0 +1,34 @@
@extends('app')
@section('title', $airport->full_name)
@section('content')
<div class="row">
<div class="col-md-6">
<h2 class="description">{{ $airport->full_name }}</h2>
</div>
<div class="col-md-6">
{{ Widget::airspaceMap([
'width' => '100%',
'height' => '250px',
'lat' => $airport->lat,
'lon' => $airport->lon,
]) }}
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3 class="description">Inbound Flights</h3>
@if(!$inbound_flights)
<div class="mini-splash">
no flights found
</div>
@else
@each('airports.table', $inbound_flights, 'flight')
@endif
<h3 class="description">Outbound Flights</h3>
@each('airports.table', $outbound_flights, 'flight')
</div>
</div>
@endsection

View File

@ -0,0 +1,19 @@
<table class="table">
<tr>
<td>
<a href="{{ route('frontend.flights.show', [$flight->id]) }}">
{{ $flight->ident }}
</a>
</td>
<td>{{ $flight->dpt_airport->icao }}</td>
<td>
{{ $flight->arr_airport->icao }}
@if($flight->alt_airport)
(Alt: {{ $flight->alt_airport->icao }})
@endif
</td>
{{--<td>{{ $flight->route }}</td>--}}
<td>{{ $flight->dpt_time }}</td>
<td>{{ $flight->arr_time }}</td>
<td>{{ $flight->notes }}</td>
</table>

View File

@ -0,0 +1,10 @@
<div id="map" style="width: {{ $config['width'] }}; height: {{ $config['height'] }}"></div>
@section('scripts')
<script>
phpvms.map.render_airspace_map({
lat: "{{$config['lat']}}",
lon: "{{$config['lon']}}",
});
</script>
@endsection