обновление бизнес логики

This commit is contained in:
2026-02-05 21:23:20 +03:00
parent 44473a8d9d
commit 6caf1c9dbb
10 changed files with 111 additions and 2119 deletions

View File

@@ -60,20 +60,12 @@ const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
loadZones(objId);
}, [currentObject?.id, loadZones]);
// Автоматический выбор модели, если currentModelPath установлен (переход из таблицы)
useEffect(() => {
if (!currentModelPath || autoSelectedRef || !onSelectModel) return;
console.log('[Monitoring] Auto-selecting model from currentModelPath:', currentModelPath);
setAutoSelectedRef(true);
onSelectModel(currentModelPath);
}, [currentModelPath, autoSelectedRef, onSelectModel]);
// Сброс флага при изменении объекта
useEffect(() => {
setAutoSelectedRef(false);
}, [currentObject?.id])
// Сортировка зон по order
const sortedZones: Zone[] = React.useMemo(() => {
const sorted = (currentZones || []).slice().sort((a: Zone, b: Zone) => {
const oa = typeof a.order === 'number' ? a.order : 0;
@@ -85,6 +77,19 @@ const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
return sorted;
}, [currentZones]);
// Автоматический выбор модели с order=0 при загрузке зон
useEffect(() => {
// Если уже был автовыбор - пропускаем
if (autoSelectedRef || !onSelectModel) return;
// Если есть зоны и первая зона (order=0) имеет model_path
if (sortedZones.length > 0 && sortedZones[0]?.model_path) {
console.log('[Monitoring] Auto-selecting model with order=0:', sortedZones[0].model_path);
setAutoSelectedRef(true);
onSelectModel(sortedZones[0].model_path);
}
}, [sortedZones, autoSelectedRef, onSelectModel])
return (
<div className="w-full">
<div className="bg-[rgb(22,24,36)] rounded-[12px] p-4 space-y-4">