From b134cd47288c45a06ff908e9c55cd31ae96f996e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 14 Apr 2019 10:55:05 -0500 Subject: [PATCH] fix gravatars not showing fix web config not saving Uri fix issue with token login --- Application/Application.csproj | 6 +- Application/IW4MServer.cs | 13 ++++- Plugins/Login/Commands/CLogin.cs | 10 ++-- .../Configuration/ApplicationConfiguration.cs | 24 +++----- .../Attributes/ConfiguratinLinked.cs} | 6 +- .../Attributes}/ConfigurationIgnore.cs | 2 +- .../Attributes}/ConfigurationOptional.cs | 2 +- .../LocalizedDisplayName.cs} | 6 +- .../Configuration/ServerConfiguration.cs | 21 ++++++- SharedLibraryCore/Services/ClientService.cs | 16 +----- SharedLibraryCore/Services/PenaltyService.cs | 3 +- WebfrontCore/Controllers/AccountController.cs | 10 ++-- WebfrontCore/Controllers/ClientController.cs | 12 +++- .../Controllers/ConfigurationController.cs | 51 ++++++++--------- WebfrontCore/ViewModels/ConfigurationInfo.cs | 2 +- WebfrontCore/Views/Configuration/Index.cshtml | 37 +++++++----- .../Views/Configuration/_ListItem.cshtml | 5 +- .../ServerConfiguration.cshtml | 56 +++++++++++++++++-- WebfrontCore/Views/Shared/_Layout.cshtml | 21 ++----- WebfrontCore/wwwroot/css/profile.css | 3 +- WebfrontCore/wwwroot/js/configuration.js | 9 +-- 21 files changed, 187 insertions(+), 128 deletions(-) rename SharedLibraryCore/{Helpers/LinkedConfiguration.cs => Configuration/Attributes/ConfiguratinLinked.cs} (57%) rename SharedLibraryCore/{Helpers => Configuration/Attributes}/ConfigurationIgnore.cs (79%) rename SharedLibraryCore/{Helpers => Configuration/Attributes}/ConfigurationOptional.cs (79%) rename SharedLibraryCore/Configuration/{LocalizedDisplayNameAttribute.cs => Attributes/LocalizedDisplayName.cs} (66%) diff --git a/Application/Application.csproj b/Application/Application.csproj index 72421892a..31082d567 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.6.1 + 2.2.6.2 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.6.1 - 2.2.6.1 + 2.2.6.3 + 2.2.6.3 diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index f2f175258..e59b978fd 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -186,7 +186,15 @@ namespace IW4MAdmin else { - Manager.GetPrivilegedClients()[E.Target.ClientId] = E.Target; + if (Manager.GetPrivilegedClients().ContainsKey(E.Target.ClientId)) + { + Manager.GetPrivilegedClients()[E.Target.ClientId] = E.Target; + } + + else + { + Manager.GetPrivilegedClients().Add(E.Target.ClientId, E.Target); + } } Logger.WriteInfo($"{E.Origin} is setting {E.Target} to permission level {newPermission}"); @@ -1002,10 +1010,11 @@ namespace IW4MAdmin Link = targetClient.AliasLink, AutomatedOffense = originClient.AdministeredPenalties?.FirstOrDefault()?.AutomatedOffense, IsEvadedOffense = isEvade + }; - await Manager.GetPenaltyService().Create(newPenalty); targetClient.SetLevel(Permission.Banned, originClient); + await Manager.GetPenaltyService().Create(newPenalty); } override public async Task Unban(string reason, EFClient Target, EFClient Origin) diff --git a/Plugins/Login/Commands/CLogin.cs b/Plugins/Login/Commands/CLogin.cs index d92385f9f..af8ffdf06 100644 --- a/Plugins/Login/Commands/CLogin.cs +++ b/Plugins/Login/Commands/CLogin.cs @@ -24,12 +24,12 @@ namespace IW4MAdmin.Plugins.Login.Commands if (!success) { string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(E.Data, client.PasswordSalt)); + success = hashedPassword[0] == client.Password; + } - if (hashedPassword[0] == client.Password) - { - success = true; - Plugin.AuthorizedClients[E.Origin.ClientId] = true; - } + if (success) + { + Plugin.AuthorizedClients[E.Origin.ClientId] = true; } _ = success ? diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index af262669c..bbf7a1fc5 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -1,4 +1,4 @@ -using SharedLibraryCore.Helpers; +using SharedLibraryCore.Configuration.Attributes; using SharedLibraryCore.Interfaces; using System; using System.Collections.Generic; @@ -10,7 +10,7 @@ namespace SharedLibraryCore.Configuration { [LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")] - [LinkedConfiguration("WebfrontBindUrl", "ManualWebfrontUrl")] + [ConfiguratinLinked("WebfrontBindUrl", "ManualWebfrontUrl")] public bool EnableWebFront { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_BIND_URL")] public string WebfrontBindUrl { get; set; } @@ -27,14 +27,14 @@ namespace SharedLibraryCore.Configuration [LocalizedDisplayName("WEBFRONT_CONFIGURATION_IGNORE_BOTS")] public bool IgnoreBots { get; set; } - [LinkedConfiguration("CustomSayName")] + [ConfiguratinLinked("CustomSayName")] [LocalizedDisplayName("SETUP_ENABLE_CUSTOMSAY")] public bool EnableCustomSayName { get; set; } [LocalizedDisplayName("SETUP_SAY_NAME")] public string CustomSayName { get; set; } [LocalizedDisplayName("SETUP_DISPLAY_SOCIAL")] - [LinkedConfiguration("SocialLinkAddress", "SocialLinkTitle")] + [ConfiguratinLinked("SocialLinkAddress", "SocialLinkTitle")] public bool EnableSocialLink { get; set; } [LocalizedDisplayName("SETUP_SOCIAL_LINK")] public string SocialLinkAddress { get; set; } @@ -42,18 +42,19 @@ namespace SharedLibraryCore.Configuration public string SocialLinkTitle { get; set; } [LocalizedDisplayName("SETUP_USE_CUSTOMENCODING")] - [LinkedConfiguration("CustomParserEncoding")] + [ConfiguratinLinked("CustomParserEncoding")] public bool EnableCustomParserEncoding { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENCODING")] public string CustomParserEncoding { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_WHITELIST")] - [LinkedConfiguration("WebfrontConnectionWhitelist")] + [ConfiguratinLinked("WebfrontConnectionWhitelist")] public bool EnableWebfrontConnectionWhitelist { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_WHITELIST_LIST")] public List WebfrontConnectionWhitelist { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] - [LinkedConfiguration("CustomLocale")] + [ConfiguratinLinked("CustomLocale")] public bool EnableCustomLocale { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] public string CustomLocale { get; set; } @@ -119,14 +120,7 @@ namespace SharedLibraryCore.Configuration } RConPollRate = 5000; - DisallowedClientNames = new List() - { - "Unknown Soldier", - "UnknownSoldier", - "CHEATER", - "VickNet" - }; - + AutoMessagePeriod = 60; return this; } diff --git a/SharedLibraryCore/Helpers/LinkedConfiguration.cs b/SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs similarity index 57% rename from SharedLibraryCore/Helpers/LinkedConfiguration.cs rename to SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs index 640d8c463..fb3beec7c 100644 --- a/SharedLibraryCore/Helpers/LinkedConfiguration.cs +++ b/SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs @@ -1,13 +1,13 @@ using System; -namespace SharedLibraryCore.Helpers +namespace SharedLibraryCore.Configuration.Attributes { [AttributeUsage(AttributeTargets.Property, Inherited = false)] - public class LinkedConfiguration : Attribute + public class ConfiguratinLinked : Attribute { public string[] LinkedPropertyNames { get; set; } - public LinkedConfiguration(params string[] linkedPropertyNames) + public ConfiguratinLinked(params string[] linkedPropertyNames) { LinkedPropertyNames = linkedPropertyNames; } diff --git a/SharedLibraryCore/Helpers/ConfigurationIgnore.cs b/SharedLibraryCore/Configuration/Attributes/ConfigurationIgnore.cs similarity index 79% rename from SharedLibraryCore/Helpers/ConfigurationIgnore.cs rename to SharedLibraryCore/Configuration/Attributes/ConfigurationIgnore.cs index 6fcb4f083..53a0c3d38 100644 --- a/SharedLibraryCore/Helpers/ConfigurationIgnore.cs +++ b/SharedLibraryCore/Configuration/Attributes/ConfigurationIgnore.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharedLibraryCore.Helpers +namespace SharedLibraryCore.Configuration.Attributes { [AttributeUsage(AttributeTargets.Property, Inherited = false)] public class ConfigurationIgnore : Attribute diff --git a/SharedLibraryCore/Helpers/ConfigurationOptional.cs b/SharedLibraryCore/Configuration/Attributes/ConfigurationOptional.cs similarity index 79% rename from SharedLibraryCore/Helpers/ConfigurationOptional.cs rename to SharedLibraryCore/Configuration/Attributes/ConfigurationOptional.cs index 1d41eb2e6..3ba98ae8f 100644 --- a/SharedLibraryCore/Helpers/ConfigurationOptional.cs +++ b/SharedLibraryCore/Configuration/Attributes/ConfigurationOptional.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharedLibraryCore.Helpers +namespace SharedLibraryCore.Configuration.Attributes { [AttributeUsage(AttributeTargets.Property, Inherited = false)] public class ConfigurationOptional : Attribute diff --git a/SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs b/SharedLibraryCore/Configuration/Attributes/LocalizedDisplayName.cs similarity index 66% rename from SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs rename to SharedLibraryCore/Configuration/Attributes/LocalizedDisplayName.cs index 35ddb1abc..39beb9504 100644 --- a/SharedLibraryCore/Configuration/LocalizedDisplayNameAttribute.cs +++ b/SharedLibraryCore/Configuration/Attributes/LocalizedDisplayName.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; -namespace SharedLibraryCore.Configuration +namespace SharedLibraryCore.Configuration.Attributes { - class LocalizedDisplayNameAttribute : DisplayNameAttribute + class LocalizedDisplayName : DisplayNameAttribute { private readonly string _localizationKey; - public LocalizedDisplayNameAttribute(string localizationKey) + public LocalizedDisplayName(string localizationKey) { _localizationKey = localizationKey; } diff --git a/SharedLibraryCore/Configuration/ServerConfiguration.cs b/SharedLibraryCore/Configuration/ServerConfiguration.cs index 812bd7351..235740694 100644 --- a/SharedLibraryCore/Configuration/ServerConfiguration.cs +++ b/SharedLibraryCore/Configuration/ServerConfiguration.cs @@ -1,4 +1,5 @@ -using SharedLibraryCore.Interfaces; +using SharedLibraryCore.Configuration.Attributes; +using SharedLibraryCore.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -7,15 +8,27 @@ namespace SharedLibraryCore.Configuration { public class ServerConfiguration : IBaseConfiguration { + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_IP")] public string IPAddress { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_PORT")] public int Port { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_PASSWORD")] public string Password { get; set; } - public IList Rules { get; set; } - public IList AutoMessages { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_RULES")] + public List Rules { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_AUTO_MESSAGES")] + public List AutoMessages { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_PATH")] + [ConfigurationOptional] public string ManualLogPath { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_RCON_PARSER")] public string RConParserVersion { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_EVENT_PARSER")] public string EventParserVersion { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_RESERVED_SLOT")] public int ReservedSlotNumber { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_GAME_LOG_SERVER")] + [ConfigurationOptional] public Uri GameLogServerUrl { get; set; } private readonly IList rconParsers; @@ -25,6 +38,8 @@ namespace SharedLibraryCore.Configuration { rconParsers = new List(); eventParsers = new List(); + Rules = new List(); + AutoMessages = new List(); } public void AddRConParser(IRConParser parser) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 1ec4ca931..800dbcc5d 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -244,19 +244,9 @@ namespace SharedLibraryCore.Services // this updates the level for all the clients with the same LinkId // only if their new level is flagged or banned - await iqMatchingClients.ForEachAsync(async (_client) => + await iqMatchingClients.ForEachAsync(_client => { _client.Level = newPermission; - - // hack this saves our change to the change history log - await changeSvc.Add(new GameEvent() - { - Type = GameEvent.EventType.ChangePermission, - Extra = newPermission, - Origin = origin, - Owner = temporalClient.CurrentServer, - Target = _client - }, ctx); #if DEBUG == true temporalClient.CurrentServer.Logger.WriteDebug($"Updated linked {_client.ClientId} to {newPermission}"); #endif @@ -451,7 +441,7 @@ namespace SharedLibraryCore.Services public async Task> FindClientsByIdentifier(string identifier) { - if (identifier.Length < 3) + if (identifier?.Length < 3) { return new List(); } @@ -468,7 +458,7 @@ namespace SharedLibraryCore.Services alias.Name.ToLower().Contains(identifier) select alias.LinkId).Distinct(); - var linkIds = iqLinkIds.ToList(); + var linkIds = await iqLinkIds.ToListAsync(); var iqClients = context.Clients .Where(c => linkIds.Contains(c.AliasLinkId) || diff --git a/SharedLibraryCore/Services/PenaltyService.cs b/SharedLibraryCore/Services/PenaltyService.cs index c458b7d20..d3da18f58 100644 --- a/SharedLibraryCore/Services/PenaltyService.cs +++ b/SharedLibraryCore/Services/PenaltyService.cs @@ -31,7 +31,6 @@ namespace SharedLibraryCore.Services IsEvadedOffense = newEntity.IsEvadedOffense }; - newEntity.Offender.ReceivedPenalties?.Add(penalty); context.Penalties.Add(penalty); await context.SaveChangesAsync(); @@ -40,11 +39,13 @@ namespace SharedLibraryCore.Services { var iqLinkedProfiles = context.Clients .Where(_client => _client.AliasLinkId == newEntity.Link.AliasLinkId) + .Where(_client => _client.Level != EFClient.Permission.Banned) // prevent adding the penalty twice to the same profile .Where(_client => _client.ClientId != penalty.OffenderId); await iqLinkedProfiles.ForEachAsync(_client => { + var linkedPenalty = new EFPenalty() { OffenderId = _client.ClientId, diff --git a/WebfrontCore/Controllers/AccountController.cs b/WebfrontCore/Controllers/AccountController.cs index a75437aa0..1f69df7ee 100644 --- a/WebfrontCore/Controllers/AccountController.cs +++ b/WebfrontCore/Controllers/AccountController.cs @@ -25,14 +25,14 @@ namespace WebfrontCore.Controllers try { -#if DEBUG == true - var client = Utilities.IW4MAdminClient(); - bool loginSuccess = true; -#else +//#if DEBUG == true +// var client = Utilities.IW4MAdminClient(); +// bool loginSuccess = true; +//#else var client = Manager.GetPrivilegedClients()[clientId]; bool loginSuccess = Manager.TokenAuthenticator.AuthorizeToken(client.NetworkId, password) || (await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, client.PasswordSalt)))[0] == client.Password; -#endif +//#endif if (loginSuccess) { diff --git a/WebfrontCore/Controllers/ClientController.cs b/WebfrontCore/Controllers/ClientController.cs index dbfc5ab45..d413c0e34 100644 --- a/WebfrontCore/Controllers/ClientController.cs +++ b/WebfrontCore/Controllers/ClientController.cs @@ -53,6 +53,16 @@ namespace WebfrontCore.Controllers }; var meta = await MetaService.GetRuntimeMeta(client.ClientId, 0, 1, DateTime.UtcNow); + var gravatar = await new MetaService().GetPersistentMeta("GravatarEmail", client); + if (gravatar != null) + { + clientDto.Meta.Add(new ProfileMeta() + { + Key = "GravatarEmail", + Type = ProfileMeta.MetaType.Other, + Value = gravatar.Value + }); + } var currentPenalty = activePenalties.FirstOrDefault(); @@ -67,7 +77,7 @@ namespace WebfrontCore.Controllers } clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive)); - + ViewBag.Title = clientDto.Name.Substring(clientDto.Name.Length - 1).ToLower()[0] == 's' ? clientDto.Name + "'" : clientDto.Name + "'s"; diff --git a/WebfrontCore/Controllers/ConfigurationController.cs b/WebfrontCore/Controllers/ConfigurationController.cs index ad812a0ab..adc1eb774 100644 --- a/WebfrontCore/Controllers/ConfigurationController.cs +++ b/WebfrontCore/Controllers/ConfigurationController.cs @@ -1,17 +1,13 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.Serialization; -using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SharedLibraryCore.Configuration; -using SharedLibraryCore.Interfaces; +using System.Linq; +using System.Threading.Tasks; using WebfrontCore.ViewModels; namespace WebfrontCore.Controllers { + [Authorize] public class ConfigurationController : BaseController { public IActionResult Edit() @@ -20,37 +16,42 @@ namespace WebfrontCore.Controllers } [HttpPost] - public async Task Edit(ApplicationConfiguration newConfiguration) + public async Task Edit(ApplicationConfiguration newConfiguration, bool addNewServer = false, bool shouldSave = false) { - var currentConfiguration = Manager.GetApplicationSettings().Configuration(); - - var newConfigurationProperties = newConfiguration.GetType().GetProperties(); - foreach (var property in currentConfiguration.GetType().GetProperties()) + if (shouldSave) { - var newProp = newConfigurationProperties.First(_prop => _prop.Name == property.Name); - var newPropValue = newProp.GetValue(newConfiguration); + var currentConfiguration = Manager.GetApplicationSettings().Configuration(); - if (newPropValue != null && newProp.CanWrite) + var newConfigurationProperties = newConfiguration.GetType().GetProperties(); + foreach (var property in currentConfiguration.GetType().GetProperties()) { - property.SetValue(currentConfiguration, newPropValue); + var newProp = newConfigurationProperties.First(_prop => _prop.Name == property.Name); + var newPropValue = newProp.GetValue(newConfiguration); + + if (newPropValue != null && newProp.CanWrite) + { + property.SetValue(currentConfiguration, newPropValue); + } } + + await Manager.GetApplicationSettings().Save(); } - await Manager.GetApplicationSettings().Save(); + if (addNewServer) + { + newConfiguration.Servers.Add(new ServerConfiguration()); + } + + return View("Index", newConfiguration); } public IActionResult GetNewListItem(string propertyName, int itemCount) { - var config = Manager.GetApplicationSettings().Configuration(); - var propertyInfo = config.GetType().GetProperties().First(_prop => _prop.Name == propertyName); - var configInfo = new ConfigurationInfo() { - Configuration = config, - PropertyValue = (IList)propertyInfo.GetValue(config) ?? new List(), - PropertyInfo = propertyInfo, - NewItemCount = itemCount + NewItemCount = itemCount, + PropertyName = propertyName }; return PartialView("_ListItem", configInfo); diff --git a/WebfrontCore/ViewModels/ConfigurationInfo.cs b/WebfrontCore/ViewModels/ConfigurationInfo.cs index 50b6c6947..da5901d09 100644 --- a/WebfrontCore/ViewModels/ConfigurationInfo.cs +++ b/WebfrontCore/ViewModels/ConfigurationInfo.cs @@ -10,7 +10,7 @@ namespace WebfrontCore.ViewModels { public class ConfigurationInfo { - public string PropertyName => PropertyInfo.Name; + public string PropertyName { get; set; } public PropertyInfo PropertyInfo { get; set; } public IList PropertyValue { get; set; } public IBaseConfiguration Configuration { get; set; } diff --git a/WebfrontCore/Views/Configuration/Index.cshtml b/WebfrontCore/Views/Configuration/Index.cshtml index 3522dda28..7ca7a030e 100644 --- a/WebfrontCore/Views/Configuration/Index.cshtml +++ b/WebfrontCore/Views/Configuration/Index.cshtml @@ -1,4 +1,5 @@ -@model SharedLibraryCore.Configuration.ApplicationConfiguration +@using SharedLibraryCore.Configuration.Attributes +@model SharedLibraryCore.Configuration.ApplicationConfiguration @{ ViewData["Title"] = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_TITLE"]; @@ -6,25 +7,27 @@ string advancedText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_ADVANCED"]; string addText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_ADD"]; string saveText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_SAVE"]; + string noticeText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_SAVING_CHANGES"]; + string addServerText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_SERVER_ADD"]; var properties = Model.GetType().GetProperties(); string[] getLinkedPropertyName(System.Reflection.PropertyInfo info) { var test = (info.GetCustomAttributes(false) - .Where(_attr => _attr.GetType() == typeof(SharedLibraryCore.Helpers.LinkedConfiguration)) - .FirstOrDefault() as SharedLibraryCore.Helpers.LinkedConfiguration); + .Where(_attr => _attr.GetType() == typeof(ConfiguratinLinked)) + .FirstOrDefault() as ConfiguratinLinked); return test?.LinkedPropertyNames ?? new string[0]; } bool shouldIgnore(System.Reflection.PropertyInfo info) => (info.GetCustomAttributes(false) - .Where(_attr => _attr.GetType() == typeof(SharedLibraryCore.Helpers.ConfigurationIgnore)) - .FirstOrDefault() as SharedLibraryCore.Helpers.ConfigurationIgnore) != null; + .Where(_attr => _attr.GetType() == typeof(ConfigurationIgnore)) + .FirstOrDefault() as ConfigurationIgnore) != null; bool isOptional(System.Reflection.PropertyInfo info) => (info.GetCustomAttributes(false) - .Where(_attr => _attr.GetType() == typeof(SharedLibraryCore.Helpers.ConfigurationOptional)) - .FirstOrDefault() as SharedLibraryCore.Helpers.ConfigurationOptional) != null; + .Where(_attr => _attr.GetType() == typeof(ConfigurationOptional)) + .FirstOrDefault() as ConfigurationOptional) != null; bool hasLinkedParent(System.Reflection.PropertyInfo info) { @@ -34,9 +37,9 @@
+

