Skip to content

Commit

Permalink
WIP - toolbox changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidreneuw committed Feb 13, 2025
1 parent 1738b10 commit 4c6aec1
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,13 @@ public async Task<PortalUser> GetPortalUserWithAchievementsAsync(string userGrap

return portalUser;
}

public async Task<bool> CheckUserInTenant(string email)
{
PrepareAuthenticatedClient();
var users = await graphServiceClient.Users.GetAsync(
test => test.QueryParameters.Filter = $"mail eq '{email}'");
if (users?.Value != null) return users.Value.Count > 0;
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@using Datahub.Shared.Entities
@using Datahub.Portal.Pages.Account

<SettingsField Label="@Localizer["Database tier"]"
Description="@Localizer["Choose a tier for the compute of your database. This will affect the performance and cost of your database."]">
<MudSelect T="string" Label="@Localizer["Database tier"]" @bind-Value="@Configuration.PSQL_SKU">
@foreach (var tier in AvailableTiers)
{
<MudSelectItem Value="@tier.PSQL_SKU">
@TierLabel(tier.PSQL_SKU)
</MudSelectItem>
}
</MudSelect>
</SettingsField>


@code {
[Parameter] public PostgresConfiguration Configuration { get; set; }

private List<PostgresTier> AvailableTiers { get; set; }
private PostgresTier DefaultTier => AvailableTiers.First(t => t.PSQL_SKU == "B_Standard_B1ms");

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
AvailableTiers = PostgresTier.GetPostgresTiers().Where(t => t.IsAvailable).ToList();
Configuration.PSQL_SKU ??= DefaultTier.PSQL_SKU;
}

private string TierLabel(string sku)
{
var skuTier = AvailableTiers.FirstOrDefault(t => t.PSQL_SKU == sku);
if (skuTier == null)
{
return sku;
}

return Localizer["{0} - {1} vCores, {2} RAM, {3}", skuTier.SKUName, skuTier.Cores, skuTier.MemorySize, skuTier.Cost];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@using Datahub.Shared
@using Datahub.Core.Services.Projects
@using Datahub.Infrastructure.Services.Toolbox
@using Datahub.Portal.Pages.Account
@using Datahub.Portal.Pages.Workspace.Toolbox.ConfigurationForms

@inherits ViewUserBase<WorkspaceToolboxPage>

Expand Down Expand Up @@ -145,7 +145,7 @@
<MudStack Spacing="4">
@foreach (var transaction in _transactions.Where(tr => tr.Type == ToolboxTransactionType.Add || tr.Type == ToolboxTransactionType.Update))
{
<MudPaper Elevation="0" Outlined Class="pa-4">
<MudPaper Elevation="0" Outlined Class="pa-8">
<MudStack Row AlignItems="AlignItems.Center" Class="mb-4">
<DHIcon Icon="@GetIcon(transaction.Tool)" Size="Size.Large"/>
<MudText Typo="Typo.h3">
Expand All @@ -156,29 +156,14 @@
@switch (transaction.Tool)
{
case TerraformTemplate.AzurePostgres:
case TerraformTemplate.AzureAppService:
<SettingsField Label="@Localizer["Database tier"]"
Description="@Localizer["Choose a tier for the compute of your database. This will affect the performance and cost of your database."]">
<MudSelect T="string" Label="@Localizer["Database tier"]">
<MudSelectItem
Value="@basicTier">@Localizer["Basic"]</MudSelectItem>
<MudSelectItem
Value="@generalPurposeTier">@Localizer["General Purpose"]</MudSelectItem>
<MudSelectItem
Value="@memoryOptimizedTier">@Localizer["Memory Optimized"]</MudSelectItem>
</MudSelect>
</SettingsField>
<SettingsField Label="@Localizer["Database size"]"
Description="@Localizer["Choose the size of your database. This will affect the cost of your database"]">
<MudSelect T="string" Label="@Localizer["Database size"]">
<MudSelectItem
Value="@basicTier">@Localizer["Basic"]</MudSelectItem>
<MudSelectItem
Value="@generalPurposeTier">@Localizer["General Purpose"]</MudSelectItem>
<MudSelectItem
Value="@memoryOptimizedTier">@Localizer["Memory Optimized"]</MudSelectItem>
</MudSelect>
</SettingsField>
transaction.OriginalData = _workspaceDefinition.AppData.PostgresConfiguration ?? new PostgresConfiguration();
transaction.UpdatedData = new PostgresConfiguration { PSQL_SKU = _workspaceDefinition.AppData.PostgresConfiguration?.PSQL_SKU ?? null };
<PostgresConfigurationForm Configuration="@transaction.UpdatedData"/>
break;
default:
<MudText Style="font-style: italic">
@Localizer["No configuration available for this tool"]
</MudText>
break;
}
</MudStack>
Expand Down Expand Up @@ -346,10 +331,8 @@
private Datahub_Project _workspace;
private WorkspaceDefinition _workspaceDefinition;
private PortalUser _viewedPortalUser;
private string basicTier = "Basic";
private string generalPurposeTier = "General Purpose";
private string memoryOptimizedTier = "Memory Optimized";
private List<ToolboxTransaction> _transactions;
private PostgresConfiguration _postgresConfiguration = new();

private List<string> _toolCatalog = new();

Expand Down
26 changes: 21 additions & 5 deletions Shared/src/Datahub.Shared/Entities/PostgresTier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ public class PostgresTier
public static List<PostgresTier> GetPostgresTiers()
{
var postgresTiers = new List<PostgresTier>();
postgresTiers.Add(new PostgresTier { SKUName = "B1ms (default)", Cores = 1, MemorySize = "2GiB", PSQL_SKU = "B_Standard_B1ms", Cost = "$12.41/month", IsAvailable = true });
postgresTiers.Add(new PostgresTier { SKUName = "B2s", Cores = 2, MemorySize = "4GiB", PSQL_SKU = "B_Standard_B2s", Cost = "$49.64/month", IsAvailable = true });
postgresTiers.Add(new PostgresTier { SKUName = "B4ms", Cores = 4, MemorySize = "16GiB", PSQL_SKU = "B_Standard_B4ms", Cost = "$198.56/month", IsAvailable = true });
postgresTiers.Add(new PostgresTier { SKUName = "B8ms", Cores = 8, MemorySize = "32GiB", PSQL_SKU = "B_Standard_B8ms", Cost = "$397.12/month", IsAvailable = true });
postgresTiers.Add(new PostgresTier
{
SKUName = "B1ms (default)", Cores = 1, MemorySize = "2GiB", PSQL_SKU = "B_Standard_B1ms",
Cost = "$12.41/month", IsAvailable = true
});
postgresTiers.Add(new PostgresTier
{
SKUName = "B2s", Cores = 2, MemorySize = "4GiB", PSQL_SKU = "B_Standard_B2s", Cost = "$49.64/month",
IsAvailable = true
});
postgresTiers.Add(new PostgresTier
{
SKUName = "B4ms", Cores = 4, MemorySize = "16GiB", PSQL_SKU = "B_Standard_B4ms", Cost = "$198.56/month",
IsAvailable = true
});
postgresTiers.Add(new PostgresTier
{
SKUName = "B8ms", Cores = 8, MemorySize = "32GiB", PSQL_SKU = "B_Standard_B8ms", Cost = "$397.12/month",
IsAvailable = true
});

return postgresTiers;
}
}
}
}

0 comments on commit 4c6aec1

Please sign in to comment.