Compare commits

..

13 Commits

Author SHA1 Message Date
075508413e logbook page unauthenticated alert 2026-04-26 17:06:09 -05:00
56b07d64a9 Merge branch 'main' into 126-all-logs-shown-when-unauthenticated 2026-04-18 11:35:53 -07:00
928a4dae43 updating api log interceptor 2026-04-18 13:33:32 -05: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
e345898341 Merge branch '126-all-logs-shown-when-unauthenticated' of https://github.com/noahspannbauer/noahspan-flying into 126-all-logs-shown-when-unauthenticated 2026-04-18 13:05:35 -05:00
a6af3c2229 updating api log interceptor 2026-04-18 13:05:11 -05: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
b8f708fd6d Merge branch 'main' into 126-all-logs-shown-when-unauthenticated 2026-04-16 08:30:29 -05:00
1c46f58afc updating api log interceptor 2026-04-16 08:27:33 -05:00
fd514e4c8b fixing all logs showing when user is unauthenticated (#127) 2026-04-07 20:44:21 -05:00
fa7a39e48a fixing all logs showing when user is unauthenticated 2026-04-07 20:41:08 -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
7 changed files with 38 additions and 20 deletions

View File

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

View File

@@ -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
}
}
})
);

View File

@@ -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 () => {

View File

@@ -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 {

View File

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

View File

@@ -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,7 +554,7 @@ const Logbook: React.FC<unknown> = () => {
onClose={() =>
dispatch({ type: 'SET_ALERT', payload: undefined })
}
severity={'info'}
severity={state.alert.severity}
>
{state.alert.message}
</Alert>
@@ -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>

View File

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