[issue 137] custom display hostnames for webfront

This commit is contained in:
RaidMax 2020-05-23 13:15:22 -05:00
parent 1241ac459e
commit e91c60a753
4 changed files with 16 additions and 5 deletions

View File

@ -30,6 +30,9 @@ namespace SharedLibraryCore.Configuration
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_GAME_LOG_SERVER")] [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_GAME_LOG_SERVER")]
[ConfigurationOptional] [ConfigurationOptional]
public Uri GameLogServerUrl { get; set; } public Uri GameLogServerUrl { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_CUSTOM_HOSTNAME")]
[ConfigurationOptional]
public string CustomHostname { get; set; }
private readonly IList<IRConParser> rconParsers; private readonly IList<IRConParser> rconParsers;
private readonly IList<IEventParser> eventParsers; private readonly IList<IEventParser> eventParsers;

View File

@ -15,7 +15,7 @@ namespace SharedLibraryCore.Configuration.Validation
.Must(_address => IPAddress.TryParse(_address, out _)); .Must(_address => IPAddress.TryParse(_address, out _));
RuleFor(_server => _server.Port) RuleFor(_server => _server.Port)
.InclusiveBetween(0, ushort.MaxValue); .InclusiveBetween(1, ushort.MaxValue);
RuleFor(_server => _server.Password) RuleFor(_server => _server.Password)
.NotEmpty(); .NotEmpty();
@ -28,6 +28,10 @@ namespace SharedLibraryCore.Configuration.Validation
RuleFor(_server => _server.ReservedSlotNumber) RuleFor(_server => _server.ReservedSlotNumber)
.InclusiveBetween(0, 32); .InclusiveBetween(0, 32);
RuleFor(_server => _server.CustomHostname)
.MinimumLength(3)
.MaximumLength(128);
} }
} }
} }

View File

@ -289,7 +289,8 @@ namespace SharedLibraryCore
public Game GameName { get; set; } public Game GameName { get; set; }
// Info // Info
public string Hostname { get; protected set; } private string hostname;
public string Hostname { get => ServerConfig.CustomHostname ?? hostname; protected set => hostname = value; }
public string Website { get; protected set; } public string Website { get; protected set; }
public string Gametype { get; set; } public string Gametype { get; set; }
public Map CurrentMap { get; set; } public Map CurrentMap { get; set; }

View File

@ -37,9 +37,12 @@
<label asp-for="@Model.ReservedSlotNumber" class="@labelClass"></label> <label asp-for="@Model.ReservedSlotNumber" class="@labelClass"></label>
<input asp-for="@Model.ReservedSlotNumber" class="@editorClass" /> <input asp-for="@Model.ReservedSlotNumber" class="@editorClass" />
<label asp-for="@Model.CustomHostname" class="@labelClass"></label>
<input asp-for="@Model.CustomHostname" class="@editorClass" placeholder="@optionalText" />
<div> <div>
<label asp-for="@Model.Rules" class="bg-primary pl-3 pr-3 p-2 w-100 mt-3"></label> <label asp-for="@Model.Rules" class="bg-primary pl-3 pr-3 p-2 w-100 mt-3"></label>
@for(i = 0; i < Model.Rules.Length; i++) @for (i = 0; i < Model.Rules.Length; i++)
{ {
<input asp-for="@Model.Rules[i]" class="@editorClass" /> <input asp-for="@Model.Rules[i]" class="@editorClass" />
} }
@ -48,11 +51,11 @@
<div class="mb-3"> <div class="mb-3">
<label asp-for="@Model.AutoMessages" class="bg-primary pl-3 pr-3 p-2 w-100 mt-3"></label> <label asp-for="@Model.AutoMessages" class="bg-primary pl-3 pr-3 p-2 w-100 mt-3"></label>
@for(i = 0; i < Model.AutoMessages.Length; i++) @for (i = 0; i < Model.AutoMessages.Length; i++)
{ {
<input asp-for="@Model.AutoMessages[i]" class="@editorClass" /> <input asp-for="@Model.AutoMessages[i]" class="@editorClass" />
} }
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="Servers.Automessages" class="btn btn-primary configuration-add-new mt-2">@addText</a> <a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="Servers.Automessages" class="btn btn-primary configuration-add-new mt-2">@addText</a>
</div> </div>
</div> </div>