mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
fix gravatars not showing
fix web config not saving Uri fix issue with token login
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user