Added User Settings
This commit is contained in:
@@ -53,6 +53,13 @@ function formatEngineType(type: string): string {
|
||||
<div class="tooltip-rows" v-if="flight?.livery_url">
|
||||
<LiveryImage :flight="flight" />
|
||||
</div>
|
||||
<div class="tooltip-divider" v-if="flight?.aircraft_registration" />
|
||||
<div class="tooltip-rows" v-if="flight?.aircraft_registration">
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">Registration</span>
|
||||
<span class="tooltip-value">{{ flight.aircraft_registration}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</GlassTooltip>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import {Flight, User} from "@/Types/types";
|
||||
import {Flight, SharedProps, User} from "@/Types/types";
|
||||
import { computed, ref, watch, nextTick } from "vue";
|
||||
import type { DataTableSortItem } from 'vuetify';
|
||||
import {FlightStats} from "@/Composables/useFlightStats";
|
||||
import DepartureBoardTableRow from "@/Components/FlightsGoneBy/DepartureBoardTableRow.vue";
|
||||
import {usePage} from "@inertiajs/vue3";
|
||||
|
||||
const props = defineProps<{
|
||||
flightStats: FlightStats
|
||||
@@ -12,24 +13,34 @@ const props = defineProps<{
|
||||
flightId?: number | null
|
||||
}>()
|
||||
|
||||
|
||||
const page = usePage<SharedProps>().props
|
||||
const ITEMS_PER_PAGE = 25
|
||||
|
||||
const headers = [
|
||||
const defaultColumns = ['airline', 'flight_number', 'from', 'to', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'registration', 'class_seat_combined']
|
||||
const columnsToShow = computed(() => page.auth.user?.resolved_settings?.departure_board_columns ?? defaultColumns)
|
||||
const showColumn = (column: string) => columnsToShow.value.includes(column)
|
||||
|
||||
const allHeaders = [
|
||||
{ title: '', key: 'airline', sortable: true },
|
||||
{ title: 'FLIGHT', key: 'flight_number', sortable: true },
|
||||
{ title: 'FROM', key: 'departure_airport', sortable: true },
|
||||
{ title: 'TO', key: 'arrival_airport', sortable: true },
|
||||
{ title: 'FROM', key: 'from', sortable: true },
|
||||
{ title: 'TO', key: 'to', sortable: true },
|
||||
{ title: 'DATE', key: 'departure_date', sortable: true },
|
||||
{ title: 'DEPART', key: 'departure_time_display', sortable: false },
|
||||
{ title: 'ARRIVE', key: 'arrival_time_display', sortable: false },
|
||||
{ title: 'DEPART', key: 'departure_time', sortable: false },
|
||||
{ title: 'ARRIVE', key: 'arrival_time', sortable: false },
|
||||
{ title: 'DURATION', key: 'duration', sortable: true },
|
||||
{ title: 'DISTANCE', key: 'distance', sortable: true },
|
||||
{ title: 'AIRCRAFT', key: 'aircraft.designator', sortable: true },
|
||||
{ title: 'REG', key: 'aircraft_registration', sortable: true },
|
||||
{ title: 'CLASS', key: 'flight_class', sortable: true },
|
||||
{ title: 'AIRCRAFT', key: 'aircraft', sortable: true },
|
||||
{ title: 'REG', key: 'registration', sortable: true },
|
||||
{ title: 'CLASS', key: 'class_seat_combined', sortable: true },
|
||||
{ title: '', key: 'actions', sortable: false },
|
||||
]
|
||||
|
||||
const headers = computed(() =>
|
||||
allHeaders.filter(h => h.key === 'actions' || showColumn(h.key))
|
||||
)
|
||||
|
||||
const CLASS_ORDER: Record<string, number> = {
|
||||
'Unspecified': 0,
|
||||
'Economy': 1,
|
||||
@@ -40,7 +51,7 @@ const CLASS_ORDER: Record<string, number> = {
|
||||
}
|
||||
|
||||
const customKeySort = {
|
||||
flight_class: (a: Flight['flight_class'], b: Flight['flight_class']) => {
|
||||
class_seat_combined: (a: Flight['flight_class'], b: Flight['flight_class']) => {
|
||||
return (CLASS_ORDER[a?.name ?? ''] ?? -1) - (CLASS_ORDER[b?.name ?? ''] ?? -1)
|
||||
},
|
||||
airline: (a: Flight['airline'], b: Flight['airline']) => {
|
||||
@@ -123,6 +134,7 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -160,6 +172,7 @@ watch(
|
||||
|
||||
<template v-else-if="!(item as any)._groupHeader">
|
||||
<DepartureBoardTableRow
|
||||
:columnsToShow="columnsToShow"
|
||||
:flight="(item as Flight)"
|
||||
:user="user"
|
||||
:can-edit="canEdit"
|
||||
|
||||
@@ -20,9 +20,12 @@ const props = defineProps<{
|
||||
highlighted?: boolean
|
||||
group?: 'upcoming' | 'departed'
|
||||
isSorting?: boolean
|
||||
columnsToShow: string[]
|
||||
}>()
|
||||
|
||||
const page = usePage<SharedProps>()
|
||||
const showColumn = (column: string) => props.columnsToShow.includes(column)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -34,11 +37,11 @@ const page = usePage<SharedProps>()
|
||||
]"
|
||||
:data-flight-id="flight.id"
|
||||
>
|
||||
<td class="v-data-table__td airline-logo-cell">
|
||||
<td v-if="showColumn('airline')" class="v-data-table__td airline-logo-cell">
|
||||
<AirlineLogo size="32" :airline="flight.airline" class="airline-logo-img" />
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td flight-number-cell">
|
||||
<td v-if="showColumn('flight_number')" class="v-data-table__td flight-number-cell">
|
||||
<div class="flight-cell">
|
||||
<Mono class="flight-number">
|
||||
{{ flight.flight_number }}
|
||||
@@ -46,56 +49,56 @@ const page = usePage<SharedProps>()
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td">
|
||||
<td v-if="showColumn('from')" class="v-data-table__td">
|
||||
<AirportToolTip :airport="flight.departure_airport">
|
||||
<Mono class="iata">{{ flight.departure_airport.display_code }}</Mono><br/>
|
||||
</AirportToolTip>
|
||||
<span class="city-name">{{ flight.departure_airport.municipality }}</span>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td">
|
||||
<td v-if="showColumn('to')" class="v-data-table__td">
|
||||
<AirportToolTip :airport="flight.arrival_airport">
|
||||
<span class="iata"><Mono>{{ flight.arrival_airport.display_code }}</Mono></span><br/>
|
||||
</AirportToolTip>
|
||||
<span class="city-name" >{{ flight.arrival_airport.municipality }}</span>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td">
|
||||
<td v-if="showColumn('departure_date')" class="v-data-table__td">
|
||||
<span class="date-cell"><Mono muted smaller>{{ flight.departure_date_display }}</Mono></span>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td">
|
||||
<td v-if="showColumn('departure_time')" class="v-data-table__td">
|
||||
<span class="time-cell">
|
||||
<Mono small>{{ flight.departure_time_display }}</Mono>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td arrival-time-cell">
|
||||
<td v-if="showColumn('arrival_time')" class="v-data-table__td arrival-time-cell">
|
||||
<Mono small>{{ flight.arrival_time_display }}</Mono>
|
||||
<DayDifference :value="flight.arrival_day_difference" />
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td duration-cell">
|
||||
<td v-if="showColumn('duration')" class="v-data-table__td duration-cell">
|
||||
<Mono muted small>{{ flight.duration_display ?? '—' }}</Mono>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td distance-cell">
|
||||
<td v-if="showColumn('distance')" class="v-data-table__td distance-cell">
|
||||
<Mono muted small>
|
||||
<Distance :unit="page.props.auth.user?.distance_unit" :value="Math.round(flight.distance)" />
|
||||
<Distance :unit="page.props.auth.user?.resolved_settings?.distance_unit" :value="Math.round(flight.distance)" />
|
||||
</Mono>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td aircraft-cell">
|
||||
<td v-if="showColumn('aircraft')" class="v-data-table__td aircraft-cell">
|
||||
<AircraftToolTip v-if="flight.aircraft" :aircraft="flight.aircraft" :flight="flight">
|
||||
<Mono muted small>{{ flight.aircraft?.designator }}</Mono>
|
||||
</AircraftToolTip>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td registration-cell">
|
||||
<td v-if="showColumn('registration')" class="v-data-table__td registration-cell">
|
||||
<Mono muted smaller v-if="flight.aircraft_registration">{{ flight.aircraft_registration }}</Mono>
|
||||
</td>
|
||||
|
||||
<td class="v-data-table__td class-badges-cell">
|
||||
<td v-if="showColumn('class_seat_combined')" class="v-data-table__td class-badges-cell">
|
||||
<span class="class-cell">
|
||||
<CrewTooltip v-if="flight.flight_reason?.name == 'Crew'" :crew-type="flight.crew_type!">
|
||||
<FlightClassBadge v-if="flight.flight_class?.internal_name === 'crew'" :flight="flight" />
|
||||
|
||||
@@ -35,12 +35,12 @@
|
||||
<div class="stat">
|
||||
<template v-if="totalDistanceKm">
|
||||
<div class="stat-primary">
|
||||
<span class="stat-num"><Distance :unit="page.auth?.user?.distance_unit" includeSpace :value="totalDistanceKm" /></span>
|
||||
<span class="stat-num"><Distance :unit="page.auth?.user?.resolved_settings?.distance_unit" includeSpace :value="totalDistanceKm" /></span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="upcomingDistanceKm">
|
||||
<div :class="totalDistanceKm ? 'stat-upcoming' : 'stat-primary'">
|
||||
<span :class="totalDistanceKm ? 'stat-upcoming-num' : 'stat-num'"><Distance :unit="page.auth?.user?.distance_unit" includeSpace :value="upcomingDistanceKm"/></span>
|
||||
<span :class="totalDistanceKm ? 'stat-upcoming-num' : 'stat-num'"><Distance :unit="page.auth?.user?.resolved_settings?.distance_unit" includeSpace :value="upcomingDistanceKm"/></span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -51,6 +51,7 @@ onUnmounted(() => document.removeEventListener('click', handleClickOutside))
|
||||
</button>
|
||||
<div v-if="dropdownOpen" class="dropdown-menu">
|
||||
<Link :href="route('import.fr24')" class="dropdown-item">Import from FR24</Link>
|
||||
<Link :href="route('profile.settings')" class="dropdown-item">Settings</Link>
|
||||
<div class="dropdown-divider" />
|
||||
<button class="dropdown-item dropdown-item--danger" @click="logout">Log Out</button>
|
||||
</div>
|
||||
@@ -76,6 +77,7 @@ onUnmounted(() => document.removeEventListener('click', handleClickOutside))
|
||||
<Link :href="route('profile.view', { user: props.auth.user.name })" class="nav-link" @click="menuOpen = false">Profile</Link>
|
||||
<Link :href="route('feed')" class="nav-link nav-link" @click="menuOpen = false">Feed</Link>
|
||||
<Link :href="route('import.fr24')" class="nav-link" @click="menuOpen = false">Import from FR24</Link>
|
||||
<Link :href="route('profile.settings')" class="nav-link" @click="menuOpen = false">Settings</Link>
|
||||
<div class="dropdown-divider" />
|
||||
<button class="nav-link nav-link--danger" @click="logout">Log Out</button>
|
||||
</template>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue';
|
||||
import DeleteUserForm from './Partials/DeleteUserForm.vue';
|
||||
import UpdatePasswordForm from './Partials/UpdatePasswordForm.vue';
|
||||
import UpdateProfileInformationForm from './Partials/UpdateProfileInformationForm.vue';
|
||||
import { Head } from '@inertiajs/vue3';
|
||||
|
||||
defineProps({
|
||||
mustVerifyEmail: {
|
||||
type: Boolean,
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Profile" />
|
||||
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<h2
|
||||
class="text-xl font-semibold leading-tight text-gray-800"
|
||||
>
|
||||
Profile
|
||||
</h2>
|
||||
</template>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="mx-auto max-w-7xl space-y-6 sm:px-6 lg:px-8">
|
||||
<div
|
||||
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
|
||||
>
|
||||
<UpdateProfileInformationForm
|
||||
:must-verify-email="mustVerifyEmail"
|
||||
:status="status"
|
||||
class="max-w-xl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
|
||||
>
|
||||
<UpdatePasswordForm class="max-w-xl" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
|
||||
>
|
||||
<DeleteUserForm class="max-w-xl" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
@@ -107,7 +107,7 @@ const filteredUnlockedCount = computed(() =>
|
||||
:key="achievement.id"
|
||||
:achievement="achievement"
|
||||
:user-achievement="userAchievements[achievement.id]"
|
||||
:distance-unit="page.auth?.user?.distance_unit"
|
||||
:distance-unit="page.auth?.user?.resolved_settings?.distance_unit"
|
||||
/>
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, computed } from 'vue'
|
||||
import axios from 'axios'
|
||||
import MainLayout from "@/Layouts/MainLayout.vue"
|
||||
import GlassBox from "@/Components/FlightsGoneBy/GlassBox.vue"
|
||||
import { Head } from "@inertiajs/vue3"
|
||||
import {SettingField} from "@/Types/types";
|
||||
defineOptions({ layout: MainLayout })
|
||||
|
||||
const props = defineProps<{
|
||||
fields: SettingField[],
|
||||
categories: Record<string, string>
|
||||
}>()
|
||||
|
||||
const values = reactive(
|
||||
Object.fromEntries(props.fields.map(f => [f.key, f.value]))
|
||||
)
|
||||
const saving = ref(false)
|
||||
const saved = ref(false)
|
||||
const error = ref(false)
|
||||
|
||||
const groupedFields = computed(() =>
|
||||
props.fields.reduce((groups: Record<string, SettingField[]>, field) => {
|
||||
const cat = field.category ?? 'General'
|
||||
;(groups[cat] ??= []).push(field)
|
||||
return groups
|
||||
}, {} as Record<string, SettingField[]>)
|
||||
)
|
||||
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
error.value = false
|
||||
try {
|
||||
await axios.patch('/settings', { settings: values })
|
||||
saved.value = true
|
||||
setTimeout(() => saved.value = false, 3000)
|
||||
} catch {
|
||||
error.value = true
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Settings" />
|
||||
<GlassBox title="Your Settings">
|
||||
<v-form @submit.prevent="save">
|
||||
<template v-for="(groupFields, category) in groupedFields" :key="category">
|
||||
<p class="text-overline text-medium-emphasis mb-1 mt-4">{{ category }}</p>
|
||||
<small v-if="categories[category]" class="text-body-2 text-medium-emphasis mb-3">
|
||||
{{ categories[category] }}
|
||||
</small>
|
||||
<v-divider class="mb-4" />
|
||||
|
||||
<template v-for="field in groupFields" :key="field.key">
|
||||
|
||||
<v-select
|
||||
v-if="field.type === 'select'"
|
||||
v-model="values[field.key]"
|
||||
:label="field.label"
|
||||
:items="field.options"
|
||||
item-title="label"
|
||||
item-value="value"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
class="mb-2"
|
||||
/>
|
||||
|
||||
<v-text-field
|
||||
v-else-if="field.type === 'text'"
|
||||
v-model="values[field.key]"
|
||||
:label="field.label"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
class="mb-2"
|
||||
/>
|
||||
|
||||
<v-checkbox
|
||||
v-else-if="field.type === 'checkbox'"
|
||||
v-model="values[field.key]"
|
||||
:label="field.label"
|
||||
color="primary"
|
||||
density="comfortable"
|
||||
hide-details
|
||||
class="mb-2"
|
||||
/>
|
||||
|
||||
<v-select
|
||||
v-else-if="field.type === 'multiselect'"
|
||||
v-model="values[field.key]"
|
||||
:label="field.label"
|
||||
:items="field.options"
|
||||
item-title="label"
|
||||
item-value="value"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
chips
|
||||
multiple
|
||||
closable-chips
|
||||
clearable
|
||||
class="mb-2"
|
||||
/>
|
||||
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<v-divider class="my-4" />
|
||||
|
||||
<div class="d-flex align-center gap-3">
|
||||
<v-btn
|
||||
type="submit"
|
||||
color="primary"
|
||||
variant="elevated"
|
||||
:loading="saving"
|
||||
min-width="140"
|
||||
>
|
||||
Save settings
|
||||
</v-btn>
|
||||
|
||||
<v-fade-transition>
|
||||
<div v-if="saved" class="d-flex align-center gap-1 text-success">
|
||||
<v-icon size="18">mdi-check-circle</v-icon>
|
||||
<span class="text-body-2">Saved</span>
|
||||
</div>
|
||||
</v-fade-transition>
|
||||
|
||||
<v-fade-transition>
|
||||
<div v-if="error" class="d-flex align-center gap-1 text-error">
|
||||
<v-icon size="18">mdi-alert-circle</v-icon>
|
||||
<span class="text-body-2">Something went wrong</span>
|
||||
</div>
|
||||
</v-fade-transition>
|
||||
</div>
|
||||
|
||||
</v-form>
|
||||
</GlassBox>
|
||||
</template>
|
||||
Vendored
+27
-1
@@ -17,7 +17,33 @@ export interface User {
|
||||
name: string
|
||||
email: string
|
||||
email_verified_at: string | null
|
||||
distance_unit: "km" | "mi" | "nm"
|
||||
resolved_settings?: UserSettings
|
||||
}
|
||||
|
||||
export type DistanceUnit = "km" | "mi" | "nm"
|
||||
|
||||
export interface UserSettings {
|
||||
distance_unit: DistanceUnit
|
||||
show_ai_tail_logos: boolean
|
||||
show_ai_livery_images: boolean
|
||||
departure_board_columns: string[]
|
||||
}
|
||||
|
||||
|
||||
export type SettingType = 'select' | 'text' | 'checkbox' | 'multiselect'
|
||||
export interface SettingOption {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface SettingField {
|
||||
key: keyof UserSettings
|
||||
type: SettingType
|
||||
label: string
|
||||
category: string
|
||||
default: UserSettings[keyof UserSettings]
|
||||
value: UserSettings[keyof UserSettings]
|
||||
options?: SettingOption[]
|
||||
}
|
||||
|
||||
export type UserActionType = "flight_cancelled" | "flight_booked" | "flight_updated" | "flight_logged" | "flight_deleted" | "flight_imported" | "flight_departing" | "flight_arriving"
|
||||
|
||||
Reference in New Issue
Block a user