From ccef318c6f3724fa834697ad266d769d1c6b4ec8 Mon Sep 17 00:00:00 2001 From: Noe Date: Wed, 7 Feb 2024 15:31:10 +0100 Subject: [PATCH] Fixed bug with duplicate alarms --- csharp/App/SaliMax/src/Program.cs | 4 +- .../dashboards/BatteryView/BatteryView.tsx | 54 ++++++++++++++++--- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index 1a8cc19eb..48e88f6ae 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -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) diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx index a5e8dfa7d..ab5722ccc 100644 --- a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx @@ -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) { - {battery.Warnings === '' ? 'None' : battery.Warnings} + {battery.Warnings === '' ? ( + 'None' + ) : battery.Warnings.split(';').length > 1 ? ( + + Multiple Warnings + + ) : ( + battery.Warnings + )} - {battery.Alarms === '' ? 'None' : battery.Alarms} + {battery.Alarms === '' ? ( + 'None' + ) : battery.Alarms.split(';').length > 1 ? ( + + Multiple Alarms + + ) : ( + battery.Alarms + )} ))}