mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2025-04-10 18:08:37 -04:00
Compare commits
No commits in common. "cc5adcffa35375792f933b344a72b36add64e20b" and "51251ee5a1249074f07d8c929e56b1e2077513ce" have entirely different histories.
cc5adcffa3
...
51251ee5a1
@ -65,9 +65,6 @@ namespace Minecraft_Realms_Emulator.Controllers.Admin
|
|||||||
|
|
||||||
if (world == null) return BadRequest("World not found");
|
if (world == null) return BadRequest("World not found");
|
||||||
|
|
||||||
world.State = "OPEN";
|
|
||||||
_context.SaveChanges();
|
|
||||||
|
|
||||||
new DockerHelper(world).StartServer();
|
new DockerHelper(world).StartServer();
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
@ -80,9 +77,6 @@ namespace Minecraft_Realms_Emulator.Controllers.Admin
|
|||||||
|
|
||||||
if (world == null) return BadRequest("World not found");
|
if (world == null) return BadRequest("World not found");
|
||||||
|
|
||||||
world.State = "CLOSED";
|
|
||||||
_context.SaveChanges();
|
|
||||||
|
|
||||||
new DockerHelper(world).StopServer();
|
new DockerHelper(world).StopServer();
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
|
@ -17,20 +17,14 @@ else
|
|||||||
@server.State
|
@server.State
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
@if (server.State == "CLOSED")
|
<button class="btn btn-success" @onclick="StartServer">
|
||||||
{
|
<i class="bi-caret-right-fill"></i>
|
||||||
<button class="btn btn-success" @onclick="StartServer">
|
Start
|
||||||
<i class="bi-caret-right-fill"></i>
|
</button>
|
||||||
Start
|
<button class="btn btn-danger" @onclick="StopServer">
|
||||||
</button>
|
<i class="bi-stop-circle-fill"></i>
|
||||||
}
|
Stop
|
||||||
else
|
</button>
|
||||||
{
|
|
||||||
<button class="btn btn-danger" @onclick="StopServer">
|
|
||||||
<i class="bi-stop-circle-fill"></i>
|
|
||||||
Stop
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -53,11 +47,6 @@ else
|
|||||||
private List<string> logs = [];
|
private List<string> logs = [];
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
|
||||||
await GetServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task GetServer()
|
|
||||||
{
|
{
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
||||||
@ -86,9 +75,7 @@ else
|
|||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
||||||
|
|
||||||
await JS.InvokeVoidAsync("serverLogsStream.start", DotNetObjectReference.Create(this), wId);
|
|
||||||
await httpClient.PutAsync($"http://localhost:8080/api/admin/servers/{wId}/open", new StringContent(""));
|
await httpClient.PutAsync($"http://localhost:8080/api/admin/servers/{wId}/open", new StringContent(""));
|
||||||
await GetServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopServer()
|
public async Task StopServer()
|
||||||
@ -96,8 +83,6 @@ else
|
|||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Environment.GetEnvironmentVariable("ADMIN_KEY"));
|
||||||
|
|
||||||
await JS.InvokeVoidAsync("serverLogsStream.stop");
|
|
||||||
await httpClient.PutAsync($"http://localhost:8080/api/admin/servers/{wId}/close", new StringContent(""));
|
await httpClient.PutAsync($"http://localhost:8080/api/admin/servers/{wId}/close", new StringContent(""));
|
||||||
await GetServer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,9 @@
|
|||||||
window.serverLogsStream = {
|
window.serverLogsStream = {
|
||||||
logs: "x",
|
|
||||||
|
|
||||||
start: (dotNetObject, serverId) => {
|
start: (dotNetObject, serverId) => {
|
||||||
logs = new EventSource(`http://localhost:8080/api/admin/servers/${serverId}/logs`, { withCredentials: true });
|
const logs = new EventSource(`http://localhost:8080/api/admin/servers/${serverId}/logs`, { withCredentials: true });
|
||||||
|
|
||||||
logs.onmessage = event => {
|
logs.onmessage = event => {
|
||||||
dotNetObject.invokeMethodAsync("ReceiveLog", event.data);
|
dotNetObject.invokeMethodAsync("ReceiveLog", event.data);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
stop: () => logs.close()
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user