Compare commits
78 Commits
115-add-lo
...
7d88890c3c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d88890c3c | |||
| a54105e8e5 | |||
| b8ec5be269 | |||
| 875b8a0d90 | |||
| 81c589001b | |||
| baedfc1675 | |||
| 4eccf8e83c | |||
| a4778d29be | |||
| 5c04870d37 | |||
| c81b514ae8 | |||
| 5a07318527 | |||
| 99e5d162ef | |||
| 755c429d04 | |||
| 6ea7326a57 | |||
| e3f385d0a4 | |||
| f33a9982cc | |||
| 100fd78551 | |||
| a87d35a5e4 | |||
| 0c4fe29553 | |||
| 03c4dacd99 | |||
| 1ed1a6c48a | |||
| 4c77ebc1d6 | |||
| 650ea704aa | |||
| d51e95f59e | |||
| 0806e114e1 | |||
| fc716c664b | |||
| 5a1e24a1ce | |||
| b93327f840 | |||
| bbcf6cb3de | |||
| 344d4f5625 | |||
| 22fbf7615b | |||
| 5a84c221d6 | |||
| 13f1e86e72 | |||
| 25f935171e | |||
| 92fec88ad1 | |||
| 833b1b107c | |||
| 674ae1cf3c | |||
| f0b61703b7 | |||
| c152f06b63 | |||
| 3c9d26e085 | |||
| 12b4f1a65b | |||
| ae03c0200c | |||
| b9668a9d48 | |||
| 19041e3967 | |||
| 5729c72fe1 | |||
| 8760998c78 | |||
| 61f8dc0e1e | |||
| cc7b694fd5 | |||
| 9553c2ec34 | |||
| 0a8c461e3d | |||
| 931d56e753 | |||
| 7ebf78f348 | |||
| 95e2d59abc | |||
| 945081dd7c | |||
| 7213dcf9e1 | |||
| a13ffeaebd | |||
| 620b258e94 | |||
| cc21a43825 | |||
| 112b56080c | |||
| 92f97a93bf | |||
| 4f6e9a072c | |||
| 0c8e4b9fba | |||
| 63d2765d19 | |||
| da76000b8d | |||
| b789e1264a | |||
| 9cc86fe79f | |||
| ee0e10072c | |||
| 899f92f342 | |||
| 5c4245179f | |||
| a7a9f01fd9 | |||
| a367b517db | |||
| fd514e4c8b | |||
| d8513e6dd0 | |||
| 5de5a165da | |||
| 26c46fe6e8 | |||
| 04e5e3e16b | |||
| 0305b424eb | |||
| 8652544471 |
@@ -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' }}
|
||||
@@ -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
|
||||
@@ -24,4 +33,6 @@ jobs:
|
||||
api:
|
||||
- 'api/**'
|
||||
client:
|
||||
- 'client/**'
|
||||
- 'client/**'
|
||||
infrastructure:
|
||||
- 'infrastructure/**'
|
||||
44
.gitea/workflows/deploy.yaml
Normal file
44
.gitea/workflows/deploy.yaml
Normal 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 }}
|
||||
@@ -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 }}
|
||||
@@ -23,8 +23,8 @@ jobs:
|
||||
name: deploy
|
||||
needs:
|
||||
- changes
|
||||
- build
|
||||
uses: ./.github/workflows/deploy.yaml
|
||||
- build-and-test
|
||||
uses: ./.gitea/workflows/deploy.yaml
|
||||
with:
|
||||
app_name: flying
|
||||
environment_name: test
|
||||
19
.gitea/workflows/pull_request.yaml
Normal file
19
.gitea/workflows/pull_request.yaml
Normal 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
|
||||
@@ -5,9 +5,9 @@ on:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build
|
||||
uses: ./.github/workflows/build_and_test.yaml
|
||||
build-and-test:
|
||||
name: build-and-test
|
||||
uses: ./.gitea/workflows/build_and_test.yaml
|
||||
with:
|
||||
environment_name: prod
|
||||
version_number: ${{ github.ref_name }}
|
||||
@@ -16,8 +16,8 @@ jobs:
|
||||
deploy:
|
||||
name: deploy
|
||||
needs:
|
||||
- build
|
||||
uses: ./.github/workflows/deploy.yaml
|
||||
- build-and-test
|
||||
uses: ./.gitea/workflows/deploy.yaml
|
||||
with:
|
||||
app_name: flying
|
||||
environment_name: prod
|
||||
44
.gitea/workflows/terraform.yaml
Normal file
44
.gitea/workflows/terraform.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: 'Terraform'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment_name:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
terraform:
|
||||
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
|
||||
run: |
|
||||
terraform -chdir=./infrastructure init -reconfigure -backend-config="./backend/${{ inputs.environment_name }}.backend.tfvars" -input=false
|
||||
|
||||
- name: Terraform plan
|
||||
run: |
|
||||
terraform -chdir=./infrastructure plan -no-color -input=false
|
||||
|
||||
# - name: Terraform apply
|
||||
# if: ${{ github.event_name != 'pull_request' }}
|
||||
# run: |
|
||||
# terraform -chdir=./infrastructure apply -no-color -input=false
|
||||
|
||||
35
.github/workflows/deploy.yaml
vendored
35
.github/workflows/deploy.yaml
vendored
@@ -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 }}
|
||||
19
.github/workflows/pull_request.yaml
vendored
19
.github/workflows/pull_request.yaml
vendored
@@ -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
|
||||
24
README.md
24
README.md
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# Flying API
|
||||
|
||||
An API for the Flying app.
|
||||
An API for the Flying app.
|
||||
...
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "2.0.2",
|
||||
"version": "2.1.5",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
|
||||
@@ -40,7 +40,7 @@ export class LogInterceptor implements NestInterceptor {
|
||||
|
||||
if (jwtPayload[rolesKeyName].includes('Flying.Read')) {
|
||||
if (data.entities) {
|
||||
const logs = data.entities.map((entity) => limitData(data.entities));
|
||||
const logs = data.entities.map((entity) => limitData(entity));
|
||||
|
||||
return {
|
||||
entities: logs,
|
||||
@@ -62,8 +62,8 @@ export class LogInterceptor implements NestInterceptor {
|
||||
const logs = publicData.slice(0, 5)
|
||||
|
||||
return {
|
||||
entities: publicData,
|
||||
total: data.total,
|
||||
entities: logs,
|
||||
total: logs.length,
|
||||
hasNextPage: false
|
||||
};
|
||||
} else {
|
||||
@@ -71,7 +71,6 @@ export class LogInterceptor implements NestInterceptor {
|
||||
|
||||
return publicData
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@@ -19,6 +19,8 @@ describe('LogService', () => {
|
||||
createQueryBuilder: jest.fn().mockReturnThis(),
|
||||
innerJoinAndSelect: jest.fn().mockReturnThis(),
|
||||
orderBy: jest.fn().mockReturnThis(),
|
||||
skip: jest.fn().mockReturnThis(),
|
||||
take: jest.fn().mockReturnThis(),
|
||||
getManyAndCount: jest.fn()
|
||||
}
|
||||
|
||||
@@ -232,14 +234,14 @@ describe('LogService', () => {
|
||||
const count = 1
|
||||
const morePages = false
|
||||
|
||||
jest.spyOn(mockLogRepository, 'findAndCount').mockReturnValue([logs, count, morePages]);
|
||||
jest.spyOn(mockQueryBuilder, 'getManyAndCount').mockReturnValue([logs, count, morePages]);
|
||||
|
||||
const {entities, total, hasNextPage} = await service.findLogsWithCount();
|
||||
|
||||
expect(entities).toEqual(logs);
|
||||
expect(count).toEqual(total);
|
||||
expect(hasNextPage).toEqual(morePages);
|
||||
expect(mockLogRepository.findAndCount).toHaveBeenCalled();
|
||||
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
|
||||
})
|
||||
|
||||
it('findLogsWithTracks => should find log entries with tracks', async () => {
|
||||
@@ -292,7 +294,7 @@ describe('LogService', () => {
|
||||
expect(entities).toEqual(logs);
|
||||
expect(count).toEqual(total);
|
||||
expect(hasNextPage).toEqual(morePages);
|
||||
expect(mockLogRepository.findAndCount).toHaveBeenCalled();
|
||||
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
|
||||
})
|
||||
|
||||
it('update => should update a log entry', async () => {
|
||||
|
||||
@@ -25,11 +25,22 @@ export class LogService {
|
||||
}
|
||||
|
||||
async findLogsWithCount(skip?: number, take?: number): Promise<Logs> {
|
||||
const [entities, total] = await this.logRepository.findAndCount({
|
||||
take,
|
||||
skip,
|
||||
relations: ['pilot', 'tracks']
|
||||
})
|
||||
// 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,
|
||||
@@ -43,7 +54,9 @@ export class LogService {
|
||||
.createQueryBuilder('logs')
|
||||
.innerJoinAndSelect('logs.tracks', 'track')
|
||||
.innerJoinAndSelect('logs.pilot', 'pilot')
|
||||
.orderBy('date')
|
||||
.orderBy('logs.date', 'DESC')
|
||||
.skip(skip)
|
||||
.take(take)
|
||||
.getManyAndCount();
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
...
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "2.0.2",
|
||||
"version": "2.1.5",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -380,13 +380,13 @@ const Logbook: React.FC<unknown> = () => {
|
||||
setPageIndex
|
||||
} = table;
|
||||
|
||||
const getLogbookEntries = async (pageIndex?: number, pageSize?: number) => {
|
||||
const getLogbookEntries = async (pageIndex: number, pageSize: number) => {
|
||||
try {
|
||||
dispatch({ type: 'SET_IS_LOADING', payload: true });
|
||||
|
||||
const response: AxiosResponse = await httpClient.get(`api/logs`, {
|
||||
params: {
|
||||
skip: pageIndex,
|
||||
skip: pageIndex * pageSize,
|
||||
take: pageSize
|
||||
}
|
||||
});
|
||||
@@ -413,7 +413,7 @@ const Logbook: React.FC<unknown> = () => {
|
||||
setColumnVisibility(columnVisibility)
|
||||
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})
|
||||
@@ -527,6 +527,10 @@ const Logbook: React.FC<unknown> = () => {
|
||||
dispatch({ type: 'SET_PAGES', payload: pages })
|
||||
}, [state.totalEntries, state.pagination?.pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
console.log(state.alert)
|
||||
}, [state.alert])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}>
|
||||
@@ -550,14 +554,14 @@ 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 && 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='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'>
|
||||
@@ -569,7 +573,7 @@ const Logbook: React.FC<unknown> = () => {
|
||||
>
|
||||
<option value={10}>10</option>
|
||||
<option value={25}>25</option>
|
||||
<option value={3}>50</option>
|
||||
<option value={50}>50</option>
|
||||
<option value={state.totalEntries}>All</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,6 +13,7 @@ export default defineConfig({
|
||||
strictPort: true
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
port: 8080,
|
||||
proxy: {
|
||||
'/api': {
|
||||
|
||||
@@ -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:
|
||||
3
infrastructure/.gitignore
vendored
3
infrastructure/.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
# Terraform
|
||||
.terraform/*
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
*.tfstate.*
|
||||
.DS_Store
|
||||
1
infrastructure/backend/prod.backend.tfvars
Normal file
1
infrastructure/backend/prod.backend.tfvars
Normal file
@@ -0,0 +1 @@
|
||||
container_name = "tfstate-flying-prod"
|
||||
1
infrastructure/backend/test.backend.tfvars
Normal file
1
infrastructure/backend/test.backend.tfvars
Normal file
@@ -0,0 +1 @@
|
||||
container_name = "tfstate-flying-test"
|
||||
@@ -16,12 +16,9 @@ terraform {
|
||||
}
|
||||
}
|
||||
|
||||
backend "remote" {
|
||||
hostname = "app.terraform.io"
|
||||
organization = "noahspan"
|
||||
|
||||
workspaces {
|
||||
prefix = "noahspan-"
|
||||
}
|
||||
backend "azurerm" {
|
||||
resource_group_name = "noahspan"
|
||||
storage_account_name = "noahspanterraform"
|
||||
key = "terraform.tfstate"
|
||||
}
|
||||
}
|
||||
@@ -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\"",
|
||||
|
||||
Reference in New Issue
Block a user