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"],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -16,9 +16,9 @@ model ConnectedAircraft {
|
||||
loginTime DateTime @default(now())
|
||||
esimatedLogoutTime DateTime?
|
||||
logoutTime DateTime?
|
||||
positionLogIds Int[] @default([])
|
||||
|
||||
// relations:
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
Station Station @relation(fields: [stationId], references: [id], onDelete: Cascade)
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
Station Station @relation(fields: [stationId], references: [id], onDelete: Cascade)
|
||||
PositionLog PositionLog[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
DELETE FROM "PositionLog";
|
||||
DELETE FROM "ConnectedAircraft";
|
||||
|
||||
ALTER TABLE "PositionLog" ADD COLUMN "connectedAircraftId" INTEGER NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PositionLog" ADD CONSTRAINT "PositionLog_connectedAircraftId_fkey" FOREIGN KEY ("connectedAircraftId") REFERENCES "ConnectedAircraft"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `positionLogIds` on the `ConnectedAircraft` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterEnum
|
||||
ALTER TYPE "PERMISSION" ADD VALUE 'LOGIN_NEXTCLOUD';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ConnectedAircraft" DROP COLUMN "positionLogIds";
|
||||
@@ -1,13 +1,15 @@
|
||||
model PositionLog {
|
||||
id Int @id @default(autoincrement())
|
||||
userId String
|
||||
simulator String
|
||||
lat Float
|
||||
lng Float
|
||||
alt Int
|
||||
speed Int
|
||||
heading Int
|
||||
timestamp DateTime @default(now())
|
||||
id Int @id @default(autoincrement())
|
||||
userId String
|
||||
connectedAircraftId Int
|
||||
simulator String
|
||||
lat Float
|
||||
lng Float
|
||||
alt Int
|
||||
speed Int
|
||||
heading Int
|
||||
timestamp DateTime @default(now())
|
||||
// relations:
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
ConnectedAircraft ConnectedAircraft @relation(fields: [connectedAircraftId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ enum PERMISSION {
|
||||
AUDIO
|
||||
PILOT
|
||||
DISPO
|
||||
LOGIN_NEXTCLOUD
|
||||
}
|
||||
|
||||
model User {
|
||||
|
||||
Reference in New Issue
Block a user