Compare commits

..

7 Commits

Author SHA1 Message Date
f07f362ad5 fixing track parsing error for new log entries 2025-05-06 12:56:11 -05:00
f15008a8db Feature/73 add flights page (#78)
* adding flights page

* adding flights page

* adding flights page

* adding flights page

* removing unused dependencies

* adding flights page
2025-03-23 11:48:41 -05:00
514f970233 Feature/73 add flights page (#77)
* adding flights page

* adding flights page

* adding flights page

* adding flights page

* removing unused dependencies
2025-03-23 11:30:32 -05:00
db94838249 Feature/73 add flights page (#76)
* adding flights page

* adding flights page

* adding flights page

* adding flights page
2025-03-23 11:24:31 -05:00
f76244d00c Feature/73 add flights page (#75)
* adding flights page

* adding flights page

* adding flights page
2025-03-23 11:09:25 -05:00
98f50641c8 adding flights page (#74)
* adding flights page

* adding flights page
2025-03-23 10:29:38 -05:00
0f1e303c27 Feature/71 add leaflet to view tracks drawer (#72)
* adding leaflet

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper
2025-03-22 23:42:08 -05:00
20 changed files with 161 additions and 78 deletions

View File

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

1
app/.gitignore vendored
View File

@@ -1,5 +1,4 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*

View File

@@ -1,7 +1,7 @@
{
"name": "app",
"private": true,
"version": "1.2.0",
"version": "1.3.0",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,9 +16,7 @@
"@noahspan/noahspan-components": "1.6.0",
"axios": "^1.7.2",
"dotenv": "^16.4.7",
"install": "^0.13.0",
"leaflet": "^1.9.4",
"pure-react-carousel": "^1.32.0",
"react": "19.0.0-rc.1",
"react-dom": "19.0.0-rc.1",
"react-hook-form": "^7.51.4",

BIN
app/public/layers-2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
app/public/layers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
app/public/marker-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

View File

@@ -1,6 +1,7 @@
import { Navigate, Route, Routes } from 'react-router-dom';
import Pilots from './components/pilots/Pilots';
import Flights from './components/flights/Flights';
import Logbook from './components/logbook/Logbook';
import Pilots from './components/pilots/Pilots';
import SiteNav from './components/siteNav/SiteNav';
import { useIsAuthenticated } from '@azure/msal-react';
@@ -19,8 +20,10 @@ const App = () => {
<>
<SiteNav />
<Routes>
<Route path='/' element={<Flights />} />
<Route path="/logbook" element={<Logbook />} />
<Route path="/pilots" element={<Pilots />} />
<Route path="/" element={<Logbook />} />
</Routes>
</>
);

View File

@@ -0,0 +1,48 @@
import { Box, Container, Grid, Spinner } from "@noahspan/noahspan-components";
import LogbookCard from "../logbookCard/LogbookCard";
import { useEffect, useState } from "react";
import { useLogs } from "../../hooks/logs/UseLogs";
import { ILogbookEntry } from "../logbook/ILogbookEntry";
const Flights = () => {
const [flights, setFlights] = useState<ILogbookEntry[]>([]);
const { logs, isLoading } = useLogs();
useEffect(() => {
const flights: ILogbookEntry[] | undefined = logs?.filter((log: ILogbookEntry) => {
if (log.tracks && JSON.parse(log.tracks).length > 0) {
return log;
}
})
if (flights && flights.length > 0) {
setFlights(flights)
}
}, [logs])
return (
<Container>
<Box sx={{ margin: '20px' }}>
<Grid container spacing={2}>
{isLoading &&
<>
<Grid display="flex" justifyContent="center" size={12}>
<Spinner />
</Grid>
<Grid display="flex" justifyContent="center" size={12}>
Loading...
</Grid>
</>
}
{!isLoading &&
<Grid size={12}>
<LogbookCard logs={flights} mode='flights' />
</Grid>
}
</Grid>
</Box>
</Container>
)
}
export default Flights;

View File

@@ -35,10 +35,7 @@ const LogTrackMaps = ({ rowKey, trackUrls }: LogTrackMapsProps) => {
config
);
const kml = new DOMParser().parseFromString(response.data, 'text/xml')
// const converted = toGeoJSON.kml(dom);
// rewind(converted, false);
convertedTracks.push(kml);
}

View File

@@ -1,5 +1,5 @@
import { useEffect, useReducer } from "react";
import { Button, Drawer, Grid, Icon, IconButton, IconName, TextField, theme, Typography, useMediaQuery } from "@noahspan/noahspan-components";
import { Button, Drawer, Grid, Icon, IconButton, IconName, Spinner, TextField, theme, Typography, useMediaQuery } from "@noahspan/noahspan-components";
import { useHttpClient } from "../../hooks/httpClient/UseHttpClient";
import { AxiosInstance, AxiosResponse } from "axios";
import { useAccessToken } from "../../hooks/accessToken/UseAcessToken";
@@ -56,7 +56,7 @@ const LogTracks = ({ isDrawerOpen, mode, onOpenClose, selectedRowKey }: LogTrack
const uploadResponse: AxiosResponse = await httpClient.post(`api/logs/log/${selectedRowKey}/track`, formData, formDataConfig);
const uploadUrl = uploadResponse.data.url;
const log = await getLog();
const tracks: string[] = JSON.parse(log.tracks!);
const tracks: string[] = log.tracks ? JSON.parse(log.tracks!) : [];
tracks.push(uploadUrl)
log.tracks = JSON.stringify(tracks);
@@ -132,13 +132,23 @@ const LogTracks = ({ isDrawerOpen, mode, onOpenClose, selectedRowKey }: LogTrack
<Typography variant="h4">{`${mode.toString().toLowerCase().charAt(0).toUpperCase() + mode.toString().slice(1).toLowerCase()} Tracks`}</Typography>
</Grid>
<Grid display="flex" justifyContent="right" size={1}>
<IconButton onClick={onCancel}>
<IconButton disabled={state.isLoading ? true : false} onClick={onCancel}>
<Icon iconName={IconName.XMARK} />
</IconButton>
</Grid>
{mode === FormMode.EDIT &&
<>
{state.tracks.length > 0 && state.tracks.map((track, index) => {
{state.isLoading &&
<>
<Grid display="flex" justifyContent="center" size={12}>
<Spinner />
</Grid>
<Grid display="flex" justifyContent="center" size={12}>
Loading...
</Grid>
</>
}
{!state.isLoading && state.tracks.length > 0 && state.tracks.map((track, index) => {
const trackSplit = track.split('/')
const filename = trackSplit[trackSplit.length - 1];
@@ -155,17 +165,18 @@ const LogTracks = ({ isDrawerOpen, mode, onOpenClose, selectedRowKey }: LogTrack
})}
<Grid display='flex' gap={2} justifyContent='right' size={12}>
<Button
disabled={state.isLoading ? true : false}
startIcon={<Icon iconName={IconName.XMARK} />}
variant="outlined"
onClick={onCancel}
size="small"
>
{mode.toString() !== FormMode.VIEW ? 'Cancel' : 'Close'}
Close
</Button>
{mode.toString() !== FormMode.VIEW && (
<Button
component='label'
loading={state.isLoading}
disabled={state.isLoading ? true : false}
startIcon={<Icon iconName={IconName.UPLOAD} />}
variant='contained'
>

View File

@@ -53,7 +53,7 @@ const Logbook: React.FC<unknown> = () => {
accessorKey: 'tracks',
header: 'Tracks',
cell: (info: any) => {
if (info.row.original.tracks && info.row.original.tracks.length > 0) {
if (info.row.original.tracks && JSON.parse(info.row.original.tracks).length > 0) {
return (
<IconButton onClick={() => onOpenCloseTracks(FormMode.VIEW, info.row.original.rowKey)}><Icon iconName={IconName.MAP_LOCATION_DOT} /></IconButton>
)
@@ -261,7 +261,7 @@ const Logbook: React.FC<unknown> = () => {
<Table columns={state.columns} data={state.entries} />
)}
{!isMedium && state.entries.length > 0 &&
<LogbookCard logs={state.entries} onDelete={onDeleteEntry} onOpenCloseForm={onOpenCloseEntryForm} />
<LogbookCard logs={state.entries} onDelete={onDeleteEntry} mode='logbook' onOpenCloseForm={onOpenCloseEntryForm} />
}
</Grid>
)}

View File

@@ -1,18 +1,19 @@
import { Card, CardContent, CardHeader, Grid, Typography } from "@noahspan/noahspan-components";
import { LogbookCardProps } from "./LogbookCardProps.interface";
import { useEffect } from "react";
import ActionMenu from "../actionMenu/ActionMenu";
import LogTrackMaps from "../logTrackMaps/LogTrackMaps";
const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
const LogbookCard = ({ logs, mode, onDelete, onOpenCloseForm }: LogbookCardProps) => {
return (
<Grid container spacing={2}>
{logs.map((log) => {
console.log(log)
return (
<Grid size={12}>
<Card key={log.rowKey}>
<CardHeader
action={<ActionMenu id={log.rowKey} onDelete={onDelete} onOpenCloseForm={onOpenCloseForm} />}
action={mode === 'logbook' ? <ActionMenu id={log.rowKey} onDelete={onDelete!} onOpenCloseForm={onOpenCloseForm!} /> : null}
subheader={log.pilotName}
title={log.date}
slotProps={{
@@ -26,6 +27,14 @@ const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
/>
<CardContent>
<Grid container spacing={1}>
{mode === 'flights' && log.tracks && JSON.parse(log.tracks).length > 0 &&
<Grid size={12}>
<LogTrackMaps
rowKey={log.rowKey}
trackUrls={JSON.parse(log.tracks)}
/>
</Grid>
}
<Grid size={12}>
<Typography variant="subtitle2">Aircraft Make and Model</Typography>
</Grid>
@@ -50,6 +59,24 @@ const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
<Grid size={12}>
<Typography variant="body1">{log.durationOfFlight}</Typography>
</Grid>
{mode === 'logbook' && log.tracks && JSON.parse(log.tracks).length > 0 &&
<>
<Grid size={12}>
<Typography variant="subtitle2">Tracks</Typography>
</Grid>
{JSON.parse(log.tracks).map((track: string) => {
const trackSplit = track.split('/')
const filename = trackSplit[trackSplit.length - 1];
return (
<Grid size={12}>
<Typography variant="body1">{filename}</Typography>
</Grid>
)
})}
</>
}
{log.notes &&
<>
<Grid size={12}>

View File

@@ -3,6 +3,7 @@ import { ILogbookEntry } from "../logbook/ILogbookEntry";
export interface LogbookCardProps {
logs: ILogbookEntry[];
onDelete: (entryId: string) => void;
onOpenCloseForm: (formMode: FormMode, id: string) => void;
mode: 'flights' | 'logbook';
onDelete?: (entryId: string) => void;
onOpenCloseForm?: (formMode: FormMode, id: string) => void;
}

View File

@@ -32,9 +32,13 @@ const SiteNav = () => {
const getPages = () => {
const pages = [
{
name: 'Logbook',
name: 'Flights',
url: '/'
},
{
name: 'Logbook',
url: '/logbook'
},
{
name: 'Pilots',
url: '/pilots'
@@ -79,7 +83,6 @@ const SiteNav = () => {
return imageUrl;
} catch (error) {
console.log(error);
throw new Error();
}
};

View File

@@ -0,0 +1,46 @@
import { useEffect, useState } from "react";
import { useHttpClient } from "../httpClient/UseHttpClient";
import { useAccessToken } from "../accessToken/UseAcessToken";
import { useIsAuthenticated } from "@azure/msal-react";
import { AxiosInstance, AxiosResponse } from "axios";
import { ILogbookEntry } from "../../components/logbook/ILogbookEntry";
export const useLogs = () => {
const [logs, setLogs] = useState<ILogbookEntry[]>();
const [isLoading, setIsLoading] = useState<boolean>(false);
const httpClient: AxiosInstance = useHttpClient();
const { getAccessToken } = useAccessToken();
const isAuthenticated = useIsAuthenticated();
useEffect(() => {
const getLogs = async () => {
try {
setIsLoading(true);
const config = isAuthenticated
? { headers: { Authorization: await getAccessToken() } }
: {};
const response: AxiosResponse = await httpClient.get(
`api/logs`,
config
);
const logs: ILogbookEntry[] = response.data;
logs.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
setLogs(logs)
} catch (error) {
return error;
} finally {
setIsLoading(false);
}
}
getLogs();
}, [])
return {
logs,
isLoading
}
}

View File

@@ -1,3 +1,4 @@
body {
background-color: #f2f2f2;
margin: 8px;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@noahspan/flying",
"version": "1.2.0",
"version": "1.3.0",
"scripts": {
"start": "concurrently 'npm run start:azure -w api' 'wait-on tcp:0.0.0.0:7071 && npm run dev -w app'",
"format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"",

51
pnpm-lock.yaml generated
View File

@@ -166,15 +166,9 @@ importers:
dotenv:
specifier: ^16.4.7
version: 16.4.7
install:
specifier: ^0.13.0
version: 0.13.0
leaflet:
specifier: ^1.9.4
version: 1.9.4
pure-react-carousel:
specifier: ^1.32.0
version: 1.32.0(react-dom@19.0.0-rc.1(react@19.0.0-rc.1))(react@19.0.0-rc.1)
react:
specifier: 19.0.0-rc.1
version: 19.0.0-rc.1
@@ -3037,16 +3031,9 @@ packages:
babel-plugin-macros:
optional: true
deep-freeze@0.0.1:
resolution: {integrity: sha512-Z+z8HiAvsGwmjqlphnHW5oz6yWlOwu6EQfFTjmeTWlDeda3FS2yv3jhq35TX/ewmsnqB+RX2IdsIOyjJCQN5tg==}
deep-is@0.1.4:
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
deepmerge@2.2.1:
resolution: {integrity: sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==}
engines: {node: '>=0.10.0'}
deepmerge@4.2.2:
resolution: {integrity: sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==}
engines: {node: '>=0.10.0'}
@@ -3185,9 +3172,6 @@ packages:
resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==}
engines: {node: '>=18'}
equals@1.0.5:
resolution: {integrity: sha512-wI15a6ZoaaXPv+55+Vh2Kqn3+efKRv8QPtcGTjW5xmanMnQzESdAt566jevtMZyt3W/jwLDTzXpMph5ECDJ2zg==}
errno@0.1.8:
resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}
hasBin: true
@@ -3741,10 +3725,6 @@ packages:
resolution: {integrity: sha512-vI2w4zl/mDluHt9YEQ/543VTCwPKWiHzKtm9dM2V0NdFcqEexDAjUHzO1oA60HRNaVifGXXM1tRRNluLVHa0Kg==}
engines: {node: '>=18'}
install@0.13.0:
resolution: {integrity: sha512-zDml/jzr2PKU9I8J/xyZBQn8rPCAY//UOYNmR01XwNwyfhEWObo2SWfSl1+0tm1u6PhxLwDnfsT/6jB7OUxqFA==}
engines: {node: '>= 0.10'}
ipaddr.js@1.9.1:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
engines: {node: '>= 0.10'}
@@ -4026,9 +4006,6 @@ packages:
resolution: {integrity: sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==}
hasBin: true
jkroso-type@1.1.1:
resolution: {integrity: sha512-zZgay+fPG6PgMUrpyFADmQmvLo39+AZa7Gc5pZhev2RhDxwANEq2etwD8d0e6rTg5NkwOIlQmaEmns3draC6Ng==}
joi@17.13.3:
resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==}
@@ -4791,12 +4768,6 @@ packages:
pure-rand@6.1.0:
resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==}
pure-react-carousel@1.32.0:
resolution: {integrity: sha512-RW0zKjjId1Xmspcqdu3v0pmlce3BVDACJ0fzt1+ZPJ4GxqJbIqt2kPAh1e5M19S5BDewihnq6kz4kIaGXleO3w==}
peerDependencies:
react: 15.x || 16.x || 17.x || 18.x
react-dom: 15.x || 16.x || 17.x || 18.x
qs@6.13.0:
resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==}
engines: {node: '>=0.6'}
@@ -9067,12 +9038,8 @@ snapshots:
optionalDependencies:
babel-plugin-macros: 3.1.0
deep-freeze@0.0.1: {}
deep-is@0.1.4: {}
deepmerge@2.2.1: {}
deepmerge@4.2.2: {}
deepmerge@4.3.1: {}
@@ -9177,10 +9144,6 @@ snapshots:
environment@1.1.0: {}
equals@1.0.5:
dependencies:
jkroso-type: 1.1.1
errno@0.1.8:
dependencies:
prr: 1.0.1
@@ -9957,8 +9920,6 @@ snapshots:
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
install@0.13.0: {}
ipaddr.js@1.9.1: {}
is-arguments@1.2.0:
@@ -10415,8 +10376,6 @@ snapshots:
jiti@1.21.7: {}
jkroso-type@1.1.1: {}
joi@17.13.3:
dependencies:
'@hapi/hoek': 9.3.0
@@ -11166,16 +11125,6 @@ snapshots:
pure-rand@6.1.0: {}
pure-react-carousel@1.32.0(react-dom@19.0.0-rc.1(react@19.0.0-rc.1))(react@19.0.0-rc.1):
dependencies:
'@babel/runtime': 7.26.10
deep-freeze: 0.0.1
deepmerge: 2.2.1
equals: 1.0.5
prop-types: 15.8.1
react: 19.0.0-rc.1
react-dom: 19.0.0-rc.1(react@19.0.0-rc.1)
qs@6.13.0:
dependencies:
side-channel: 1.1.0