Upgraded mooncore. Done required refactoring to function with new version
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
@page "/admin/servers/all"
|
||||
|
||||
@using MoonCore.Blazor.FlyonUi.Alerts
|
||||
@using MoonCore.Blazor.FlyonUi.Common
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Blazor.FlyonUi.Grid
|
||||
@using MoonCore.Blazor.FlyonUi.Grid.Columns
|
||||
@using MoonCore.Common
|
||||
@using Moonlight.Shared.Http.Responses.Admin.Users
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
@@ -32,8 +33,7 @@
|
||||
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="ServerResponse"
|
||||
EnablePagination="true"
|
||||
ItemsProvider="ItemsProviderAsync">
|
||||
ItemSource="ItemSource">
|
||||
<PropertyColumn Field="x => x.Id"/>
|
||||
<TemplateColumn Title="Name">
|
||||
<td>
|
||||
@@ -99,11 +99,11 @@
|
||||
private Dictionary<int, NodeResponse> Nodes = new();
|
||||
private Dictionary<int, UserResponse> Users = new();
|
||||
|
||||
private async Task<DataGridItemResult<ServerResponse>> ItemsProviderAsync(
|
||||
DataGridItemRequest request
|
||||
)
|
||||
private ItemSource<ServerResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<ServerResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
var query = $"?startIndex={startIndex}&count={count}";
|
||||
|
||||
var countedData = await ApiClient.GetJson<CountedData<ServerResponse>>($"api/admin/servers{query}");
|
||||
|
||||
@@ -142,11 +142,7 @@
|
||||
Users[user.Id] = user;
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
Items = countedData.Items,
|
||||
TotalCount = countedData.TotalCount
|
||||
};
|
||||
return countedData;
|
||||
}
|
||||
|
||||
private async Task DeleteAsync(ServerResponse response)
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using MoonCore.Blazor.FlyonUi.Alerts
|
||||
@using MoonCore.Blazor.FlyonUi.Common
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||
@using MoonlightServers.Frontend.Services
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Statistics
|
||||
@@ -12,6 +12,7 @@
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Blazor.FlyonUi.Grid
|
||||
@using MoonCore.Blazor.FlyonUi.Grid.Columns
|
||||
@using MoonCore.Common
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
@inject NodeService NodeService
|
||||
@@ -35,8 +36,7 @@
|
||||
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="NodeResponse"
|
||||
EnablePagination="true"
|
||||
ItemsProvider="ItemsProviderAsync">
|
||||
ItemSource="ItemSource">
|
||||
<PropertyColumn Field="x => x.Id"/>
|
||||
<TemplateColumn Title="Name">
|
||||
<td>
|
||||
@@ -159,12 +159,12 @@
|
||||
|
||||
private Dictionary<int, NodeSystemStatusResponse?> StatusResponses = new();
|
||||
private Dictionary<int, StatisticsResponse?> Statistics = new();
|
||||
|
||||
private ItemSource<NodeResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<DataGridItemResult<NodeResponse>> ItemsProviderAsync(
|
||||
DataGridItemRequest request
|
||||
)
|
||||
private async Task<IEnumerable<NodeResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
var query = $"?startIndex={startIndex}&count={count}";
|
||||
|
||||
var countedData = await ApiClient.GetJson<CountedData<NodeResponse>>($"api/admin/servers/nodes{query}");
|
||||
|
||||
@@ -210,12 +210,8 @@
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
});
|
||||
|
||||
return new()
|
||||
{
|
||||
Items = countedData.Items,
|
||||
TotalCount = countedData.TotalCount
|
||||
};
|
||||
|
||||
return countedData;
|
||||
}
|
||||
|
||||
private async Task DeleteAsync(NodeResponse response)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
@page "/admin/servers/stars"
|
||||
|
||||
@using MoonCore.Blazor.FlyonUi.Alerts
|
||||
@using MoonCore.Blazor.FlyonUi.Common
|
||||
@using MoonCore.Blazor.FlyonUi.Helpers
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||
@using MoonCore.Exceptions
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Blazor.FlyonUi.Grid
|
||||
@using MoonCore.Blazor.FlyonUi.Grid.Columns
|
||||
@using MoonCore.Common
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
@inject DownloadService DownloadService
|
||||
@@ -38,8 +39,7 @@
|
||||
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="StarResponse"
|
||||
EnablePagination="true"
|
||||
ItemsProvider="ItemsProviderAsync">
|
||||
ItemSource="ItemSource">
|
||||
<PropertyColumn Field="x => x.Id" />
|
||||
<TemplateColumn Title="Name">
|
||||
<td>
|
||||
@@ -91,19 +91,13 @@
|
||||
{
|
||||
private DataGrid<StarResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<StarResponse>> ItemsProviderAsync(
|
||||
DataGridItemRequest request
|
||||
)
|
||||
private ItemSource<StarResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<StarResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
var query = $"?startIndex={startIndex}&count={count}";
|
||||
|
||||
var countedData = await ApiClient.GetJson<CountedData<StarResponse>>($"api/admin/servers/stars{query}");
|
||||
|
||||
return new()
|
||||
{
|
||||
TotalCount = countedData.TotalCount,
|
||||
Items = countedData.Items
|
||||
};
|
||||
return await ApiClient.GetJson<CountedData<StarResponse>>($"api/admin/servers/stars{query}");
|
||||
}
|
||||
|
||||
private async Task DeleteAsync(StarResponse response)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
@page "/servers"
|
||||
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Common
|
||||
@using MoonlightServers.Frontend.UI.Components.Servers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Frontend.Services
|
||||
@using MoonlightServers.Shared.Http.Responses.Client.Servers
|
||||
|
||||
@@ -74,14 +74,14 @@
|
||||
|
||||
private async Task LoadOwnServersAsync(LazyLoader lazyLoader)
|
||||
{
|
||||
OwnServers = await CountedData<ServerDetailResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
OwnServers = await CountedData.AllAsync<ServerDetailResponse>(async (startIndex, count) =>
|
||||
await ServerService.GetServersAsync(startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task LoadSharedServersAsync(LazyLoader lazyLoader)
|
||||
{
|
||||
SharedServers = await CountedData<ServerDetailResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
SharedServers = await CountedData.AllAsync<ServerDetailResponse>(async (startIndex, count) =>
|
||||
await ServerService.GetSharedServersAsync(startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user