From e007824fa9f85212daa760bcdaf488064664c73e Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 20 Apr 2026 16:42:11 +1000 Subject: [PATCH] Add more airlines and fix edit bugs --- app/Http/Controllers/FlightController.php | 18 +- .../Controllers/FlightProfileController.php | 7 +- package-lock.json | 19 ++ package.json | 1 + .../Charts/ChartTypes/DonutChart.vue | 10 +- .../ScrollingHorizontalBarChart.vue | 10 +- .../Charts/ChartTypes/VerticalBarChart.vue | 116 ++++++--- .../FlightsGoneBy/DepartureBoard.vue | 87 ++++--- .../Components/FlightsGoneBy/FlightCharts.vue | 72 +++--- .../Components/FlightsGoneBy/FlightFilter.vue | 112 +++++---- .../FlightsGoneBy/FlightMapAndCharts.vue | 10 +- resources/js/Composables/useFlightStats.ts | 226 ++++++++++++------ resources/js/Pages/AddFlight.vue | 2 +- resources/js/Pages/UserProfile.vue | 41 +++- routes/web.php | 3 +- 15 files changed, 458 insertions(+), 276 deletions(-) diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php index 6aeee7d..5950df7 100644 --- a/app/Http/Controllers/FlightController.php +++ b/app/Http/Controllers/FlightController.php @@ -97,9 +97,9 @@ class FlightController extends Controller { $validated = $request->validate($this->rules()); - auth()->user()->flights()->create($this->flightPayload($validated)); + $newFlight = auth()->user()->flights()->create($this->flightPayload($validated)); - return redirect()->route('dashboard', Auth::user()->name); + return redirect()->route('profile.departure-board', [Auth::user()->name, $newFlight->id]); } public function update(Request $request, UserFlight $flight) @@ -110,14 +110,14 @@ class FlightController extends Controller $flight->update($this->flightPayload($validated)); - return redirect()->route('dashboard', Auth::user()->name); + return redirect()->route('profile.departure-board', [Auth::user()->name, $flight->id]); } public function add(){ return Inertia::render('AddFlight', [ - 'seat_types' => SeatType::all()->toArray(), - 'flight_reasons' => FlightReason::all()->toArray(), - 'flight_classes' => FlightClass::all()->toArray(), + 'seat_types' => SeatType::orderBy('id')->get()->toArray(), + 'flight_reasons' => FlightReason::orderBy('id')->get()->toArray(), + 'flight_classes' => FlightClass::orderBy('id')->get()->toArray(), ]); } @@ -148,9 +148,9 @@ class FlightController extends Controller ]; return Inertia::render('AddFlight', [ 'flight' => $flightData, - 'seat_types' => SeatType::all()->toArray(), - 'flight_classes' => FlightClass::all()->toArray(), - 'flight_reasons' => FlightReason::all()->toArray(), + 'seat_types' => SeatType::orderBy('id')->get()->toArray(), + 'flight_reasons' => FlightReason::orderBy('id')->get()->toArray(), + 'flight_classes' => FlightClass::orderBy('id')->get()->toArray(), ]); } } diff --git a/app/Http/Controllers/FlightProfileController.php b/app/Http/Controllers/FlightProfileController.php index 6cbdbb8..8d24533 100644 --- a/app/Http/Controllers/FlightProfileController.php +++ b/app/Http/Controllers/FlightProfileController.php @@ -10,7 +10,7 @@ use Inertia\Inertia; class FlightProfileController extends Controller { - public function profileData(string $username, string $view) : array { + public function profileData(string $username, string $view, ?int $selectedFlightId = null) : array { $user = User::whereRaw(DB::raw('LOWER(name) = ?'), [strtolower($username)])->firstOrFail(); $flights = UserFlight::where('user_id', $user->id) @@ -33,11 +33,12 @@ class FlightProfileController extends Controller 'canEdit' => auth()->check() && auth()->id() === $user->id, 'flights' => UserFlightResource::collection($flights)->resolve(), 'initialView' => $view, + 'selectedFlightId' => $selectedFlightId, ]; } - public function departureBoard(string $username){ - $profileData = $this->profileData($username, 'board'); + public function departureBoard(string $username, ?UserFlight $flight = null){ + $profileData = $this->profileData($username, 'board', $flight?->id); return Inertia::render('UserProfile', $profileData); } diff --git a/package-lock.json b/package-lock.json index 4e1e68a..56bb29e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@mdi/font": "^7.4.47", "apexcharts": "^5.10.5", + "chart.js": "^4.5.1", "echarts": "^6.0.0", "flag-icons": "^7.5.0", "maplibre-gl": "^5.22.0", @@ -182,6 +183,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kurkle/color": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz", + "integrity": "sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==", + "license": "MIT" + }, "node_modules/@mapbox/jsonlint-lines-primitives": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz", @@ -2378,6 +2385,18 @@ "node": ">=8" } }, + "node_modules/chart.js": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.5.1.tgz", + "integrity": "sha512-GIjfiT9dbmHRiYi6Nl2yFCq7kkwdkp1W/lp2J99rX0yo9tgJGn3lKQATztIjb5tVtevcBtIdICNWqlq5+E8/Pw==", + "license": "MIT", + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=8" + } + }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", diff --git a/package.json b/package.json index 5317a09..11d27c8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "@mdi/font": "^7.4.47", "apexcharts": "^5.10.5", + "chart.js": "^4.5.1", "echarts": "^6.0.0", "flag-icons": "^7.5.0", "maplibre-gl": "^5.22.0", diff --git a/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/DonutChart.vue b/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/DonutChart.vue index 476ce19..6d25a9d 100644 --- a/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/DonutChart.vue +++ b/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/DonutChart.vue @@ -18,7 +18,7 @@ const chartOptions = computed(() => ({ type: 'donut', background: 'transparent', fontFamily: 'inherit', - lazy: true, + animations: { enabled: false }, }, theme: { mode: 'dark' }, labels: props.labels, @@ -64,20 +64,16 @@ const chartOptions = computed(() => ({ }, })) -const ready = ref(false) @@ -100,4 +96,8 @@ const ready = ref(false) .chart-hidden { visibility: hidden; } + +:deep(svg) { + outline: none; +} diff --git a/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/ScrollingHorizontalBarChart.vue b/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/ScrollingHorizontalBarChart.vue index eb94254..76295a9 100644 --- a/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/ScrollingHorizontalBarChart.vue +++ b/resources/js/Components/FlightsGoneBy/Charts/ChartTypes/ScrollingHorizontalBarChart.vue @@ -37,7 +37,7 @@ const chartOptions = computed(() => ({ toolbar: { show: false }, animations: { enabled: false }, stacked: true, - lazy: true, + animation: { enabled: false }, }, theme: { mode: 'dark' }, plotOptions: { @@ -74,7 +74,6 @@ const chartOptions = computed(() => ({ }, })) -const ready = ref(false)