Issue fixes (#341)

* Better error handling around ACARS position updates

* Add step for decimals on fuel block/used fields closes #340

* Styling

* Rename AcarsController to LiveMapController; update JS dependencies
This commit is contained in:
Nabeel S
2019-08-05 13:07:22 -04:00
committed by GitHub
parent 9f3ba05880
commit 753804b71b
9 changed files with 1234 additions and 187 deletions

View File

@@ -39,7 +39,7 @@ A full development environment can be brought up using Docker:
```bash ```bash
composer install composer install
npm install yarn install
docker-compose build docker-compose build
docker-compose up docker-compose up
``` ```
@@ -49,3 +49,13 @@ Then go to `http://localhost`. If you're using dnsmasq, the `app` container is l
``` ```
127.0.0.1 phpvms.test 127.0.0.1 phpvms.test
``` ```
## Building JS/CSS assets
Yarn is required, run:
```bash
make build-assets
```
This will build all of the assets according to the webpack file.

View File

@@ -15,10 +15,11 @@ use App\Models\Pirep;
use App\Repositories\AcarsRepository; use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository; use App\Repositories\PirepRepository;
use App\Services\GeoService; use App\Services\GeoService;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Log; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/** /**
* Class AcarsController * Class AcarsController
@@ -157,10 +158,13 @@ class AcarsController extends Controller
} }
} }
$update = Acars::create($position); try {
$update->save(); $update = Acars::create($position);
$update->save();
$count++; $count++;
} catch (QueryException $ex) {
Log::info('Error on adding ACARS position: '.$ex->getMessage());
}
} }
// Change the PIREP status if it's as SCHEDULED before // Change the PIREP status if it's as SCHEDULED before
@@ -207,9 +211,13 @@ class AcarsController extends Controller
$log['created_at'] = Carbon::createFromTimeString($log['created_at']); $log['created_at'] = Carbon::createFromTimeString($log['created_at']);
} }
$acars = Acars::create($log); try {
$acars->save(); $acars = Acars::create($log);
$count++; $acars->save();
$count++;
} catch (QueryException $ex) {
Log::info('Error on adding ACARS position: '.$ex->getMessage());
}
} }
return $this->message($count.' logs added', $count); return $this->message($count.' logs added', $count);
@@ -250,9 +258,13 @@ class AcarsController extends Controller
$log['created_at'] = Carbon::createFromTimeString($log['created_at']); $log['created_at'] = Carbon::createFromTimeString($log['created_at']);
} }
$acars = Acars::create($log); try {
$acars->save(); $acars = Acars::create($log);
$count++; $acars->save();
$count++;
} catch (QueryException $ex) {
Log::info('Error on adding ACARS position: '.$ex->getMessage());
}
} }
return $this->message($count.' logs added', $count); return $this->message($count.' logs added', $count);

View File

@@ -7,10 +7,7 @@ use App\Repositories\AcarsRepository;
use App\Services\GeoService; use App\Services\GeoService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
/** class LiveMapController extends Controller
* Class AcarsController
*/
class AcarsController extends Controller
{ {
private $acarsRepo; private $acarsRepo;
private $geoSvc; private $geoSvc;
@@ -39,7 +36,7 @@ class AcarsController extends Controller
$pireps = $this->acarsRepo->getPositions(); $pireps = $this->acarsRepo->getPositions();
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps); $positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
return view('acars.index', [ return view('livemap.index', [
'pireps' => $pireps, 'pireps' => $pireps,
'positions' => $positions, 'positions' => $positions,
]); ]);

View File

@@ -13,7 +13,7 @@ Route::group([
Route::get('users', 'UserController@index')->name('users.index'); Route::get('users', 'UserController@index')->name('users.index');
Route::get('pilots', 'UserController@index')->name('pilots.index'); Route::get('pilots', 'UserController@index')->name('pilots.index');
Route::get('livemap', 'AcarsController@index')->name('livemap.index'); Route::get('livemap', 'LiveMapController@index')->name('livemap.index');
}); });
/* /*

View File

@@ -24,6 +24,7 @@
"icheck": "~1.0", "icheck": "~1.0",
"jquery": "~3.4", "jquery": "~3.4",
"jquery-pjax": "~2.0", "jquery-pjax": "~2.0",
"js-yaml": "^3.13.1",
"laravel-mix": "^2.1.14", "laravel-mix": "^2.1.14",
"leaflet": "^1.3.4", "leaflet": "^1.3.4",
"leaflet-ajax": "2.1.0", "leaflet-ajax": "2.1.0",
@@ -48,6 +49,6 @@
"copy-webpack-plugin": "^4.6.0", "copy-webpack-plugin": "^4.6.0",
"tailwindcss": "^0.5.3", "tailwindcss": "^0.5.3",
"webpack-bundle-analyzer": "^3.3", "webpack-bundle-analyzer": "^3.3",
"webpack-dev-server": ">=3.1.11" "webpack-dev-server": "^3.1.11"
} }
} }

View File

@@ -168,7 +168,11 @@
{{ Form::label('block_fuel', 'Block Fuel:') }} {{ Form::label('block_fuel', 'Block Fuel:') }}
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
{{ Form::number('block_fuel', null, ['class' => 'form-control', 'min' => 0]) }} {{ Form::number('block_fuel', null, [
'class' => 'form-control',
'min' => 0,
'step' => '0.01',
]) }}
<p class="text-danger">{{ $errors->first('block_fuel') }}</p> <p class="text-danger">{{ $errors->first('block_fuel') }}</p>
</div> </div>
</div> </div>
@@ -179,7 +183,11 @@
{{ Form::label('fuel_used', 'Fuel Used:') }} {{ Form::label('fuel_used', 'Fuel Used:') }}
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
{{ Form::number('fuel_used', null, ['class' => 'form-control', 'min' => 0]) }} {{ Form::number('fuel_used', null, [
'class' => 'form-control',
'min' => 0,
'step' => '0.01'
]) }}
<p class="text-danger">{{ $errors->first('fuel_used') }}</p> <p class="text-danger">{{ $errors->first('fuel_used') }}</p>
</div> </div>
</div> </div>

View File

@@ -123,34 +123,6 @@ flight reports that have been filed. You've been warned!
<p class="text-danger">{{ $errors->first('minutes') }}</p> <p class="text-danger">{{ $errors->first('minutes') }}</p>
@endif @endif
</div> </div>
<div class="col-3">
{{--{{ Form::label('submitted_date', __('pireps.dateflown')) }}
{{ Form::text('submmitted_date', null, [
'placeholder' => __('pireps.departuredate'),
'class' => 'form-control',
'readonly' => $pirep->read_only]) }}--}}
</div>
<div class="col-3">
{{--{{ Form::label('departure_time', __('flights.departuretime')) }}
{{ Form::text('departure_time', null, [
'placeholder' => __('flights.departuretime'),
'class' => 'form-control',
'readonly' => $pirep->read_only]) }}--}}
</div>
<div class="col-3">
{{--{{ Form::label('arrival_time', __('flights.arrivaltime')) }}
{{ Form::text('arrival_time', null, [
'placeholder' => __('flights.arrivaltime'),
'class' => 'form-control',
'readonly' => $pirep->read_only]) }}--}}
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -237,6 +209,7 @@ flight reports that have been filed. You've been warned!
{{ Form::number('block_fuel', null, [ {{ Form::number('block_fuel', null, [
'class' => 'form-control', 'class' => 'form-control',
'min' => '0', 'min' => '0',
'step' => '0.01',
'readonly' => (!empty($pirep) && $pirep->read_only), 'readonly' => (!empty($pirep) && $pirep->read_only),
]) }} ]) }}
</div> </div>
@@ -252,6 +225,7 @@ flight reports that have been filed. You've been warned!
{{ Form::number('fuel_used', null, [ {{ Form::number('fuel_used', null, [
'class' => 'form-control', 'class' => 'form-control',
'min' => '0', 'min' => '0',
'step' => '0.01',
'readonly' => (!empty($pirep) && $pirep->read_only), 'readonly' => (!empty($pirep) && $pirep->read_only),
]) }} ]) }}
</div> </div>

1319
yarn.lock

File diff suppressed because it is too large Load Diff