Server Settings: Consolidate Storage and Files (#3863)

* Server Settings: Consolidate Storage and Files

* Improve storage options name display

* Remove file services from services page

* Remove more code
This commit is contained in:
d11n
2022-06-15 14:06:16 +02:00
committed by GitHub
parent 346821f0d6
commit c56821300a
11 changed files with 63 additions and 86 deletions

View File

@@ -236,10 +236,10 @@ namespace BTCPayServer.Controllers
if (forceChoice || savedSettings == null)
{
var providersList = _StorageProviderServices.Select(a =>
new SelectListItem(a.StorageProvider().ToString(), a.StorageProvider().ToString())
new SelectListItem(typeof(StorageProvider).DisplayName(a.StorageProvider().ToString()), a.StorageProvider().ToString())
);
return View(new ChooseStorageViewModel()
return View(new ChooseStorageViewModel
{
ProvidersList = providersList,
ShowChangeWarning = savedSettings != null,

View File

@@ -292,8 +292,7 @@ namespace BTCPayServer.Controllers
return View(_policiesSettings);
}
[Route("server/policies")]
[HttpPost]
[HttpPost("server/policies")]
public async Task<IActionResult> Policies([FromServices] BTCPayNetworkProvider btcPayNetworkProvider, PoliciesSettings settings, string command = "")
{
@@ -352,10 +351,9 @@ namespace BTCPayServer.Controllers
}
[Route("server/services")]
public async Task<IActionResult> Services()
public IActionResult Services()
{
var result = new ServicesViewModel();
result.ExternalServices = _externalServiceOptions.Value.ExternalServices.ToList();
var result = new ServicesViewModel { ExternalServices = _externalServiceOptions.Value.ExternalServices.ToList() };
// other services
foreach (var externalService in _externalServiceOptions.Value.OtherExternalServices)
@@ -363,7 +361,7 @@ namespace BTCPayServer.Controllers
result.OtherExternalServices.Add(new ServicesViewModel.OtherExternalService()
{
Name = externalService.Key,
Link = this.Request.GetAbsoluteUriNoPathBase(externalService.Value).AbsoluteUri
Link = Request.GetAbsoluteUriNoPathBase(externalService.Value).AbsoluteUri
});
}
if (CanShowSSHService())
@@ -371,13 +369,13 @@ namespace BTCPayServer.Controllers
result.OtherExternalServices.Add(new ServicesViewModel.OtherExternalService()
{
Name = "SSH",
Link = this.Url.Action(nameof(SSHService))
Link = Url.Action(nameof(SSHService))
});
}
result.OtherExternalServices.Add(new ServicesViewModel.OtherExternalService()
{
Name = "Dynamic DNS",
Link = this.Url.Action(nameof(DynamicDnsServices))
Link = Url.Action(nameof(DynamicDnsServices))
});
foreach (var torService in _torServices.Services)
{
@@ -403,13 +401,6 @@ namespace BTCPayServer.Controllers
}
}
// external storage services
var storageSettings = await _SettingsRepository.GetSettingAsync<StorageSettings>();
result.ExternalStorageServices.Add(new ServicesViewModel.OtherExternalService()
{
Name = storageSettings == null ? "Not set" : storageSettings.Provider.ToString(),
Link = Url.Action("Storage")
});
return View(result);
}
@@ -463,8 +454,6 @@ namespace BTCPayServer.Controllers
return null;
}
[Route("server/services/{serviceName}/{cryptoCode?}")]
public async Task<IActionResult> Service(string serviceName, string cryptoCode, bool showQR = false, ulong? nonce = null)
{

View File

@@ -5,17 +5,15 @@ namespace BTCPayServer.Models.ServerViewModels
{
public class ServicesViewModel
{
public class OtherExternalService
{
public string Name { get; set; }
public string Link { get; set; }
}
public List<ExternalService> ExternalServices { get; set; } = new List<ExternalService>();
public List<OtherExternalService> OtherExternalServices { get; set; } = new List<OtherExternalService>();
public List<OtherExternalService> TorHttpServices { get; set; } = new List<OtherExternalService>();
public List<OtherExternalService> TorOtherServices { get; set; } = new List<OtherExternalService>();
public List<OtherExternalService> ExternalStorageServices { get; set; } = new List<OtherExternalService>();
public List<ExternalService> ExternalServices { get; set; } = new ();
public List<OtherExternalService> OtherExternalServices { get; set; } = new ();
public List<OtherExternalService> TorHttpServices { get; set; } = new ();
public List<OtherExternalService> TorOtherServices { get; set; } = new ();
}
}

View File

@@ -1,10 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace BTCPayServer.Storage.Models
{
public enum StorageProvider
{
[Display(Name = "Azure Blob Storage")]
AzureBlobStorage = 0,
[Display(Name = "Amazon S3")]
AmazonS3 = 1,
[Display(Name = "Google Cloud Storage")]
GoogleCloudStorage = 2,
[Display(Name = "Local File System")]
FileSystem = 3
}
}

View File

@@ -1,12 +1,12 @@
@model BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration.AmazonS3StorageConfiguration
@{
ViewData.SetActivePage(ServerNavPages.Services, "Amazon S3 Storage");
ViewData.SetActivePage(ServerNavPages.Files, "Amazon S3 Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col-xl-10 col-xxl-constrain">
<form method="post">
<div class="form-group">
<label asp-for="ContainerName" class="form-label"></label>

View File

@@ -1,12 +1,12 @@
@model BTCPayServer.Storage.Services.Providers.AzureBlobStorage.Configuration.AzureBlobStorageConfiguration
@{
ViewData.SetActivePage(ServerNavPages.Services, "Azure Blob Storage");
ViewData.SetActivePage(ServerNavPages.Files, "Azure Blob Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col-xl-10 col-xxl-constrain">
<form method="post">
<div class="form-group">
<label asp-for="ContainerName" class="form-label">Container Name</label>

View File

@@ -1,13 +1,13 @@
@model BTCPayServer.Storage.Services.Providers.FileSystemStorage.Configuration.FileSystemStorageConfiguration
@{
ViewData.SetActivePage(ServerNavPages.Services, $"Local Filesystem Storage");
ViewData.SetActivePage(ServerNavPages.Files, $"Local Filesystem Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<p>Any uploaded files are being saved on the same machine that hosts BTCPay; please pay attention to your storage space.</p>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col-xl-10 col-xxl-constrain">
<a asp-action="Storage" asp-route-forceChoice="true">Change Storage provider</a>
</div>
</div>

View File

@@ -1,12 +1,12 @@
@model BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration.GoogleCloudStorageConfiguration
@{
ViewData.SetActivePage(ServerNavPages.Services, "Google Cloud Storage");
ViewData.SetActivePage(ServerNavPages.Files, "Google Cloud Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col-xl-10 col-xxl-constrain">
<form method="post">
<div class="form-group">
<label asp-for="ContainerName" class="form-label">Container Name</label>

View File

@@ -3,10 +3,15 @@
ViewData.SetActivePage(ServerNavPages.Files, "File Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col">
<div class="d-flex align-items-center justify-content-between mt-n1 mb-4">
<h3 class="mb-0">@ViewData["Title"]</h3>
<a asp-action="storage" asp-route-forceChoice="true" asp-route-returnurl="@ViewData["ReturnUrl"]" class="btn btn-secondary d-flex align-items-center">
<vc:icon symbol="settings"/>
<span class="ms-1">Settings</span>
</a>
</div>
@if (!Model.StorageConfigured)
{
@@ -56,7 +61,7 @@
<td>@file.Timestamp.ToBrowserDate()</td>
<td>@file.ApplicationUser.UserName</td>
<td class="text-end">
<a href="@Url.Action("Files", "UIServer", new { fileIds = new string[] { file.Id} })">Get Link</a>
<a href="@Url.Action("Files", "UIServer", new { fileIds = new string[] { file.Id } })">Get Link</a>
- <a asp-action="CreateTemporaryFileUrl" asp-route-fileId="@file.Id">Get Temp Link</a>
- <a asp-action="DeleteFile" asp-route-fileId="@file.Id">Remove</a>
</td>

View File

@@ -126,30 +126,6 @@
</table>
</div>
}
<div class="mb-5">
<h4 class="mb-3">External storage services</h4>
<p class="text-secondary mb-0">Integrated storage providers to store file uploads from BTCPay Server.</p>
<table class="table table-hover mt-2">
<thead>
<tr>
<th>Name</th>
<th style="text-align: right">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var s in Model.ExternalStorageServices)
{
<tr>
<td>@s.Name</td>
<td style="text-align: right">
<a href="@s.Link" rel="noreferrer noopener">Edit</a>
</td>
</tr>
}
</tbody>
</table>
</div>
@section PageFootContent {
<partial name="_ValidationScriptsPartial" />

View File

@@ -1,12 +1,12 @@
@model BTCPayServer.Storage.ViewModels.ChooseStorageViewModel
@{
ViewData.SetActivePage(ServerNavPages.Services, "Storage");
ViewData.SetActivePage(ServerNavPages.Files, "Storage");
}
<h3 class="mb-4">@ViewData["Title"]</h3>
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div class="col-xl-10 col-xxl-constrain">
@if (Model.ShowChangeWarning)
{
<div class="alert alert-danger mb-4">