Refactored ui. Improved console experience. Added command endpoint

This commit is contained in:
2025-07-18 21:16:52 +02:00
parent f8c11b2dd8
commit 265a4b280b
43 changed files with 479 additions and 149 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using MoonCore.Exceptions;
using MoonlightServers.Daemon.ServerSystem.SubSystems;
using MoonlightServers.Daemon.Services;
using MoonlightServers.DaemonShared.DaemonSide.Http.Requests;
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Servers;
using MoonlightServers.DaemonShared.Enums;
@@ -10,7 +11,7 @@ namespace MoonlightServers.Daemon.Http.Controllers.Servers;
[Authorize]
[ApiController]
[Route("api/servers")]
[Route("api/servers/{serverId:int}")]
public class ServersController : Controller
{
private readonly ServerService ServerService;
@@ -20,19 +21,19 @@ public class ServersController : Controller
ServerService = serverService;
}
[HttpPost("{serverId:int}/sync")]
[HttpPost("sync")]
public async Task Sync([FromRoute] int serverId)
{
await ServerService.Sync(serverId);
}
[HttpDelete("{serverId:int}")]
[HttpDelete]
public async Task Delete([FromRoute] int serverId)
{
await ServerService.Delete(serverId);
}
[HttpGet("{serverId:int}/status")]
[HttpGet("status")]
public Task<ServerStatusResponse> GetStatus([FromRoute] int serverId)
{
var server = ServerService.Find(serverId);
@@ -48,7 +49,7 @@ public class ServersController : Controller
return Task.FromResult(result);
}
[HttpGet("{serverId:int}/logs")]
[HttpGet("logs")]
public async Task<ServerLogsResponse> GetLogs([FromRoute] int serverId)
{
var server = ServerService.Find(serverId);
@@ -65,7 +66,7 @@ public class ServersController : Controller
};
}
[HttpGet("{serverId:int}/stats")]
[HttpGet("stats")]
public Task<ServerStatsResponse> GetStats([FromRoute] int serverId)
{
var server = ServerService.Find(serverId);
@@ -85,4 +86,17 @@ public class ServersController : Controller
IoWrite = statsSubSystem.CurrentStats.IoWrite
});
}
[HttpPost("command")]
public async Task Command([FromRoute] int serverId, [FromBody] ServerCommandRequest request)
{
var server = ServerService.Find(serverId);
if (server == null)
throw new HttpApiException("No server with this id found", 404);
var consoleSubSystem = server.GetRequiredSubSystem<ConsoleSubSystem>();
await consoleSubSystem.WriteInput(request.Command);
}
}

View File

@@ -49,6 +49,13 @@
<_ContentIncludedByDefault Remove="storage\volumes\2\usercache.json" />
<_ContentIncludedByDefault Remove="storage\volumes\2\version_history.json" />
<_ContentIncludedByDefault Remove="storage\volumes\2\whitelist.json" />
<_ContentIncludedByDefault Remove="volumes\3\banned-ips.json" />
<_ContentIncludedByDefault Remove="volumes\3\banned-players.json" />
<_ContentIncludedByDefault Remove="volumes\3\ops.json" />
<_ContentIncludedByDefault Remove="volumes\3\plugins\spark\config.json" />
<_ContentIncludedByDefault Remove="volumes\3\usercache.json" />
<_ContentIncludedByDefault Remove="volumes\3\version_history.json" />
<_ContentIncludedByDefault Remove="volumes\3\whitelist.json" />
</ItemGroup>
</Project>