Skip to content

Commit

Permalink
Merge pull request #37 Main Release to Dev
Browse files Browse the repository at this point in the history
Main Release
  • Loading branch information
g-martin772 authored Jun 9, 2024
2 parents c21458c + a9ab5ce commit 32f281c
Show file tree
Hide file tree
Showing 125 changed files with 10,047 additions and 1,456 deletions.
10 changes: 5 additions & 5 deletions MPM-Betting.Api/MPM-Betting.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions MPM-Betting.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Net.Mail;
using Microsoft.EntityFrameworkCore;
using MPM_Betting.DataModel;
using MPM_Betting.Services;
using MPM_Betting.Services.Data;
using MPM_Betting.Services.Data.BetManager;
using MPM_Betting.Services.Data.GameData;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -16,8 +16,15 @@
builder.AddMpmMail();
builder.AddFootballApi();



builder.Services.AddSingleton<BetProcessor>();
builder.Services.AddSingleton<GameDataUpdater>();
builder.Services.AddSingleton<GameDataUpdateScheduler>();
builder.Services.AddSingleton<GameDataQueueWorker>();
builder.Services.AddSingleton<IBackgroundTaskQueue>(_ => new GameDataUpdateQueue(100));
builder.Services.AddHostedService(services => services.GetRequiredService<BetProcessor>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataUpdater>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataUpdateScheduler>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataQueueWorker>());

var app = builder.Build();

