Updated pv view in frontend

Updated CORS settings in createBucket function
This commit is contained in:
Noe 2024-07-01 13:25:24 +02:00
parent fd4610208d
commit e05c36051b
3 changed files with 64 additions and 15 deletions

View File

@ -135,22 +135,71 @@ public static class S3
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 response = await region.GetS3Client().PutBucketAsync(request);
var response = await region
.GetS3Client()
.PutBucketAsync(request);
return response.HttpStatusCode switch
if (response.HttpStatusCode == HttpStatusCode.OK)
{
HttpStatusCode.OK => region.Bucket(name),
_ => null
};
// Define CORS configuration rules
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)
{

View File

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

View File

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