Started implementing variables tab and api controller
This commit is contained in:
@@ -13,6 +13,7 @@ public class DefaultServerTabProvider : IServerTabProvider
|
||||
[
|
||||
ServerTab.CreateFromComponent<ConsoleTab>("Console", "console", 0),
|
||||
ServerTab.CreateFromComponent<FilesTab>("Files", "files", 1),
|
||||
ServerTab.CreateFromComponent<VariablesTab>("Variables", "variables", 2),
|
||||
ServerTab.CreateFromComponent<SettingsTab>("Settings", "settings", 10),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using MoonCore.Attributes;
|
||||
using MoonCore.Helpers;
|
||||
using MoonCore.Models;
|
||||
using MoonlightServers.Shared.Http.Requests.Client.Servers.Variables;
|
||||
using MoonlightServers.Shared.Http.Responses.Client.Servers.Variables;
|
||||
using MoonlightServers.Shared.Http.Responses.Users.Servers;
|
||||
|
||||
namespace MoonlightServers.Frontend.Services;
|
||||
@@ -49,7 +51,7 @@ public class ServerService
|
||||
$"api/client/servers/{serverId}/ws"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async Task Install(int serverId)
|
||||
{
|
||||
await HttpApiClient.Post(
|
||||
@@ -65,14 +67,14 @@ public class ServerService
|
||||
$"api/client/servers/{serverId}/start"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async Task Stop(int serverId)
|
||||
{
|
||||
await HttpApiClient.Post(
|
||||
$"api/client/servers/{serverId}/stop"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async Task Kill(int serverId)
|
||||
{
|
||||
await HttpApiClient.Post(
|
||||
@@ -81,4 +83,31 @@ public class ServerService
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables
|
||||
|
||||
public async Task<ServerVariableDetailResponse[]> GetVariables(int serverId)
|
||||
{
|
||||
return await HttpApiClient.GetJson<ServerVariableDetailResponse[]>(
|
||||
$"api/client/servers/{serverId}/variables"
|
||||
);
|
||||
}
|
||||
|
||||
public async Task UpdateVariables(int serverId, UpdateServerVariableRangeRequest request)
|
||||
{
|
||||
await HttpApiClient.Patch(
|
||||
$"api/client/servers/{serverId}/variables",
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async Task UpdateVariable(int serverId, UpdateServerVariableRequest request)
|
||||
{
|
||||
await HttpApiClient.Put(
|
||||
$"api/client/servers/{serverId}/variables",
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
@using MoonCore.Blazor.Tailwind.Components
|
||||
@using MoonlightServers.Frontend.Services
|
||||
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Variables
|
||||
|
||||
@inherits BaseServerTab
|
||||
|
||||
@inject ServerService ServerService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
@foreach (var variable in Variables)
|
||||
{
|
||||
<div class="sm:col-span-2 card card-body p-5">
|
||||
<label class="block text-sm font-medium leading-6 text-white">
|
||||
@variable.Name
|
||||
</label>
|
||||
<p class="mt-1 mb-2.5 text-sm leading-6 text-gray-400">
|
||||
@variable.Description
|
||||
</p>
|
||||
<div class="mt-auto">
|
||||
<input value="@variable.Value" type="text" class="form-input w-full">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</LazyLoader>
|
||||
|
||||
@code
|
||||
{
|
||||
private ServerVariableDetailResponse[] Variables;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
{
|
||||
Variables = await ServerService.GetVariables(Server.Id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user