mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
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:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user