fix issue on about page with duplicate server names or inactive servers
This commit is contained in:
parent
b2afc410f2
commit
a2c7d92162
@ -27,14 +27,20 @@ namespace WebfrontCore.Controllers
|
||||
? Localization["WEBFRONT_NAV_ABOUT"]
|
||||
: _appConfig.CommunityInformation.Name;
|
||||
|
||||
var activeServers = _appConfig.Servers.Where(server =>
|
||||
Manager.GetServers().FirstOrDefault(s => s.IP == server.IPAddress && s.Port == server.Port) != null);
|
||||
|
||||
var info = new CommunityInfo
|
||||
{
|
||||
GlobalRules = _appConfig.GlobalRules,
|
||||
ServerRules =
|
||||
_appConfig.Servers.ToDictionary(
|
||||
config => Manager.GetServers().FirstOrDefault(server =>
|
||||
server.IP == config.IPAddress && server.Port == config.Port)?.Hostname,
|
||||
config => config.Rules),
|
||||
ServerRules = activeServers.ToDictionary(
|
||||
config =>
|
||||
{
|
||||
var server = Manager.GetServers().FirstOrDefault(server =>
|
||||
server.IP == config.IPAddress && server.Port == config.Port);
|
||||
return (server.Hostname, server.EndPoint);
|
||||
},
|
||||
config => config.Rules),
|
||||
CommunityInformation = _appConfig.CommunityInformation
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace WebfrontCore.ViewModels
|
||||
public class CommunityInfo
|
||||
{
|
||||
public string[] GlobalRules { get; set; }
|
||||
public Dictionary<string, string[]> ServerRules { get; set; }
|
||||
public Dictionary<(string, long), string[]> ServerRules { get; set; }
|
||||
public CommunityInformationConfiguration CommunityInformation { get; set; }
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
@using SharedLibraryCore.Configuration
|
||||
@model WebfrontCore.ViewModels.CommunityInfo
|
||||
@{
|
||||
IEnumerable<KeyValuePair<string, string[]>> allRules = new[] {new KeyValuePair<string, string[]>(ViewBag.Localization["WEBFRONT_ABOUT_GLOBAL_RULES"], Model.GlobalRules)};
|
||||
IEnumerable<KeyValuePair<(string, long), string[]>> allRules = new[] {new KeyValuePair<(string, long), string[]>((ViewBag.Localization["WEBFRONT_ABOUT_GLOBAL_RULES"], 0), Model.GlobalRules)};
|
||||
var serverRules = Model.ServerRules?.Where(server => server.Value != null && server.Value.Any()).ToList();
|
||||
if (serverRules?.Any() ?? false)
|
||||
{
|
||||
@ -56,7 +56,7 @@
|
||||
<h2 class="pb-3 p-0 col-12 text-center text-md-left">@ViewBag.Localization["WEBFRONT_ABOUT_COMMUNITY_GUIDELINES"]</h2>
|
||||
}
|
||||
|
||||
@foreach (var (serverName, rules) in allRules)
|
||||
@foreach (var ((serverName, id), rules) in allRules)
|
||||
{
|
||||
if (!rules.Any())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user