Overhaul of the highlight system
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useMemo } from 'react'
|
||||
import * as statusColors from '../../lib/statusColors'
|
||||
|
||||
interface AlertItem {
|
||||
id: number
|
||||
@@ -31,10 +32,14 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
|
||||
const getStatusColor = (type: string) => {
|
||||
switch (type) {
|
||||
case 'critical': return '#b3261e'
|
||||
case 'warning': return '#fd7c22'
|
||||
case 'info': return '#00ff00'
|
||||
default: return '#666'
|
||||
case 'critical':
|
||||
return statusColors.STATUS_COLOR_CRITICAL
|
||||
case 'warning':
|
||||
return statusColors.STATUS_COLOR_WARNING
|
||||
case 'info':
|
||||
return statusColors.STATUS_COLOR_NORMAL
|
||||
default:
|
||||
return statusColors.STATUS_COLOR_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +109,14 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
<td className="py-4">
|
||||
<span
|
||||
className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium text-white"
|
||||
style={{ backgroundColor: item.priority === 'high' ? '#b3261e' : item.priority === 'medium' ? '#fd7c22' : '#00ff00' }}
|
||||
style={{
|
||||
backgroundColor:
|
||||
item.priority === 'high'
|
||||
? statusColors.STATUS_COLOR_CRITICAL
|
||||
: item.priority === 'medium'
|
||||
? statusColors.STATUS_COLOR_WARNING
|
||||
: statusColors.STATUS_COLOR_NORMAL,
|
||||
}}
|
||||
>
|
||||
{item.priority === 'high' ? 'Высокий' : item.priority === 'medium' ? 'Средний' : 'Низкий'}
|
||||
</span>
|
||||
@@ -142,4 +154,4 @@ const AlertsList: React.FC<AlertsListProps> = ({ alerts, onAcknowledgeToggle, in
|
||||
)
|
||||
}
|
||||
|
||||
export default AlertsList
|
||||
export default AlertsList
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use client'
|
||||
|
||||
|
||||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
import * as statusColors from '../../lib/statusColors'
|
||||
|
||||
interface Detector {
|
||||
detector_id: number
|
||||
name: string
|
||||
@@ -30,14 +31,14 @@ interface RawDetector {
|
||||
priority: string
|
||||
}>
|
||||
}
|
||||
|
||||
|
||||
interface DetectorListProps {
|
||||
objectId?: string
|
||||
selectedDetectors: number[]
|
||||
onDetectorSelect: (detectorId: number, selected: boolean) => void
|
||||
initialSearchTerm?: string
|
||||
}
|
||||
|
||||
|
||||
const DetectorList: React.FC<DetectorListProps> = ({ objectId, selectedDetectors, onDetectorSelect, initialSearchTerm = '' }) => {
|
||||
const [detectors, setDetectors] = useState<Detector[]>([])
|
||||
const [searchTerm, setSearchTerm] = useState<string>(initialSearchTerm)
|
||||
@@ -150,12 +151,15 @@ const DetectorList: React.FC<DetectorListProps> = ({ objectId, selectedDetectors
|
||||
<td className="py-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className={`w-3 h-3 rounded-full`}
|
||||
className="w-3 h-3 rounded-full"
|
||||
style={{ backgroundColor: detector.status }}
|
||||
></div>
|
||||
<span className="text-sm text-gray-300">
|
||||
{detector.status === '#b3261e' ? 'Критическое' :
|
||||
detector.status === '#fd7c22' ? 'Предупреждение' : 'Норма'}
|
||||
{detector.status === statusColors.STATUS_COLOR_CRITICAL
|
||||
? 'Критическое'
|
||||
: detector.status === statusColors.STATUS_COLOR_WARNING
|
||||
? 'Предупреждение'
|
||||
: 'Норма'}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
@@ -187,15 +191,15 @@ const DetectorList: React.FC<DetectorListProps> = ({ objectId, selectedDetectors
|
||||
<div className="text-sm text-gray-400">Всего</div>
|
||||
</div>
|
||||
<div className="bg-[#161824] p-4 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-500">{filteredDetectors.filter(d => d.status === '#00ff00').length}</div>
|
||||
<div className="text-2xl font-bold text-green-500">{filteredDetectors.filter(d => d.status === statusColors.STATUS_COLOR_NORMAL).length}</div>
|
||||
<div className="text-sm text-gray-400">Норма</div>
|
||||
</div>
|
||||
<div className="bg-[#161824] p-4 rounded-lg">
|
||||
<div className="text-2xl font-bold text-orange-500">{filteredDetectors.filter(d => d.status === '#fd7c22').length}</div>
|
||||
<div className="text-2xl font-bold text-orange-500">{filteredDetectors.filter(d => d.status === statusColors.STATUS_COLOR_WARNING).length}</div>
|
||||
<div className="text-sm text-gray-400">Предупреждения</div>
|
||||
</div>
|
||||
<div className="bg-[#161824] p-4 rounded-lg">
|
||||
<div className="text-2xl font-bold text-red-500">{filteredDetectors.filter(d => d.status === '#b3261e').length}</div>
|
||||
<div className="text-2xl font-bold text-red-500">{filteredDetectors.filter(d => d.status === statusColors.STATUS_COLOR_CRITICAL).length}</div>
|
||||
<div className="text-sm text-gray-400">Критические</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -209,4 +213,4 @@ const DetectorList: React.FC<DetectorListProps> = ({ objectId, selectedDetectors
|
||||
)
|
||||
}
|
||||
|
||||
export default DetectorList
|
||||
export default DetectorList
|
||||
|
||||
Reference in New Issue
Block a user