mirror of
https://github.com/dotnetcore/AgileConfig.git
synced 2026-10-22 15:16:00 +08:00
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using AgileConfig.Server.Apisite.Models;
|
|
using AgileConfig.Server.Apisite.Websocket;
|
|
using AgileConfig.Server.Common;
|
|
using AgileConfig.Server.IService;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace AgileConfig.Server.Apisite.Controllers
|
|
{
|
|
public class ReportController : Controller
|
|
{
|
|
private readonly IConfigService _configService;
|
|
private readonly IAppService _appService;
|
|
private readonly IServerNodeService _serverNodeService;
|
|
|
|
public ReportController(IConfigService configService, IAppService appService, IServerNodeService serverNodeService)
|
|
{
|
|
_appService = appService;
|
|
_configService = configService;
|
|
_serverNodeService = serverNodeService;
|
|
}
|
|
|
|
public IActionResult Clients()
|
|
{
|
|
var report = WebsocketCollection.Instance.Report();
|
|
|
|
return Json(report);
|
|
}
|
|
|
|
public IActionResult ServerNodeClients(string address)
|
|
{
|
|
var report = Program.RemoteServerNodeManager.GetClientsReport(address);
|
|
|
|
return Json(report);
|
|
}
|
|
|
|
public async Task<IActionResult> AppCount()
|
|
{
|
|
var appCount = await _appService.CountEnabledAppsAsync();
|
|
return Json(appCount);
|
|
}
|
|
|
|
public async Task<IActionResult> ConfigCount()
|
|
{
|
|
var configCount = await _configService.CountEnabledConfigsAsync();
|
|
return Json(configCount);
|
|
}
|
|
|
|
public async Task<IActionResult> NodeCount()
|
|
{
|
|
var nodeCount = (await _serverNodeService.GetAllNodesAsync()).Count;
|
|
return Json(nodeCount);
|
|
}
|
|
|
|
public async Task<IActionResult> RemoteNodesStatus()
|
|
{
|
|
var nodes = await _serverNodeService.GetAllNodesAsync();
|
|
var result = new List<object>();
|
|
|
|
nodes.ForEach(n => {
|
|
result.Add(new {
|
|
n,
|
|
server_status = Program.RemoteServerNodeManager.GetClientsReport(n.Address)
|
|
});
|
|
});
|
|
|
|
return Json(result);
|
|
}
|
|
}
|
|
}
|