removed AircraftID, Added NExtcloud permission
This commit is contained in:
@@ -5,18 +5,12 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
|
||||
try {
|
||||
const connectedAircraftId = request.nextUrl.searchParams.get("connectedAircraftId");
|
||||
|
||||
const aircraft = await prisma.connectedAircraft.findUnique({
|
||||
where: {
|
||||
id: connectedAircraftId ? parseInt(connectedAircraftId) : undefined,
|
||||
},
|
||||
});
|
||||
if (!aircraft) return NextResponse.json({ error: "Aircraft not found" }, { status: 404 });
|
||||
if (!connectedAircraftId)
|
||||
return NextResponse.json({ error: "connectedAircraftId is required" }, { status: 400 });
|
||||
|
||||
const positionLog = await prisma.positionLog.findMany({
|
||||
where: {
|
||||
id: {
|
||||
in: aircraft.positionLogIds,
|
||||
},
|
||||
connectedAircraftId: Number(connectedAircraftId),
|
||||
timestamp: {
|
||||
gte: new Date(Date.now() - 2 * 60 * 60 * 1000), // Last 2 hours
|
||||
},
|
||||
|
||||
@@ -44,9 +44,11 @@ export const PUT = async (req: Request) => {
|
||||
if (!activeAircraft) {
|
||||
return Response.json({ message: "No active aircraft found" }, { status: 400 });
|
||||
}
|
||||
|
||||
const positionLog = await prisma.positionLog.create({
|
||||
data: {
|
||||
...position,
|
||||
connectedAircraftId: activeAircraft.id,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
@@ -64,9 +66,6 @@ export const PUT = async (req: Request) => {
|
||||
posHeading: positionLog.heading,
|
||||
posSpeed: positionLog.speed,
|
||||
posH145active: h145,
|
||||
positionLogIds: {
|
||||
push: positionLog.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ const styles = `
|
||||
`;
|
||||
|
||||
const PenaltyNoticeTemplate = ({ user, staffName }: { user: User; staffName: string }) => (
|
||||
<Html lang="de">
|
||||
<html lang="de">
|
||||
<meta content="text/html; charset=utf-8" httpEquiv="Content-Type" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<link
|
||||
@@ -158,7 +158,7 @@ const PenaltyNoticeTemplate = ({ user, staffName }: { user: User; staffName: str
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</Html>
|
||||
</html>
|
||||
);
|
||||
|
||||
export function renderBannNotice({ user, staffName }: { user: User; staffName: string }) {
|
||||
|
||||
@@ -65,7 +65,7 @@ const styles = `
|
||||
`;
|
||||
|
||||
const Template = ({ user, code }: { user: User; code: string }) => (
|
||||
<Html lang="de">
|
||||
<html lang="de">
|
||||
<meta content="text/html; charset=utf-8" httpEquiv="Content-Type" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<link
|
||||
@@ -191,7 +191,7 @@ const Template = ({ user, code }: { user: User; code: string }) => (
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</Html>
|
||||
</html>
|
||||
);
|
||||
|
||||
export function renderVerificationCode({ user, code }: { user: User; code: string }) {
|
||||
|
||||
@@ -66,7 +66,7 @@ const styles = `
|
||||
`;
|
||||
|
||||
const Template = ({ event, user }: { user: User; event: Event }) => (
|
||||
<Html lang="de">
|
||||
<html lang="de">
|
||||
<meta content="text/html; charset=utf-8" httpEquiv="Content-Type" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<link
|
||||
@@ -142,7 +142,7 @@ const Template = ({ event, user }: { user: User; event: Event }) => (
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</Html>
|
||||
</html>
|
||||
);
|
||||
|
||||
export function renderCourseCompleted({ user, event }: { user: User; event: Event }) {
|
||||
|
||||
@@ -65,7 +65,7 @@ const styles = `
|
||||
`;
|
||||
|
||||
const Template = ({ user, password }: { user: User; password: string }) => (
|
||||
<Html lang="de">
|
||||
<html lang="de">
|
||||
<meta content="text/html; charset=utf-8" httpEquiv="Content-Type" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<link
|
||||
@@ -148,7 +148,7 @@ const Template = ({ user, password }: { user: User; password: string }) => (
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</Html>
|
||||
</html>
|
||||
);
|
||||
|
||||
export function renderPasswordChanged({ user, password }: { user: User; password: string }) {
|
||||
|
||||
@@ -54,7 +54,7 @@ const styles = `
|
||||
`;
|
||||
|
||||
const TimeBanTemplate = ({ user, staffName }: { user: User; staffName: string }) => (
|
||||
<Html lang="de">
|
||||
<html lang="de">
|
||||
<meta content="text/html; charset=utf-8" httpEquiv="Content-Type" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<link
|
||||
@@ -160,7 +160,7 @@ const TimeBanTemplate = ({ user, staffName }: { user: User; staffName: string })
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</Html>
|
||||
</html>
|
||||
);
|
||||
|
||||
export function renderTimeBanNotice({ user, staffName }: { user: User; staffName: string }) {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
{
|
||||
"extends": "@repo/typescript-config/nextjs.json",
|
||||
"extends": "@repo/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"types": ["node", "react"]
|
||||
},
|
||||
"include": ["."],
|
||||
"include": ["**/*.ts", "./index.ts", "**/*.d.ts"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
@@ -56,5 +56,6 @@ export const GET = async (req: NextRequest) => {
|
||||
return NextResponse.json({
|
||||
...user,
|
||||
moodleLastname: `${user?.lastname.split("")[0]}. - ${user?.publicId}`,
|
||||
fullName: `${user?.firstname} ${user?.lastname} - ${user?.publicId}`,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -28,6 +28,6 @@ export const services = [
|
||||
"https://nextcloud.virtualairrescue.com",
|
||||
"http://nextcloud.virtualairrescue.com/",
|
||||
],
|
||||
requiredPermissions: ["ADMIN_USER"],
|
||||
requiredPermissions: ["LOGIN_NEXTCLOUD"],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user