Skip to content

Commit

Permalink
Merge branch 'main' into pryazhentsev/aircraft-data-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
johanohly authored Oct 6, 2024
2 parents 8fb6339 + 7f1cbde commit a5248b3
Show file tree
Hide file tree
Showing 107 changed files with 14,496 additions and 646 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-changelog-label-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: read
pull-requests: write
steps:
- name: Check for required label(s)
uses: mheap/github-action-required-labels@v5
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/johly/airtrail?style=for-the-badge)]()
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/johanohly/AirTrail/build.yml?style=for-the-badge)]()
[![GitHub Release](https://img.shields.io/github/v/release/johanohly/AirTrail?style=for-the-badge)]()
[![Contributors](https://img.shields.io/github/contributors/johanohly/AirTrail?style=for-the-badge)]()
[![GitHub Stars](https://img.shields.io/github/stars/johanohly/AirTrail?style=for-the-badge)]()

<div align="center">
<a href="https://johanohly.github.io/AirTrail/">
<img src="static/favicon.png" alt="AirTrail logo" width="80" height="80">
Expand All @@ -17,10 +23,11 @@
- **World Map**: View all your flights on an interactive world map.
- **Flight History**: Keep track of all your flights in one place.
- **Statistics**: Get insights into your flight history with statistics.
- **User Authentication**: Allow multiple users and secure your data with user authentication.
- **Multiple Users**: Manage multiple users, share flights among them, secure your data with user authentication and
integrate with your OAuth provider.
- **Responsive Design**: Use the application on any device with a responsive design.
- **Dark Mode**: Switch between light and dark mode.
- **Import Flights**: Import flights from various sources.
- **Import Flights**: Import flights from various sources including MyFlightRadar24, App in the Air and JetLog.

## 🚀 Getting Started

Expand Down
Binary file modified bun.lockb
Binary file not shown.
93 changes: 93 additions & 0 deletions docs/docs/features/export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
sidebar_position: 3
---

# Export

The export feature allows you to export your flight data from AirTrail.

## Export flights

To export your flights, follow these steps:

1. Go to the AirTrail application.
2. Go to the settings page.
3. Click on the "Export" tab.
4. Choose your desired export format (CSV or JSON).

## Export formats

### CSV

The CSV export option allows you to export your flights as a CSV file, which can be opened in any spreadsheet
application like Microsoft Excel or Google Sheets. It is a simple and easy-to-use format that can be used to
analyze your flight data.

#### Format

The CSV file contains the following columns:

- `date`: The date of the flight (YYYY-MM-DD format).
- `from`: The IATA code of the departure airport.
- `to`: The IATA code of the arrival airport.
- `departure`: The departure time in ISO 8601 format (if available).
- `arrival`: The arrival time in ISO 8601 format (if available).
- `duration`: The duration of the flight in seconds.
- `flightNumber`: The flight number (if available).
- `flightReason`: The reason for the flight (if provided).
- `airline`: The airline operating the flight (if available).
- `aircraft`: The type of aircraft used (if available).
- `aircraftReg`: The registration number of the aircraft (if available).
- `note`: Any additional notes about the flight.
- `seat`: The type of seat (e.g., window, aisle, etc.).
- `seatNumber`: The seat number (if available).
- `seatClass`: The class of the seat (e.g., economy, business).

### JSON

:::tip
The JSON format can be reimported into AirTrail using the import feature.
:::

The JSON export option provides a more structured format that is ideal for developers or when integrating the data into
other systems. It contains nested objects for each flight and detailed data for each user and their seat information.

#### Format

The JSON file follows this structure:

```json
{
"users": [
{
"id": "user_id",
"displayName": "User Name",
"username": "username"
}
],
"flights": [
{
"date": "YYYY-MM-DD",
"from": "ICAO_CODE",
"to": "ICAO_CODE",
"departure": "ISO_8601_DATETIME",
"arrival": "ISO_8601_DATETIME",
"duration": flight_duration_in_seconds,
"flightNumber": "FLIGHT_NUMBER",
"flightReason": "FLIGHT_REASON",
"airline": "ICAO_AIRLINE_CODE",
"aircraft": "ICAO_AIRCRAFT_TYPE",
"aircraftReg": "AIRCRAFT_REGISTRATION",
"note": "FLIGHT_NOTE",
"seats": [
{
"userId": "USER_ID",
"guestName": "GUEST_NAME",
"seat": "SEAT_TYPE",
"seatNumber": "SEAT_NUMBER",
"seatClass": "SEAT_CLASS"
}
]
}
]
}
48 changes: 44 additions & 4 deletions docs/docs/features/import.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
sidebar_position: 1
sidebar_position: 2
---

# Import

The import feature allows you to import flight data from other sources into AirTrail.
Currently, AirTrail supports importing flights from [MyFlightradar24](https://my.flightradar24.com)
and [App in the Air](https://appintheair.com).
, [App in the Air](https://appintheair.com), [JetLog](https://github.com/pbogre/jetlog)
and [AirTrail JSON files](/docs/features/export).

## Import flights from MyFlightradar24

Expand All @@ -22,7 +23,7 @@ Once you have the CSV file, you can import it into AirTrail by following these s
1. Go to the AirTrail application.
2. Go to the settings page.
3. Click on the "Import" tab.
4. Click on the "Choose File" button and select the CSV file you downloaded from MyFlightradar24.
4. Click on the "Select file" button and select the CSV file you downloaded from MyFlightradar24.
5. Click on the "Import" button to start the import process.

After the import process is complete, you will see your flights on the map.
Expand All @@ -41,7 +42,46 @@ Once you have the text file, you can import it into AirTrail by following these
1. Go to the AirTrail application.
2. Go to the settings page.
3. Click on the "Import" tab.
4. Click on the "Choose File" button and select the text file you received from App in the Air.
4. Click on the "Select file" button and select the text file you received from App in the Air.
5. Click on the "Import" button to start the import process.

After the import process is complete, you will see your flights on the map.

## Import flights from JetLog

:::tip
Make sure the file you are importing is called `jetlog.csv`. If it is not, rename it to `jetlog.csv` before importing.
:::

While logged in to your JetLog account, follow these steps to export your flights:

1. Go to your JetLog instance.
2. Go to the "Settings" page in the top right corner.
3. Click on the "Export to CSV" button to download your flights as a CSV file.

Once you have the CSV file, you can import it into AirTrail by following these steps:

1. Go to the AirTrail application.
2. Go to the settings page.
3. Click on the "Import" tab.
4. Click on the "Select file" button and select the CSV file you downloaded from JetLog.
5. Click on the "Import" button to start the import process.

After the import process is complete, you will see your flights on the map.

## Import flights from AirTrail JSON files

:::tip
Make sure the file you are importing is called `airtrail.json`. If it is not, rename it to `airtrail.json` before
importing.
:::

Once you have the JSON file, you can import it into AirTrail by following these steps:

1. Go to the AirTrail application.
2. Go to the settings page.
3. Click on the "Import" tab.
4. Click on the "Select file" button and select the JSON file you want to import.
5. Click on the "Import" button to start the import process.

After the import process is complete, you will see your flights on the map.
37 changes: 37 additions & 0 deletions docs/docs/features/oauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_position: 4
---

# OAuth Authentication

AirTrail supports authentication via OpenID Connect (OIDC).
This allows you to use your existing identity provider to authenticate users in AirTrail.

## Prerequisites

Before you can configure OAuth authentication in AirTrail, you need to set up an OAuth client in your identity provider.
The specific steps to do this depend on the identity provider you are using, but in general you will need to:

1. Register a new OIDC/OAuth2 client in your identity provider.
2. Configure the client with the following settings:
- Client type: `Confidential`
- Application type: `Web application`
- Grant type: `Authorization Code`
3. Add the following redirect URI to the client configuration:
- `http://DOMAIN:PORT/login`

## Configuration

To configure OAuth authentication in AirTrail, go to the `Settings` page and click on the `OAuth` tab (you need to be an
admin to access this page).
Here you can enter the following settings:

| Setting | Default | Description |
|---------------|----------------|-----------------------------------------------------------------------------------------------------|
| Enabled | `false` | Whether to enable OAuth authentication. |
| Issuer URL | | The URL of the OIDC issuer (e.g. `https://accounts.google.com/.well-known/openid-configuration`). |
| Client ID | | The client ID of the OAuth client you created in your identity provider. |
| Client Secret | | The client secret of the OAuth client you created in your identity provider. |
| Scope | openid profile | The scopes to send with the request. |
| Auto Register | `true` | Whether to automatically register new users if no existing AirTrail user is found for the username. |
| Auto Login | `false` | Whether to automatically launch the OAuth login flow when a user visits the login page. |
27 changes: 27 additions & 0 deletions docs/docs/features/statistics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
sidebar_position: 1
---

# Statistics

Get insights into your flying habits with the statistics page.
Statistics are available through the bottom navigation bar.

## Fields

:::tip Note
Statistics only take into account flights that have been completed.
:::

| Field | Description |
|--------------------|----------------------------------------------------------------------|
| Flights | The total number of flights you have completed. |
| Distance | The total distance you have flown. |
| Duration | The total time you have spent flying. |
| Airports | The total number of airports you have visited. |
| Seat Classes | The distribution of flights by seat class (Economy, Business, etc.). |
| Seat Distribution | The distribution of flights by seat (Window, Aisle, etc.). |
| Flight Reason | The distribution of flights by reason (Business, Leisure, etc.). |
| Continents Visited | The amount you have visited each continent. |
| Flights by month | The amount of flights per month. |
| Flights by weekday | The amount of flights per weekday. |
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "airtrail",
"version": "0.1.1",
"version": "0.2.0",
"type": "module",
"scripts": {
"build": "vite build",
Expand All @@ -18,12 +18,12 @@
"@layerstack/utils": "^0.0.3",
"@lucia-auth/adapter-postgresql": "^3.1.2",
"@node-rs/argon2": "^1.8.3",
"@o7/icon": "^0.2.3",
"@o7/icon": "^0.3.9",
"@prisma/client": "^5.19.1",
"@tanstack/svelte-query": "^5.51.16",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"bits-ui": "^0.21.13",
"bits-ui": "^0.21.15",
"clsx": "^2.1.1",
"cobe": "^0.6.3",
"d3-array": "^3.2.4",
Expand All @@ -32,18 +32,22 @@
"devalue": "^5.0.0",
"formsnap": "^1.0.1",
"kysely": "^0.27.4",
"layerchart": "^0.43.8",
"layerchart": "^0.52.1",
"lru-cache": "^11.0.0",
"lucide-svelte": "^0.437.0",
"maplibre-gl": "^4.5.1",
"mode-watcher": "^0.4.1",
"openid-client": "^5.7.0",
"pg": "^8.12.0",
"semver": "^7.6.3",
"svelte-maplibre": "^0.9.11",
"svelte-markdown": "^0.4.1",
"svelte-motion": "^0.12.2",
"svelte-sonner": "^0.3.27",
"sveltekit-superforms": "^2.16.1",
"tailwind-merge": "^2.4.0",
"tailwind-variants": "^0.2.1",
"topojson-client": "^3.1.0",
"trpc-svelte-query": "^2.1.0",
"vaul-svelte": "^0.3.2",
"zod": "^3.23.8"
Expand All @@ -56,10 +60,14 @@
"@sveltejs/adapter-node": "^5.2.2",
"@sveltejs/kit": "^2.5.24",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/d3-geo": "^3.1.0",
"@types/d3-scale": "^4.0.8",
"@types/d3-shape": "^3.1.6",
"@types/lru-cache": "^7.10.10",
"@types/pg": "^8.11.8",
"@types/semver": "^7.5.8",
"@types/topojson-client": "^3.1.5",
"@types/topojson-specification": "^1.0.5",
"autoprefixer": "^10.4.19",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
26 changes: 26 additions & 0 deletions prisma/migrations/20240925181003_oauth/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- AlterTable
ALTER TABLE "user"
ADD COLUMN "oauth_id" TEXT,
ALTER COLUMN "password" DROP NOT NULL;

-- CreateTable
CREATE TABLE "app_config"
(
"id" SERIAL NOT NULL,
"enabled" BOOLEAN NOT NULL DEFAULT false,
"issuer_url" TEXT,
"client_id" TEXT,
"client_secret" TEXT,
"scope" TEXT NOT NULL DEFAULT 'openid profile',
"auto_register" BOOLEAN NOT NULL DEFAULT true,
"auto_login" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "app_config_pkey" PRIMARY KEY ("id")
);

-- Insert
INSERT INTO "app_config" ("enabled", "scope", "auto_register",
"auto_login")
VALUES (false, 'openid profile', true,
false);

16 changes: 16 additions & 0 deletions prisma/migrations/20241003080714_visited_countries/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "visited_country" (
"id" SERIAL NOT NULL,
"code" INTEGER NOT NULL,
"status" TEXT NOT NULL,
"note" TEXT,
"user_id" TEXT NOT NULL,

CONSTRAINT "visited_country_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "visited_country_code_user_id_key" ON "visited_country"("code", "user_id");

-- AddForeignKey
ALTER TABLE "visited_country" ADD CONSTRAINT "visited_country_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Loading

0 comments on commit a5248b3

Please sign in to comment.