-
Notifications
You must be signed in to change notification settings - Fork 6
#659 Realops Pre-file/Export Buttons #829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0419948
Create Vite alias for blades
kjporter ac8a690
Update error message images
kjporter 1f3008c
Update pilot guide resources
kjporter 9dd9fa3
Update footer resources
kjporter 8d98352
Update landing page resources
kjporter 2923b79
Update resource location
kjporter 6470107
Remove unused graphics
kjporter 0c426b6
Move assets and update path
kjporter 4e4f160
Delete _1541188979.png
kjporter b0e40cd
Move assets and update path
kjporter 0f45a12
Move assets and update path
kjporter 19ff314
Move assets and update path
kjporter 2fccef8
Remove unused assets
kjporter bbab8d6
Add img resource imports
kjporter 84220c7
Merge branch 'main' into image-cleanup
kjporter bde923d
Update app.js
kjporter 80b993c
Update RealopsFlight.php
kjporter 39992f2
Vite image alias
kjporter db81f18
Fix logo asset checks
kjporter 3e41102
Update footer.blade.php
kjporter 5051a59
Update pilot_passport_certificate.blade.php
kjporter f11b6ee
Update package.json
kjporter 368aaed
Revert "Update package.json"
kjporter 10f8d04
Add Preferred Routes
kjporter 7e04c99
Add Aircraft Types
kjporter c086983
Add Aircraft Types
kjporter 122e5d8
Integrate Pre-File Logic
kjporter df529f5
Merge branch 'main' into realops-prefile-button
kjporter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
|
|
||
| class Aircraft extends Model { | ||
| protected $table = "aircraft"; | ||
| public $timestamps = false; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| <?php | ||
|
|
||
| namespace App\Console\Commands; | ||
|
|
||
| use GuzzleHttp\Client; | ||
| use Illuminate\Console\Command; | ||
| use Illuminate\Support\Facades\Storage; | ||
| use Symfony\Component\Console\Helper\ProgressIndicator; | ||
| use Symfony\Component\Console\Output\ConsoleOutput; | ||
|
|
||
| class UpdateFAA extends Command { | ||
| /** | ||
| * The name and signature of the console command. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $signature = 'FAA:update-faa'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Updates FAA-specific datafiles'; | ||
|
|
||
| const FAA_DATA_URL = 'https://www.fly.faa.gov/rmt/data_file/'; | ||
| private $routes = [ | ||
| [ | ||
| 'name' => 'PRD', | ||
| 'model' => 'App\PreferredRoute', | ||
| 'file' => 'prefroutes_db.csv' | ||
| ] | ||
| ]; | ||
| private ProgressIndicator $progressIndicator; | ||
| private $path; | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| */ | ||
| public function handle() { | ||
| $this->info('Updating FAA-specific datafiles'); | ||
| $this->path = Storage::disk('local')->path('private/'); | ||
| $this->setup_progress_indicator(); | ||
| $this->update_routes(); | ||
| } | ||
|
|
||
| private function update_routes(): void { | ||
| foreach ($this->routes as $route) { | ||
| $route = (object) $route; | ||
| $this->progressIndicator->start("Fetching $route->name info from FAA server..."); | ||
| $this->call_api(SELF::FAA_DATA_URL . $route->file, $this->path, strtolower($route->name) . '_new.csv'); | ||
| $this->progressIndicator->finish("Fetching $route->name info from FAA server... done"); | ||
|
|
||
| // Update table | ||
| $this->progressIndicator->start("Updating $route->name table..."); | ||
| if (($handle = fopen($this->path . strtolower($route->name) . '_new.csv', "r")) !== false) { | ||
| $route->model::truncate(); | ||
| while (($rte_line = fgetcsv($handle, null, ",")) !== false) { | ||
| if (!is_array($rte_line)) { | ||
| continue; | ||
| } | ||
| $bom = "\xef\xbb\xbf"; | ||
| if (substr($rte_line[0], 0, 3) === $bom) { | ||
| $rte_line[0] = substr($rte_line[0], 3); | ||
| } | ||
| if ($rte_line[0] == 'RCode' || $rte_line[0] == 'Orig') { // It's the header line, skip it | ||
| continue; | ||
| } | ||
| if ($route->name == 'CDR') { | ||
| $load_arr = [ | ||
| 'route_code' => $rte_line[0], | ||
| 'origin' => $rte_line[1], | ||
| 'destination' => $rte_line[2], | ||
| 'departure_fix' => substr($rte_line[3], 0, 5), // Enforce 5 characters | ||
| 'route_string' => $rte_line[4], | ||
| 'departure_center' => $rte_line[5], | ||
| 'arrival_center' => $rte_line[6], | ||
| 'transit_centers' => $rte_line[7], | ||
| 'coordination_required' => $rte_line[8], | ||
| 'play' => $rte_line[9], | ||
| 'navigation_equipment' => $rte_line[10] | ||
| ]; | ||
| } else { | ||
| $load_arr = [ | ||
| 'orig' => $rte_line[0], | ||
| 'route_string' => $rte_line[1], | ||
| 'dest' => $rte_line[2], | ||
| 'hours1' => $rte_line[3], | ||
| 'hours2' => $rte_line[4], | ||
| 'hours3' => $rte_line[5], | ||
| 'type' => $rte_line[6], | ||
| 'area' => $rte_line[7], | ||
| 'altitude' => (is_numeric($rte_line[8])) ? $rte_line[8] : null, | ||
| 'aircraft' => $rte_line[9], | ||
| 'direction' => $rte_line[10], | ||
| 'seq' => $rte_line[11], | ||
| 'dcntr' => $rte_line[12], | ||
| 'acntr' => $rte_line[13] | ||
| ]; | ||
| } | ||
| $route->model::create($load_arr); | ||
| $this->progressIndicator->advance(); | ||
| } | ||
| fclose($handle); | ||
| } | ||
| $this->progressIndicator->finish("Updating $route->name table... done"); | ||
|
|
||
| // Remove, rename file | ||
| $this->info("Removing unused local $route->name files"); | ||
| if (file_exists($this->path . $route->name . '.csv')) { | ||
| unlink($this->path . $route->name . '.csv'); | ||
| $this->info("- Deleted $route->name.csv"); | ||
| } | ||
| if (file_exists($this->path . $route->name . '_new.csv')) { | ||
| rename($this->path . $route->name . '_new.csv', $this->path . $route->name . '.csv'); | ||
| } | ||
| $this->info("$route->name file cleanup complete"); | ||
| } | ||
| } | ||
|
|
||
| private function call_api($url, $path = null, $write_file = null): string|null { | ||
| $progress = $this->progressIndicator; | ||
| $write_to_filename = (is_null($write_file)) ? basename($url) : $write_file; | ||
| $client = new Client(); | ||
| $response = $client->get($url, [ | ||
| 'config' => [ | ||
| 'curl' => [ | ||
| 'CURLOPT_RETURNTRANSFER' => true, | ||
| 'CURLOPT_CONNECTTIMEOUT' => 3, | ||
| 'CURLOPT_ENCODING' => 'gzip', | ||
| 'CURLOPT_SSL_VERIFYPEER' => false | ||
| ] | ||
| ], | ||
| 'progress' => function () use ($progress) { | ||
| $progress->advance(); | ||
| }, | ||
| 'sink' => $path . $write_to_filename | ||
| ]); | ||
| if ($response->getStatusCode() == 200) { | ||
| return $response->getBody(); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private function setup_progress_indicator(): void { | ||
| $output = new ConsoleOutput; | ||
| $this->progressIndicator = new ProgressIndicator($output); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
|
|
||
| class PreferredRoute extends Model { | ||
| protected $table = 'prd_route'; | ||
| protected $guarded = []; | ||
|
|
||
| public static function routeLookup(string $departure, string $arrival, string $ac_type = 'jets'): string { | ||
| $routes = PreferredRoute::where('orig', substr($departure, 1))->where('dest', substr($arrival, 1))->where(function ($query) use ($ac_type) { | ||
| $query->where('aircraft', 'LIKE', '%' . strtoupper($ac_type) . '%')->orWhere('aircraft', ''); | ||
| })->first(); | ||
| if (!$routes) { | ||
| return ''; | ||
| } | ||
| /* | ||
| PRDs normally contain the origin and destination ID as the first and last points. | ||
| SimBrief doesn't like this. Remove. | ||
| */ | ||
| $route = explode(' ', $routes->route_string); | ||
| if ($route[0] == substr($departure, 1)) { | ||
| unset($route[0]); | ||
| } | ||
| if (end($route) == substr($arrival, 1)) { | ||
| array_pop($route); | ||
| } | ||
| return implode(' ', $route); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please recreate from latest main, all of image cleanup is included