Compare commits

...

68 Commits

Author SHA1 Message Date
e3f385d0a4 Merge pull request 'adding infisical action to workflows' (#142) from 141-update-workflows-with-infisical into main
Some checks failed
Main / changes (push) Successful in 24s
Main / build-and-test (push) Failing after 21s
Main / deploy (push) Failing after 7s
Reviewed-on: #142
2026-07-13 11:42:21 -04:00
f33a9982cc adding infisical action to workflows
All checks were successful
Pull Request / changes (pull_request) Successful in 18s
Pull Request / build-and-test (pull_request) Successful in 1m50s
2026-07-13 10:33:45 -05:00
100fd78551 adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Failing after 20s
2026-07-13 09:31:14 -05:00
a87d35a5e4 adding infisical action to workflows
All checks were successful
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Successful in 1m49s
2026-07-13 09:25:17 -05:00
0c4fe29553 adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 17s
Pull Request / build-and-test (pull_request) Failing after 19s
2026-07-13 09:20:14 -05:00
03c4dacd99 adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Failing after 20s
2026-07-13 09:15:51 -05:00
1ed1a6c48a adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 19s
Pull Request / build-and-test (pull_request) Failing after 16s
2026-07-13 08:51:16 -05:00
4c77ebc1d6 adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Failing after 3s
2026-07-13 08:49:43 -05:00
650ea704aa adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 1m6s
Pull Request / build-and-test (pull_request) Failing after 2m51s
2026-07-13 08:43:03 -05:00
d51e95f59e adding infisical action to workflows
Some checks failed
Pull Request / changes (pull_request) Successful in 57s
Pull Request / build-and-test (pull_request) Failing after 4m0s
2026-07-13 08:04:16 -05:00
0806e114e1 fixing build and test workflow
All checks were successful
Main / changes (push) Successful in 18s
Main / build-and-test (push) Successful in 5m48s
Main / deploy (push) Successful in 2m28s
Tag / build (push) Successful in 5m51s
Tag / deploy (push) Successful in 2m27s
2026-05-31 06:21:20 -05:00
fc716c664b fixing build and test workflow
All checks were successful
Main / changes (push) Successful in 22s
Main / build-and-test (push) Successful in 5m46s
Main / deploy (push) Successful in 2m34s
2026-05-31 06:09:58 -05:00
5a1e24a1ce updating version to 2.1.5
All checks were successful
Main / changes (push) Successful in 26s
Main / build-and-test (push) Successful in 5m58s
Main / deploy (push) Successful in 2m33s
2026-05-31 05:51:16 -05:00
b93327f840 updating log interceptor for read role
All checks were successful
Main / changes (push) Successful in 18s
Main / build-and-test (push) Successful in 5m49s
Main / deploy (push) Successful in 2m27s
2026-05-21 08:10:48 -05:00
bbcf6cb3de updating log interceptor for read role
Some checks failed
Main / changes (push) Successful in 24s
Main / build-and-test (push) Successful in 5m49s
Main / deploy (push) Failing after 2m24s
2026-05-21 07:44:36 -05:00
344d4f5625 updating log interceptor for read role
Some checks failed
Main / changes (push) Successful in 23s
Main / build-and-test (push) Successful in 5m51s
Main / deploy (push) Failing after 21s
2026-05-21 07:35:42 -05:00
22fbf7615b updating log interceptor for read role
Some checks failed
Main / changes (push) Successful in 18s
Main / build (push) Failing after 32s
Main / deploy (push) Has been skipped
2026-05-21 07:30:57 -05:00
5a84c221d6 updating log interceptor for read role
Some checks failed
Main / changes (push) Successful in 22s
Main / build (push) Successful in 6m15s
Main / deploy (push) Failing after 18s
2026-05-20 22:12:51 -05:00
13f1e86e72 Merge pull request '133-read-role-returns-500-from-api' (#135) from 133-read-role-returns-500-from-api into main
All checks were successful
Main / changes (push) Successful in 23s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
Reviewed-on: #135
2026-05-20 23:10:54 -04:00
25f935171e updating log interceptor for read role
All checks were successful
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Successful in 1m48s
2026-05-20 22:07:33 -05:00
92fec88ad1 updating log interceptor for read role (#134)
Some checks failed
Main / changes (push) Successful in 25s
Main / build (push) Successful in 7m32s
Main / deploy (push) Failing after 48s
Reviewed-on: #134
Co-authored-by: noahspannbauer <noahspannbauer@icloud.com>
Co-committed-by: noahspannbauer <noahspannbauer@icloud.com>
2026-05-20 22:37:05 -04:00
833b1b107c updating log interceptor for read role
All checks were successful
Pull Request / changes (pull_request) Successful in 23s
Pull Request / build-and-test (pull_request) Successful in 4m15s
2026-05-20 21:31:16 -05:00
674ae1cf3c updating log interceptor for read role
All checks were successful
Pull Request / changes (pull_request) Successful in 25s
Pull Request / build (pull_request) Has been skipped
2026-05-20 21:27:06 -05:00
f0b61703b7 renaming .github to .gitea
All checks were successful
Main / changes (push) Successful in 26s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 12:41:38 -05:00
c152f06b63 renaming .github to .gitea
All checks were successful
Main / changes (push) Successful in 59s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 12:39:48 -05:00
3c9d26e085 renaming .github to .gitea
All checks were successful
Main / changes (push) Successful in 11s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 12:20:37 -05:00
12b4f1a65b renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:19:28 -05:00
ae03c0200c renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:16:08 -05:00
b9668a9d48 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:12:07 -05:00
19041e3967 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 1m41s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:08:55 -05:00
5729c72fe1 renaming .github to .gitea
All checks were successful
Main / changes (push) Successful in 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:07:15 -05:00
8760998c78 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:05:59 -05:00
61f8dc0e1e renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:04:05 -05:00
cc7b694fd5 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 08:02:14 -05:00
9553c2ec34 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:59:57 -05:00
0a8c461e3d renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:54:43 -05:00
931d56e753 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 7s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:50:58 -05:00
7ebf78f348 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 58s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:41:50 -05:00
95e2d59abc renaming .github to .gitea
All checks were successful
Main / changes (push) Successful in 3s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:40:54 -05:00
945081dd7c renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 8s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:39:04 -05:00
7213dcf9e1 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 21s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:38:04 -05:00
a13ffeaebd renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 22s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:34:15 -05:00
620b258e94 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 21s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:22:46 -05:00
cc21a43825 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 26s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:18:07 -05:00
112b56080c renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 1m12s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:14:06 -05:00
92f97a93bf renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 9s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-19 07:12:40 -05:00
4f6e9a072c renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 1m49s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-18 20:34:54 -05:00
0c8e4b9fba renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 58s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-18 20:21:39 -05:00
63d2765d19 renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 4m59s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-18 20:12:52 -05:00
da76000b8d renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 1m47s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-18 19:56:36 -05:00
b789e1264a renaming .github to .gitea
Some checks failed
Main / changes (push) Failing after 0s
Main / build (push) Has been skipped
Main / deploy (push) Has been skipped
2026-05-18 19:42:09 -05:00
9cc86fe79f renaming .github to .gitea 2026-05-18 19:22:36 -05:00
ee0e10072c updating version number 2026-04-26 17:19:20 -05:00
899f92f342 126 all logs shown when unauthenticated (#131)
* fixing all logs showing when user is unauthenticated

* updating api log interceptor

* updating api log interceptor

* updating api log interceptor

* logbook page unauthenticated alert
2026-04-26 17:08:34 -05:00
5c4245179f 126 all logs shown when unauthenticated (#130)
* fixing all logs showing when user is unauthenticated

* updating api log interceptor

* updating api log interceptor

* updating api log interceptor
2026-04-18 11:37:23 -07:00
a7a9f01fd9 126 all logs shown when unauthenticated (#129)
* fixing all logs showing when user is unauthenticated

* updating api log interceptor

* updating api log interceptor
2026-04-18 11:09:50 -07:00
a367b517db updating api log interceptor (#128)
* fixing all logs showing when user is unauthenticated

* updating api log interceptor
2026-04-16 06:31:28 -07:00
fd514e4c8b fixing all logs showing when user is unauthenticated (#127) 2026-04-07 20:44:21 -05:00
d8513e6dd0 fixing logbook skip take order by (#125) 2026-03-23 20:19:58 -05:00
5de5a165da 122 fix flights skip take and order by (#123)
* fixing flights skip take order by

* fixing flights skip take order by

* fixing flights skip take order by
2026-03-22 10:19:06 -05:00
26c46fe6e8 updating verison number to 2.1.0 2026-03-22 09:44:06 -05:00
04e5e3e16b 119 fix pilot page responsiveness (#121)
* fixing pilot page responsiveness

* fixing pilot page responsiveness
2026-03-22 09:27:15 -05:00
0305b424eb fixing pilot page responsiveness (#120) 2026-03-22 09:14:24 -05:00
8652544471 115 add load more button to logbook mobile view (#118)
* fixing logbook page responsiveness

* fixing logbook page responsiveness

* fixing logbook page responsiveness

* fixing logbook page responsiveness
2026-03-21 20:57:22 -05:00
b7b6bdcf4a 115 add load more button to logbook mobile view (#117)
* fixing logbook page responsiveness

* fixing logbook page responsiveness

* fixing logbook page responsiveness
2026-03-21 20:41:50 -05:00
9c96774f7b fixing logbook page responsiveness (#116)
* fixing logbook page responsiveness

* fixing logbook page responsiveness
2026-03-21 20:30:05 -05:00
a9abb5863c adding load more button to flights page (#114) 2026-03-21 10:43:44 -05:00
477469831f adding pagination to logbook table (#112) 2026-03-16 07:30:29 -05:00
36 changed files with 1041 additions and 265 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -15,12 +15,22 @@ jobs:
environment: ${{ inputs.environment_name }}
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
sparse-checkout: |
api
client
- name: Get Secrets from Infisical
uses: Infisical/secrets-action@v1.0.16
with:
domain: ${{ secrets.INFISICAL_DOMAIN }}
client-id: ${{ secrets.INFISICAL_CLIENT_ID }}
client-secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
project-slug: ${{ secrets.INFISICAL_PROJECT_SLUG }}
env-slug: ${{ inputs.environment_name }}
secret-path: /flying
- name: Install Nest CLI
run: |
npm install -g @nestjs/cli
@@ -28,7 +38,7 @@ jobs:
- name: 'Setup Node'
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: |
@@ -44,21 +54,20 @@ jobs:
- name: Build Client
env:
VITE_API_URL: ${{ vars.VITE_API_URL }}
VITE_BASE_URL: ${{ vars.VITE_BASE_URL }}
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
VITE_ISSUER_URI: ${{ vars.VITE_ISSUER_URI }}
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
VITE_API_URL: ${{ env.VITE_API_URL }}
VITE_BASE_URL: ${{ env.VITE_BASE_URL }}
VITE_CLIENT_ID: ${{ env.VITE_CLIENT_ID }}
VITE_ISSUER_URI: ${{ env.VITE_ISSUER_URI }}
VITE_TENANT_ID: ${{ env.VITE_TENANT_ID }}
run: |
printenv
npm run build -w client
- name: Log into Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Setup Docker Buildx
if: ${{ github.event_name != 'pull_request' }}

View File

@@ -7,6 +7,9 @@ on:
client:
value: ${{ jobs.changes.outputs.client }}
permissions:
contents: read
jobs:
changes:
name: filter
@@ -15,7 +18,13 @@ jobs:
api: ${{ steps.filter.outputs.api }}
client: ${{ steps.filter.outputs.client }}
steps:
- uses: actions/checkout@v3
- name: 'Setup Node'
uses: actions/setup-node@v6
with:
node-version: '22.x'
- name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter

View File

@@ -0,0 +1,44 @@
name: Deploy
on:
workflow_call:
inputs:
app_name:
required: true
type: string
environment_name:
required: true
type: string
version_number:
required: true
type: string
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment_name }}
steps:
- name: Get Secrets from Infisical
uses: Infisical/secrets-action@v1.0.16
with:
domain: ${{ secrets.INFISICAL_DOMAIN }}
client-id: ${{ secrets.INFISICAL_CLIENT_ID }}
client-secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
project-slug: ${{ secrets.INFISICAL_PROJECT_SLUG }}
env-slug: ${{ inputs.environment_name }}
secret-path: /flying
- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Log in to Azure
run: |
az login --service-principal --username ${{ env.AZURE_CLIENT_ID }} --password ${{ env.AZURE_CLIENT_SECRET }} --tenant ${{ env.AZURE_TENANT_ID }}
- name: Update Container App
run: |
az containerapp update --name ${{ inputs.app_name }}-${{ inputs.environment_name }} --container-name ${{ inputs.app_name }} --resource-group ${{ env.RESOURCE_GROUP }} --image docker.io/noahspan/${{ inputs.app_name }}:${{ inputs.version_number }}

View File

@@ -0,0 +1,43 @@
name: 'Infrastructure'
on:
workflow_dispatch:
inputs:
environment_name:
type: string
jobs:
infrastructure:
runs-on: ubuntu-latest
environment:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
infrastructure
- name: Get Secrets from Infisical
uses: Infisical/secrets-action@v1.0.16
with:
domain: ${{ secrets.INFISICAL_DOMAIN }}
client-id: ${{ secrets.INFISICAL_CLIENT_ID }}
client-secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
project-slug: ${{ secrets.INFISICAL_PROJECT_SLUG }}
env-slug: ${{ inputs.environment_name }}
secret-path: /flying/terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v4
- name: Terraform init
uses: |
terraform init -input=false
- name: Terraform plan
uses: |
terraform plan -no-color -input=false
- name: Terraform apply
uses: |
terraform apply -no-color -

View File

@@ -6,14 +6,14 @@ on:
jobs:
changes:
uses: ./.github/workflows/changes.yaml
uses: ./.gitea/workflows/changes.yaml
build:
build-and-test:
if: ${{ needs.changes.outputs.api == 'true' || needs.changes.outputs.client == 'true' }}
name: build
name: build-and-test
needs:
- changes
uses: ./.github/workflows/build_and_test.yaml
uses: ./.gitea/workflows/build_and_test.yaml
with:
environment_name: test
version_number: ${{ github.run_id }}
@@ -24,7 +24,7 @@ jobs:
needs:
- changes
- build
uses: ./.github/workflows/deploy.yaml
uses: ./.gitea/workflows/deploy.yaml
with:
app_name: flying
environment_name: test

View File

@@ -0,0 +1,19 @@
name: Pull Request
on:
pull_request:
jobs:
changes:
uses: ./.gitea/workflows/changes.yaml
build:
if: ${{ needs.changes.outputs.api == 'true' || needs.changes.outputs.client == 'true'}}
name: build-and-test
needs:
- changes
uses: ./.gitea/workflows/build_and_test.yaml
with:
environment_name: test
version_number: ${{ github.run_id }}
secrets: inherit

View File

@@ -7,7 +7,7 @@ on:
jobs:
build:
name: build
uses: ./.github/workflows/build_and_test.yaml
uses: ./.gitea/workflows/build_and_test.yaml
with:
environment_name: prod
version_number: ${{ github.ref_name }}
@@ -17,7 +17,7 @@ jobs:
name: deploy
needs:
- build
uses: ./.github/workflows/deploy.yaml
uses: ./.gitea/workflows/deploy.yaml
with:
app_name: flying
environment_name: prod

View File

@@ -1,35 +0,0 @@
name: Deploy
on:
workflow_call:
inputs:
app_name:
required: true
type: string
environment_name:
required: true
type: string
version_number:
required: true
type: string
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment_name }}
steps:
- name: Log in to Azure
uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
- name: Azure CLI script
uses: azure/cli@v2
with:
azcliversion: latest
inlineScript: |
az containerapp update --name ${{ inputs.app_name }}-${{ inputs.environment_name }} --container-name ${{ inputs.app_name }} --resource-group noahspan --image docker.io/noahspan/${{ inputs.app_name }}:${{ inputs.version_number }}

View File

@@ -1,19 +0,0 @@
name: Pull Request
on:
pull_request:
jobs:
changes:
uses: ./.github/workflows/changes.yaml
build:
if: ${{ needs.changes.outputs.app == 'true' || needs.changes.outputs.client == 'true'}}
name: build
needs:
- changes
uses: ./.github/workflows/build_and_test.yaml
with:
environment_name: pull_request
version_number: ${{ github.run_id }}
secrets: inherit

View File

@@ -1,3 +1,23 @@
# Flying (React and NestJS)
# Flying
A pilot logbook app
A web app for tracking pilot flight hours and sharing flight tracks.
## Built With
## Getting Started
### Prerequisites
### Installation
## Usage
## Roadmap
- [ ] Expense tracking for plane rental, instructor fees, and fuel rates
- [ ] Export logbook to CSV
- [ ]
## License
## Contact

View File

@@ -1,3 +1,4 @@
# Flying API
An API for the Flying app.
An API for the Flying app.
...

View File

@@ -1,6 +1,6 @@
{
"name": "api",
"version": "2.0.2",
"version": "2.1.5",
"description": "",
"author": "",
"private": true,

View File

@@ -1,5 +0,0 @@
import { JwtPayload } from "jwt-decode";
export interface CustomJwtPayload extends JwtPayload {
permissions: string[];
}

View File

@@ -13,7 +13,8 @@ describe('LogController', () => {
create: jest.fn(),
delete: jest.fn(),
find: jest.fn(),
findAll: jest.fn(),
findLogsWithCount: jest.fn(),
findLogsWithTracks: jest.fn(),
update: jest.fn()
}
@@ -38,18 +39,41 @@ describe('LogController', () => {
})
it('find => should find a log by id', async () => {
const id: string = '95834f84-0a02-44d3-884e-a20237adeca0';
const log = {
id: '95834f84-0a02-44d3-884e-a20237adeca0',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: []
} as LogEntity
jest.spyOn(mockLogService, 'find').mockReturnValue(log);
const result = await controller.find(id);
const result = await controller.find(log.id);
expect(result).toEqual(log);
expect(mockLogService.find).toHaveBeenCalled();
expect(mockLogService.find).toHaveBeenCalledWith(id);
expect(mockLogService.find).toHaveBeenCalledWith(log.id);
})
it('find => should fail to find a log by id', async () => {
@@ -69,42 +93,201 @@ describe('LogController', () => {
}
})
it('findAll => should find all logs', async () => {
const id: string = '95834f84-0a02-44d3-884e-a20237adeca0';
it('findLogsWithCount => should find logs with count', async () => {
const log = {
id: '95834f84-0a02-44d3-884e-a20237adeca0',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: [
{
"id": "4645ce0c-6fd7-432c-8089-777a7139cf7e",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KANE_KONA_20250628.kml",
"order": 1
},
{
"id": "5ce26898-a18b-46f4-b989-3fb7acdace08",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KONA_KANE_20250628.kml",
"order": 2
}
]
} as LogEntity;
const logs = [log]
const count = 1
const morePages = false
jest.spyOn(mockLogService, 'findAll').mockReturnValue(logs);
jest.spyOn(mockLogService, 'findLogsWithCount').mockReturnValue({
entities: logs,
total: count,
hasNextPage: morePages
});
const result = await controller.findAll();
const {entities, total, hasNextPage} = await controller.findLogsWithCount();
expect(result).toEqual(logs);
expect(mockLogService.findAll).toHaveBeenCalled();
expect(entities).toEqual(logs);
expect(total).toEqual(count);
expect(hasNextPage).toEqual(morePages)
expect(mockLogService.findLogsWithCount).toHaveBeenCalled();
})
it('findAll => should fail to find all logs', async () => {
jest.spyOn(mockLogService, 'findAll').mockRejectedValue(new Error('Logs not found'))
it('findLogsWithCount => should fail to find logs with count', async () => {
jest.spyOn(mockLogService, 'findLogsWithCount').mockRejectedValue(new Error('Logs not found'))
try {
await controller.findAll();
await controller.findLogsWithCount();
fail('findAll did not throw error');
fail('findLogsWithCount did not throw error');
} catch (error) {
expect(error).toBeInstanceOf(Error);
expect(mockLogService.findAll).toHaveBeenCalled();
expect(mockLogService.findAll).rejects.toThrow('Logs not found')
expect(mockLogService.findLogsWithCount).toHaveBeenCalled();
expect(mockLogService.findLogsWithCount).rejects.toThrow('Logs not found')
}
})
it('findLogsWithTracks => should find logs with tracks', async () => {
const log = {
id: '95834f84-0a02-44d3-884e-a20237adeca0',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: [
{
"id": "4645ce0c-6fd7-432c-8089-777a7139cf7e",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KANE_KONA_20250628.kml",
"order": 1
},
{
"id": "5ce26898-a18b-46f4-b989-3fb7acdace08",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KONA_KANE_20250628.kml",
"order": 2
}
]
} as LogEntity;
const logs = [log]
const count = 1
const morePages = false
jest.spyOn(mockLogService, 'findLogsWithTracks').mockReturnValue({
entities: logs,
total: count,
hasNextPage: morePages
});
const {entities, total, hasNextPage} = await controller.findLogsWithTracks();
expect(entities).toEqual(logs);
expect(total).toEqual(count);
expect(hasNextPage).toEqual(morePages)
expect(mockLogService.findLogsWithTracks).toHaveBeenCalled();
})
it('findLogsWithCount => should fail to find logs with tracks', async () => {
jest.spyOn(mockLogService, 'findLogsWithTracks').mockRejectedValue(new Error('Logs not found'))
try {
await controller.findLogsWithTracks();
fail('findLogsWithTracks did not throw error');
} catch (error) {
expect(error).toBeInstanceOf(Error);
expect(mockLogService.findLogsWithTracks).toHaveBeenCalled();
expect(mockLogService.findLogsWithTracks).rejects.toThrow('Logs not found')
}
})
it('create => should create a new log', async () => {
const logDto = {
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test'
} as LogDto;
const log = {
id: '95834f84-0a02-44d3-884e-a20237adeca0',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: []
} as LogEntity;
jest.spyOn(mockLogService, 'create').mockReturnValue(log);
@@ -116,9 +299,31 @@ describe('LogController', () => {
expect(result).toEqual(log);
})
it('create => should failt to create a new log', async () => {
it('create => should fail to create a new log', async () => {
const logDto = {
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test'
} as LogDto;
jest.spyOn(mockLogService, 'create').mockRejectedValue(new Error('Log failed to create'))
@@ -138,7 +343,29 @@ describe('LogController', () => {
it('update => should update an existing log', async () => {
const id: string = '95834f84-0a02-44d3-884e-a20237adeca0';
const logDto = {
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test'
} as LogDto
jest.spyOn(mockLogService, 'update').mockReturnValue(logDto);
@@ -153,7 +380,29 @@ describe('LogController', () => {
it('update => should fail to update an exising log', async () => {
const id: string = '95834f84-0a02-44d3-884e-a20237adeca0';
const logDto = {
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test'
} as LogDto;
jest.spyOn(mockLogService, 'update').mockRejectedValue(new Error('Log failed to update'))

View File

@@ -7,6 +7,7 @@ import {
Param,
Post,
Put,
Query,
UseGuards,
UseInterceptors
} from '@nestjs/common';
@@ -19,6 +20,7 @@ import { LogInterceptor } from './log.interceptor';
import { FileService } from '../file/file.service';
import { DeleteResult, InsertResult, UpdateResult } from 'typeorm';
import { Reflector } from '@nestjs/core';
import { Logs } from './logs.interface';
const reflector = new Reflector();
@@ -30,7 +32,30 @@ export class LogController {
private readonly logService: LogService
) {}
@Get()
@Public()
async findLogsWithCount(@Query('skip') skip?, @Query('take') take?: number,): Promise<Logs> {
try {
return await this.logService.findLogsWithCount(skip, take)
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode)
}
}
@Get('flights')
@Public()
async findLogsWithTracks(@Query('skip') skip?, @Query('take') take?: number,): Promise<Logs> {
try {
return await this.logService.findLogsWithTracks(skip, take)
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Get(':id')
@Public()
async find(
@@ -44,19 +69,6 @@ export class LogController {
throw new HttpException(customError.message, customError.statusCode);
}
}
@Get()
@Public()
async findAll(): Promise<LogEntity[]> {
try {
return await this.logService.findAll();
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Post()
@UseGuards(AuthGuard)

View File

@@ -15,23 +15,21 @@ export class LogInterceptor implements NestInterceptor {
]);
return handler.handle().pipe(
map((data: LogEntity[]) => {
map((data: any) => {
const req = context.switchToHttp().getRequest();
const limitData = (data) => {
return data.map((log: LogEntity) => {
return {
id: log.id,
pilot: {
name: log.pilot.name
},
date: log.date,
aircraftMakeModel: log.aircraftMakeModel,
routeFrom: log.routeFrom,
routeTo: log.routeTo,
durationOfFlight: log.durationOfFlight,
tracks: log.tracks,
};
});
const limitData = (log: LogEntity) => {
return {
id: log.id,
pilot: {
name: log.pilot.name
},
date: log.date,
aircraftMakeModel: log.aircraftMakeModel,
routeFrom: log.routeFrom,
routeTo: log.routeTo,
durationOfFlight: log.durationOfFlight,
tracks: log.tracks,
};
}
if (req.headers.authorization) {
@@ -41,17 +39,38 @@ export class LogInterceptor implements NestInterceptor {
const rolesKeyName = Object.keys(jwtPayload).find((key) => key.includes('roles'));
if (jwtPayload[rolesKeyName].includes('Flying.Read')) {
const logs = limitData(data);
if (data.entities) {
const logs = data.entities.map((entity) => limitData(entity));
return logs;
return {
entities: logs,
total: data.total,
hasNextPage: data.hasNextPage
};
} else {
const log = limitData(data);
return log;
}
} else {
return data;
}
} else if (!req.headers.authorization && isPublic) {
const publicData = limitData(data)
const logs = publicData.slice(0, 5)
if (data.entities) {
const publicData = data.entities.map((entity) => limitData(entity))
const logs = publicData.slice(0, 5)
return logs;
return {
entities: logs,
total: logs.length,
hasNextPage: false
};
} else {
const publicData = limitData(data);
return publicData
}
}
})
);

View File

@@ -15,9 +15,19 @@ describe('LogService', () => {
deleteFolder: jest.fn()
}
const mockQueryBuilder = {
createQueryBuilder: jest.fn().mockReturnThis(),
innerJoinAndSelect: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
skip: jest.fn().mockReturnThis(),
take: jest.fn().mockReturnThis(),
getManyAndCount: jest.fn()
}
const mockLogRepository = {
createQueryBuilder: jest.fn().mockReturnValue(mockQueryBuilder),
delete: jest.fn(),
find: jest.fn(),
findAndCount: jest.fn(),
findOne: jest.fn(),
findOneBy: jest.fn(),
save: jest.fn(),
@@ -59,7 +69,7 @@ describe('LogService', () => {
expect(service).toBeDefined();
})
it('create => shoule create a log entry', async () => {
it('create => should create a log entry', async () => {
const logDto = {
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
@@ -181,7 +191,7 @@ describe('LogService', () => {
})
})
it('findAll => should find all log entries', async () => {
it('findLogsWithCount => should find log entries with count', async () => {
const log = {
id: 'd685f1ca-28e0-40b9-8713-74467db12965',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
@@ -207,16 +217,84 @@ describe('LogService', () => {
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: []
tracks: [
{
"id": "4645ce0c-6fd7-432c-8089-777a7139cf7e",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KANE_KONA_20250628.kml",
"order": 1
},
{
"id": "5ce26898-a18b-46f4-b989-3fb7acdace08",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KONA_KANE_20250628.kml",
"order": 2
}
]
} as LogEntity;
const logs = [log]
const logs = [log];
const count = 1
const morePages = false
jest.spyOn(mockQueryBuilder, 'getManyAndCount').mockReturnValue([logs, count, morePages]);
jest.spyOn(mockLogRepository, 'find').mockReturnValue(logs);
const {entities, total, hasNextPage} = await service.findLogsWithCount();
const result = await service.findAll();
expect(entities).toEqual(logs);
expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages);
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
})
expect(result).toEqual(logs);
expect(mockLogRepository.find).toHaveBeenCalled();
it('findLogsWithTracks => should find log entries with tracks', async () => {
const log = {
id: 'd685f1ca-28e0-40b9-8713-74467db12965',
pilotId: '7c4bae6b-9ec4-469e-8e16-fcbf0b940936',
date: new Date('2026-02-21'),
aircraftMakeModel: 'Cessna 172M',
aircraftIdentity: 'N12345',
routeFrom: 'KMSP',
routeTo: 'KMSP',
durationOfFlight: 1,
singleEngineLand: 1,
simulatorAtd: null,
landingsDay: 1,
landingsNight: null,
groundTrainingReceived: null,
flightTrainingReceived: null,
crossCountry: 1,
night: null,
solo: 1,
pilotInCommand: 1,
instrumentActual: null,
instrumentSimulated: null,
instrumentApproaches: null,
instrumentHolds: null,
instrumentNavTrack: null,
notes: 'This is a test',
tracks: [
{
"id": "4645ce0c-6fd7-432c-8089-777a7139cf7e",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KANE_KONA_20250628.kml",
"order": 1
},
{
"id": "5ce26898-a18b-46f4-b989-3fb7acdace08",
"url": "http://127.0.0.1:10000/devstoreaccount1/tracks/0e7a641a-0264-47f0-88bf-7c296c842d8b/FlightAware_N70392_KONA_KANE_20250628.kml",
"order": 2
}
]
} as LogEntity;
const logs = [log];
const count = 1
const morePages = false
jest.spyOn(mockQueryBuilder, 'getManyAndCount').mockResolvedValue([logs, count, morePages])
const {entities, total, hasNextPage} = await service.findLogsWithTracks();
expect(entities).toEqual(logs);
expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages);
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
})
it('update => should update a log entry', async () => {

View File

@@ -7,6 +7,7 @@ import { PilotService } from '../pilot/pilot.service';
import { PilotEntity } from '../pilot/pilot.entity';
import { CustomError } from '../error/customError';
import { FileService } from '../file/file.service';
import { Logs } from './logs.interface';
@Injectable()
export class LogService {
@@ -17,18 +18,52 @@ export class LogService {
) {}
async find(id: string): Promise<LogEntity> {
const logEntity: LogEntity = await this.logRepository.findOne({
return await this.logRepository.findOne({
where: { id: id },
relations: ['pilot', 'tracks']
});
return logEntity;
}
async findAll(): Promise<LogEntity[]> {
return await this.logRepository.find({
relations: ['pilot', 'tracks']
});
async findLogsWithCount(skip?: number, take?: number): Promise<Logs> {
// const [entities, total] = await this.logRepository.findAndCount({
// take,
// skip,
// order: {
// date: 'DESC'
// },
// relations: ['pilot', 'tracks']
// })
const [entities, total] = await this.logRepository
.createQueryBuilder('logs')
.innerJoinAndSelect('logs.pilot', 'pilot')
.orderBy('logs.date', 'DESC')
.skip(skip)
.take(take)
.getManyAndCount()
return {
entities,
total,
hasNextPage: skip + take < total
}
}
async findLogsWithTracks(skip?: number, take?: number): Promise<Logs> {
const [entities, total] = await this.logRepository
.createQueryBuilder('logs')
.innerJoinAndSelect('logs.tracks', 'track')
.innerJoinAndSelect('logs.pilot', 'pilot')
.orderBy('logs.date', 'DESC')
.skip(skip)
.take(take)
.getManyAndCount();
return {
entities,
total,
hasNextPage: skip + take < total
}
}
async create(logDto: LogDto): Promise<LogDto> {

View File

@@ -0,0 +1,7 @@
import { LogEntity } from "src/log/log.entity";
export interface Logs {
entities: LogEntity[],
total: number,
hasNextPage: boolean
}

View File

@@ -7,6 +7,7 @@ import { LogService } from "../log/log.service";
import { LogEntity } from "../log/log.entity";
import { CustomError } from "../error/customError";
import { FileService } from "../file/file.service";
import { Logs } from "src/log/logs.interface";
@Injectable()
export class TrackService {

View File

@@ -0,0 +1 @@
...

View File

@@ -1,7 +1,7 @@
{
"name": "client",
"private": true,
"version": "2.0.2",
"version": "2.1.5",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -5,39 +5,68 @@ import { LogbookEntry } from "../logbook/LogbookEntry.interface";
import { initialState, reducer } from "./reducer";
import { useOidc } from "../../auth/oidcConfig";
import Alert from "../alert/Alert";
import { AxiosError, AxiosResponse } from "axios";
import httpClient from "../../httpClient/httpClient";
import { useBreakpoints } from "../../hooks/useBreakpoints/UseBreakpoints";
import { ScreenSize } from "../../enums/screenSize";
const Flights = () => {
const [state, dispatch] = useReducer(reducer, initialState);
const { logs, logsLoading } = useLogs();
const { isUserLoggedIn } = useOidc();
const { screenSize } = useBreakpoints();
const getFlights = async (pageIndex: number, pageSize: number) => {
try {
const response: AxiosResponse = await httpClient.get(`api/logs/flights`, {
params: {
skip: pageIndex,
take: pageSize
}
});
const flights: LogbookEntry[] = response.data.entities;
const hasMore: boolean = response.data.hasNextPage;
const total: number = response.data.total;
if (flights.length > 0) {
const newFlights: LogbookEntry[] = [...state.flights, ...flights]
const newPageIndex: number = state.pageIndex + flights.length;
dispatch({ type: 'SET_FLIGHTS', payload: { flights: newFlights, hasMoreFlights: hasMore, pageIndex: newPageIndex, totalFlights: total }})
if (!isUserLoggedIn && flights.length >= 5) {
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'A limited number of flights displayed. Sign in to view all flights.'}})
} else {
dispatch({ type: 'SET_ALERT', payload: undefined })
}
} else {
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'No flights found' }})
}
} catch (error) {
const axiosError = error as AxiosError;
dispatch({
type: 'SET_ALERT',
payload: { severity: 'error', message: `Loading of flights failed with the following message: ${axiosError.message}`}
});
} finally {
dispatch({ type: 'SET_IS_LOADING', payload: false })
}
}
const loadMore = () => {
getFlights(state.pageIndex, state.pageSize)
}
useEffect(() => {
const flights: LogbookEntry[] | undefined = logs?.filter((log: LogbookEntry) => {
if (log.tracks && log.tracks.length > 0) {
return log;
}
})
if (flights && flights.length > 0) {
dispatch({ type: 'SET_FLIGHTS', payload: flights})
if (!isUserLoggedIn && flights.length >= 5) {
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'A limited number of flights displayed. Sign in to view all flights.'}})
} else {
dispatch({ type: 'SET_ALERT', payload: undefined })
}
} else {
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'No flights found' }})
}
}, [logs])
getFlights(state.pageIndex, state.pageSize);
}, [])
return (
<div className='max-w-screen-lg mx-auto'>
<div className={`max-w-screen-lg mx-auto ${screenSize === ScreenSize.SM || screenSize === ScreenSize.MD? 'mr-4 ml-4' : ''}`}>
<div className='prose mt-5 mb-5'>
<h1>Flights</h1>
</div>
{!logsLoading && state.alert && (
{!state.isLoading && state.alert && (
<div>
<Alert
className='mb-5'
@@ -50,14 +79,21 @@ const Flights = () => {
</Alert>
</div>
)}
{!logsLoading &&
{!state.isLoading &&
<div>
<LogbookCard logs={state.flights} mode='flights' />
<div>
<LogbookCard logs={state.flights} mode='flights' />
</div>
{state.hasMoreFlights &&
<div className='flex items-center justify-center mb-5'>
<button className='btn btn-link' onClick={loadMore}>Load more</button>
</div>
}
</div>
}
{logsLoading && [...Array(5)].map((_element, index) => {
{state.isLoading && [...Array(5)].map((_element, index) => {
return (
<div className='card bg-base-100 border border-base-300 p-2 mb-7'>
<div className='card bg-base-100 border border-base-300 p-2 mb-5'>
<div className='card-body' key={index}>
<div className='skeleton h-10 w-[150px]' />
<div className='skeleton h-[350px]' />

View File

@@ -5,4 +5,8 @@ export interface FlightsState {
alert: Alert | undefined;
flights: LogbookEntry[];
isLoading: boolean;
hasMoreFlights: boolean;
pageIndex: number;
pageSize: number
totalFlights: number;
}

View File

@@ -5,13 +5,17 @@ import { FlightsState } from "./FlightsState.interface";
type Action =
| { type: 'SET_ALERT'; payload: Alert | undefined }
| { type: 'SET_FLIGHTS'; payload: LogbookEntry[] }
| { type: 'SET_FLIGHTS'; payload: { flights: LogbookEntry[], hasMoreFlights: boolean, pageIndex: number, totalFlights: number } }
| { type: 'SET_IS_LOADING'; payload: boolean }
export const initialState: FlightsState = {
alert: undefined,
flights: [],
isLoading: true
isLoading: true,
hasMoreFlights: true,
pageIndex: 0,
pageSize: 5,
totalFlights: 0
}
export const reducer = (
@@ -28,7 +32,10 @@ export const reducer = (
case 'SET_FLIGHTS': {
return {
...state,
flights: action.payload
flights: action.payload.flights,
hasMoreFlights: action.payload.hasMoreFlights,
pageIndex: action.payload.pageIndex,
totalFlights: action.payload.totalFlights
}
}
case 'SET_IS_LOADING': {

View File

@@ -12,19 +12,40 @@ import { UserRole } from '../../enums/userRole';
import { useBreakpoints } from '../../hooks/useBreakpoints/UseBreakpoints';
import { ScreenSize } from '../../enums/screenSize';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAdd, faEllipsisVertical, faPen, faEye, faTrash, faMapLocationDot } from '@fortawesome/free-solid-svg-icons'
import { CellContext, ColumnDef, flexRender, getCoreRowModel, getPaginationRowModel, HeaderContext, useReactTable } from '@tanstack/react-table';
import { faAdd, faEllipsisVertical, faPen, faEye, faTrash, faAngleLeft, faAngleRight, faAnglesLeft, faAnglesRight } from '@fortawesome/free-solid-svg-icons'
import { CellContext, ColumnDef, flexRender, getCoreRowModel, HeaderContext, PaginationState, useReactTable } from '@tanstack/react-table';
import { useLogbookContext } from '../../hooks/logbookContext/UseLogbookContext';
import LogbookDrawer from '../logbookDrawer/LogbookDrawer';
import Alert from '../alert/Alert';
import TrackMap from '../trackMap/TrackMap';
interface ActionsProps {
id: string;
}
const Logbook: React.FC<unknown> = () => {
const [state, dispatch] = useReducer(reducer, initialState);
const [columnVisibility, setColumnVisibility] = useState({})
const logbookContext = useLogbookContext()
const [columnVisibility, setColumnVisibility] = useState({});
const logbookContext = useLogbookContext();
const { isUserLoggedIn } = useOidc();
const { userRole } = useUserRole();
const { screenSize } = useBreakpoints();
const Actions = ({ id }: ActionsProps) => {
return (
<div className='dropdown dropdown-end'>
<div tabIndex={0} role='button' className='btn btn-ghost p-0'><FontAwesomeIcon icon={faEllipsisVertical} /></div>
<ul tabIndex={-1} className="dropdown-content menu bg-base-100 rounded-box w-52 p-2 shadow-sm border border-base-300 !z-[100]">
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onOpenCloseDrawer(FormMode.EDIT, id)}><FontAwesomeIcon icon={faPen} />Edit</a></li>
}
<li><a onClick={() => onOpenCloseDrawer(FormMode.VIEW, id)}><FontAwesomeIcon icon={faEye} />View</a></li>
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onDeleteLog(id)}><FontAwesomeIcon icon={faTrash} />Delete</a></li>
}
</ul>
</div>
)
}
const columnTotal = (info: HeaderContext<LogbookEntry, unknown>): number => {
const values: number[] = info.table.getPaginationRowModel().rows.map((row: any) => Number(row.getValue(info.column.id))).filter((value: any) => !Number.isNaN(value));
let total: number = 0;
@@ -116,18 +137,7 @@ const Logbook: React.FC<unknown> = () => {
},
cell: (info: CellContext<LogbookEntry, unknown>) => {
return (
<div className='dropdown dropdown-end'>
<div tabIndex={0} role='button' className='btn btn-ghost'><FontAwesomeIcon icon={faEllipsisVertical} /></div>
<ul tabIndex={-1} className="dropdown-content menu bg-base-100 rounded-box w-52 p-2 shadow-sm border border-base-300 !z-[100]">
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onOpenCloseDrawer(FormMode.EDIT, info.row.original.id)}><FontAwesomeIcon icon={faPen} />Edit</a></li>
}
<li><a onClick={() => onOpenCloseDrawer(FormMode.VIEW, info.row.original.id)}><FontAwesomeIcon icon={faEye} />View</a></li>
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onDeleteLog(info.row.original.id)}><FontAwesomeIcon icon={faTrash} />Delete</a></li>
}
</ul>
</div>
<Actions id={info.row.original.id} />
)
}
}
@@ -338,31 +348,51 @@ const Logbook: React.FC<unknown> = () => {
actions
];
const onPaginationChange = (updater: any) => {
const newPaginationState: PaginationState = typeof updater === 'function' ? updater(state.pagination) : updater;
dispatch({ type: 'SET_PAGINATION', payload: newPaginationState })
}
const table = useReactTable({
data: state.entries,
columns: columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
initialState: {
pagination: {
pageIndex: 0,
pageSize: 100
}
},
manualPagination: true,
onColumnVisibilityChange: setColumnVisibility,
onPaginationChange: onPaginationChange,
rowCount: state.totalEntries,
state: {
columnVisibility: columnVisibility,
pagination: state.pagination
}
});
const getLogbookEntries = async () => {
const {
firstPage,
getCanNextPage,
getCanPreviousPage,
getPageCount,
getState,
lastPage,
nextPage,
previousPage,
setPageIndex
} = table;
const getLogbookEntries = async (pageIndex: number, pageSize: number) => {
try {
dispatch({ type: 'SET_IS_LOADING', payload: true });
const response: AxiosResponse = await httpClient.get(`api/logs`);
const response: AxiosResponse = await httpClient.get(`api/logs`, {
params: {
skip: pageIndex * pageSize,
take: pageSize
}
});
if (response.data.length > 0) {
const entries: LogbookEntry[] = response.data;
if (response.data.entities.length > 0) {
const entries: LogbookEntry[] = response.data.entities;
const entryColumns: string[] = Object.keys(entries[0]);
const columnVisibility: {[key: string]: boolean} = {}
@@ -381,9 +411,9 @@ const Logbook: React.FC<unknown> = () => {
entries.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
setColumnVisibility(columnVisibility)
dispatch({ type: 'SET_ENTRIES', payload: entries });
dispatch({ type: 'SET_ENTRIES', payload: { entries: entries, totalEntries: response.data.total }});
if (!isUserLoggedIn && response.data.length >= 5) {
if (!isUserLoggedIn && response.data.entities.length >= 5) {
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'A limited number of log entries displayed. Sign in to view all log entries.'}})
} else {
dispatch({ type: 'SET_ALERT', payload: undefined})
@@ -448,7 +478,7 @@ const Logbook: React.FC<unknown> = () => {
payload: false
});
logbookContext.dispatch({ type: 'SET_SELECTED_LOG_ID', payload: '' })
await getLogbookEntries();
await getLogbookEntries(state.pagination?.pageIndex, state.pagination?.pageSize);
} catch (error) {
const axiosError = error as AxiosError;
@@ -468,19 +498,46 @@ const Logbook: React.FC<unknown> = () => {
});
};
const onRowsPerPageChanged = (event: any) => {
const newPaginationState: PaginationState = {
pageIndex: 0,
pageSize: event.target.value !== 'All' ? Number(event.target.value) : state.totalEntries
};
dispatch({ type: 'SET_PAGINATION', payload: newPaginationState })
}
useEffect(() => {
if (!logbookContext.state.isDrawerOpen) {
getLogbookEntries();
getLogbookEntries(state.pagination.pageIndex, state.pagination.pageSize);
}
}, [logbookContext.state.isDrawerOpen]);
}, [logbookContext.state.isDrawerOpen, state.pagination.pageIndex, state.pagination.pageSize]);
useEffect(() => {
const pages: number[] = [];
if (state.pagination?.pageSize) {
const totalPages = getPageCount();
for(let i = 0; i < totalPages; i++) {
pages.push(i + 1)
}
}
dispatch({ type: 'SET_PAGES', payload: pages })
}, [state.totalEntries, state.pagination?.pageSize])
useEffect(() => {
console.log(state.alert)
}, [state.alert])
return (
<>
<div className='mr-10 ml-10 grid grid-cols-12'>
<div className='prose max-w-none col-span-10 mt-5 mb-5'>
<div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}>
<div className='prose max-w-none col-span-6 mt-5 mb-5'>
<h1>Logbook</h1>
</div>
<div className='col-span-2 justify-self-end self-center'>
<div className='col-span-6 justify-self-end self-center'>
{userRole === UserRole.WRITE &&
<button className='btn btn-primary'
onClick={() => onOpenCloseDrawer(FormMode.ADD)}
@@ -497,15 +554,31 @@ const Logbook: React.FC<unknown> = () => {
onClose={() =>
dispatch({ type: 'SET_ALERT', payload: undefined })
}
severity={'info'}
severity={state.alert.severity}
>
{state.alert.message}
</Alert>
</div>
)}
{!state.isLoading && state.entries.length > 0 && screenSize !== ScreenSize.SM && (
<div className='col-span-12 p-5 bg-base-100 border border-base-100 rounded-lg'>
<div className='overflow-x-auto'>
{!state.isLoading && state.entries.length > 0 && screenSize !== ScreenSize.SM && screenSize !== ScreenSize.MD && (
<div className='col-span-12 pr-5 pb-5 pl-5 bg-base-100 border border-base-100 rounded-lg'>
<div className='overflow-x-auto mb-5'>
<div className='col-span-12 justify-self-end self-center mt-1 mr-1 mb-2'>
<label className='select select-sm select-ghost'>
<span className='label'>Rows per page</span>
<select
defaultValue={1}
onChange={onRowsPerPageChanged}
value={state.pagination?.pageSize}
>
<option value={10}>10</option>
<option value={25}>25</option>
<option value={50}>50</option>
<option value={state.totalEntries}>All</option>
</select>
</label>
</div>
<table className='table min-w-full h-auto table-auto w-full'>
<thead className='bg-base-200'>
{table.getHeaderGroups().map((headerGroup, headerGroupIndex) => (
@@ -591,10 +664,92 @@ const Logbook: React.FC<unknown> = () => {
</thead>
</table>
</div>
{state.pagination.pageSize !== state.totalEntries &&
<div className='col-span-12 justify-self-center self-center'>
<div className='join'>
<button
className='join-item btn btn-sm'
onClick={firstPage}
>
<FontAwesomeIcon icon={faAnglesLeft} />
</button>
<button
className='join-item btn btn-sm'
onClick={previousPage}
disabled={!getCanPreviousPage()}
>
<FontAwesomeIcon icon={faAngleLeft} />
</button>
{state.pages.map((page, index) => {
return (
<button
className={`join-item btn btn-sm ${getState().pagination.pageIndex === index ? 'btn-active' : ''}`}
onClick={() => setPageIndex(index)}
>
{page}
</button>
)
})}
<button
className='join-item btn btn-sm'
onClick={() => nextPage()}
disabled={!getCanNextPage()}
>
<FontAwesomeIcon icon={faAngleRight} />
</button>
<button
className='join-item btn btn-sm'
onClick={lastPage}
>
<FontAwesomeIcon icon={faAnglesRight} />
</button>
</div>
</div>
}
</div>
)}
{state.entries.length > 0 && screenSize === ScreenSize.SM &&
<LogbookCard logs={state.entries} onDelete={onDeleteLog} mode='logbook' onOpenCloseForm={onOpenCloseDrawer} />
<div className='col-span-12'>
<>
{table.getRowModel().rows.map((row) => {
const date = new Date(row.original.date.replace('Z', ''));
const formattedDate: string = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
return (
<div className='card bg-base-100 border border-base-300 mb-5'>
<div className={`card-body ${screenSize === ScreenSize.SM || screenSize === ScreenSize.MD ? 'p-4' : ''}`} key={row.id}>
<div className={`grid grid-cols-12 gap-3`}>
<>
<div className='col-span-8'>
<h2 className='card-title font-bold text-2xl'>{formattedDate}</h2>
</div>
<div className='col-span-4 justify-self-end self-center'>
<Actions id={row.original.id} />
</div>
{row.getVisibleCells().map((cell) => {
return (
<>
{cell.column.columnDef.header !== 'Actions' && cell.column.columnDef.header !== 'Date' && cell.column.columnDef.header !== 'Pilot' &&
<>
<div className='col-span-8 font-bold'>
<span>{cell.getContext().column.columnDef.header?.toString()}</span>
</div>
<div className='col-span-4'>
<span>{flexRender(cell.column.columnDef.cell, cell.getContext())}</span>
</div>
</>
}
</>
)
})}
</>
</div>
</div>
</div>
)
})}
</>
</div>
}
{state.isLoading && !state.alert && (
<div className='col-span-12 p-5 bg-base-100 border border-base-100 rounded-lg'>

View File

@@ -1,4 +1,4 @@
import { ColumnDef } from '@tanstack/react-table';
import { ColumnDef, PaginationState } from '@tanstack/react-table';
import { FormMode } from '../../enums/formMode';
import { Alert } from '../../interfaces/Alert.interface';
import { LogbookEntry } from './LogbookEntry.interface';
@@ -10,4 +10,7 @@ export interface LogbookState {
isConfirmDialogLoading: boolean;
isConfirmDialogOpen: boolean;
isLoading: boolean;
pages: number[];
pagination: PaginationState;
totalEntries: number;
}

View File

@@ -1,4 +1,4 @@
import { ColumnDef } from '@tanstack/react-table';
import { ColumnDef, PaginationState } from '@tanstack/react-table';
import { FormMode } from '../../enums/formMode';
import { Alert } from '../../interfaces/Alert.interface';
import { LogbookEntry } from './LogbookEntry.interface';
@@ -7,11 +7,12 @@ import { LogbookState } from './LogbookState.interface';
type Action =
| { type: 'SET_COLUMNS'; payload: ColumnDef<LogbookEntry>[] }
| { type: 'SET_IS_CONFIRMATION_DIALOG_OPEN'; payload: boolean }
| { type: 'SET_ENTRIES'; payload: LogbookEntry[] }
| { type: 'SET_ENTRIES'; payload: { entries: LogbookEntry[], totalEntries: number } }
| { type: 'SET_ALERT'; payload: Alert | undefined }
| { type: 'SET_IS_CONFIRMATION_DIALOG_LOADING'; payload: boolean }
| { type: 'SET_IS_LOADING'; payload: boolean };
| { type: 'SET_IS_LOADING'; payload: boolean }
| { type: 'SET_PAGES'; payload: number[] }
| { type: 'SET_PAGINATION'; payload: PaginationState };
export const initialState: LogbookState = {
alert: undefined,
@@ -19,7 +20,13 @@ export const initialState: LogbookState = {
entries: [],
isConfirmDialogLoading: false,
isConfirmDialogOpen: false,
isLoading: false
isLoading: false,
pages: [],
pagination: {
pageIndex: 0,
pageSize: 10
},
totalEntries: 0
};
export const reducer = (
@@ -42,7 +49,8 @@ export const reducer = (
case 'SET_ENTRIES': {
return {
...state,
entries: action.payload
entries: action.payload.entries,
totalEntries: action.payload.totalEntries
};
}
case 'SET_ALERT': {
@@ -63,6 +71,18 @@ export const reducer = (
isLoading: action.payload
};
}
case 'SET_PAGES': {
return {
...state,
pages: action.payload
}
}
case 'SET_PAGINATION': {
return {
...state,
pagination: action.payload
}
}
default: {
return state;
}

View File

@@ -1,7 +1,12 @@
import { LogbookCardProps } from "./LogbookCardProps.interface";
import TrackMap from "../trackMap/TrackMap";
import { useBreakpoints } from "../../hooks/useBreakpoints/UseBreakpoints";
import { ScreenSize } from "../../enums/screenSize";
import { useEffect } from "react";
const LogbookCard = ({ logs, mode, onDelete, onOpenCloseForm }: LogbookCardProps) => {
const { screenSize } = useBreakpoints();
return (
<div>
{logs.map((log) => {
@@ -9,8 +14,8 @@ const LogbookCard = ({ logs, mode, onDelete, onOpenCloseForm }: LogbookCardProps
const formattedDate: string = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
return (
<div className='card bg-base-100 border border-base-300 p-2'>
<div className='card-body' key={log.id}>
<div className='card bg-base-100 border border-base-300 p-2 mb-5'>
<div className={`card-body ${screenSize === ScreenSize.SM || screenSize === ScreenSize.MD ? 'p-2' : ''}`} key={log.id}>
<h2 className='card-title font-bold text-2xl'>{formattedDate}</h2>
<div>
{mode === 'flights' && log.tracks && log.tracks.length > 0 &&
@@ -24,10 +29,10 @@ const LogbookCard = ({ logs, mode, onDelete, onOpenCloseForm }: LogbookCardProps
}
</div>
<div className='collapse collapse-arrow bg-base-100 border-base-300 border'>
<input type='radio' name='details-accordion' />
<input type='checkbox' />
<div className='collapse-title font-semibold'>Details</div>
<div className='collapse-content'>
<div className='grid grid-cols-12 gap-3 mr-[30%] ml-[30%] mt-4 mb-4'>
<div className={`grid grid-cols-12 gap-3 ${screenSize === ScreenSize.SM || screenSize === ScreenSize.MD ? 'mr-[5%] ml-[5%]' : 'mr-[30%] ml-[30%]'} mt-4 mb-4`}>
<div className='col-span-6 font-bold'>
<span>Aircraft Make and Model</span>
</div>

View File

@@ -17,11 +17,31 @@ import { Pilot } from './Pilot.interface';
import Alert from '../alert/Alert';
import { useOidc } from '../../auth/oidcConfig';
interface ActionsProps {
id: string;
}
const Pilots: React.FC<unknown> = () => {
const [state, dispatch] = useReducer(reducer, initialState);
const { userRole } = useUserRole();
const { screenSize } = useBreakpoints();
const { isUserLoggedIn } = useOidc();
const Actions = ({ id }: ActionsProps) => {
return (
<div className='dropdown dropdown-end'>
<div tabIndex={0} role='button' className='btn btn-ghost'><FontAwesomeIcon icon={faEllipsisVertical} /></div>
<ul tabIndex={-1} className="dropdown-content menu bg-base-100 rounded-box z-1 w-52 p-2 shadow-sm border border-base-300">
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onOpenClosePilotForm(FormMode.EDIT, id)}><FontAwesomeIcon icon={faPen} />Edit</a></li>
}
<li><a onClick={() => onOpenClosePilotForm(FormMode.VIEW, id)}><FontAwesomeIcon icon={faEye} />View</a></li>
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onDeletePilot(id)}><FontAwesomeIcon icon={faTrash} />Delete</a></li>
}
</ul>
</div>
)
}
const getPilots = async () => {
try {
@@ -134,18 +154,7 @@ const Pilots: React.FC<unknown> = () => {
},
cell: (info: CellContext<Pilot, unknown>) => {
return (
<div className='dropdown dropdown-end'>
<div tabIndex={0} role='button' className='btn btn-ghost'><FontAwesomeIcon icon={faEllipsisVertical} /></div>
<ul tabIndex={-1} className="dropdown-content menu bg-base-100 rounded-box z-1 w-52 p-2 shadow-sm border border-base-300">
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onOpenClosePilotForm(FormMode.EDIT, info.row.original.id)}><FontAwesomeIcon icon={faPen} />Edit</a></li>
}
<li><a onClick={() => onOpenClosePilotForm(FormMode.VIEW, info.row.original.id)}><FontAwesomeIcon icon={faEye} />View</a></li>
{isUserLoggedIn && userRole === UserRole.WRITE &&
<li><a onClick={() => onDeletePilot(info.row.original.id)}><FontAwesomeIcon icon={faTrash} />Delete</a></li>
}
</ul>
</div>
<Actions id={info.row.original.id} />
)
}
}
@@ -172,11 +181,11 @@ const Pilots: React.FC<unknown> = () => {
return (
<>
<div className='mr-10 ml-10 grid grid-cols-12'>
<div className='prose max-w-none col-span-10 mt-5 mb-5' >
<div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}>
<div className='prose max-w-none col-span-6 mt-5 mb-5' >
<h1>Pilots</h1>
</div>
<div className='col-span-2 justify-self-end self-center'>
<div className='col-span-6 justify-self-end self-center'>
{!state.isLoading && userRole === UserRole.WRITE &&
<button
className='btn btn-primary'
@@ -259,9 +268,40 @@ const Pilots: React.FC<unknown> = () => {
</table>
</div>
}
{/* {state.pilots.length > 0 && screenSize === ScreenSize.SM &&
<PilotCard pilots={state.pilots} onDelete={onDeletePilot} onOpenCloseForm={onOpenClosePilotForm} />
} */}
{state.pilots.length > 0 && screenSize === ScreenSize.SM &&
<div className='col-span-12'>
<>
{table.getRowModel().rows.map((row) => {
return (
<div className='card bg-base-100 border border-base-300 mb-5'>
<div className={`card-body ${screenSize === ScreenSize.SM || screenSize === ScreenSize.MD ? 'p-4' : ''}`} key={row.id}>
<div className={`grid grid-cols-12 gap-3`}>
<>
{row.getVisibleCells().map((cell) => {
return (
<>
{cell.column.columnDef.header !== 'Actions' &&
<>
<div className='col-span-10 self-center'>
<span>{flexRender(cell.column.columnDef.cell, cell.getContext())}</span>
</div>
<div className='col-span-2'>
<Actions id={row.original.id} />
</div>
</>
}
</>
)
})}
</>
</div>
</div>
</div>
)
})}
</>
</div>
}
</div>
{state.isFormOpen && (
<PilotForm

View File

@@ -13,6 +13,7 @@ export default defineConfig({
strictPort: true
},
server: {
host: true,
port: 8080,
proxy: {
'/api': {

View File

@@ -3,15 +3,30 @@ version: '3.8'
services:
azurite:
container_name: azurite-flying
image: mcr.microsoft.com/azure-storage/azurite
image: mcr.microsoft.com/azure-storage/azurite
ports:
- '10000:10000'
- '10001:10001'
- '10002:10002'
command: 'azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --loose --skipApiVersionCheck'
healthcheck:
test: ["CMD", "nc", "-z", "127.0.0.1", "10000"]
volumes:
- ./azurite-data:/data
seed:
image: mcr.microsoft.com/azure-cli
depends_on:
azurite:
condition: service_healthy
volumes:
- ./seed-data:/data
entrypoint: >
sh -c "
az storage container create --name mycontainer --connection-string 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;' &&
az storage blob upload-batch --destination mycontainer --source /data --connection-string 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;'
"
restore:
container_name: restore
image: litestream/litestream:0.3.13
@@ -51,6 +66,7 @@ services:
condition: service_started
volumes:
# azurite-data:
azurite-data:
backup:
data:
data:
seed-data:

View File

@@ -1,4 +1,5 @@
# Terraform
.terraform/*
*.tfstate
*.tfstate.*
*.tfstate.*
.DS_Store

8
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@noahspan/flying",
"version": "2.0.0-alpha-3",
"version": "2.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@noahspan/flying",
"version": "2.0.0-alpha-3",
"version": "2.0.2",
"workspaces": [
"api",
"client",
@@ -26,7 +26,7 @@
}
},
"api": {
"version": "2.0.0-alpha-3",
"version": "2.0.2",
"license": "UNLICENSED",
"dependencies": {
"@azure/storage-blob": "^12.27.0",
@@ -81,7 +81,7 @@
}
},
"client": {
"version": "2.0.0-alpha-3",
"version": "2.0.2",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^7.1.0",
"@fortawesome/free-solid-svg-icons": "^7.1.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@noahspan/flying",
"version": "2.0.2",
"version": "2.1.5",
"scripts": {
"start": "node api/dist/main",
"format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"",