Compare commits
7 Commits
124-fix-lo
...
v2.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
| ee0e10072c | |||
| 899f92f342 | |||
| 5c4245179f | |||
| a7a9f01fd9 | |||
| a367b517db | |||
| fd514e4c8b | |||
| d8513e6dd0 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "api",
|
"name": "api",
|
||||||
"version": "2.1.1",
|
"version": "2.1.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ export class LogInterceptor implements NestInterceptor {
|
|||||||
const logs = publicData.slice(0, 5)
|
const logs = publicData.slice(0, 5)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entities: publicData,
|
entities: logs,
|
||||||
total: data.total,
|
total: logs.length,
|
||||||
hasNextPage: false
|
hasNextPage: false
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -71,7 +71,6 @@ export class LogInterceptor implements NestInterceptor {
|
|||||||
|
|
||||||
return publicData
|
return publicData
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -234,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 () => {
|
||||||
@@ -294,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 () => {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.1.1",
|
"version": "2.1.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -413,7 +413,7 @@ const Logbook: React.FC<unknown> = () => {
|
|||||||
setColumnVisibility(columnVisibility)
|
setColumnVisibility(columnVisibility)
|
||||||
dispatch({ type: 'SET_ENTRIES', payload: { entries: entries, totalEntries: response.data.total }});
|
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.'}})
|
dispatch({ type: 'SET_ALERT', payload: { severity: 'info', message: 'A limited number of log entries displayed. Sign in to view all log entries.'}})
|
||||||
} else {
|
} else {
|
||||||
dispatch({ type: 'SET_ALERT', payload: undefined})
|
dispatch({ type: 'SET_ALERT', payload: undefined})
|
||||||
@@ -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.alert)
|
||||||
|
}, [state.alert])
|
||||||
|
|
||||||
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`}>
|
||||||
@@ -550,7 +554,7 @@ const Logbook: React.FC<unknown> = () => {
|
|||||||
onClose={() =>
|
onClose={() =>
|
||||||
dispatch({ type: 'SET_ALERT', payload: undefined })
|
dispatch({ type: 'SET_ALERT', payload: undefined })
|
||||||
}
|
}
|
||||||
severity={'info'}
|
severity={state.alert.severity}
|
||||||
>
|
>
|
||||||
{state.alert.message}
|
{state.alert.message}
|
||||||
</Alert>
|
</Alert>
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@noahspan/flying",
|
"name": "@noahspan/flying",
|
||||||
"version": "2.1.1",
|
"version": "2.1.4",
|
||||||
"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\"",
|
||||||
|
|||||||
Reference in New Issue
Block a user