feat: add GPS tracking with Traccar integration
- Add GPS module with Traccar client service for device management - Add driver enrollment flow with QR code generation - Add real-time location tracking on driver profiles - Add GPS settings configuration in admin tools - Add Auth0 OpenID Connect setup script for Traccar - Add deployment configs for production server - Update nginx configs for SSL on GPS port 5055 - Add timezone setting support - Various UI improvements and bug fixes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,7 @@ model Driver {
|
||||
events ScheduleEvent[]
|
||||
assignedVehicle Vehicle? @relation("AssignedDriver")
|
||||
messages SignalMessage[] // Signal chat messages
|
||||
gpsDevice GpsDevice? // GPS tracking device
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -281,6 +282,9 @@ model PdfSettings {
|
||||
showAppUrl Boolean @default(false)
|
||||
pageSize PageSize @default(LETTER)
|
||||
|
||||
// Timezone for correspondence and display (IANA timezone format)
|
||||
timezone String @default("America/New_York")
|
||||
|
||||
// Content Toggles
|
||||
showFlightInfo Boolean @default(true)
|
||||
showDriverNames Boolean @default(true)
|
||||
@@ -303,3 +307,81 @@ enum PageSize {
|
||||
A4
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// GPS Tracking
|
||||
// ============================================
|
||||
|
||||
model GpsDevice {
|
||||
id String @id @default(uuid())
|
||||
driverId String @unique
|
||||
driver Driver @relation(fields: [driverId], references: [id], onDelete: Cascade)
|
||||
|
||||
// Traccar device information
|
||||
traccarDeviceId Int @unique // Traccar's internal device ID
|
||||
deviceIdentifier String @unique // Unique ID for Traccar Client app
|
||||
|
||||
// Privacy & Consent
|
||||
enrolledAt DateTime @default(now())
|
||||
consentGiven Boolean @default(false)
|
||||
consentGivenAt DateTime?
|
||||
lastActive DateTime? // Last location report timestamp
|
||||
|
||||
// Settings
|
||||
isActive Boolean @default(true)
|
||||
|
||||
// Location history
|
||||
locationHistory GpsLocationHistory[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("gps_devices")
|
||||
}
|
||||
|
||||
model GpsLocationHistory {
|
||||
id String @id @default(uuid())
|
||||
deviceId String
|
||||
device GpsDevice @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
||||
|
||||
latitude Float
|
||||
longitude Float
|
||||
altitude Float?
|
||||
speed Float? // km/h
|
||||
course Float? // Bearing in degrees
|
||||
accuracy Float? // Meters
|
||||
battery Float? // Battery percentage (0-100)
|
||||
|
||||
timestamp DateTime
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@map("gps_location_history")
|
||||
@@index([deviceId, timestamp])
|
||||
@@index([timestamp]) // For cleanup job
|
||||
}
|
||||
|
||||
model GpsSettings {
|
||||
id String @id @default(uuid())
|
||||
|
||||
// Update frequency (seconds)
|
||||
updateIntervalSeconds Int @default(60)
|
||||
|
||||
// Shift-based tracking (4AM - 1AM next day)
|
||||
shiftStartHour Int @default(4) // 4 AM
|
||||
shiftStartMinute Int @default(0)
|
||||
shiftEndHour Int @default(1) // 1 AM next day
|
||||
shiftEndMinute Int @default(0)
|
||||
|
||||
// Data retention (days)
|
||||
retentionDays Int @default(30)
|
||||
|
||||
// Traccar credentials
|
||||
traccarAdminUser String @default("admin")
|
||||
traccarAdminPassword String? // Encrypted or hashed
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("gps_settings")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user