Fixed bug with duplicate alarms

This commit is contained in:
Noe 2024-02-07 15:31:10 +01:00
parent d5c870b4eb
commit ccef318c6f
2 changed files with 50 additions and 8 deletions

View File

@ -276,6 +276,7 @@ internal static class Program
private static void SendSalimaxStateAlarm(StatusMessage currentSalimaxState, StatusRecord record)
{
var s3Bucket = Config.Load().S3?.Bucket;
var subsribedNow = false;
//Every 15 iterations(30 seconds), the installation sends a heartbit message to the queue
_heartBitInterval++;
@ -283,12 +284,13 @@ internal static class Program
//When the controller boots, it tries to subscribe to the queue
if (_subscribeToQueueForTheFirstTime == false)
{
subsribedNow = true;
_subscribeToQueueForTheFirstTime = true;
_subscribedToQueue = RabbitMqManager.SubscribeToQueue(currentSalimaxState, s3Bucket, VpnServerIp);
}
//If already subscribed to the queue and the status has been changed, update the queue
if (_subscribedToQueue && currentSalimaxState.Status != _prevSalimaxState)
if (!subsribedNow && _subscribedToQueue && currentSalimaxState.Status != _prevSalimaxState)
{
_prevSalimaxState = currentSalimaxState.Status;
if (s3Bucket != null)

View File

@ -10,6 +10,7 @@ import {
useTheme
} from '@mui/material';
import { TopologyValues } from '../Log/graph.util';
import { Link } from 'react-router-dom';
interface BatteryViewProps {
values: TopologyValues;
@ -20,6 +21,9 @@ function BatteryView(props: BatteryViewProps) {
return null;
}
const theme = useTheme();
const searchParams = new URLSearchParams(location.search);
const installationId = parseInt(searchParams.get('installation'));
const currentTab = searchParams.get('tab');
const numOfBatteries = props.values.batteryView.values[0].value
.toString()
@ -146,24 +150,60 @@ function BatteryView(props: BatteryViewProps) {
<TableCell
style={{
width: '15%',
width: '20%',
textAlign: 'center',
padding: '8px',
fontWeight: battery.Warnings !== '' ? 'bold' : 'inherit',
backgroundColor:
battery.Warnings === '' ? 'inherit' : 'FF033E'
battery.Warnings === '' ? 'inherit' : '#ff9900',
color: battery.Warnings != '' ? 'black' : 'inherit'
}}
>
{battery.Warnings === '' ? 'None' : battery.Warnings}
{battery.Warnings === '' ? (
'None'
) : battery.Warnings.split(';').length > 1 ? (
<Link
style={{ color: 'black' }}
to={
'?installation=' +
installationId +
'&tab=log' +
'&open=warning'
}
>
Multiple Warnings
</Link>
) : (
battery.Warnings
)}
</TableCell>
<TableCell
sx={{
width: '15%',
width: '20%',
textAlign: 'center',
marginLeft: '10px',
backgroundColor: battery.Alarms === '' ? 'inherit' : 'FF033E'
fontWeight: battery.Alarms !== '' ? 'bold' : 'inherit',
backgroundColor:
battery.Alarms === '' ? 'inherit' : '#FF033E',
color: battery.Alarms != '' ? 'black' : 'inherit'
}}
>
{battery.Alarms === '' ? 'None' : battery.Alarms}
{battery.Alarms === '' ? (
'None'
) : battery.Alarms.split(';').length > 1 ? (
<Link
style={{ color: 'black' }}
to={
'?installation=' +
installationId +
'&tab=log' +
'&open=error'
}
>
Multiple Alarms
</Link>
) : (
battery.Alarms
)}
</TableCell>
</TableRow>
))}