@ViewData["Title"]

+
@noticeText
-
- @foreach (var property in properties) { if (shouldIgnore(property)) @@ -59,12 +62,13 @@ { if (hasLinkedParent(property)) { -
+
@if (linkedPropertyNames.Length == 0) { - @Html.Label(property.Name, null, new { @class = "" }) + @Html.Label(property.Name, null, new { @class = "mt-2" }) } @Html.Editor(property.Name, new { htmlAttributes = new { @class = $"form-group form-control bg-dark text-white-50 {(linkedPropertyNames.Length == 0 ? "mb-3" : "mb-0")}" } }) + @addText
} @@ -73,7 +77,14 @@ @Html.Label(property.Name, null, new { @class = "bg-primary pl-3 pr-3 p-2 mb-0 w-100" })
@Html.Editor(property.Name, new { htmlAttributes = new { @class = "form-control bg-dark text-white-50 mt-3 mb-3", placeholder = isOptional(property) ? optionalText : "" } }) - @addText + @if (property.PropertyType.GenericTypeArguments[0].Name == "ServerConfiguration") + { + + } + else + { + @addText + }
} } @@ -97,7 +108,7 @@ } } } - +
diff --git a/WebfrontCore/Views/Configuration/_ListItem.cshtml b/WebfrontCore/Views/Configuration/_ListItem.cshtml index 6631a67c6..47a0d9767 100644 --- a/WebfrontCore/Views/Configuration/_ListItem.cshtml +++ b/WebfrontCore/Views/Configuration/_ListItem.cshtml @@ -1,6 +1,3 @@ @model WebfrontCore.ViewModels.ConfigurationInfo -@{ - int index = Model.PropertyValue.Count + (Model.NewItemCount - Model.PropertyValue.Count); -} - \ No newline at end of file + \ No newline at end of file diff --git a/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml b/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml index 7f59b3fcc..aab157a81 100644 --- a/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml +++ b/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml @@ -1,6 +1,52 @@ -@model List -@Html.EditorFor(s => s) -@*@foreach (var server in Model) +@model IList +@{ + string labelClass = "mb-2 mt-1"; + string editorClass = "form-control bg-dark text-white-50 text-box single-line mb-2 mt-0"; + string addText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONFIGURATION_ADD"]; + string optionalText = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["COMMAND_HELP_OPTIONAL"]; + int startAt = ViewBag.AddNew ?? false ? Model.Count - 1 : 0; +} + +@for (int i = startAt; i < Model.Count; i++) { - @Html.EditorFor(s => server.EventParserVersion); -}*@ \ No newline at end of file +
@Model[i].IPAddress:@Model[i].Port
+
+ @Html.LabelFor(model => model[i].IPAddress, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].IPAddress, new { htmlAttributes = new { @class = editorClass } }) + + @Html.LabelFor(model => model[i].Port, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].Port, new { htmlAttributes = new { @class = editorClass } }) + + @Html.LabelFor(model => model[i].Password, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].Password, new { htmlAttributes = new { @class = editorClass } }) + + @Html.LabelFor(model => model[i].ManualLogPath, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].ManualLogPath, new { htmlAttributes = new { @class = editorClass, placeholder = optionalText } }) + + @Html.LabelFor(model => model[i].GameLogServerUrl, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].GameLogServerUrl, new { htmlAttributes = new { @class = editorClass, placeholder = optionalText } }) + + @Html.LabelFor(model => model[i].RConParserVersion, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].RConParserVersion, new { htmlAttributes = new { @class = editorClass } }) + + @Html.LabelFor(model => model[i].EventParserVersion, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].EventParserVersion, new { htmlAttributes = new { @class = editorClass } }) + + @Html.LabelFor(model => model[i].ReservedSlotNumber, null, new { @class = labelClass }) + @Html.EditorFor(model => model[i].ReservedSlotNumber, new { htmlAttributes = new { @class = editorClass } }) + +
+ @Html.LabelFor(model => model[i].Rules, null, new { @class = "bg-primary pl-3 pr-3 p-2 w-100 mt-3" }) + @Html.EditorFor(model => model[i].Rules, new { htmlAttributes = new { @class = editorClass } }) + @addText +
+ +
+ @Html.LabelFor(model => model[i].AutoMessages, null, new { @class = "bg-primary pl-3 pr-3 p-2 w-100 mt-3" }) + @Html.EditorFor(model => model[i].AutoMessages, new { htmlAttributes = new { @class = editorClass } }) + @addText +
+
+} + +@**@ diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index d9d217b32..0a7005b2e 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -55,22 +55,11 @@ } diff --git a/WebfrontCore/wwwroot/css/profile.css b/WebfrontCore/wwwroot/css/profile.css index 1484c88d2..55cf2e012 100644 --- a/WebfrontCore/wwwroot/css/profile.css +++ b/WebfrontCore/wwwroot/css/profile.css @@ -152,6 +152,7 @@ #profile_avatar { min-width: 8rem; min-height: 8rem; + background-size: contain; } .profile-shortcode { @@ -181,7 +182,7 @@ cursor: pointer; } - .profile-action:hover { + .profile-action.oi:hover { opacity: 0.75; } diff --git a/WebfrontCore/wwwroot/js/configuration.js b/WebfrontCore/wwwroot/js/configuration.js index 2400c0f0b..37028847b 100644 --- a/WebfrontCore/wwwroot/js/configuration.js +++ b/WebfrontCore/wwwroot/js/configuration.js @@ -13,16 +13,11 @@ $('.configuration-add-new').click(function (e) { e.preventDefault(); - //let totalItems = $(this).siblings().length; - //let inputHtml = $(this).siblings().last().get(0).outerHTML; - //inputHtml = inputHtml.replace('_' + totalItems - 1 + '_', '_' + totalItems + '_'); - //inputHtml = inputHtml.replace('[' + totalItems - 1 + ']', '[' + totalItems + ']'); - //$(this).parent().prepend(inputHtml); - + let parentElement = $(this).parent(); $.get($(this).attr('href') + '&itemCount=' + $(this).siblings().length, function (response) { - parentElement.prepend(response); + $(response).insertBefore(parentElement.children().last()); }); }); }); \ No newline at end of file