Upgraded mooncore. Done required refactoring to function with new version
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using XtermBlazor
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
|
||||
|
||||
@inject IJSRuntime JsRuntime
|
||||
@inject ILogger<FullScreenModal> Logger
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@using MoonlightServers.Frontend.UI.Components.Forms
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
||||
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
@using MoonCore.Blazor.FlyonUi.Alerts
|
||||
@using MoonCore.Blazor.FlyonUi.Common
|
||||
@using MoonCore.Blazor.FlyonUi.Grid
|
||||
@using MoonCore.Blazor.FlyonUi.Grid.Columns
|
||||
@using MoonCore.Blazor.FlyonUi.Modals
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Common
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Frontend.UI.Components.Nodes.Modals
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
||||
@@ -34,9 +35,8 @@
|
||||
<div class="col-span-1 md:col-span-2 -mb-3">
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="NodeAllocationResponse"
|
||||
EnablePagination="true"
|
||||
ItemsProvider="ItemsProviderAsync">
|
||||
<PropertyColumn Field="x => x.IpAddress" Title="IP Address" />
|
||||
ItemSource="ItemSource">
|
||||
<PropertyColumn Field="x => x.IpAddress" Title="IP Address"/>
|
||||
<PropertyColumn Field="x => x.Port"/>
|
||||
<TemplateColumn>
|
||||
<td>
|
||||
@@ -63,22 +63,16 @@
|
||||
[Parameter] public NodeResponse Node { get; set; }
|
||||
|
||||
private DataGrid<NodeAllocationResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<NodeAllocationResponse>> ItemsProviderAsync(
|
||||
DataGridItemRequest request
|
||||
)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
|
||||
var countedData = await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
var query = $"?startIndex={startIndex}&count={count}";
|
||||
|
||||
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Node.Id}/allocations{query}"
|
||||
);
|
||||
|
||||
return new()
|
||||
{
|
||||
TotalCount = countedData.TotalCount,
|
||||
Items = countedData.Items
|
||||
};
|
||||
}
|
||||
|
||||
private async Task AddAllocationRangeAsync()
|
||||
|
||||
@@ -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 @@
|
||||
<div class="mt-2">
|
||||
<InputMultipleItem TItem="NodeAllocationResponse"
|
||||
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
SearchField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
Value="Parent.Allocations"
|
||||
ItemSource="ItemSourceAsync">
|
||||
ItemSource="ItemSource">
|
||||
</InputMultipleItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,19 +26,17 @@
|
||||
[Parameter] public CreateServerRequest Request { get; set; }
|
||||
[Parameter] public Create Parent { get; set; }
|
||||
|
||||
private async Task<NodeAllocationResponse[]> ItemSourceAsync()
|
||||
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
// Handle unselected node
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
if (Parent.Node == null)
|
||||
return [];
|
||||
|
||||
var items = await CountedData<NodeAllocationResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
|
||||
);
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -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 @@
|
||||
<div class="mt-2">
|
||||
<InputItem TItem="UserResponse"
|
||||
DisplayField="@(x => x.Username)"
|
||||
SearchField="@(x => x.Username)"
|
||||
ItemSource="LoadUsersAsync"
|
||||
ItemSource="UsersItemSource"
|
||||
@bind-Value="Parent.Owner">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -34,8 +34,7 @@
|
||||
<div class="mt-2">
|
||||
<InputItem TItem="StarResponse"
|
||||
DisplayField="@(x => x.Name)"
|
||||
SearchField="@(x => x.Name)"
|
||||
ItemSource="LoadStarsAsync"
|
||||
ItemSource="StarsItemSource"
|
||||
@bind-Value="Parent.Star">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -46,8 +45,7 @@
|
||||
<div class="mt-2">
|
||||
<InputItem TItem="NodeResponse"
|
||||
DisplayField="@(x => x.Name)"
|
||||
SearchField="@(x => x.Name)"
|
||||
ItemSource="LoadNodesAsync"
|
||||
ItemSource="NodesItemSource"
|
||||
@bind-Value="Parent.Node">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -91,30 +89,28 @@
|
||||
[Parameter] public CreateServerRequest Request { get; set; }
|
||||
[Parameter] public Create Parent { get; set; }
|
||||
|
||||
private async Task<StarResponse[]> LoadStarsAsync()
|
||||
private ItemSource<StarResponse> StarsItemSource => ItemSourceFactory.From(LoadStarsAsync);
|
||||
private ItemSource<NodeResponse> NodesItemSource => ItemSourceFactory.From(LoadNodesAsync);
|
||||
private ItemSource<UserResponse> UsersItemSource => ItemSourceFactory.From(LoadUsersAsync);
|
||||
|
||||
private async Task<IEnumerable<StarResponse>> LoadStarsAsync(int startIndex, int count)
|
||||
{
|
||||
return await CountedData<StarResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarResponse>>(
|
||||
$"api/admin/servers/stars?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<StarResponse>>(
|
||||
$"api/admin/servers/stars?startIndex={startIndex}&count={count}"
|
||||
);
|
||||
}
|
||||
|
||||
private async Task<NodeResponse[]> LoadNodesAsync()
|
||||
private async Task<IEnumerable<NodeResponse>> LoadNodesAsync(int startIndex, int count)
|
||||
{
|
||||
return await CountedData<NodeResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeResponse>>(
|
||||
$"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<NodeResponse>>(
|
||||
$"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
|
||||
);
|
||||
}
|
||||
|
||||
private async Task<UserResponse[]> LoadUsersAsync()
|
||||
private async Task<IEnumerable<UserResponse>> LoadUsersAsync(int startIndex, int count)
|
||||
{
|
||||
return await CountedData<UserResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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<StarVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
|
||||
StarVariables = await CountedData.AllAsync(async (index, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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<ServerShareResponse>.LoadAllAsync(async (startIndex, count)
|
||||
Shares = await CountedData.AllAsync<ServerShareResponse>(async (startIndex, count)
|
||||
=> await ShareService.GetAsync(Server.Id, startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<ServerVariableDetailResponse>.LoadAllAsync(async (startIndex, count)
|
||||
Variables = await CountedData.AllAsync<ServerVariableDetailResponse>(async (startIndex, count)
|
||||
=> await ServerService.GetVariablesAsync(Server.Id, startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 @@
|
||||
<InputMultipleItem TItem="NodeAllocationResponse"
|
||||
Value="Parent.Allocations"
|
||||
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
SearchField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
ItemSource="LoaderAsync">
|
||||
ItemSource="ItemSource">
|
||||
</InputMultipleItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,12 +28,12 @@
|
||||
[Parameter] public ServerResponse Server { get; set; }
|
||||
[Parameter] public Update Parent { get; set; }
|
||||
|
||||
private async Task<NodeAllocationResponse[]> LoaderAsync()
|
||||
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
return await CountedData<NodeAllocationResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 @@
|
||||
<div class="mt-2">
|
||||
<InputItem TItem="UserResponse"
|
||||
DisplayField="@(x => x.Username)"
|
||||
SearchField="@(x => x.Username)"
|
||||
@bind-Value="Parent.Owner"
|
||||
ItemSource="LoaderAsync">
|
||||
ItemSource="UserItemSource">
|
||||
</InputItem>
|
||||
|
||||
</div>
|
||||
@@ -64,12 +64,12 @@
|
||||
[Parameter] public UpdateServerRequest Request { get; set; }
|
||||
[Parameter] public Update Parent { get; set; }
|
||||
|
||||
private async Task<UserResponse[]> LoaderAsync()
|
||||
private ItemSource<UserResponse> UserItemSource => ItemSourceFactory.From(LoadAsync);
|
||||
|
||||
private async Task<IEnumerable<UserResponse>> LoadAsync(int startIndex, int count)
|
||||
{
|
||||
return await CountedData<UserResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
return await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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<StarVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
StarVariables = await CountedData.AllAsync<StarVariableResponse>(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Server.StarId}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
|
||||
ServerVariables = await CountedData<ServerVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
ServerVariables = await CountedData.AllAsync<ServerVariableResponse>(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<ServerVariableResponse>>(
|
||||
$"api/admin/servers/{Server.Id}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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
|
||||
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
|
||||
@@ -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 @@
|
||||
<div class="flex justify-end">
|
||||
<button type="button" @onclick="AddDockerImageAsync" class="btn btn-primary">Add docker image</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid sm:grid-cols-2 xl:grid-cols-3 gap-4 mt-5">
|
||||
@foreach (var dockerImage in DockerImages)
|
||||
{
|
||||
@@ -30,11 +30,13 @@
|
||||
</div>
|
||||
|
||||
<div class="gap-x-2">
|
||||
<button type="button" @onclick="() => UpdateDockerImageAsync(dockerImage)" class="btn btn-primary">
|
||||
<button type="button" @onclick="() => UpdateDockerImageAsync(dockerImage)"
|
||||
class="btn btn-primary">
|
||||
<i class="icon-settings text-base"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" @onclick="() => DeleteDockerImageAsync(dockerImage)" class="btn btn-error">
|
||||
<button type="button" @onclick="() => DeleteDockerImageAsync(dockerImage)"
|
||||
class="btn btn-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -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<CountedData<StarDockerImageResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex=0&count=100"
|
||||
DockerImages = await CountedData.AllAsync<StarDockerImageResponse>(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarDockerImageResponse>>(
|
||||
$"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<CreateStarDockerImageRequest, Task> 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<CreateDockerImageModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
});
|
||||
|
||||
await ModalService.LaunchAsync<CreateDockerImageModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||
}
|
||||
|
||||
|
||||
private async Task UpdateDockerImageAsync(StarDockerImageResponse dockerImage)
|
||||
{
|
||||
Func<UpdateStarDockerImageRequest, Task> 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<UpdateDockerImageModal>(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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@
|
||||
<i class="icon-variable text-xl align-middle mr-2"></i>
|
||||
<span class="align-middle text-lg">@variable.Name</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="gap-x-2">
|
||||
<button type="button" @onclick="() => UpdateVariableAsync(variable)" class="btn btn-primary">
|
||||
<i class="icon-settings text-base"></i>
|
||||
@@ -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<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/variables?startIndex=0&count=100"
|
||||
CurrentVariables = await CountedData.AllAsync<StarVariableResponse>(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
|
||||
CurrentVariables = pagedVariables.Items;
|
||||
}
|
||||
|
||||
private async Task AddVariableAsync()
|
||||
@@ -65,27 +65,24 @@
|
||||
Func<CreateStarVariableRequest, Task> 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<CreateVariableModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
}, "max-w-xl");
|
||||
|
||||
await ModalService.LaunchAsync<CreateVariableModal>(parameters => { parameters.Add("OnSubmit", onSubmit); }, "max-w-xl");
|
||||
}
|
||||
|
||||
|
||||
private async Task UpdateVariableAsync(StarVariableResponse variable)
|
||||
{
|
||||
Func<UpdateStarVariableRequest, Task> 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<UpdateVariableModal>(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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user