New api and zone management; highligh occlusion and highlighAll functionality; improved search in reports and alerts history + autofill; refactored alert panel
This commit is contained in:
@@ -45,15 +45,22 @@ export async function POST(req: NextRequest) {
|
||||
})
|
||||
}
|
||||
|
||||
const body = await req.json().catch(() => ({ })) as { format?: 'csv' | 'pdf', hours?: number }
|
||||
const body = await req.json().catch(() => ({ })) as { format?: 'csv' | 'pdf', hours?: number, detector_ids?: number[] }
|
||||
const reportFormat = (body.format || '').toLowerCase()
|
||||
|
||||
const url = new URL(req.url)
|
||||
const qpFormat = (url.searchParams.get('format') || '').toLowerCase()
|
||||
const qpHoursRaw = url.searchParams.get('hours')
|
||||
const qpDetectorIds = url.searchParams.get('detector_ids')
|
||||
const qpHours = qpHoursRaw ? Number(qpHoursRaw) : undefined
|
||||
const finalFormat = reportFormat || qpFormat
|
||||
const finalHours = typeof body.hours === 'number' ? body.hours : (typeof qpHours === 'number' && !Number.isNaN(qpHours) ? qpHours : 168)
|
||||
const finalDetectorIds = body.detector_ids || (qpDetectorIds ? qpDetectorIds.split(',').map(id => Number(id)) : undefined)
|
||||
|
||||
const requestBody: any = { report_format: finalFormat, hours: finalHours }
|
||||
if (finalDetectorIds && finalDetectorIds.length > 0) {
|
||||
requestBody.detector_ids = finalDetectorIds
|
||||
}
|
||||
|
||||
let backendRes = await fetch(`${backendUrl}/account/get-reports/`, {
|
||||
method: 'POST',
|
||||
@@ -61,7 +68,7 @@ export async function POST(req: NextRequest) {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
body: JSON.stringify({ report_format: finalFormat, hours: finalHours }),
|
||||
body: JSON.stringify(requestBody),
|
||||
})
|
||||
|
||||
if (!backendRes.ok && backendRes.status === 404) {
|
||||
|
||||
Reference in New Issue
Block a user