Add weather to the dashboard for the current airport

This commit is contained in:
Nabeel Shahzad
2018-04-02 06:47:05 -05:00
parent cfd0853d79
commit bb73af3806
7 changed files with 75 additions and 58 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ class PirepController extends Controller
# See if this user is at the current airport # See if this user is at the current airport
if (setting('pilots.only_flights_from_current') if (setting('pilots.only_flights_from_current')
&& $user->current_airport_id !== $pirep->dpt_airport_id) && $user->curr_airport_id !== $pirep->dpt_airport_id)
{ {
throw new UserNotAtAirport(); throw new UserNotAtAirport();
} }
@@ -18,9 +18,8 @@ class DashboardController extends Controller
* DashboardController constructor. * DashboardController constructor.
* @param PirepRepository $pirepRepo * @param PirepRepository $pirepRepo
*/ */
public function __construct( public function __construct(PirepRepository $pirepRepo)
PirepRepository $pirepRepo {
) {
$this->pirepRepo = $pirepRepo; $this->pirepRepo = $pirepRepo;
} }
@@ -37,8 +36,12 @@ class DashboardController extends Controller
} catch (\Exception $e) { } catch (\Exception $e) {
} }
// Get the current airport for the weather
$current_airport = $user->curr_airport_id ?? $user->home_airport_id;
return view('dashboard.index', [ return view('dashboard.index', [
'user' => $user, 'user' => $user,
'current_airport' => $current_airport,
'last_pirep' => $last_pirep, 'last_pirep' => $last_pirep,
]); ]);
} }
@@ -244,7 +244,7 @@ class PirepController extends Controller
# Are they allowed at this airport? # Are they allowed at this airport?
if (setting('pilots.only_flights_from_current') if (setting('pilots.only_flights_from_current')
&& Auth::user()->current_airport_id !== $pirep->dpt_airport_id) { && Auth::user()->curr_airport_id !== $pirep->dpt_airport_id) {
return $this->flashError( return $this->flashError(
'You are currently not at the departure airport!', 'You are currently not at the departure airport!',
'frontend.pireps.create' 'frontend.pireps.create'
-1
View File
@@ -32,7 +32,6 @@ class CheckWx extends Widget
]); ]);
$data = json_decode($data); $data = json_decode($data);
#dd($data);
if($data->results === 1) { if($data->results === 1) {
$data = $data->data[0]; $data = $data->data[0];
@@ -58,15 +58,50 @@
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;"> <div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Your Last Report Your Last Report
</div> </div>
@include("pireps.pirep_card", ['pirep' => $last_pirep]) @include('pireps.pirep_card', ['pirep' => $last_pirep])
@endif @endif
{{ Widget::latestNews(['count' => 1]) }} {{ Widget::latestNews(['count' => 1]) }}
</div> </div>
{{-- Sidebar --}}
<div class="col-sm-4"> <div class="col-sm-4">
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Weather at {{ $current_airport }}
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
{{ Widget::checkWx(['icao' => $current_airport]) }}
</div>
</div>
</div>
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Recent Reports
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
{{ Widget::latestPireps(['count' => 5]) }} {{ Widget::latestPireps(['count' => 5]) }}
</div>
</div>
</div>
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Newest Pilots
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
{{ Widget::latestPilots(['count' => 5]) }} {{ Widget::latestPilots(['count' => 5]) }}
</div> </div>
</div> </div>
</div>
</div>
</div>
@endsection @endsection
@@ -1,10 +1,3 @@
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Newest Pilots
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
<table> <table>
@foreach($users as $u) @foreach($users as $u)
<tr> <tr>
@@ -15,6 +8,3 @@
</tr> </tr>
@endforeach @endforeach
</table> </table>
</div>
</div>
</div>
@@ -1,10 +1,3 @@
<div class="card">
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Recent Reports
</div>
<div class="card-block">
<!-- Tab panes -->
<div class="tab-content">
<table> <table>
@foreach($pireps as $p) @foreach($pireps as $p)
<tr> <tr>
@@ -19,6 +12,3 @@
</tr> </tr>
@endforeach @endforeach
</table> </table>
</div>
</div>
</div>