Adding page for Theme settings

This commit is contained in:
lepipele 2018-04-19 11:39:51 -05:00
parent b87ec4f3d9
commit 97b59be9bf
5 changed files with 78 additions and 21 deletions

View File

@ -216,12 +216,27 @@ namespace BTCPayServer.Controllers
[Route("server/policies")] [Route("server/policies")]
[HttpPost] [HttpPost]
public async Task<IActionResult> Policies(PoliciesSettings settings) public async Task<IActionResult> Policies(PoliciesSettings settings)
{
await _SettingsRepository.UpdateSetting(settings);
TempData["StatusMessage"] = "Policies updated successfully";
return View(settings);
}
[Route("server/theme")]
public async Task<IActionResult> Theme()
{
var data = (await _SettingsRepository.GetSettingAsync<ThemeSettings>()) ?? new ThemeSettings();
return View(data);
}
[Route("server/theme")]
[HttpPost]
public async Task<IActionResult> Theme(ThemeSettings settings)
{ {
await _SettingsRepository.UpdateSetting(settings); await _SettingsRepository.UpdateSetting(settings);
// TODO: remove controller/class-level property and have only reference to // TODO: remove controller/class-level property and have only reference to
// CssThemeManager here in this method // CssThemeManager here in this method
_CssThemeManager.Update(settings); _CssThemeManager.Update(settings);
TempData["StatusMessage"] = "Policies upadated successfully"; TempData["StatusMessage"] = "Theme settings updated successfully";
return View(settings); return View(settings);
} }

View File

@ -23,11 +23,11 @@ namespace BTCPayServer.HostedServices
private async void Update(SettingsRepository settingsRepository) private async void Update(SettingsRepository settingsRepository)
{ {
var data = (await settingsRepository.GetSettingAsync<PoliciesSettings>()) ?? new PoliciesSettings(); var data = (await settingsRepository.GetSettingAsync<ThemeSettings>()) ?? new ThemeSettings();
Update(data); Update(data);
} }
public void Update(PoliciesSettings data) public void Update(ThemeSettings data)
{ {
UpdateBootstrap(data.BootstrapCssUri); UpdateBootstrap(data.BootstrapCssUri);
UpdateCreativeStart(data.CreativeStartCssUri); UpdateCreativeStart(data.CreativeStartCssUri);

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace BTCPayServer.Services
{
public class ThemeSettings
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string BootstrapCssUri { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string CreativeStartCssUri { get; set; }
}
}

View File

@ -15,24 +15,6 @@
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<form method="post"> <form method="post">
<div class="form-group">
<label asp-for="BootstrapCssUri"></label>
<input asp-for="BootstrapCssUri" class="form-control" />
<span asp-validation-for="BootstrapCssUri" class="text-danger"></span>
<p class="form-text text-muted">
<a href="https://bootstrap.build/app/v4.0/" target="_blank">Build your own theme</a>
or <a href="https://bootswatch.com/" target="_blank">pick one already made</a>
</p>
</div>
<div class="form-group">
<label asp-for="CreativeStartCssUri"></label>
<input asp-for="CreativeStartCssUri" class="form-control" />
<span asp-validation-for="CreativeStartCssUri" class="text-danger"></span>
<p class="form-text text-muted">
<a href="https://startbootstrap.com/template-overviews/creative/" target="_blank">Creative Start theme</a>
is used on top of Bootstrap
</p>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="RequiresConfirmedEmail"></label> <label asp-for="RequiresConfirmedEmail"></label>
<input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-inline" /> <input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-inline" />

View File

@ -0,0 +1,43 @@
@model BTCPayServer.Services.ThemeSettings
@{
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Theme);
}
<h4>@ViewData["Title"]</h4>
@Html.Partial("_StatusMessage", TempData["StatusMessage"])
<div class="row">
<div class="col-lg-6">
<div asp-validation-summary="All" class="text-danger"></div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<form method="post">
<div class="form-group">
<label asp-for="BootstrapCssUri"></label>
<input asp-for="BootstrapCssUri" class="form-control" />
<span asp-validation-for="BootstrapCssUri" class="text-danger"></span>
<p class="form-text text-muted">
<a href="https://bootstrap.build/app/v4.0/" target="_blank">Build your own theme</a>
or <a href="https://bootswatch.com/" target="_blank">pick one already made</a>
</p>
</div>
<div class="form-group">
<label asp-for="CreativeStartCssUri"></label>
<input asp-for="CreativeStartCssUri" class="form-control" />
<span asp-validation-for="CreativeStartCssUri" class="text-danger"></span>
<p class="form-text text-muted">
<a href="https://startbootstrap.com/template-overviews/creative/" target="_blank">Creative Start theme</a>
is used on top of Bootstrap
</p>
</div>
<button type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
</form>
</div>
</div>
@section Scripts {
@await Html.PartialAsync("_ValidationScriptsPartial")
}