2021-10-09 22:11:47 -04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Configuration;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using WebfrontCore.Extensions;
|
|
|
|
|
using WebfrontCore.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class AboutController : BaseController
|
|
|
|
|
{
|
|
|
|
|
private readonly ApplicationConfiguration _appConfig;
|
|
|
|
|
|
|
|
|
|
public AboutController(IManager manager, ApplicationConfiguration appConfig) : base(manager)
|
|
|
|
|
{
|
|
|
|
|
_appConfig = appConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2021-10-16 14:30:26 -04:00
|
|
|
|
ViewBag.Description = Localization["WEBFRONT_ABOUT_DESCRIPTION"].FormatExt(
|
2021-10-09 22:11:47 -04:00
|
|
|
|
_appConfig.ShouldUseFallbackBranding()
|
|
|
|
|
? _appConfig.WebfrontCustomBranding
|
|
|
|
|
: _appConfig.CommunityInformation.Name);
|
|
|
|
|
ViewBag.Title = _appConfig.ShouldUseFallbackBranding()
|
|
|
|
|
? Localization["WEBFRONT_NAV_ABOUT"]
|
|
|
|
|
: _appConfig.CommunityInformation.Name;
|
|
|
|
|
|
2021-10-19 21:02:31 -04:00
|
|
|
|
var activeServers = _appConfig.Servers.Where(server =>
|
2023-04-04 23:21:18 -04:00
|
|
|
|
Manager.GetServers().FirstOrDefault(s => s.ListenAddress == server.IPAddress && s.ListenPort == server.Port) != null);
|
2021-10-19 21:02:31 -04:00
|
|
|
|
|
2021-10-09 22:11:47 -04:00
|
|
|
|
var info = new CommunityInfo
|
|
|
|
|
{
|
|
|
|
|
GlobalRules = _appConfig.GlobalRules,
|
2021-10-19 21:02:31 -04:00
|
|
|
|
ServerRules = activeServers.ToDictionary(
|
|
|
|
|
config =>
|
|
|
|
|
{
|
2023-04-04 23:21:18 -04:00
|
|
|
|
var server = Manager.GetServers().First(server =>
|
|
|
|
|
server.ListenAddress == config.IPAddress && server.ListenPort == config.Port);
|
|
|
|
|
return (server.ServerName, server.EndPoint);
|
2021-10-19 21:02:31 -04:00
|
|
|
|
},
|
|
|
|
|
config => config.Rules),
|
2021-10-09 22:11:47 -04:00
|
|
|
|
CommunityInformation = _appConfig.CommunityInformation
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-05 10:54:57 -04:00
|
|
|
|
}
|