Переделана навигация к датчикам, добавлена работа поиска тултипов на модели, добавлен функционал перехода из дашборда и истории тревог к датчику с тревогой на 3д модели
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import React, { useState, useMemo } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import useNavigationStore from '../../app/store/navigationStore'
|
||||
import * as statusColors from '../../lib/statusColors'
|
||||
|
||||
interface AlertItem {
|
||||
@@ -12,6 +14,8 @@ interface AlertItem {
|
||||
detector_name?: string
|
||||
location?: string
|
||||
object?: string
|
||||
serial_number?: string
|
||||
floor?: number
|
||||
}
|
||||
|
||||
interface AlertsListProps {
|
||||
@@ -21,6 +25,8 @@ interface AlertsListProps {
|
||||
}
|
||||
|
||||
const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, initialSearchTerm = '' }) => {
|
||||
const router = useRouter()
|
||||
const { navigateToSensor } = useNavigationStore()
|
||||
const [searchTerm, setSearchTerm] = useState(initialSearchTerm)
|
||||
|
||||
const filteredAlerts = useMemo(() => {
|
||||
@@ -46,6 +52,26 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
}
|
||||
}
|
||||
|
||||
const handleGoTo3D = async (alert: AlertItem, viewType: 'building' | 'floor') => {
|
||||
// Используем доступные идентификаторы датчика
|
||||
const sensorId = alert.serial_number || alert.detector_name || alert.detector_id
|
||||
|
||||
if (!sensorId) {
|
||||
console.warn('[AlertsList] Alert missing sensor identifier:', alert)
|
||||
return
|
||||
}
|
||||
|
||||
const sensorSerialNumber = await navigateToSensor(
|
||||
sensorId,
|
||||
alert.floor || null,
|
||||
viewType
|
||||
)
|
||||
|
||||
if (sensorSerialNumber) {
|
||||
router.push(`/navigation?focusSensorId=${encodeURIComponent(sensorSerialNumber)}`)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Поиск */}
|
||||
@@ -81,6 +107,7 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
<th style={interSemiboldStyle} className="text-left text-white text-sm py-3">Приоритет</th>
|
||||
<th style={interSemiboldStyle} className="text-left text-white text-sm py-3">Подтверждено</th>
|
||||
<th style={interSemiboldStyle} className="text-left text-white text-sm py-3">Время</th>
|
||||
<th style={interSemiboldStyle} className="text-center text-white text-sm py-3">3D Вид</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -141,11 +168,33 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
<td style={interRegularStyle} className="py-4 text-sm text-gray-300">
|
||||
{new Date(item.timestamp).toLocaleString('ru-RU')}
|
||||
</td>
|
||||
<td className="py-4">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<button
|
||||
onClick={() => handleGoTo3D(item, 'building')}
|
||||
className="p-1.5 rounded hover:bg-blue-600/20 transition-colors group"
|
||||
title="Показать на общей модели"
|
||||
>
|
||||
<img src="/icons/Building3D.png" alt="Здание" className="w-5 h-5 opacity-70 group-hover:opacity-100" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleGoTo3D(item, 'floor')}
|
||||
className="p-1.5 rounded hover:bg-blue-600/20 transition-colors group"
|
||||
title="Показать на этаже"
|
||||
>
|
||||
<img
|
||||
src="/icons/Floor3D.png"
|
||||
alt="Этаж"
|
||||
className="w-5 h-5 opacity-70 group-hover:opacity-100"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{filteredAlerts.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={7} className="py-8 text-center text-gray-400">
|
||||
<td colSpan={8} className="py-8 text-center text-gray-400">
|
||||
Записей не найдено
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user