c0865b82a0
Show chat on mobile view of server overview basic authentication switched to extreme-ip-lookup for ip lookups (SSL)
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using SharedLibrary;
|
|
using SharedLibrary.Dtos;
|
|
using SharedLibrary.Objects;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WebfrontCore.Controllers
|
|
{
|
|
public class ConsoleController : BaseController
|
|
{
|
|
public IActionResult Index()
|
|
{
|
|
var activeServers = Manager.Servers.Select(s => new ServerInfo()
|
|
{
|
|
Name = s.Hostname,
|
|
ID = s.GetHashCode(),
|
|
});
|
|
|
|
ViewBag.Description = "Use the IW4MAdmin web console to execute commands";
|
|
ViewBag.Title = "Web Console";
|
|
ViewBag.Keywords = "IW4MAdmin, console, execute, commands";
|
|
|
|
return View(activeServers);
|
|
}
|
|
|
|
public async Task<IActionResult> ExecuteAsync(int serverId, string command)
|
|
{
|
|
|
|
var server = Manager.Servers.First(s => s.GetHashCode() == serverId);
|
|
var client = User.AsPlayer();
|
|
client.CurrentServer = server;
|
|
|
|
var remoteEvent = new Event(Event.GType.Say, command, client, null, server);
|
|
|
|
await server.ExecuteEvent(remoteEvent);
|
|
|
|
var response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToList();
|
|
|
|
// remove the added command response
|
|
for (int i = 0; i < response.Count; i++)
|
|
server.CommandResult.Remove(response[i]);
|
|
|
|
return View("_Response", response);
|
|
}
|
|
}
|
|
}
|