Updated History view in front-end

This commit is contained in:
Noe 2024-06-12 12:43:25 +02:00
parent e6c32b7162
commit 8d30d783fe
3 changed files with 44 additions and 50 deletions

View File

@ -319,7 +319,7 @@ internal static class Program
if (s3Bucket != null)
RabbitMqManager.InformMiddleware(currentSalimaxState);
}
else if (_subscribedToQueue && _heartBitInterval >= 15)
else if (_subscribedToQueue && _heartBitInterval >= 30)
{
//Send a heartbit to the backend
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
@ -676,38 +676,39 @@ internal static class Program
var s3Path = timeStamp.ToUnixTime() + ".csv";
var request = s3Config.CreatePutRequest(s3Path);
// This is temporary for Wittman, but now it's for all Instalattion
// This is temporary for Wittman, but now it's for all Installation
await File.WriteAllTextAsync("/var/www/html/status.csv", csv.SplitLines().Where(l => !l.Contains("Secret")).JoinLines());
var response = await request.PutAsync(new StringContent(csv));
//Use this for no compression
//var response = await request.PutAsync(new StringContent(csv));
//Compress CSV data to a byte array
byte[] compressedBytes;
using (var memoryStream = new MemoryStream())
{
//Create a zip directory and put the compressed file inside
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
var entry = archive.CreateEntry("data.csv", CompressionLevel.SmallestSize); // Add CSV data to the ZIP archive
using (var entryStream = entry.Open())
using (var writer = new StreamWriter(entryStream))
{
writer.Write(csv);
}
}
compressedBytes = memoryStream.ToArray();
}
// Encode the compressed byte array as a Base64 string
string base64String = Convert.ToBase64String(compressedBytes);
// Create StringContent from Base64 string
var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64");
// Upload the compressed data (ZIP archive) to S3
var response = await request.PutAsync(stringContent);
// Compress CSV data to a byte array
// byte[] compressedBytes;
// using (var memoryStream = new MemoryStream())
// {
// //Create a zip directory and put the compressed file inside
// using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
// {
// var entry = archive.CreateEntry("data.csv", CompressionLevel.SmallestSize); // Add CSV data to the ZIP archive
// using (var entryStream = entry.Open())
// using (var writer = new StreamWriter(entryStream))
// {
// writer.Write(csv);
// }
// }
//
// compressedBytes = memoryStream.ToArray();
// }
//
// // Encode the compressed byte array as a Base64 string
// string base64String = Convert.ToBase64String(compressedBytes);
//
// // Create StringContent from Base64 string
// var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64");
//
// // Upload the compressed data (ZIP archive) to S3
// var response = await request.PutAsync(stringContent);
//
if (response.StatusCode != 200)
{
Console.WriteLine("ERROR: PUT");

View File

@ -62,16 +62,9 @@ public record S3Config
String contentType = "application/base64",
String md5Hash = "")
{
// StringToSign = HTTP-Verb + "\n" +
// Content-MD5 + "\n" +
// Content-Type + "\n" +
// Date + "\n" +
// CanonicalizedAmzHeaders +
// CanonicalizedResource;
//contentType = "application/base64; charset=utf-8";
contentType = "text/plain; charset=utf-8";
contentType = "application/base64; charset=utf-8";
//contentType = "text/plain; charset=utf-8";
var payload = $"{method}\n{md5Hash}\n{contentType}\n{date}\n/{bucket.Trim('/')}/{s3Path.Trim('/')}";
using var hmacSha1 = new HMACSHA1(UTF8.GetBytes(s3Secret));

View File

@ -124,7 +124,7 @@ function HistoryOfActions(props: HistoryProps) {
</div>
<div
style={{
flex: 1,
flex: 6,
marginTop: '15px',
display: 'flex',
alignItems: 'center',
@ -157,13 +157,13 @@ function HistoryOfActions(props: HistoryProps) {
// Extract the time part (e.g., "12:34:56")
const timePart = date.toLocaleTimeString();
return (
<>
<React.Fragment key={index}>
<Divider />
<div
key={index}
style={{
height: '40px',
minHeight: '40px',
marginBottom: '10px',
display: 'flex',
alignItems: 'center'
@ -183,7 +183,6 @@ function HistoryOfActions(props: HistoryProps) {
fontWeight="bold"
color="text.primary"
gutterBottom
noWrap
>
{action.userName}
</Typography>
@ -203,7 +202,6 @@ function HistoryOfActions(props: HistoryProps) {
fontWeight="bold"
color="text.primary"
gutterBottom
noWrap
>
{datePart}
</Typography>
@ -222,7 +220,6 @@ function HistoryOfActions(props: HistoryProps) {
fontWeight="bold"
color="text.primary"
gutterBottom
noWrap
>
{timePart}
</Typography>
@ -230,7 +227,7 @@ function HistoryOfActions(props: HistoryProps) {
<div
style={{
flex: 3,
flex: 6,
display: 'flex',
marginTop: '15px',
alignItems: 'center',
@ -242,13 +239,16 @@ function HistoryOfActions(props: HistoryProps) {
fontWeight="bold"
color="text.primary"
gutterBottom
noWrap
style={{
whiteSpace: 'normal',
wordBreak: 'break-word'
}}
>
{action.description}
</Typography>
</div>
</div>
</>
</React.Fragment>
);
})}
</div>