переделана логика загрузки модели, замена страницы Объекты на другой внешний вид, добавление в меню пункта Объекты

This commit is contained in:
2026-02-03 19:00:02 +03:00
parent 458222817e
commit 5e58f6ef76
24 changed files with 3514 additions and 1161 deletions

View File

@@ -3,6 +3,7 @@
import React from 'react'
import { useRouter } from 'next/navigation'
import useNavigationStore from '@/app/store/navigationStore'
import AreaChart from '../dashboard/AreaChart'
interface DetectorType {
detector_id: number
@@ -53,6 +54,14 @@ const DetectorMenu: React.FC<DetectorMenuProps> = ({ detector, isOpen, onClose,
const formattedTimestamp = latestTimestamp
? latestTimestamp.toLocaleString('ru-RU', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
: 'Нет данных'
// Данные для графика за последние 3 дня (мок данные)
const chartData: { timestamp: string; value: number }[] = [
{ timestamp: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(), value: 75 },
{ timestamp: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(), value: 82 },
{ timestamp: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString(), value: 78 },
{ timestamp: new Date().toISOString(), value: 85 },
]
// Определение типа детектора и его отображаемого названия
const rawDetectorTypeCode = (detector.detector_type || '').toUpperCase()
@@ -216,8 +225,16 @@ const DetectorMenu: React.FC<DetectorMenuProps> = ({ detector, isOpen, onClose,
// Компактный режим с якорной позицией (всплывающее окно)
// Используется для отображения информации при наведении на детектор в списке
if (compact && anchor) {
// Проверяем границы экрана и корректируем позицию
const tooltipHeight = 450 // Примерная высота толтипа с графиком
const viewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800
const bottomOverflow = anchor.top + tooltipHeight - viewportHeight
// Если толтип выходит за нижнюю границу, сдвигаем вверх
const adjustedTop = bottomOverflow > 0 ? anchor.top - bottomOverflow - 20 : anchor.top
return (
<div className="absolute z-40" style={{ left: anchor.left, top: anchor.top }}>
<div className="absolute z-40" style={{ left: anchor.left, top: adjustedTop }}>
<div className="rounded-[10px] bg-black/80 text-white text-xs px-3 py-2 shadow-xl min-w-[300px] max-w-[400px]">
<div className="flex items-start justify-between gap-3">
<div className="flex-1">
@@ -244,6 +261,14 @@ const DetectorMenu: React.FC<DetectorMenuProps> = ({ detector, isOpen, onClose,
</button>
</div>
<DetailsSection compact={true} />
{/* График за последние 3 дня */}
<div className="mt-3">
<div className="text-[rgb(113,113,122)] text-[11px] mb-2">График за 3 дня</div>
<div className="min-h-[100px]">
<AreaChart data={chartData} />
</div>
</div>
</div>
</div>
)
@@ -279,6 +304,14 @@ const DetectorMenu: React.FC<DetectorMenuProps> = ({ detector, isOpen, onClose,
{/* Секция с детальной информацией о детекторе */}
<DetailsSection />
{/* График за последние 3 дня */}
<div className="mt-6">
<h4 className="text-white text-base font-medium mb-4">График за последние 3 дня</h4>
<div className="min-h-[200px] bg-[rgb(22,24,36)] rounded-lg p-4">
<AreaChart data={chartData} />
</div>
</div>
{/* Кнопка закрытия панели */}
<button
onClick={onClose}