fix gravatars not showing
fix web config not saving Uri fix issue with token login
This commit is contained in:
parent
b9c4a1b5f6
commit
b134cd4728
@ -6,7 +6,7 @@
|
||||
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
|
||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||
<Version>2.2.6.1</Version>
|
||||
<Version>2.2.6.2</Version>
|
||||
<Authors>RaidMax</Authors>
|
||||
<Company>Forever None</Company>
|
||||
<Product>IW4MAdmin</Product>
|
||||
@ -31,8 +31,8 @@
|
||||
<PropertyGroup>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
<TieredCompilation>true</TieredCompilation>
|
||||
<AssemblyVersion>2.2.6.1</AssemblyVersion>
|
||||
<FileVersion>2.2.6.1</FileVersion>
|
||||
<AssemblyVersion>2.2.6.3</AssemblyVersion>
|
||||
<FileVersion>2.2.6.3</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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)
|
||||
|
@ -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 ?
|
||||
|
@ -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<string> 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<string>()
|
||||
{
|
||||
"Unknown Soldier",
|
||||
"UnknownSoldier",
|
||||
"CHEATER",
|
||||
"VickNet"
|
||||
};
|
||||
|
||||
AutoMessagePeriod = 60;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
@ -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
|
@ -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;
|
||||
}
|
@ -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<string> Rules { get; set; }
|
||||
public IList<string> AutoMessages { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_RULES")]
|
||||
public List<string> Rules { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_AUTO_MESSAGES")]
|
||||
public List<string> 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<IRConParser> rconParsers;
|
||||
@ -25,6 +38,8 @@ namespace SharedLibraryCore.Configuration
|
||||
{
|
||||
rconParsers = new List<IRConParser>();
|
||||
eventParsers = new List<IEventParser>();
|
||||
Rules = new List<string>();
|
||||
AutoMessages = new List<string>();
|
||||
}
|
||||
|
||||
public void AddRConParser(IRConParser parser)
|
||||
|
@ -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<IList<EFClient>> FindClientsByIdentifier(string identifier)
|
||||
{
|
||||
if (identifier.Length < 3)
|
||||
if (identifier?.Length < 3)
|
||||
{
|
||||
return new List<EFClient>();
|
||||
}
|
||||
@ -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) ||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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";
|
||||
|
@ -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<IActionResult> Edit(ApplicationConfiguration newConfiguration)
|
||||
public async Task<IActionResult> 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<string>(),
|
||||
PropertyInfo = propertyInfo,
|
||||
NewItemCount = itemCount
|
||||
NewItemCount = itemCount,
|
||||
PropertyName = propertyName
|
||||
};
|
||||
|
||||
return PartialView("_ListItem", configInfo);
|
||||
|
@ -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; }
|
||||
|
@ -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 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 text-white-50 ">
|
||||
<h3 class="text-white">@ViewData["Title"]</h3>
|
||||
<h5 class="mb-4">@noticeText</h5>
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
@foreach (var property in properties)
|
||||
{
|
||||
if (shouldIgnore(property))
|
||||
@ -59,12 +62,13 @@
|
||||
{
|
||||
if (hasLinkedParent(property))
|
||||
{
|
||||
<div id="@($"{property.Name}_content")" class="@(linkedPropertyNames.Length == 0 ? "" : "hide") bg-dark pl-3 pr-3">
|
||||
<div id="@($"{property.Name}_content")" class="@(linkedPropertyNames.Length == 0 ? "hide" : "hide") bg-dark pl-3 pr-3 pb-2">
|
||||
@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")}" } })
|
||||
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="@property.Name" class="btn btn-primary configuration-add-new">@addText</a>
|
||||
</div>
|
||||
}
|
||||
|
||||
@ -73,7 +77,14 @@
|
||||
@Html.Label(property.Name, null, new { @class = "bg-primary pl-3 pr-3 p-2 mb-0 w-100" })
|
||||
<div id="@($"{property.Name}_content")" class="pl-3 pr-3 pt-2 pb-3 bg-dark">
|
||||
@Html.Editor(property.Name, new { htmlAttributes = new { @class = "form-control bg-dark text-white-50 mt-3 mb-3", placeholder = isOptional(property) ? optionalText : "" } })
|
||||
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="@property.Name" class="btn btn-primary configuration-add-new mt-2">@addText</a>
|
||||
@if (property.PropertyType.GenericTypeArguments[0].Name == "ServerConfiguration")
|
||||
{
|
||||
<button asp-action="Edit" asp-route-addNewServer="true" class="btn btn-primary">@addServerText</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="@property.Name" class="btn btn-primary configuration-add-new">@addText</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@ -97,7 +108,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
<button asp-controller="Configuration" asp-action="Edit" class="btn btn-primary btn-block">@saveText</button>
|
||||
<button asp-controller="Configuration" asp-action="Edit" asp-route-shouldSave="true" class="btn btn-primary btn-block">@saveText</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,6 +1,3 @@
|
||||
@model WebfrontCore.ViewModels.ConfigurationInfo
|
||||
@{
|
||||
int index = Model.PropertyValue.Count + (Model.NewItemCount - Model.PropertyValue.Count);
|
||||
}
|
||||
|
||||
<input class="form-control bg-dark text-white-50 mb-2 text-box single-line" id="@($"{Model.PropertyName}_{index}_")" name="@($"{Model.PropertyName}[{index}]")" type="text" />
|
||||
<input class="form-control bg-dark text-white-50 mb-2 text-box single-line" id="@($"{Model.PropertyName.Replace('[', '_').Replace(']', '_').Replace('.', '_')}_{Model.NewItemCount - 1}_")" name="@($"{Model.PropertyName}[{Model.NewItemCount- 1}]")" type="text" />
|
@ -1,6 +1,52 @@
|
||||
@model List<SharedLibraryCore.Configuration.ServerConfiguration>
|
||||
@Html.EditorFor(s => s)
|
||||
@*@foreach (var server in Model)
|
||||
@model IList<SharedLibraryCore.Configuration.ServerConfiguration>
|
||||
@{
|
||||
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);
|
||||
}*@
|
||||
<div class="h4 text-white mb-0">@Model[i].IPAddress:@Model[i].Port</div>
|
||||
<div class="border-bottom mb-3">
|
||||
@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 } })
|
||||
|
||||
<div>
|
||||
@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 } })
|
||||
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="@($"Servers[{i}].Rules")" class="btn btn-primary configuration-add-new mt-2">@addText</a>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
@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 } })
|
||||
<a asp-controller="Configuration" asp-action="GetNewListItem" asp-route-propertyName="@($"Servers[{i}].Automessages")" class="btn btn-primary configuration-add-new mt-2">@addText</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@*<button asp-controller="Configuration" asp-action="Edit" asp-route-addNewServer="true" class="btn btn-primary">@addServerText</button>*@
|
||||
|
@ -55,22 +55,11 @@
|
||||
<a href="#" class="nav-link oi oi-person dropdown-toggle oi-fix-navbar w-100" id="account_dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></a>
|
||||
|
||||
<div class="dropdown-menu p-0" aria-labelledby="account_dropdown">
|
||||
@Html.ActionLink(loc["WEBFRONT_NAV_CONSOLE"], "Index", "Console", new { area = "" }, new
|
||||
{
|
||||
@class = "dropdown-item bg-dark text-muted text-center text-lg-left",
|
||||
title = "Web Console"
|
||||
})
|
||||
@Html.ActionLink(loc["WEBFRONT_NAV_PROFILE"], "ProfileAsync", "Client", new { id = ViewBag.User.ClientId }, new
|
||||
{
|
||||
@class = "dropdown-item bg-dark text-muted text-center text-lg-left",
|
||||
title = "Client Profile",
|
||||
})
|
||||
@Html.ActionLink(loc["WEBFRONT_NAV_LOGOUT"], "LogoutAsync", "Account", new { area = "" }, new
|
||||
{
|
||||
@class = "dropdown-item bg-dark text-muted text-center text-lg-left",
|
||||
title = "Logout of account"
|
||||
})
|
||||
<a class="dropdown-item bg-dark text-muted text-center text-lg-left profile-action" href="#" data-action="GenerateLoginToken" aria-hidden="true" title="@loc["WEBFRONT_ACTION_TOKEN"]">@loc["WEBFRONT_ACTION_TOKEN"]</a>
|
||||
<a asp-controller="Console" asp-action="Index" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_CONSOLE"]</a>
|
||||
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@ViewBag.User.ClientId" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_PROFILE"]</a>
|
||||
<a asp-controller="Configuration" asp-action="Edit" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_EDIT_CONFIGURATION"]</a>
|
||||
<a class="dropdown-item bg-dark text-muted text-center text-lg-left profile-action" href="#" data-action="GenerateLoginToken" title="@loc["WEBFRONT_ACTION_TOKEN"]">@loc["WEBFRONT_ACTION_TOKEN"]</a>
|
||||
<a asp-controller="Account" asp-action="LogoutAsync" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_LOGOUT"]</a>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user