|
@@ -63,22 +63,16 @@
[Parameter] public NodeResponse Node { get; set; }
private DataGrid Grid;
-
- private async Task> ItemsProviderAsync(
- DataGridItemRequest request
- )
- {
- var query = $"?startIndex={request.StartIndex}&count={request.Count}";
- var countedData = await ApiClient.GetJson>(
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
+ {
+ var query = $"?startIndex={startIndex}&count={count}";
+
+ return await ApiClient.GetJson>(
$"api/admin/servers/nodes/{Node.Id}/allocations{query}"
);
-
- return new()
- {
- TotalCount = countedData.TotalCount,
- Items = countedData.Items
- };
}
private async Task AddAllocationRangeAsync()
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Allocations.razor b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Allocations.razor
index cb276ea..5e82390 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Allocations.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Allocations.razor
@@ -1,8 +1,9 @@
+@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@using MoonCore.Blazor.FlyonUi.Forms
+@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
@@ -13,9 +14,8 @@
+ ItemSource="ItemSource">
@@ -26,19 +26,17 @@
[Parameter] public CreateServerRequest Request { get; set; }
[Parameter] public Create Parent { get; set; }
- private async Task ItemSourceAsync()
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
{
// Handle unselected node
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (Parent.Node == null)
return [];
- var items = await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
);
-
- return items;
}
}
\ No newline at end of file
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/General.razor b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/General.razor
index fd0121f..dddb6e6 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/General.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/General.razor
@@ -1,10 +1,11 @@
+@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using Moonlight.Shared.Http.Responses.Admin.Users
@using MoonCore.Blazor.FlyonUi.Forms
+@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
@@ -22,8 +23,7 @@
@@ -34,8 +34,7 @@
@@ -46,8 +45,7 @@
@@ -91,30 +89,28 @@
[Parameter] public CreateServerRequest Request { get; set; }
[Parameter] public Create Parent { get; set; }
- private async Task LoadStarsAsync()
+ private ItemSource StarsItemSource => ItemSourceFactory.From(LoadStarsAsync);
+ private ItemSource NodesItemSource => ItemSourceFactory.From(LoadNodesAsync);
+ private ItemSource UsersItemSource => ItemSourceFactory.From(LoadUsersAsync);
+
+ private async Task> LoadStarsAsync(int startIndex, int count)
{
- return await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/servers/stars?startIndex={startIndex}&count={count}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/servers/stars?startIndex={startIndex}&count={count}"
);
}
- private async Task LoadNodesAsync()
+ private async Task> LoadNodesAsync(int startIndex, int count)
{
- return await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
);
}
- private async Task LoadUsersAsync()
+ private async Task> LoadUsersAsync(int startIndex, int count)
{
- return await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/users?startIndex={startIndex}&count={count}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/users?startIndex={startIndex}&count={count}"
);
}
}
\ No newline at end of file
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Variables.razor b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Variables.razor
index ae34c01..77b5b2f 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Variables.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/CreatePartials/Variables.razor
@@ -1,7 +1,7 @@
@using MoonCore.Blazor.FlyonUi.Components
+@using MoonCore.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Frontend.UI.Views.Admin.All
@using MoonlightServers.Shared.Http.Requests.Admin.ServerVariables
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
@@ -51,10 +51,10 @@
StarVariables = [];
return;
}
-
- StarVariables = await CountedData.LoadAllAsync(async (startIndex, count) =>
+
+ StarVariables = await CountedData.AllAsync(async (index, count) =>
await ApiClient.GetJson>(
- $"api/admin/servers/stars/{Parent.Star.Id}/variables?startIndex={startIndex}&count={count}"
+ $"api/admin/servers/stars/{Parent.Star.Id}/variables?startIndex={index}&count={count}"
)
);
}
@@ -77,7 +77,7 @@
{
Key = starVariable.Key
};
-
+
Request.Variables.Add(serverVar);
}
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/CreateShareModal.razor b/MoonlightServers.Frontend/UI/Components/Servers/CreateShareModal.razor
index be3051e..97a4227 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/CreateShareModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/CreateShareModal.razor
@@ -3,7 +3,7 @@
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
@using MoonlightServers.Shared.Http.Responses.Client.Servers
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/SharesTab.razor b/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/SharesTab.razor
index 08f995b..7b86a3a 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/SharesTab.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/SharesTab.razor
@@ -2,7 +2,7 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
-@using MoonCore.Models
+@using MoonCore.Common
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Shares
@@ -65,7 +65,7 @@
private async Task LoadAsync(LazyLoader _)
{
- Shares = await CountedData.LoadAllAsync(async (startIndex, count)
+ Shares = await CountedData.AllAsync(async (startIndex, count)
=> await ShareService.GetAsync(Server.Id, startIndex, count)
);
}
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/VariablesTab.razor b/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/VariablesTab.razor
index 06f0232..8cd6580 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/VariablesTab.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/ServerTabs/VariablesTab.razor
@@ -1,6 +1,6 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
-@using MoonCore.Models
+@using MoonCore.Common
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Variables
@@ -42,7 +42,7 @@
private async Task LoadAsync(LazyLoader _)
{
- Variables = await CountedData.LoadAllAsync(async (startIndex, count)
+ Variables = await CountedData.AllAsync(async (startIndex, count)
=> await ServerService.GetVariablesAsync(Server.Id, startIndex, count)
);
}
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Allocations.razor b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Allocations.razor
index 0ac3e92..d404d5f 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Allocations.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Allocations.razor
@@ -1,9 +1,10 @@
+@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
@using MoonCore.Blazor.FlyonUi.Forms
+@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
@@ -15,8 +16,7 @@
+ ItemSource="ItemSource">
@@ -28,12 +28,12 @@
[Parameter] public ServerResponse Server { get; set; }
[Parameter] public Update Parent { get; set; }
- private async Task LoaderAsync()
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
{
- return await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
);
}
}
\ No newline at end of file
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/General.razor b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/General.razor
index 85393ee..7e6d3b3 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/General.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/General.razor
@@ -1,8 +1,9 @@
+@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using Moonlight.Shared.Http.Responses.Admin.Users
@using MoonCore.Blazor.FlyonUi.Forms
+@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
@@ -20,9 +21,8 @@
+ ItemSource="UserItemSource">
@@ -64,12 +64,12 @@
[Parameter] public UpdateServerRequest Request { get; set; }
[Parameter] public Update Parent { get; set; }
- private async Task LoaderAsync()
+ private ItemSource UserItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
{
- return await CountedData.LoadAllAsync(async (startIndex, count) =>
- await ApiClient.GetJson>(
- $"api/admin/users?startIndex={startIndex}&count={count}"
- )
+ return await ApiClient.GetJson>(
+ $"api/admin/users?startIndex={startIndex}&count={count}"
);
}
}
\ No newline at end of file
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Variables.razor b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Variables.razor
index 6f45404..9b6dd73 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Variables.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/UpdatePartials/Variables.razor
@@ -1,7 +1,7 @@
@using MoonCore.Blazor.FlyonUi.Components
+@using MoonCore.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Shared.Http.Requests.Admin.ServerVariables
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
@using MoonlightServers.Shared.Http.Responses.Admin.ServerVariables
@@ -50,13 +50,13 @@
private async Task LoadAsync(LazyLoader _)
{
- StarVariables = await CountedData.LoadAllAsync(async (startIndex, count) =>
+ StarVariables = await CountedData.AllAsync(async (startIndex, count) =>
await ApiClient.GetJson>(
$"api/admin/servers/stars/{Server.StarId}/variables?startIndex={startIndex}&count={count}"
)
);
- ServerVariables = await CountedData.LoadAllAsync(async (startIndex, count) =>
+ ServerVariables = await CountedData.AllAsync(async (startIndex, count) =>
await ApiClient.GetJson>(
$"api/admin/servers/{Server.Id}/variables?startIndex={startIndex}&count={count}"
)
diff --git a/MoonlightServers.Frontend/UI/Components/Servers/UpdateShareModal.razor b/MoonlightServers.Frontend/UI/Components/Servers/UpdateShareModal.razor
index baeecd2..064af66 100644
--- a/MoonlightServers.Frontend/UI/Components/Servers/UpdateShareModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Servers/UpdateShareModal.razor
@@ -4,7 +4,7 @@
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Shares
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateDockerImageModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateDockerImageModal.razor
index 0b583fe..2730c80 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateDockerImageModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateDockerImageModal.razor
@@ -2,7 +2,7 @@
@using MoonlightServers.Frontend.UI.Components.Forms
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateParseConfigModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateParseConfigModal.razor
index 55dcd63..ad460ff 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateParseConfigModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateParseConfigModal.razor
@@ -2,7 +2,7 @@
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Models
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateVariableModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateVariableModal.razor
index 132f0a0..4d137d0 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateVariableModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/CreateVariableModal.razor
@@ -3,7 +3,7 @@
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
@using MoonlightServers.Frontend.UI.Components.Forms
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateDockerImageModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateDockerImageModal.razor
index a17e8f7..0a2d1d7 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateDockerImageModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateDockerImageModal.razor
@@ -3,7 +3,7 @@
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateParseConfigModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateParseConfigModal.razor
index f70e71c..6c29cf9 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateParseConfigModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateParseConfigModal.razor
@@ -2,7 +2,7 @@
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Models
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateVariableModal.razor b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateVariableModal.razor
index 56ac0a2..20750b1 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateVariableModal.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/Modals/UpdateVariableModal.razor
@@ -4,7 +4,7 @@
@using MoonlightServers.Frontend.UI.Components.Forms
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
-@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
+@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/DockerImage.razor b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/DockerImage.razor
index a617630..75febf5 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/DockerImage.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/DockerImage.razor
@@ -2,8 +2,8 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
+@using MoonCore.Common
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Frontend.UI.Components.Stars.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
@@ -18,7 +18,7 @@
-
+
@foreach (var dockerImage in DockerImages)
{
@@ -30,11 +30,13 @@
-
@@ -47,19 +49,17 @@
@code
{
[Parameter] public StarResponse Star { get; set; }
-
+
private StarDockerImageResponse[] DockerImages;
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader _)
{
- var pagedVariables = await ApiClient.GetJson >(
- $"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex=0&count=100"
+ DockerImages = await CountedData.AllAsync(async (startIndex, count) =>
+ await ApiClient.GetJson>(
+ $"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex={startIndex}&count={count}"
+ )
);
-
- // TODO: Improve paged stuff
-
- DockerImages = pagedVariables.Items;
}
private async Task AddDockerImageAsync()
@@ -67,34 +67,31 @@
Func onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/dockerImages", request);
-
+
await ToastService.SuccessAsync("Successfully created docker image");
await LazyLoader.ReloadAsync();
};
-
- await ModalService.LaunchAsync(parameters =>
- {
- parameters.Add("OnSubmit", onSubmit);
- });
+
+ await ModalService.LaunchAsync(parameters => { parameters.Add("OnSubmit", onSubmit); });
}
-
+
private async Task UpdateDockerImageAsync(StarDockerImageResponse dockerImage)
{
Func onSubmit = async request =>
{
await ApiClient.Patch($"api/admin/servers/stars/{Star.Id}/dockerImages/{dockerImage.Id}", request);
-
+
await ToastService.SuccessAsync("Successfully updated docker image");
await LazyLoader.ReloadAsync();
};
-
+
await ModalService.LaunchAsync(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
parameters.Add("DockerImage", dockerImage);
});
}
-
+
private async Task DeleteDockerImageAsync(StarDockerImageResponse dockerImage)
{
await AlertService.ConfirmDangerAsync(
@@ -103,7 +100,7 @@
async () =>
{
await ApiClient.Delete($"api/admin/servers/stars/{Star.Id}/dockerImages/{dockerImage.Id}");
-
+
await ToastService.SuccessAsync("Successfully deleted docker image");
await LazyLoader.ReloadAsync();
}
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Misc.razor b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Misc.razor
index 495598e..40b9c06 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Misc.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Misc.razor
@@ -1,6 +1,6 @@
@using MoonCore.Blazor.FlyonUi.Components
+@using MoonCore.Common
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
diff --git a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Variables.razor b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Variables.razor
index 383898b..ce78720 100644
--- a/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Variables.razor
+++ b/MoonlightServers.Frontend/UI/Components/Stars/UpdatePartials/Variables.razor
@@ -2,8 +2,8 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
+@using MoonCore.Common
@using MoonCore.Helpers
-@using MoonCore.Models
@using MoonlightServers.Frontend.UI.Components.Stars.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@@ -28,7 +28,7 @@
@variable.Name
-
+
UpdateVariableAsync(variable)" class="btn btn-primary">
@@ -47,17 +47,17 @@
@code
{
[Parameter] public StarResponse Star { get; set; }
-
+
private StarVariableResponse[] CurrentVariables;
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader arg)
{
- var pagedVariables = await ApiClient.GetJson>(
- $"api/admin/servers/stars/{Star.Id}/variables?startIndex=0&count=100"
+ CurrentVariables = await CountedData.AllAsync(async (startIndex, count) =>
+ await ApiClient.GetJson>(
+ $"api/admin/servers/stars/{Star.Id}/variables?startIndex={startIndex}&count={count}"
+ )
);
-
- CurrentVariables = pagedVariables.Items;
}
private async Task AddVariableAsync()
@@ -65,27 +65,24 @@
Func onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/variables", request);
-
+
await ToastService.SuccessAsync("Successfully created variable");
await LazyLoader.ReloadAsync();
};
-
- await ModalService.LaunchAsync(parameters =>
- {
- parameters.Add("OnSubmit", onSubmit);
- }, "max-w-xl");
+
+ await ModalService.LaunchAsync(parameters => { parameters.Add("OnSubmit", onSubmit); }, "max-w-xl");
}
-
+
private async Task UpdateVariableAsync(StarVariableResponse variable)
{
Func onSubmit = async request =>
{
await ApiClient.Patch($"api/admin/servers/stars/{Star.Id}/variables/{variable.Id}", request);
-
+
await ToastService.SuccessAsync("Successfully updated variable");
await LazyLoader.ReloadAsync();
};
-
+
await ModalService.LaunchAsync(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
@@ -101,7 +98,7 @@
async () =>
{
await ApiClient.Delete($"api/admin/servers/stars/{Star.Id}/variables/{variable.Id}");
-
+
await ToastService.SuccessAsync("Successfully deleted variable");
await LazyLoader.ReloadAsync();
}
diff --git a/MoonlightServers.Frontend/UI/Views/Admin/All/Index.razor b/MoonlightServers.Frontend/UI/Views/Admin/All/Index.razor
index 98933d8..89739c8 100644
--- a/MoonlightServers.Frontend/UI/Views/Admin/All/Index.razor
+++ b/MoonlightServers.Frontend/UI/Views/Admin/All/Index.razor
@@ -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 @@
+ ItemSource="ItemSource">
@@ -99,11 +99,11 @@
private Dictionary Nodes = new();
private Dictionary Users = new();
- private async Task> ItemsProviderAsync(
- DataGridItemRequest request
- )
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
{
- var query = $"?startIndex={request.StartIndex}&count={request.Count}";
+ var query = $"?startIndex={startIndex}&count={count}";
var countedData = await ApiClient.GetJson>($"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)
diff --git a/MoonlightServers.Frontend/UI/Views/Admin/Nodes/Index.razor b/MoonlightServers.Frontend/UI/Views/Admin/Nodes/Index.razor
index 84de7f0..b2babc1 100644
--- a/MoonlightServers.Frontend/UI/Views/Admin/Nodes/Index.razor
+++ b/MoonlightServers.Frontend/UI/Views/Admin/Nodes/Index.razor
@@ -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 @@
+ ItemSource="ItemSource">
@@ -159,12 +159,12 @@
private Dictionary StatusResponses = new();
private Dictionary Statistics = new();
+
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
- private async Task> ItemsProviderAsync(
- DataGridItemRequest request
- )
+ private async Task> LoadAsync(int startIndex, int count)
{
- var query = $"?startIndex={request.StartIndex}&count={request.Count}";
+ var query = $"?startIndex={startIndex}&count={count}";
var countedData = await ApiClient.GetJson>($"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)
diff --git a/MoonlightServers.Frontend/UI/Views/Admin/Stars/Index.razor b/MoonlightServers.Frontend/UI/Views/Admin/Stars/Index.razor
index aa35fcd..3b10c88 100644
--- a/MoonlightServers.Frontend/UI/Views/Admin/Stars/Index.razor
+++ b/MoonlightServers.Frontend/UI/Views/Admin/Stars/Index.razor
@@ -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 @@
+ ItemSource="ItemSource">
|
@@ -91,19 +91,13 @@
{
private DataGrid Grid;
- private async Task> ItemsProviderAsync(
- DataGridItemRequest request
- )
+ private ItemSource ItemSource => ItemSourceFactory.From(LoadAsync);
+
+ private async Task> LoadAsync(int startIndex, int count)
{
- var query = $"?startIndex={request.StartIndex}&count={request.Count}";
+ var query = $"?startIndex={startIndex}&count={count}";
- var countedData = await ApiClient.GetJson>($"api/admin/servers/stars{query}");
-
- return new()
- {
- TotalCount = countedData.TotalCount,
- Items = countedData.Items
- };
+ return await ApiClient.GetJson>($"api/admin/servers/stars{query}");
}
private async Task DeleteAsync(StarResponse response)
diff --git a/MoonlightServers.Frontend/UI/Views/Client/Index.razor b/MoonlightServers.Frontend/UI/Views/Client/Index.razor
index 0ac125a..d648a54 100644
--- a/MoonlightServers.Frontend/UI/Views/Client/Index.razor
+++ b/MoonlightServers.Frontend/UI/Views/Client/Index.razor
@@ -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.LoadAllAsync(async (startIndex, count) =>
+ OwnServers = await CountedData.AllAsync(async (startIndex, count) =>
await ServerService.GetServersAsync(startIndex, count)
);
}
private async Task LoadSharedServersAsync(LazyLoader lazyLoader)
{
- SharedServers = await CountedData.LoadAllAsync(async (startIndex, count) =>
+ SharedServers = await CountedData.AllAsync(async (startIndex, count) =>
await ServerService.GetSharedServersAsync(startIndex, count)
);
}
| | | |