Compare commits

..

6 Commits

Author SHA1 Message Date
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
7 changed files with 92 additions and 33 deletions

View File

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

View File

@@ -19,6 +19,8 @@ describe('LogService', () => {
createQueryBuilder: jest.fn().mockReturnThis(), createQueryBuilder: jest.fn().mockReturnThis(),
innerJoinAndSelect: jest.fn().mockReturnThis(), innerJoinAndSelect: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(), orderBy: jest.fn().mockReturnThis(),
skip: jest.fn().mockReturnThis(),
take: jest.fn().mockReturnThis(),
getManyAndCount: jest.fn() getManyAndCount: jest.fn()
} }
@@ -232,14 +234,14 @@ describe('LogService', () => {
const count = 1 const count = 1
const morePages = false 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(); const {entities, total, hasNextPage} = await service.findLogsWithCount();
expect(entities).toEqual(logs); expect(entities).toEqual(logs);
expect(count).toEqual(total); expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages); expect(hasNextPage).toEqual(morePages);
expect(mockLogRepository.findAndCount).toHaveBeenCalled(); expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
}) })
it('findLogsWithTracks => should find log entries with tracks', async () => { it('findLogsWithTracks => should find log entries with tracks', async () => {
@@ -292,7 +294,7 @@ describe('LogService', () => {
expect(entities).toEqual(logs); expect(entities).toEqual(logs);
expect(count).toEqual(total); expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages); expect(hasNextPage).toEqual(morePages);
expect(mockLogRepository.findAndCount).toHaveBeenCalled(); expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
}) })
it('update => should update a log entry', async () => { it('update => should update a log entry', async () => {

View File

@@ -25,11 +25,22 @@ export class LogService {
} }
async findLogsWithCount(skip?: number, take?: number): Promise<Logs> { async findLogsWithCount(skip?: number, take?: number): Promise<Logs> {
const [entities, total] = await this.logRepository.findAndCount({ // const [entities, total] = await this.logRepository.findAndCount({
take, // take,
skip, // skip,
relations: ['pilot', 'tracks'] // 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 { return {
entities, entities,
@@ -43,7 +54,9 @@ export class LogService {
.createQueryBuilder('logs') .createQueryBuilder('logs')
.innerJoinAndSelect('logs.tracks', 'track') .innerJoinAndSelect('logs.tracks', 'track')
.innerJoinAndSelect('logs.pilot', 'pilot') .innerJoinAndSelect('logs.pilot', 'pilot')
.orderBy('date') .orderBy('logs.date', 'DESC')
.skip(skip)
.take(take)
.getManyAndCount(); .getManyAndCount();
return { return {

View File

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

View File

@@ -380,13 +380,13 @@ const Logbook: React.FC<unknown> = () => {
setPageIndex setPageIndex
} = table; } = table;
const getLogbookEntries = async (pageIndex?: number, pageSize?: number) => { const getLogbookEntries = async (pageIndex: number, pageSize: number) => {
try { try {
dispatch({ type: 'SET_IS_LOADING', payload: true }); dispatch({ type: 'SET_IS_LOADING', payload: true });
const response: AxiosResponse = await httpClient.get(`api/logs`, { const response: AxiosResponse = await httpClient.get(`api/logs`, {
params: { params: {
skip: pageIndex, skip: pageIndex * pageSize,
take: pageSize take: pageSize
} }
}); });
@@ -527,6 +527,10 @@ const Logbook: React.FC<unknown> = () => {
dispatch({ type: 'SET_PAGES', payload: pages }) dispatch({ type: 'SET_PAGES', payload: pages })
}, [state.totalEntries, state.pagination?.pageSize]) }, [state.totalEntries, state.pagination?.pageSize])
useEffect(() => {
console.log(state.pagination)
}, [state.pagination])
return ( return (
<> <>
<div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}> <div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}>
@@ -569,7 +573,7 @@ const Logbook: React.FC<unknown> = () => {
> >
<option value={10}>10</option> <option value={10}>10</option>
<option value={25}>25</option> <option value={25}>25</option>
<option value={3}>50</option> <option value={50}>50</option>
<option value={state.totalEntries}>All</option> <option value={state.totalEntries}>All</option>
</select> </select>
</label> </label>

View File

@@ -17,11 +17,31 @@ import { Pilot } from './Pilot.interface';
import Alert from '../alert/Alert'; import Alert from '../alert/Alert';
import { useOidc } from '../../auth/oidcConfig'; import { useOidc } from '../../auth/oidcConfig';
interface ActionsProps {
id: string;
}
const Pilots: React.FC<unknown> = () => { const Pilots: React.FC<unknown> = () => {
const [state, dispatch] = useReducer(reducer, initialState); const [state, dispatch] = useReducer(reducer, initialState);
const { userRole } = useUserRole(); const { userRole } = useUserRole();
const { screenSize } = useBreakpoints(); const { screenSize } = useBreakpoints();
const { isUserLoggedIn } = useOidc(); 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 () => { const getPilots = async () => {
try { try {
@@ -134,18 +154,7 @@ const Pilots: React.FC<unknown> = () => {
}, },
cell: (info: CellContext<Pilot, unknown>) => { cell: (info: CellContext<Pilot, unknown>) => {
return ( return (
<div className='dropdown dropdown-end'> <Actions id={info.row.original.id} />
<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>
) )
} }
} }
@@ -172,11 +181,11 @@ const Pilots: React.FC<unknown> = () => {
return ( return (
<> <>
<div className='mr-10 ml-10 grid grid-cols-12'> <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-10 mt-5 mb-5' > <div className='prose max-w-none col-span-6 mt-5 mb-5' >
<h1>Pilots</h1> <h1>Pilots</h1>
</div> </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 && {!state.isLoading && userRole === UserRole.WRITE &&
<button <button
className='btn btn-primary' className='btn btn-primary'
@@ -259,9 +268,40 @@ const Pilots: React.FC<unknown> = () => {
</table> </table>
</div> </div>
} }
{/* {state.pilots.length > 0 && screenSize === ScreenSize.SM && {state.pilots.length > 0 && screenSize === ScreenSize.SM &&
<PilotCard pilots={state.pilots} onDelete={onDeletePilot} onOpenCloseForm={onOpenClosePilotForm} /> <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> </div>
{state.isFormOpen && ( {state.isFormOpen && (
<PilotForm <PilotForm

View File

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