diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 535fbe1..b80dbe9 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -555,6 +555,23 @@ namespace CarCareTracker.Controllers } return Json(false); } + [Authorize(Roles = nameof(UserData.IsRootUser))] + public IActionResult GetServerConfiguration() + { + var viewModel = new ServerSettingsViewModel + { + PostgresConnection = _config.GetServerPostgresConnection(), + AllowedFileExtensions = _config.GetAllowedFileUploadExtensions(), + CustomLogoURL = _config.GetLogoUrl(), + MessageOfTheDay = _config.GetMOTD(), + WebHookURL = _config.GetWebHookUrl(), + CustomWidgetsEnabled = _config.GetCustomWidgetsEnabled(), + InvariantAPIEnabled = _config.GetInvariantApi(), + SMTPConfig = _config.GetMailConfig(), + OIDCConfig = _config.GetOpenIDConfig() + }; + return PartialView("_ServerConfig", viewModel); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Models/Settings/ServerSettingsViewModel.cs b/Models/Settings/ServerSettingsViewModel.cs new file mode 100644 index 0000000..1b4e286 --- /dev/null +++ b/Models/Settings/ServerSettingsViewModel.cs @@ -0,0 +1,17 @@ +namespace CarCareTracker.Models +{ + public class ServerSettingsViewModel + { + public string LocaleInfo { get; set; } + public string PostgresConnection { get; set; } + public string AllowedFileExtensions { get; set; } + public string CustomLogoURL { get; set; } + public string MessageOfTheDay { get; set; } + public string WebHookURL { get; set; } + public bool CustomWidgetsEnabled { get; set; } + public bool InvariantAPIEnabled { get; set; } + public MailConfig SMTPConfig { get; set; } = new MailConfig(); + public OpenIDConfig OIDCConfig { get; set; } = new OpenIDConfig(); + + } +} diff --git a/Views/Home/_ServerConfig.cshtml b/Views/Home/_ServerConfig.cshtml new file mode 100644 index 0000000..73d6b6e --- /dev/null +++ b/Views/Home/_ServerConfig.cshtml @@ -0,0 +1,62 @@ +@using CarCareTracker.Helper +@inject IConfigHelper config +@inject ITranslationHelper translator +@model ServerSettingsViewModel +@{ + var userConfig = config.GetUserConfig(User); + var userLanguage = userConfig.UserLanguage; +} +