Compare commits

..

2 Commits

Author SHA1 Message Date
Noe bb5b91b380 Merge remote-tracking branch 'origin/main' 2024-07-01 13:25:34 +02:00
Noe e05c36051b Updated pv view in frontend
Updated CORS settings in createBucket function
2024-07-01 13:25:24 +02:00
3 changed files with 64 additions and 15 deletions

View File

@ -135,22 +135,71 @@ public static class S3
yield break; yield break;
} }
} }
public static async Task<S3Bucket?> PutBucket(this S3Region region, String name) public static async Task<S3Bucket?> PutBucket(this S3Region region, string name)
{ {
var request = new PutBucketRequest { BucketName = name }; var request = new PutBucketRequest { BucketName = name };
var response = await region.GetS3Client().PutBucketAsync(request);
var response = await region if (response.HttpStatusCode == HttpStatusCode.OK)
.GetS3Client()
.PutBucketAsync(request);
return response.HttpStatusCode switch
{ {
HttpStatusCode.OK => region.Bucket(name), // Define CORS configuration rules
_ => null var corsConfiguration = new CORSConfiguration
}; {
Rules = new List<CORSRule>
{
new CORSRule
{
AllowedHeaders = new List<string> { "*" },
AllowedMethods = new List<string> { "GET", "HEAD" },
AllowedOrigins = new List<string> { "*" },
ExposeHeaders = new List<string>() // Empty list as per your settings
}
}
};
// Create a PutCORSConfigurationRequest
var putCorsRequest = new PutCORSConfigurationRequest
{
BucketName = name,
Configuration = corsConfiguration
};
// Set the CORS configuration for the bucket
var corsResponse = await region.GetS3Client().PutCORSConfigurationAsync(putCorsRequest);
if (corsResponse.HttpStatusCode == HttpStatusCode.OK)
{
return region.Bucket(name);
}
else
{
Console.WriteLine("Failed to set CORS configuration.");
return null;
}
}
else
{
Console.WriteLine("Failed to create bucket.");
return null;
}
} }
// public static async Task<S3Bucket?> PutBucket(this S3Region region, String name)
// {
// var request = new PutBucketRequest { BucketName = name };
//
// var response = await region
// .GetS3Client()
// .PutBucketAsync(request);
//
// return response.HttpStatusCode switch
// {
// HttpStatusCode.OK => region.Bucket(name),
// _ => null
// };
// }
public static async Task<Boolean> PutCors(this S3Bucket bucket, CORSConfiguration corsConfiguration) public static async Task<Boolean> PutCors(this S3Bucket bucket, CORSConfiguration corsConfiguration)
{ {

View File

@ -96,7 +96,7 @@ function PvView(props: PvViewProps) {
style={{ color: 'black', fontWeight: 'bold' }} style={{ color: 'black', fontWeight: 'bold' }}
mt={2} mt={2}
> >
Battery service is not available at the moment Pv view is not available at the moment
</Typography> </Typography>
<Typography variant="body2" style={{ color: 'black' }}> <Typography variant="body2" style={{ color: 'black' }}>
Please wait or refresh the page Please wait or refresh the page

View File

@ -92,10 +92,10 @@ function SalidomoInstallationTabs() {
/> />
) )
}, },
// { {
// value: 'overview', value: 'overview',
// label: <FormattedMessage id="overview" defaultMessage="Overview" /> label: <FormattedMessage id="overview" defaultMessage="Overview" />
// }, },
{ {
value: 'log', value: 'log',
label: <FormattedMessage id="log" defaultMessage="Log" /> label: <FormattedMessage id="log" defaultMessage="Log" />