Expand Down
6 changes: 3 additions & 3 deletions MPM-Betting.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18954",
"applicationUrl": "http://0.0.0.0:18954",
"sslPort": 44303
}
},
Expand All @@ -14,7 +14,7 @@
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5241",
"applicationUrl": "http://0.0.0.0:5241",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand All @@ -24,7 +24,7 @@
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7258;http://localhost:5241",
"applicationUrl": "https://0.0.0.0:7258;http://0.0.0.0:5241",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
7 changes: 3 additions & 4 deletions MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Publishing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.UserSecrets;
Expand Down Expand Up @@ -71,7 +69,8 @@ public static IResourceBuilder<ParameterResource> CreateStablePassword(this IDis
{
ParameterDefault generatedPassword = new GenerateParameterDefault
{
MinLength = 22, // enough to give 128 bits of entropy when using the default 67 possible characters. See remarks in PasswordGenerator.Generate
MinLength = 22, // Enough to give 128 bits of entropy when using the default 67 possible characters.
// See remarks in PasswordGenerator.Generate
Lower = lower,
Upper = upper,
Numeric = numeric,
Expand Down Expand Up @@ -122,7 +121,7 @@ private static bool TrySetUserSecret(string applicationName, string name, string
return false;

var appAssembly = Assembly.Load(new AssemblyName(applicationName));
if (appAssembly?.GetCustomAttribute<UserSecretsIdAttribute>()?.UserSecretsId is not { } userSecretsId)
if (appAssembly.GetCustomAttribute<UserSecretsIdAttribute>()?.UserSecretsId is not { } userSecretsId)
return false;

// Save the value to the secret store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class MailDevResource(string name) : ContainerResource(name), IResourceWithConnectionString
{
private EndpointReference? _smtpReference;
private EndpointReference SmtpEndpoint => _smtpReference ??= new EndpointReference(this, "smtp");
private EndpointReference? m_SmtpReference;
private EndpointReference SmtpEndpoint => m_SmtpReference ??= new EndpointReference(this, "smtp");

public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create(
$"smtp://{SmtpEndpoint.Property(EndpointProperty.Host)}:{SmtpEndpoint.Property(EndpointProperty.Port)}"
Expand Down
22 changes: 12 additions & 10 deletions MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var builder = DistributedApplication.CreateBuilder(args);

if (!builder.ExecutionContext.IsPublishMode)
if (!builder.ExecutionContext.IsPublishMode && Environment.GetEnvironmentVariable("AZF") == "true")
{
var azurite = builder.AddContainer("azurite", "mcr.microsoft.com/azure-storage/azurite")
.WithEndpoint(port: 10000, name: "blob", targetPort: 11000)
Expand All @@ -15,20 +15,22 @@
// .WithReference(queue)
// .WithEnvironment("QueueConnectionString", queueConnStrCallback)

var functions = builder.AddAzureFunction<MPM_Betting_Functions>("functions")
builder.AddAzureFunction<MPM_Betting_Functions>("functions")
.WithReference(azurite.GetEndpoint("queue"))
.WithEnvironment("QueueConnectionString", queueConnStrCallback);
}

if (builder.ExecutionContext.IsPublishMode || Environment.GetEnvironmentVariable("METRICS") == "true")
{
builder.AddContainer("grafana", "grafana/grafana")
.WithBindMount(GetFullPath("../grafana/config"), "/etc/grafana", isReadOnly: false)
.WithBindMount(GetFullPath("../grafana/dashboards"), "/var/lib/grafana/dashboards", isReadOnly: false)
.WithHttpEndpoint(port: 3000, targetPort: 3000, isProxied: false);
builder.AddContainer("prometheus", "prom/prometheus")
.WithBindMount(GetFullPath("../prometheus"), "/etc/prometheus")
.WithHttpEndpoint(port: 9090, targetPort: 9090, isProxied: false);
}

var grafana = builder.AddContainer("grafana", "grafana/grafana")
.WithBindMount(GetFullPath("../grafana/config"), "/etc/grafana", isReadOnly: false)
.WithBindMount(GetFullPath("../grafana/dashboards"), "/var/lib/grafana/dashboards", isReadOnly: false)
.WithHttpEndpoint(port: 3000, targetPort: 3000, isProxied: false);

var prometheus = builder.AddContainer("prometheus", "prom/prometheus")
.WithBindMount(GetFullPath("../prometheus"), "/etc/prometheus")
.WithHttpEndpoint(port: 9090, targetPort: 9090, isProxied: false);

var redis = builder.AddRedis("redis")
.WithPersistence()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Prometheus;

namespace Microsoft.Extensions.Hosting;

Expand Down Expand Up @@ -52,7 +51,7 @@ public static IHostBuilder AddServiceDefaults(this IHostBuilder builder)
services.AddOpenTelemetryExporters(context.Configuration);
});

builder.ConfigureServices((context, services) => {
builder.ConfigureServices((_, services) => {
services.AddServiceDiscovery();
services.ConfigureHttpClientDefaults(http =>
{
Expand Down Expand Up @@ -185,7 +184,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
// Add a default liveness check to ensure the app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
Expand Down
55 changes: 39 additions & 16 deletions MPM-Betting.Blazor.ComponentLibrary/DesktopView/Groups.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,58 @@
@using MPM_Betting.Services.Data
@using MPM_Betting.Blazor.ComponentLibrary.DesktopView.SmallComponents
@using Blazorise
@using Microsoft.AspNetCore.Authorization
@using MPM_Betting.Blazor.ComponentLibrary.Core
@using MPM_Betting.DataModel.User
@using MPM_Betting.Services.Domains
@attribute [StreamRendering]
@rendermode InteractiveServer
@inject UserDomain UserDomain
@inject NavigationManager NavigationManager
@attribute [Authorize]

<div class="row GroupsContainer">
<div class="col-11 GroupsMainBox">
<div class="col-11 GroupsMainBox" onclick="@SwitchToGroups">
<h2 class="pt-3 fw-bold">Your Groups</h2>
<div class="line"></div>

@if(GroupsList == null)
@if (User is null)
{
<div> Loading... (I think)</div>
<div class="fs-5 pt-4"> Log in to see your groups</div>
}
else if (GroupsList == null)
{
<div> Loading...</div>
}
else if (GroupsList.Count == 0)
{
<div class="NoGroupsLayout">
<div class="fs-5"> You are not in any groups yet. </div>
</div>
}
else
{
@foreach(var group in GroupsList)
{
<div class="GroupEntry row">
<img class="col-2" src="./Images/Logo_cropped.png"/>
<div class="col-3 GroupEntryImageBox">
<img width="60%" src="./Images/Logo_cropped.png" alt="image"/>
</div>
<div class="col-7">@group.Name</div>
@* TODO Abfrage >:c *@
@switch(1)
{
case 1:
<div class="col-3 gold">1st</div>
<div class="col-2 gold">1st</div>
break;
case 2:
<div class="col-3 silver">2nd</div>
<div class="col-2 silver">2nd</div>
break;
case 3:
<div class="col-3 bronze">3rd</div>
<div class="col-2 bronze">3rd</div>
break;
default:
<div class="col-3">4th</div>
<div class="col-2">4th</div>
break;
}
</div>
Expand All @@ -48,26 +63,34 @@
</div>

@code {
[CascadingParameter] private SyncContextWithPayload<MpmUser>? User { get; set; }
MpmUser? m_UserInstance;
[CascadingParameter] private SyncContextWithPayload<MpmUser>? UserTask { get; set; }
MpmUser? User;
public List<MpmGroup> GroupsList { get; set; }

protected override async Task OnInitializedAsync()
{
if (User is null) return;
await User.SyncEvent.Task;
if (User.Payload is not null)
m_UserInstance = User.Payload;
if (UserTask is null)
return;

await UserTask.SyncEvent.Task;

if (m_UserInstance is null) return;
UserDomain.SetUser(m_UserInstance);
if (UserTask.Payload is not null)
User = UserTask.Payload;

if (User is null) return;
UserDomain.SetUser(User);
var groupResult = await UserDomain.GetGroups();
if (groupResult.IsSuccess)
{
GroupsList = groupResult.Value;
StateHasChanged();
}
}

private void SwitchToGroups()
{
NavigationManager.NavigateTo("/groups");
}

public class TestGroups
{
Expand Down
21 changes: 20 additions & 1 deletion MPM-Betting.Blazor.ComponentLibrary/DesktopView/Groups.razor.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
.GroupsContainer {
.NoGroupsLayout {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
}

.NoGroupsLayout > * {
margin-top: 3%;
margin-bottom: 5%;
}

.GroupsContainer {
justify-self: center;
justify-items: center;
margin-top: 5%;
Expand Down Expand Up @@ -36,12 +49,18 @@
.GroupEntry {
display: flex;
justify-content: left;
align-items: center;
margin: 1% 0;
font-size: 18px;
padding: 2% 0;
border-radius: 10px;
}

.GroupEntryImageBox {
display: flex;
justify-content: center;
}

.GroupEntry:hover {
background: rgb(90,90,90);
}
Expand Down
34 changes: 0 additions & 34 deletions MPM-Betting.Blazor.ComponentLibrary/DesktopView/Leagues.razor

This file was deleted.

Loading

0 comments on commit 32f281c

Please sign in to comment.