Added Notifications
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class AircraftApiController extends Controller
|
||||
{
|
||||
public function getLivery(string $aircraftDesignator){
|
||||
$path = "images/livery_templates/{$aircraftDesignator}.png";
|
||||
return $this->imageIfExists($path);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,21 +49,8 @@ class AirlineApiController extends ApiController
|
||||
|
||||
public function getLivery(string $airlineInternalName, string $aircraftDesignator){
|
||||
$path = "images/liveries/{$airlineInternalName}_{$aircraftDesignator}.png";
|
||||
$cacheLimit = 60 * 60 * 72;
|
||||
|
||||
if(!Storage::disk('local')->exists($path)){
|
||||
return response()->json(['error' => 'Livery not found'], 404);
|
||||
}
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
$lastModified = filemtime($fullPath);
|
||||
|
||||
return response()->file($fullPath, [
|
||||
'Content-Type' => 'image/png',
|
||||
'Cache-Control' => 'public, max-age='.$cacheLimit, // 24 hours
|
||||
'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified) . ' GMT',
|
||||
'ETag' => md5($path . $lastModified),
|
||||
]);
|
||||
return $this->imageIfExists($path);
|
||||
}
|
||||
|
||||
function parseAirlineData(Airline $airline){
|
||||
|
||||
@@ -2,7 +2,23 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
public function imageIfExists(string $path, $cacheLimit = 60 * 60 * 72){
|
||||
if(!Storage::disk('local')->exists($path)){
|
||||
return response()->json(['error' => 'Image not found'], 404);
|
||||
}
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
$lastModified = filemtime($fullPath);
|
||||
|
||||
return response()->file($fullPath, [
|
||||
'Content-Type' => 'image/png',
|
||||
'Cache-Control' => 'public, max-age='.$cacheLimit, // 24 hours
|
||||
'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified) . ' GMT',
|
||||
'ETag' => md5($path . $lastModified),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class FlightController extends Controller
|
||||
return redirect()->route('profile.departure-board', [Auth::user()->name, $flight->id]);
|
||||
}
|
||||
|
||||
public function delete(UserFlight $flight)
|
||||
public function delete(UserFlight $flight, ?string $referrer = 'departure-board')
|
||||
{
|
||||
$this->authorize('delete', $flight);
|
||||
|
||||
@@ -296,7 +296,7 @@ class FlightController extends Controller
|
||||
]);
|
||||
|
||||
$flight->delete();
|
||||
return redirect()->route('profile.departure-board', [Auth::user()->name]);
|
||||
return redirect()->route('profile.'.$referrer, [Auth::user()->name]);
|
||||
}
|
||||
|
||||
public function staticData() : array {
|
||||
|
||||
@@ -52,10 +52,10 @@ class FlightProfileController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
return Inertia::render('UserFlight', [
|
||||
'flightCount' => $user->flights()->count(),
|
||||
'flightCount' => $user->departedFlights()->count(),
|
||||
'flight' => $userFlight->snapshot($userFlight->id),
|
||||
'canEdit' => auth()->check() && auth()->id() === $user->id,
|
||||
'user' => $user,
|
||||
'isFollowing' => auth()->check() && auth()->user()->isFollowing($user),
|
||||
]);
|
||||
|
||||
@@ -227,17 +227,32 @@ class UserFlight extends Model
|
||||
return Attribute::make(
|
||||
get: function () {
|
||||
|
||||
if(!$this->airline || !$this->aircraft){
|
||||
$apiUrl = config('app.logo_api_url');
|
||||
|
||||
if (!$this->aircraft) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = "images/liveries/{$this->airline->internal_name}_{$this->aircraft->designator}.png";
|
||||
|
||||
if(!Storage::disk('local')->exists($path)){
|
||||
if ($this->airline){
|
||||
$path = "images/liveries/{$this->airline->internal_name}_{$this->aircraft->designator}.png";
|
||||
if (Storage::disk('local')->exists($path)) {
|
||||
$finalPath = $apiUrl."/airline/{$this->airline->internal_name}/livery/{$this->aircraft->designator}";
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($finalPath)){
|
||||
$path = "images/livery_templates/{$this->aircraft->designator}.png";
|
||||
if (Storage::disk('local')->exists($path)) {
|
||||
$finalPath = $apiUrl."/aircraft/{$this->aircraft->designator}/livery";
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($finalPath)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return config('app.logo_api_url')."/airline/{$this->airline->internal_name}/livery/{$this->aircraft->designator}";
|
||||
return $finalPath;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { Flight } from "@/Types/types";
|
||||
import {Flight, User} from "@/Types/types";
|
||||
import AirlineLogo from "@/Components/FlightsGoneBy/AirlineLogo.vue";
|
||||
import AirportToolTip from "@/Components/FlightsGoneBy/AirportToolTip.vue";
|
||||
import AircraftToolTip from "@/Components/FlightsGoneBy/AircraftToolTip.vue";
|
||||
import Distance from "@/Components/Distance.vue";
|
||||
import UserFlightContextMenu from "@/Components/FlightsGoneBy/UserFlightContextMenu.vue";
|
||||
|
||||
defineProps<{
|
||||
flight: Flight
|
||||
showTooltips?: boolean
|
||||
canEdit?: boolean
|
||||
user?: User
|
||||
}>()
|
||||
|
||||
|
||||
@@ -19,6 +22,8 @@ defineProps<{
|
||||
<span v-if="flight.flight_class?.name !== 'Unspecified'" class="pass-header-class">
|
||||
{{ flight.flight_class?.name }}
|
||||
</span>
|
||||
<span v-else></span>
|
||||
<UserFlightContextMenu v-if="user" :profile-user="user" :flight="flight" :can-edit="canEdit ?? false" referrer="boarding-passes"/>
|
||||
</div>
|
||||
|
||||
<div class="pass-body">
|
||||
@@ -159,7 +164,7 @@ defineProps<{
|
||||
.pass-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
justify-content: space-between; /* was flex-end */
|
||||
padding: 0.5rem 0.85rem;
|
||||
min-height: 2rem;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Flight } from "@/Types/types";
|
||||
import {Flight, User} from "@/Types/types";
|
||||
import BoardingPass from "@/Components/FlightsGoneBy/BoardingPass.vue";
|
||||
import { FlightStats } from "@/Composables/useFlightStats";
|
||||
|
||||
const props = defineProps<{
|
||||
flightStats: FlightStats
|
||||
canEdit: boolean
|
||||
user: User
|
||||
}>()
|
||||
|
||||
const upcomingFlights = computed(() =>
|
||||
@@ -64,7 +65,7 @@ function isUpcoming(flight: Flight): boolean {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<BoardingPass :flight="flight" />
|
||||
<BoardingPass :user="user" :canEdit="canEdit" :flight="flight" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,11 +9,9 @@ import InlineBadge from "@/Components/FlightsGoneBy/InlineBadge.vue";
|
||||
import AirportToolTip from "@/Components/FlightsGoneBy/AirportToolTip.vue";
|
||||
import AircraftToolTip from "@/Components/FlightsGoneBy/AircraftToolTip.vue";
|
||||
import {FlightStats} from "@/Composables/useFlightStats";
|
||||
import GlassTooltip from "@/Components/FlightsGoneBy/GlassTooltip.vue";
|
||||
import CrewTooltip from "@/Components/FlightsGoneBy/CrewTooltip.vue";
|
||||
import {Link, router} from "@inertiajs/vue3";
|
||||
import AllianceLogo from "@/Components/FlightsGoneBy/AllianceLogo.vue";
|
||||
import Distance from "@/Components/Distance.vue";
|
||||
import UserFlightContextMenu from "@/Components/FlightsGoneBy/UserFlightContextMenu.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
flightStats: FlightStats
|
||||
@@ -23,16 +21,6 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
|
||||
function editRoute(id: number) {
|
||||
return route('flights.edit', { flight: id })
|
||||
}
|
||||
|
||||
const flightToDelete = ref<Flight | null>(null)
|
||||
const showDeleteDialog = computed({
|
||||
get: () => flightToDelete.value !== null,
|
||||
set: (val) => { if (!val) flightToDelete.value = null }
|
||||
})
|
||||
|
||||
const ITEMS_PER_PAGE = 25
|
||||
|
||||
const headers = [
|
||||
@@ -77,7 +65,6 @@ const customKeySort = {
|
||||
}
|
||||
|
||||
|
||||
const deleting = ref(false)
|
||||
const sortBy = ref<DataTableSortItem[]>([])
|
||||
const currentPage = ref(1)
|
||||
|
||||
@@ -268,54 +255,7 @@ watch(
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td actions-cell">
|
||||
<v-menu>
|
||||
<template #activator="{ props: menuProps }">
|
||||
<v-btn
|
||||
v-bind="menuProps"
|
||||
icon="mdi-dots-horizontal"
|
||||
variant="text"
|
||||
size="small"
|
||||
density="compact"
|
||||
/>
|
||||
</template>
|
||||
<v-list density="compact" bg-color="#1a1e2e">
|
||||
<v-list-item
|
||||
prepend-icon="mdi-magnify"
|
||||
title="View Details"
|
||||
:href="`/u/${user.name}/flight/${(item as Flight).id}`"
|
||||
/>
|
||||
<v-list-item v-if="canEdit"
|
||||
prepend-icon="mdi-pencil-outline"
|
||||
title="Edit"
|
||||
:href="editRoute((item as Flight).id)"
|
||||
/>
|
||||
<v-list-item v-if="canEdit"
|
||||
prepend-icon="mdi-trash-can-outline"
|
||||
title="Delete"
|
||||
@click="flightToDelete = (item as Flight)"
|
||||
/>
|
||||
|
||||
</v-list>
|
||||
</v-menu>
|
||||
<v-dialog v-if="canEdit" v-model="showDeleteDialog" max-width="400">
|
||||
<v-card title="Delete Flight">
|
||||
<v-card-text>Are you sure you want to delete this flight?</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn v-if="!deleting" @click="flightToDelete = null">Cancel</v-btn>
|
||||
<v-btn
|
||||
color="error"
|
||||
:loading="deleting"
|
||||
@click="deleting = true; router.delete(
|
||||
route('flights.delete', { flight: flightToDelete!.id }),
|
||||
{ onFinish: () => { deleting = false; flightToDelete = null } }
|
||||
)"
|
||||
>
|
||||
Delete
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<UserFlightContextMenu :profile-user="user" :can-edit="canEdit" :flight="(item as Flight)" />
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@@ -28,6 +28,7 @@ defineProps<{
|
||||
padding: 2.5rem 2rem;
|
||||
font-family: 'Barlow', sans-serif;
|
||||
width: 100%;
|
||||
max-width: 2000px;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
@@ -37,20 +38,6 @@ defineProps<{
|
||||
min-height: 50dvh;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
display: block;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border: 3px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: white;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.7s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.board-wrapper {
|
||||
padding: 1em 0.25em;
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, ref} from "vue";
|
||||
import {Flight, User} from "@/Types/types";
|
||||
import {router} from "@inertiajs/vue3";
|
||||
|
||||
defineProps<{
|
||||
profileUser: User
|
||||
flight: Flight
|
||||
canEdit: boolean
|
||||
referrer?: "departure-board" | "boarding-passes"
|
||||
}>()
|
||||
|
||||
const deleting = ref(false)
|
||||
function editRoute(id: number) {
|
||||
return route('flights.edit', { flight: id })
|
||||
}
|
||||
|
||||
const flightToDelete = ref<Flight | null>(null)
|
||||
const showDeleteDialog = computed({
|
||||
get: () => flightToDelete.value !== null,
|
||||
set: (val) => { if (!val) flightToDelete.value = null }
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-menu>
|
||||
<template #activator="{ props: menuProps }">
|
||||
<v-btn
|
||||
v-bind="menuProps"
|
||||
icon="mdi-dots-horizontal"
|
||||
variant="text"
|
||||
size="small"
|
||||
density="compact"
|
||||
/>
|
||||
</template>
|
||||
<v-list density="compact" bg-color="#1a1e2e">
|
||||
<v-list-item
|
||||
prepend-icon="mdi-magnify"
|
||||
title="View Details"
|
||||
:href="route('profile.flight', { userFlight: flight.id, user: profileUser.name })"
|
||||
/>
|
||||
<v-list-item v-if="canEdit"
|
||||
prepend-icon="mdi-pencil-outline"
|
||||
title="Edit"
|
||||
:href="editRoute(flight.id)"
|
||||
/>
|
||||
<v-list-item v-if="canEdit"
|
||||
prepend-icon="mdi-trash-can-outline"
|
||||
title="Delete"
|
||||
@click="flightToDelete = flight"
|
||||
/>
|
||||
|
||||
</v-list>
|
||||
</v-menu>
|
||||
<v-dialog v-if="canEdit" v-model="showDeleteDialog" max-width="400">
|
||||
<v-card title="Delete Flight">
|
||||
<v-card-text>Are you sure you want to delete this flight?</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn v-if="!deleting" @click="flightToDelete = null">Cancel</v-btn>
|
||||
<v-btn
|
||||
color="error"
|
||||
:loading="deleting"
|
||||
@click="deleting = true; router.delete(
|
||||
route('flights.delete', { flight: flightToDelete!.id , referrer: referrer ?? 'departure-board'}),
|
||||
{ onFinish: () => { deleting = false; flightToDelete = null } }
|
||||
)"
|
||||
>
|
||||
Delete
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -19,6 +19,7 @@ const props = defineProps<{
|
||||
flight: Flight
|
||||
flightCount: number
|
||||
isFollowing: boolean
|
||||
canEdit: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
||||
@@ -37,7 +38,7 @@ const props = defineProps<{
|
||||
<div class="profile-grid">
|
||||
<RoutePanel :flight="flight" />
|
||||
<Panel label="Flight Details">
|
||||
<BoardingPass :showToolTips="false" style="width:100%;max-width:600px; margin:0 auto" :flight="flight"/>
|
||||
<BoardingPass :user="user" :showToolTips="false" style="width:100%;max-width:600px; margin:0 auto" :flight="flight" :canEdit="canEdit" />
|
||||
<DetailRows>
|
||||
|
||||
</DetailRows>
|
||||
|
||||
@@ -124,7 +124,7 @@ function switchView(view: ProfileView) {
|
||||
<ProfileLayout :is-following="isFollowing" :flightCount="flightCount" :user="user" :loading="flightsLoading">
|
||||
<ProfileViewSwitcher :user="user" :active-view="activeView" @update:active-view="switchView" />
|
||||
<DepartureBoard v-if="activeView === 'board'" :flight-id="localSelectedFlightId" :flight-stats="stats" :canEdit="canEdit" :user="user" />
|
||||
<BoardingPasses v-if="activeView === 'passes'" :flight-stats="stats" :canEdit="canEdit" />
|
||||
<BoardingPasses v-if="activeView === 'passes'" :flight-stats="stats" :canEdit="canEdit" :user="user" />
|
||||
<FlightMapAndCharts
|
||||
v-if="activeView === 'map'"
|
||||
:stats="stats"
|
||||
|
||||
+10
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\AchievementController;
|
||||
use App\Http\Controllers\AdminToolsController;
|
||||
use App\Http\Controllers\Api\AircraftApiController;
|
||||
use App\Http\Controllers\Api\AirlineApiController;
|
||||
use App\Http\Controllers\Api\UserApiController;
|
||||
use App\Http\Controllers\FeedController;
|
||||
@@ -27,7 +28,10 @@ use Inertia\Inertia;
|
||||
Route::domain(config('app.domain'))->group(
|
||||
function() {
|
||||
Route::get('/', function () {
|
||||
return Inertia::render(auth()->check() ? 'Dashboard' : 'Auth/Login');
|
||||
if (auth()->check()) {
|
||||
return redirect()->route('profile.view', auth()->user()->name);
|
||||
}
|
||||
return redirect()->route('login');
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +52,7 @@ Route::domain(config('app.domain'))->group(
|
||||
Route::get('/flights/add', [FlightController::class, 'add'])->name('flights.add');
|
||||
Route::get('/flights/{flight}/edit', [FlightController::class, 'edit'])->name('flights.edit');
|
||||
Route::put('/flights/{flight}', [FlightController::class, 'update'])->name('flights.update');
|
||||
Route::delete('/flights/{flight}', [FlightController::class, 'delete'])->name('flights.delete');
|
||||
Route::delete('/flights/{flight}/{referrer?}', [FlightController::class, 'delete'])->name('flights.delete');
|
||||
|
||||
|
||||
|
||||
@@ -117,6 +121,10 @@ Route::domain(config('app.api_domain'))->group(function () {
|
||||
Route::get('{airlineInternalName}/livery/{aircraftDesignator}', 'getLivery')->name('airline.livery');
|
||||
});
|
||||
|
||||
Route::prefix('aircraft')->controller(AircraftApiController::class)->group(function () {
|
||||
Route::get('{aircraftDesignator}/livery', 'getLivery')->name('aircraft.livery');
|
||||
});
|
||||
|
||||
|
||||
Route::prefix('user')->controller(UserApiController::class)->group(function () {
|
||||
Route::get('{username}/next-flight', 'nextFlight');
|
||||
|
||||
Reference in New Issue
Block a user