Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee095d6ae8 |
@@ -133,7 +133,7 @@ class SettingsRegistry
|
|||||||
'category' => 'FlightsGoneBy Settings',
|
'category' => 'FlightsGoneBy Settings',
|
||||||
'type' => 'multiselect',
|
'type' => 'multiselect',
|
||||||
'label' => 'Which columns to show on the Departure Board',
|
'label' => 'Which columns to show on the Departure Board',
|
||||||
'default' => ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'registration', 'class_seat_combined'],
|
'default' => ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'aircraft_registration', 'class_seat_combined'],
|
||||||
'options' => [
|
'options' => [
|
||||||
['value' => 'airline', 'label' => 'Airline Logo w/ Info Popup'],
|
['value' => 'airline', 'label' => 'Airline Logo w/ Info Popup'],
|
||||||
['value' => 'airline.name', 'label' => 'Airline Name'],
|
['value' => 'airline.name', 'label' => 'Airline Name'],
|
||||||
@@ -148,7 +148,7 @@ class SettingsRegistry
|
|||||||
['value' => 'duration', 'label' => 'Duration'],
|
['value' => 'duration', 'label' => 'Duration'],
|
||||||
['value' => 'distance', 'label' => 'Distance'],
|
['value' => 'distance', 'label' => 'Distance'],
|
||||||
['value' => 'aircraft', 'label' => 'Aircraft Designator w/ Info Popup'],
|
['value' => 'aircraft', 'label' => 'Aircraft Designator w/ Info Popup'],
|
||||||
['value' => 'registration', 'label' => 'Aircraft Registration'],
|
['value' => 'aircraft_registration', 'label' => 'Aircraft Registration'],
|
||||||
['value' => 'aircraft.manufacturer_code', 'label' => 'Aircraft Manufacturer'],
|
['value' => 'aircraft.manufacturer_code', 'label' => 'Aircraft Manufacturer'],
|
||||||
['value' => 'aircraft.model_full_name', 'label' => 'Aircraft Model'],
|
['value' => 'aircraft.model_full_name', 'label' => 'Aircraft Model'],
|
||||||
['value' => 'flight_class', 'label' => 'Class'],
|
['value' => 'flight_class', 'label' => 'Class'],
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->renameDepartureBoardColumn('registration', 'aircraft_registration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$this->renameDepartureBoardColumn('aircraft_registration', 'registration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Walk every user's settings JSON and rename a value inside
|
||||||
|
* departure_board_columns, if present.
|
||||||
|
*/
|
||||||
|
private function renameDepartureBoardColumn(string $from, string $to): void
|
||||||
|
{
|
||||||
|
DB::table('users')
|
||||||
|
->select('id', 'settings')
|
||||||
|
->whereNotNull('settings')
|
||||||
|
->orderBy('id')
|
||||||
|
->chunkById(500, function ($users) use ($from, $to) {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$settings = json_decode($user->settings, true);
|
||||||
|
|
||||||
|
// Skip rows with malformed/empty JSON rather than blowing up the migration.
|
||||||
|
if (! is_array($settings) || ! isset($settings['departure_board_columns'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_array($settings['departure_board_columns'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = $settings['departure_board_columns'];
|
||||||
|
$key = array_search($from, $columns, true);
|
||||||
|
|
||||||
|
if ($key === false) {
|
||||||
|
continue; // nothing to change for this user
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns[$key] = $to;
|
||||||
|
$settings['departure_board_columns'] = $columns;
|
||||||
|
|
||||||
|
DB::table('users')
|
||||||
|
->where('id', $user->id)
|
||||||
|
->update([
|
||||||
|
'settings' => json_encode($settings),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -9,8 +9,6 @@ import ButtonLink from "@/Components/FlightsGoneBy/ButtonLink.vue";
|
|||||||
import Distance from "@/Components/Distance.vue";
|
import Distance from "@/Components/Distance.vue";
|
||||||
import FormattedNumber from "@/Components/FormattedNumber.vue";
|
import FormattedNumber from "@/Components/FormattedNumber.vue";
|
||||||
|
|
||||||
const distanceAchievementCategoryId = 6
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
achievement: Achievement
|
achievement: Achievement
|
||||||
userAchievement?: UserAchievement
|
userAchievement?: UserAchievement
|
||||||
@@ -18,6 +16,20 @@ const props = defineProps<{
|
|||||||
distanceUnit? : "mi" | "km" | "nm"
|
distanceUnit? : "mi" | "km" | "nm"
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const dynamicDistanceUnit = computed(() => {
|
||||||
|
if(props.achievement.internal_name == 'distance.million_miles'){
|
||||||
|
return 'mi'
|
||||||
|
}
|
||||||
|
|
||||||
|
if(props.achievement.internal_name == 'distance.million_kilometers'){
|
||||||
|
return 'km'
|
||||||
|
}
|
||||||
|
|
||||||
|
return props.distanceUnit ?? 'km';
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const progress = computed(() => {
|
const progress = computed(() => {
|
||||||
if (!props.achievement.progressive || !props.achievement.threshold) return null
|
if (!props.achievement.progressive || !props.achievement.threshold) return null
|
||||||
const current = props.userAchievement?.progress ?? 0
|
const current = props.userAchievement?.progress ?? 0
|
||||||
@@ -88,9 +100,9 @@ const unlocked = computed(() => {
|
|||||||
|
|
||||||
<template v-if="achievement.progressive && progress">
|
<template v-if="achievement.progressive && progress">
|
||||||
<div class="progress-label">
|
<div class="progress-label">
|
||||||
<span v-if="achievement.achievement_category_id == distanceAchievementCategoryId">
|
<span v-if="achievement.category?.internal_name == 'distance'">
|
||||||
<Distance :unit="distanceUnit" :showUnits="false" :value="Math.min(progress.current, progress.threshold)" /> /
|
<Distance :unit="dynamicDistanceUnit" :showUnits="false" :value="Math.min(progress.current, progress.threshold)" /> /
|
||||||
<Distance :unit="distanceUnit" :value="progress.threshold" />
|
<Distance :unit="dynamicDistanceUnit" :value="progress.threshold" />
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<FormattedNumber :value="Math.min(progress.current, progress.threshold)" /> /
|
<FormattedNumber :value="Math.min(progress.current, progress.threshold)" /> /
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ const props = defineProps<{
|
|||||||
const page = usePage<SharedProps>().props
|
const page = usePage<SharedProps>().props
|
||||||
const ITEMS_PER_PAGE = 25
|
const ITEMS_PER_PAGE = 25
|
||||||
|
|
||||||
const defaultColumns = ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'registration', 'class_seat_combined', 'note']
|
const defaultColumns = ['airline', 'flight_number', 'departure_airport', 'arrival_airport', 'departure_date', 'departure_time', 'arrival_time', 'duration', 'distance', 'aircraft', 'aircraft_registration', 'class_seat_combined', 'note']
|
||||||
const columnsToShow = computed(() => page.auth.user?.resolved_settings?.departure_board_columns ?? defaultColumns)
|
const columnsToShow = computed(() => page.auth.user?.resolved_settings?.departure_board_columns ?? defaultColumns)
|
||||||
const showColumn = (column: string) =>
|
const showColumn = (column: string) => columnsToShow.value.includes(column)
|
||||||
columnsToShow.value.includes(column) ||
|
|
||||||
(column === 'aircraft_registration' && columnsToShow.value.includes('registration'))
|
|
||||||
|
|
||||||
const allHeaders = [
|
const allHeaders = [
|
||||||
{ title: '', key: 'airline', sortable: true, resizable: false},
|
{ title: '', key: 'airline', sortable: true, resizable: false},
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ const showColumn = (column: string) => props.columnsToShow.includes(column)
|
|||||||
</AircraftToolTip>
|
</AircraftToolTip>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td v-if="showColumn('registration')" class="v-data-table__td registration-cell">
|
<td v-if="showColumn('aircraft_registration')" class="v-data-table__td registration-cell">
|
||||||
<Mono muted smaller v-if="flight.aircraft_registration">{{ flight.aircraft_registration }}</Mono>
|
<Mono muted smaller v-if="flight.aircraft_registration">{{ flight.aircraft_registration }}</Mono>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user