Updated RabbitMq to receive messages from Salidomo
Fixed bug in front-end when changing role from partner to client Sorted installation view (alarms first)
This commit is contained in:
parent
8646790824
commit
cba04ba01c
|
@ -57,9 +57,9 @@ public static class RabbitMqManager
|
||||||
if (receivedStatusMessage != null)
|
if (receivedStatusMessage != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("----------------------------------------------");
|
Console.WriteLine("----------------------------------------------");
|
||||||
Console.WriteLine("Received a message from installation: " + receivedStatusMessage.InstallationId + " and status is: " + receivedStatusMessage.Status);
|
|
||||||
int installationId = (int)Db.Installations.Where(f => f.Product == 0 && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.Id).FirstOrDefault();
|
|
||||||
|
|
||||||
|
int installationId = (int)Db.Installations.Where(f => f.Product == receivedStatusMessage.Product && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.Id).FirstOrDefault();
|
||||||
|
Console.WriteLine("Received a message from installation: " + installationId + " , product is: "+receivedStatusMessage.Product+ " and status is: " + receivedStatusMessage.Status);
|
||||||
|
|
||||||
//This is a heartbit message, just update the timestamp for this installation.
|
//This is a heartbit message, just update the timestamp for this installation.
|
||||||
//There is no need to notify the corresponding front-ends.
|
//There is no need to notify the corresponding front-ends.
|
||||||
|
@ -77,7 +77,7 @@ public static class RabbitMqManager
|
||||||
{
|
{
|
||||||
Warning newWarning = new Warning
|
Warning newWarning = new Warning
|
||||||
{
|
{
|
||||||
InstallationId = receivedStatusMessage.InstallationId,
|
InstallationId = installationId,
|
||||||
Description = warning.Description,
|
Description = warning.Description,
|
||||||
Date = warning.Date,
|
Date = warning.Date,
|
||||||
Time = warning.Time,
|
Time = warning.Time,
|
||||||
|
@ -85,7 +85,7 @@ public static class RabbitMqManager
|
||||||
Seen = false
|
Seen = false
|
||||||
};
|
};
|
||||||
//Create a new warning and add it to the database
|
//Create a new warning and add it to the database
|
||||||
Db.HandleWarning(newWarning, receivedStatusMessage.InstallationId);
|
Db.HandleWarning(newWarning, installationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,12 @@ public static class RabbitMqManager
|
||||||
//Traverse the Alarm list, and store each of them to the database
|
//Traverse the Alarm list, and store each of them to the database
|
||||||
if (receivedStatusMessage.Alarms != null)
|
if (receivedStatusMessage.Alarms != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Add an alarm for installation "+receivedStatusMessage.InstallationId);
|
Console.WriteLine("Add an alarm for installation "+installationId);
|
||||||
foreach (var alarm in receivedStatusMessage.Alarms)
|
foreach (var alarm in receivedStatusMessage.Alarms)
|
||||||
{
|
{
|
||||||
Error newError = new Error
|
Error newError = new Error
|
||||||
{
|
{
|
||||||
InstallationId = receivedStatusMessage.InstallationId,
|
InstallationId = installationId,
|
||||||
Description = alarm.Description,
|
Description = alarm.Description,
|
||||||
Date = alarm.Date,
|
Date = alarm.Date,
|
||||||
Time = alarm.Time,
|
Time = alarm.Time,
|
||||||
|
@ -106,7 +106,7 @@ public static class RabbitMqManager
|
||||||
Seen = false
|
Seen = false
|
||||||
};
|
};
|
||||||
//Create a new error and add it to the database
|
//Create a new error and add it to the database
|
||||||
Db.HandleError(newError, receivedStatusMessage.InstallationId);
|
Db.HandleError(newError, installationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ dotnet publish \
|
||||||
-r linux-x64
|
-r linux-x64
|
||||||
|
|
||||||
echo -e "\n============================ Deploy ============================\n"
|
echo -e "\n============================ Deploy ============================\n"
|
||||||
ip_addresses=("10.2.3.115" "10.2.3.104" "10.2.4.33" "10.2.4.32" "10.2.4.36" "10.2.4.35" "10.2.4.154" "10.2.4.113" "10.2.4.29")
|
#ip_addresses=("10.2.3.115" "10.2.3.104" "10.2.4.33" "10.2.4.32" "10.2.4.36" "10.2.4.35" "10.2.4.154" "10.2.4.113" "10.2.4.29")
|
||||||
#ip_addresses=("10.2.4.154" "10.2.4.29")
|
#ip_addresses=("10.2.4.154" "10.2.4.29")
|
||||||
|
ip_addresses=("10.2.3.115" "10.2.3.104" "10.2.4.33" "10.2.4.32" "10.2.4.36" "10.2.4.35" "10.2.4.154" "10.2.4.29")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ip_address in "${ip_addresses[@]}"; do
|
for ip_address in "${ip_addresses[@]}"; do
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define Amax
|
#undef Amax
|
||||||
#undef GridLimit
|
#undef GridLimit
|
||||||
|
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
@ -486,6 +486,7 @@ internal static class Program
|
||||||
var returnedStatus = new StatusMessage
|
var returnedStatus = new StatusMessage
|
||||||
{
|
{
|
||||||
InstallationId = installationId,
|
InstallationId = installationId,
|
||||||
|
Product = 0,
|
||||||
Status = salimaxAlarmsState,
|
Status = salimaxAlarmsState,
|
||||||
Type = MessageType.AlarmOrWarning,
|
Type = MessageType.AlarmOrWarning,
|
||||||
Alarms = alarmList,
|
Alarms = alarmList,
|
||||||
|
|
|
@ -25,9 +25,29 @@ export const fetchDailyData = (
|
||||||
if (r.status === 404) {
|
if (r.status === 404) {
|
||||||
return Promise.resolve(FetchResult.notAvailable);
|
return Promise.resolve(FetchResult.notAvailable);
|
||||||
} else if (r.status === 200) {
|
} else if (r.status === 200) {
|
||||||
const text = await r.text();
|
// const text = await r.text();
|
||||||
|
const csvtext = await r.text(); // Assuming the server returns the Base64 encoded ZIP file as text
|
||||||
|
|
||||||
|
//const response = await fetch(url); // Fetch the resource from the server
|
||||||
|
const contentEncoding = r.headers.get('content-type');
|
||||||
|
|
||||||
|
if (contentEncoding != 'application/base64; charset=utf-8') {
|
||||||
|
return parseCsv(csvtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const byteArray = Uint8Array.from(atob(csvtext), (c) =>
|
||||||
|
c.charCodeAt(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
//Decompress the byte array using JSZip
|
||||||
|
const zip = await JSZip.loadAsync(byteArray);
|
||||||
|
// Assuming the CSV file is named "data.csv" inside the ZIP archive
|
||||||
|
const csvContent = await zip.file('data.csv').async('text');
|
||||||
|
|
||||||
|
return parseCsv(csvContent);
|
||||||
|
|
||||||
//console.log(parseCsv(text));
|
//console.log(parseCsv(text));
|
||||||
return parseCsv(text);
|
//return parseCsv(text);
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve(FetchResult.notAvailable);
|
return Promise.resolve(FetchResult.notAvailable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,33 @@ function InstallationTabs() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
: currentUser.userType == UserType.partner
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
value: 'live',
|
||||||
|
label: <FormattedMessage id="live" defaultMessage="Live" />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'overview',
|
||||||
|
label: <FormattedMessage id="overview" defaultMessage="Overview" />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'batteryview',
|
||||||
|
label: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="batteryview"
|
||||||
|
defaultMessage="Battery View"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
value: 'information',
|
||||||
|
label: (
|
||||||
|
<FormattedMessage id="information" defaultMessage="Information" />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
value: 'live',
|
value: 'live',
|
||||||
|
@ -219,7 +246,8 @@ function InstallationTabs() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
: [
|
: currentUser.userType == UserType.partner
|
||||||
|
? [
|
||||||
{
|
{
|
||||||
value: 'list',
|
value: 'list',
|
||||||
icon: <ListIcon id="mode-toggle-button-list-icon" />
|
icon: <ListIcon id="mode-toggle-button-list-icon" />
|
||||||
|
@ -249,6 +277,37 @@ function InstallationTabs() {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
value: 'information',
|
||||||
|
label: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="information"
|
||||||
|
defaultMessage="Information"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
value: 'list',
|
||||||
|
icon: <ListIcon id="mode-toggle-button-list-icon" />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'tree',
|
||||||
|
icon: <AccountTreeIcon id="mode-toggle-button-tree-icon" />
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
value: 'live',
|
||||||
|
label: <FormattedMessage id="live" defaultMessage="Live" />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'overview',
|
||||||
|
label: (
|
||||||
|
<FormattedMessage id="overview" defaultMessage="Overview" />
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'information',
|
value: 'information',
|
||||||
label: (
|
label: (
|
||||||
|
|
|
@ -9,11 +9,30 @@ import { InstallationsContext } from 'src/contexts/InstallationsContextProvider'
|
||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import routes from '../../../Resources/routes.json';
|
import routes from '../../../Resources/routes.json';
|
||||||
import Folder from './Folder';
|
import Folder from './Folder';
|
||||||
|
import { WebSocketContext } from '../../../contexts/WebSocketContextProvider';
|
||||||
|
|
||||||
function InstallationTree() {
|
function InstallationTree() {
|
||||||
const { foldersAndInstallations, fetchAllFoldersAndInstallations } =
|
const { foldersAndInstallations, fetchAllFoldersAndInstallations } =
|
||||||
useContext(InstallationsContext);
|
useContext(InstallationsContext);
|
||||||
|
|
||||||
|
const webSocketContext = useContext(WebSocketContext);
|
||||||
|
const { getStatus } = webSocketContext;
|
||||||
|
|
||||||
|
const sortedInstallations = [...foldersAndInstallations].sort((a, b) => {
|
||||||
|
// Compare the status field of each installation and sort them based on the status.
|
||||||
|
//Installations with alarms go first
|
||||||
|
let a_status = getStatus(a.id);
|
||||||
|
let b_status = getStatus(b.id);
|
||||||
|
|
||||||
|
if (a_status > b_status) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a_status < b_status) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAllFoldersAndInstallations();
|
fetchAllFoldersAndInstallations();
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -23,7 +42,7 @@ function InstallationTree() {
|
||||||
return (
|
return (
|
||||||
node.parentId == parent_id && (
|
node.parentId == parent_id && (
|
||||||
<CustomTreeItem node={node} parent_id={parent_id}>
|
<CustomTreeItem node={node} parent_id={parent_id}>
|
||||||
{foldersAndInstallations.map((subnode) => {
|
{sortedInstallations.map((subnode) => {
|
||||||
return (
|
return (
|
||||||
subnode != node &&
|
subnode != node &&
|
||||||
subnode.parentId == node.id && (
|
subnode.parentId == node.id && (
|
||||||
|
|
Loading…
Reference in New Issue