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

View File

@@ -182,7 +182,7 @@ class PirepController extends Controller
# See if this user is at the current airport
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();
}

View File

@@ -18,9 +18,8 @@ class DashboardController extends Controller
* DashboardController constructor.
* @param PirepRepository $pirepRepo
*/
public function __construct(
PirepRepository $pirepRepo
) {
public function __construct(PirepRepository $pirepRepo)
{
$this->pirepRepo = $pirepRepo;
}
@@ -37,9 +36,13 @@ class DashboardController extends Controller
} catch (\Exception $e) {
}
// Get the current airport for the weather
$current_airport = $user->curr_airport_id ?? $user->home_airport_id;
return view('dashboard.index', [
'user' => $user,
'last_pirep' => $last_pirep,
'user' => $user,
'current_airport' => $current_airport,
'last_pirep' => $last_pirep,
]);
}
}

View File

@@ -244,7 +244,7 @@ class PirepController extends Controller
# Are they allowed at this airport?
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(
'You are currently not at the departure airport!',
'frontend.pireps.create'

View File

@@ -32,7 +32,6 @@ class CheckWx extends Widget
]);
$data = json_decode($data);
#dd($data);
if($data->results === 1) {
$data = $data->data[0];
@@ -42,9 +41,9 @@ class CheckWx extends Widget
}
return view('widgets.check_wx', [
'config' => $this->config,
'data' => $data,
'unit_alt' => setting('units.altitude'),
'config' => $this->config,
'data' => $data,
'unit_alt' => setting('units.altitude'),
'unit_dist' => setting('units.distance'),
'unit_temp' => setting('units.temperature'),
]);

View File

@@ -58,15 +58,50 @@
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
Your Last Report
</div>
@include("pireps.pirep_card", ['pirep' => $last_pirep])
@include('pireps.pirep_card', ['pirep' => $last_pirep])
@endif
{{ Widget::latestNews(['count' => 1]) }}
</div>
{{-- Sidebar --}}
<div class="col-sm-4">
{{ Widget::latestPireps(['count' => 5]) }}
{{ Widget::latestPilots(['count' => 5]) }}
<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]) }}
</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]) }}
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -1,20 +1,10 @@
<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>
@foreach($users as $u)
<tr>
<td style="padding-right: 10px;">
<span class="title">{{ $u->pilot_id }}</span>
</td>
<td>{{ $u->name }}</td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
<table>
@foreach($users as $u)
<tr>
<td style="padding-right: 10px;">
<span class="title">{{ $u->pilot_id }}</span>
</td>
<td>{{ $u->name }}</td>
</tr>
@endforeach
</table>

View File

@@ -1,24 +1,14 @@
<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>
@foreach($pireps as $p)
<tr>
<td style="padding-right: 10px;">
<span class="title">{{ $p->airline->code }}</span>
</td>
<td>
{{ $p->dpt_airport_id }}-
{{ $p->arr_airport_id }}&nbsp;
{{ $p->aircraft->name }}
</td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
<table>
@foreach($pireps as $p)
<tr>
<td style="padding-right: 10px;">
<span class="title">{{ $p->airline->code }}</span>
</td>
<td>
{{ $p->dpt_airport_id }}-
{{ $p->arr_airport_id }}&nbsp;
{{ $p->aircraft->name }}
</td>
</tr>
@endforeach
</table>