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"]
|
? Localization["WEBFRONT_NAV_ABOUT"]
|
||||||
: _appConfig.CommunityInformation.Name;
|
: _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
|
var info = new CommunityInfo
|
||||||
{
|
{
|
||||||
GlobalRules = _appConfig.GlobalRules,
|
GlobalRules = _appConfig.GlobalRules,
|
||||||
ServerRules =
|
ServerRules = activeServers.ToDictionary(
|
||||||
_appConfig.Servers.ToDictionary(
|
config =>
|
||||||
config => Manager.GetServers().FirstOrDefault(server =>
|
{
|
||||||
server.IP == config.IPAddress && server.Port == config.Port)?.Hostname,
|
var server = Manager.GetServers().FirstOrDefault(server =>
|
||||||
config => config.Rules),
|
server.IP == config.IPAddress && server.Port == config.Port);
|
||||||
|
return (server.Hostname, server.EndPoint);
|
||||||
|
},
|
||||||
|
config => config.Rules),
|
||||||
CommunityInformation = _appConfig.CommunityInformation
|
CommunityInformation = _appConfig.CommunityInformation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace WebfrontCore.ViewModels
|
|||||||
public class CommunityInfo
|
public class CommunityInfo
|
||||||
{
|
{
|
||||||
public string[] GlobalRules { get; set; }
|
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; }
|
public CommunityInformationConfiguration CommunityInformation { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
@using SharedLibraryCore.Configuration
|
@using SharedLibraryCore.Configuration
|
||||||
@model WebfrontCore.ViewModels.CommunityInfo
|
@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();
|
var serverRules = Model.ServerRules?.Where(server => server.Value != null && server.Value.Any()).ToList();
|
||||||
if (serverRules?.Any() ?? false)
|
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>
|
<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())
|
if (!rules.Any())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user