Skip to content

Commit 174ae5d

Browse files
committed
added todos and moved the settings api url
1 parent d2c8421 commit 174ae5d

5 files changed

Lines changed: 14 additions & 11 deletions

File tree

NetEvent/Client/Pages/Administration/SystemInfo.razor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public partial class SystemInfo
1717
private ISystemInfoDataService _SystemInfoDataService { get; set; } = default!;
1818

1919
#endregion
20+
21+
// TODO: deceide if _ClientComponents should be SystemInfoComponentEntryDto or not
2022
private readonly IList<SystemInfoComponentEntryDto> _ClientComponents = new List<SystemInfoComponentEntryDto>();
2123
private SystemInfoDto _SystemInfos = new SystemInfoDto();
2224
private string searchStringComponents = string.Empty;
@@ -37,6 +39,7 @@ protected override async Task OnInitializedAsync()
3739
}
3840
}
3941

42+
// TODO: maybe consolidate filter functions?
4043
private bool FilterFuncComponents1(SystemInfoComponentEntryDto systeminfocomponententry) => FilterFuncComponents(systeminfocomponententry, searchStringComponents);
4144

4245
private static bool FilterFuncComponents(SystemInfoComponentEntryDto systeminfocomponententry, string searchString)

NetEvent/Client/Services/SystemSettingsService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async Task<List<SystemSettingValueDto>> GetSystemSettingsAsync(SystemSett
4545
{
4646
var client = _HttpClientFactory.CreateClient(Constants.BackendApiHttpClientName);
4747

48-
var result = await client.GetFromJsonAsync<List<SystemSettingValueDto>>($"api/system/{systemSettingGroup}/all", cancellationToken);
48+
var result = await client.GetFromJsonAsync<List<SystemSettingValueDto>>($"api/system/settings/{systemSettingGroup}/all", cancellationToken);
4949

5050
if (result == null)
5151
{
@@ -68,7 +68,7 @@ public async Task<ServiceResult> UpdateSystemSetting(SystemSettingGroup systemSe
6868
{
6969
var client = _HttpClientFactory.CreateClient(Constants.BackendApiHttpClientName);
7070

71-
var response = await client.PostAsJsonAsync($"api/system/{systemSettingGroup}", systemSetting, cancellationToken);
71+
var response = await client.PostAsJsonAsync($"api/system/settings/{systemSettingGroup}", systemSetting, cancellationToken);
7272

7373
response.EnsureSuccessStatusCode();
7474

NetEvent/Server.Tests/SystemModuleTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task GetOrganizationHandler_Success_Test()
3232
}
3333

3434
// Act
35-
var response = await Client.GetFromJsonAsync<List<SystemSettingValueDto>>($"/api/system/{SystemSettingGroup.OrganizationData}/all");
35+
var response = await Client.GetFromJsonAsync<List<SystemSettingValueDto>>($"/api/system/settings/{SystemSettingGroup.OrganizationData}/all");
3636

3737
// Assert
3838
Assert.NotNull(response);
@@ -49,7 +49,7 @@ public async Task PostOrganizationHandler_Success_Test()
4949
// Insert
5050
var organizationDataCreate = new SystemSettingValueDto("key", "value");
5151

52-
var responseCreate = await Client.PostAsync($"/api/system/{SystemSettingGroup.OrganizationData}", JsonContent.Create(organizationDataCreate));
52+
var responseCreate = await Client.PostAsync($"/api/system/settings/{SystemSettingGroup.OrganizationData}", JsonContent.Create(organizationDataCreate));
5353

5454
responseCreate.EnsureSuccessStatusCode();
5555

@@ -65,7 +65,7 @@ public async Task PostOrganizationHandler_Success_Test()
6565
// Update value
6666
var organizationDataUpdate = new SystemSettingValueDto("key", "value2");
6767

68-
var responseUpdate = await Client.PostAsync($"/api/system/{SystemSettingGroup.OrganizationData}", JsonContent.Create(organizationDataUpdate));
68+
var responseUpdate = await Client.PostAsync($"/api/system/settings/{SystemSettingGroup.OrganizationData}", JsonContent.Create(organizationDataUpdate));
6969

7070
responseUpdate.EnsureSuccessStatusCode();
7171

@@ -84,9 +84,9 @@ public async Task PostOrganizationHandler_Error_Test()
8484
{
8585
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
8686

87-
var responseCreate = await Client.PostAsync($"/api/system/{SystemSettingGroup.OrganizationData}", JsonContent.Create(new SystemSettingValueDto(null, "value")));
87+
var responseCreate = await Client.PostAsync($"/api/system/settings/{SystemSettingGroup.OrganizationData}", JsonContent.Create(new SystemSettingValueDto(null, "value")));
8888
Assert.False(responseCreate.IsSuccessStatusCode);
89-
var responseUpdate = await Client.PostAsync($"/api/system/{SystemSettingGroup.OrganizationData}", JsonContent.Create(new SystemSettingValueDto("key", null)));
89+
var responseUpdate = await Client.PostAsync($"/api/system/settings/{SystemSettingGroup.OrganizationData}", JsonContent.Create(new SystemSettingValueDto("key", null)));
9090
Assert.False(responseUpdate.IsSuccessStatusCode);
9191

9292
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.

NetEvent/Server/Modules/System/Endpoints/GetSystemInfo/GetSystemInfoHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ public Task<GetSystemInfoResponse> Handle(GetSystemInfoRequest request, Cancella
2727
systeminfocomponents.Add(new SystemInfoComponentEntryDto(assem.ManifestModule.Name.ToString(), assem.ToString()));
2828
}
2929

30+
// TODO: is it possible to make that better?
3031
systeminfoversions.Add(new SystemInfoVersionEntryDto("NETEVENT", Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion));
3132
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDNODE", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDNODE")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
3233
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDID", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDID")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
3334
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDNUMBER", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDNUMBER")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
3435
systeminfoversions.Add(new SystemInfoVersionEntryDto("SOURCE_COMMIT", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SOURCE_COMMIT")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
3536

37+
// TODO: think about healthchecks and healthcheck modularity (to perform checks on various services like game servers, the mail server, payment apis ...) and remove dummy services
3638
systeminfohealth.Add(new SystemInfoHealthEntryDto("NETEVENT Server", string.Empty, true));
3739
systeminfohealth.Add(new SystemInfoHealthEntryDto("Email Service", "servername", false));
3840

NetEvent/Server/Modules/System/SystemModule.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ public class SystemModule : ModuleBase
1818
public override IEndpointRouteBuilder MapEndpoints(IEndpointRouteBuilder endpoints)
1919
{
2020
endpoints.MapGet("/api/system/info/all", async ([FromServices] IMediator m) => ToApiResult(await m.Send(new GetSystemInfoRequest())));
21-
22-
// TODO: move to system/settings/
23-
endpoints.MapGet("/api/system/{systemSettingGroup}/all", async ([FromRoute] SystemSettingGroup systemSettingGroup, [FromServices] IMediator m) => ToApiResult(await m.Send(new GetSystemSettingsRequest(systemSettingGroup))));
24-
endpoints.MapPost("/api/system/{systemSettingGroup}", async ([FromRoute] SystemSettingGroup systemSettingGroup, [FromBody] Shared.Dto.SystemSettingValueDto systemSettingsValue, [FromServices] IMediator m) => ToApiResult(await m.Send(new PostSystemSettingsRequest(systemSettingGroup, systemSettingsValue))));
21+
endpoints.MapGet("/api/system/settings/{systemSettingGroup}/all", async ([FromRoute] SystemSettingGroup systemSettingGroup, [FromServices] IMediator m) => ToApiResult(await m.Send(new GetSystemSettingsRequest(systemSettingGroup))));
22+
endpoints.MapPost("/api/system/settings/{systemSettingGroup}", async ([FromRoute] SystemSettingGroup systemSettingGroup, [FromBody] Shared.Dto.SystemSettingValueDto systemSettingsValue, [FromServices] IMediator m) => ToApiResult(await m.Send(new PostSystemSettingsRequest(systemSettingGroup, systemSettingsValue))));
2523

2624
return endpoints;
2725
}

0 commit comments

Comments
 (0)