diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index fb2873721..39a26e92a 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -1,34 +1,58 @@ using SharedLibraryCore.Interfaces; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; namespace SharedLibraryCore.Configuration { public class ApplicationConfiguration : IBaseConfiguration { + [LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")] public bool EnableWebFront { get; set; } + [LocalizedDisplayName("SETUP_ENABLE_MULTIOWN")] public bool EnableMultipleOwners { get; set; } + [LocalizedDisplayName("SETUP_ENABLE_STEPPEDPRIV")] public bool EnableSteppedHierarchy { get; set; } + [LocalizedDisplayName("SETUP_DISPLAY_SOCIAL")] public bool EnableSocialLink { get; set; } + [LocalizedDisplayName("SETUP_ENABLE_CUSTOMSAY")] public bool EnableCustomSayName { get; set; } + [LocalizedDisplayName("SETUP_SAY_NAME")] public string CustomSayName { get; set; } + [LocalizedDisplayName("SETUP_SOCIAL_LINK")] public string SocialLinkAddress { get; set; } + [LocalizedDisplayName("SETUP_SOCIAL_TITLE")] public string SocialLinkTitle { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_BIND_URL")] public string WebfrontBindUrl { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_MANUAL_URL")] public string ManualWebfrontUrl { get; set; } public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl) ? WebfrontBindUrl.Replace("0.0.0.0", "127.0.0.1") : ManualWebfrontUrl; + [LocalizedDisplayName("SETUP_USE_CUSTOMENCODING")] + public bool EnableCustomParserEncoding { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENCODING")] public string CustomParserEncoding { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] + public bool EnableCustomLocale { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] public string CustomLocale { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_DB_PROVIDER")] public string DatabaseProvider { get; set; } = "sqlite"; + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CONNECTION_STRING")] public string ConnectionString { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_RCON_POLLRATE")] public int RConPollRate { get; set; } = 5000; + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_IGNORE_BOTS")] public bool IgnoreBots { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAX_TB")] public TimeSpan MaximumTempBanTime { get; set; } = new TimeSpan(24 * 30, 0, 0); + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_WHITELIST")] public bool EnableWebfrontConnectionWhitelist { get; set; } public List WebfrontConnectionWhitelist { get; set; } public string Id { get; set; } public List Servers { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_AUTOMESSAGE_PERIOD")] public int AutoMessagePeriod { get; set; } public List AutoMessages { get; set; } public List GlobalRules { get; set; } diff --git a/SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs b/SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs new file mode 100644 index 000000000..35ddb1abc --- /dev/null +++ b/SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace SharedLibraryCore.Configuration +{ + class LocalizedDisplayNameAttribute : DisplayNameAttribute + { + private readonly string _localizationKey; + public LocalizedDisplayNameAttribute(string localizationKey) + { + _localizationKey = localizationKey; + } + + public override string DisplayName => Utilities.CurrentLocalization.LocalizationIndex[_localizationKey]; + } +} diff --git a/WebfrontCore/Controllers/ConfigurationController.cs b/WebfrontCore/Controllers/ConfigurationController.cs new file mode 100644 index 000000000..444a67e79 --- /dev/null +++ b/WebfrontCore/Controllers/ConfigurationController.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace WebfrontCore.Controllers +{ + public class ConfigurationController : BaseController + { + public IActionResult Edit() + { + return View("Index", Manager.GetApplicationSettings().Configuration()); + } + } +} \ No newline at end of file diff --git a/WebfrontCore/Views/Configuration/Index.cshtml b/WebfrontCore/Views/Configuration/Index.cshtml new file mode 100644 index 000000000..796b568e2 --- /dev/null +++ b/WebfrontCore/Views/Configuration/Index.cshtml @@ -0,0 +1,150 @@ +@model SharedLibraryCore.Configuration.ApplicationConfiguration + +@{ + ViewData["Title"] = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_TITLE"]; + string optionalText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["COMMAND_HELP_OPTIONAL"]; + string advancedText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_ADVANCED"]; + string addText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_ADD"]; +} + +
+
+
+
+ + +
+ +
+
+
+ + + +
+
+ + + +
+
+ + +
+ +
+ +
+ +
+ + +
+ +
+
+
+ + + +
+
+ + + +
+
+ + +
+ +
+
+
+ + + +
+
+ + +
+ +
+ +
+ +
+
+ @Html.EditorFor(model => model.WebfrontConnectionWhitelist, new { htmlAttributes = new { @class = "form-control bg-dark text-white-50 mb-2" } }) +
@addText
+
+ +
+
@advancedText
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+
+ + + +
+
+ +
+ +
+
+
+
+@section scripts { + + + +} + diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index 384f8e319..d9d217b32 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -28,53 +28,51 @@
-