mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-29 11:54:27 +01:00
Merge pull request #2455 from btcpayserver/feat/improving-files-page
Improving File Storage page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Extensions;
|
||||
@@ -19,6 +20,8 @@ using BTCPayServer.Storage.ViewModels;
|
||||
using BTCPayServer.Views;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BTCPayServer.Controllers
|
||||
@@ -30,13 +33,14 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
var fileUrl = string.IsNullOrEmpty(fileId) ? null : await _FileService.GetFileUrl(Request.GetAbsoluteRootUri(), fileId);
|
||||
|
||||
return View(new ViewFilesViewModel()
|
||||
var model = new ViewFilesViewModel()
|
||||
{
|
||||
Files = await _StoredFileRepository.GetFiles(),
|
||||
SelectedFileId = string.IsNullOrEmpty(fileUrl) ? null : fileId,
|
||||
DirectFileUrl = fileUrl,
|
||||
StorageConfigured = (await _SettingsRepository.GetSettingAsync<StorageSettings>()) != null
|
||||
});
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpGet("server/files/{fileId}/delete")]
|
||||
@@ -174,8 +178,13 @@ namespace BTCPayServer.Controllers
|
||||
var savedSettings = await _SettingsRepository.GetSettingAsync<StorageSettings>();
|
||||
if (forceChoice || savedSettings == null)
|
||||
{
|
||||
var providersList = _StorageProviderServices.Select(a =>
|
||||
new SelectListItem(a.StorageProvider().ToString(), a.StorageProvider().ToString())
|
||||
);
|
||||
|
||||
return View(new ChooseStorageViewModel()
|
||||
{
|
||||
ProvidersList = providersList,
|
||||
ShowChangeWarning = savedSettings != null,
|
||||
Provider = savedSettings?.Provider ?? BTCPayServer.Storage.Models.StorageProvider.FileSystem
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using BTCPayServer.Storage.Models;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace BTCPayServer.Storage.ViewModels
|
||||
{
|
||||
public class ChooseStorageViewModel
|
||||
{
|
||||
public IEnumerable<SelectListItem> ProvidersList { get; set; }
|
||||
public StorageProvider Provider { get; set; }
|
||||
public bool ShowChangeWarning { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@model BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration.AmazonS3StorageConfiguration
|
||||
@model BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration.AmazonS3StorageConfiguration
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services, "Amazon S3 Storage");
|
||||
}
|
||||
@@ -7,10 +7,6 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
@if (!ViewContext.ModelState.IsValid)
|
||||
{
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label asp-for="ContainerName"></label>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@model BTCPayServer.Storage.Services.Providers.AzureBlobStorage.Configuration.AzureBlobStorageConfiguration
|
||||
@model BTCPayServer.Storage.Services.Providers.AzureBlobStorage.Configuration.AzureBlobStorageConfiguration
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services, "Azure Blob Storage");
|
||||
}
|
||||
@@ -7,10 +7,6 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
@if (!ViewContext.ModelState.IsValid)
|
||||
{
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label asp-for="ContainerName"></label>
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
<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-lg-6">
|
||||
@if (!ViewContext.ModelState.IsValid)
|
||||
{
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
}
|
||||
<a asp-action="Storage" asp-route-forceChoice="true">Change Storage provider</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@model BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration.GoogleCloudStorageConfiguration
|
||||
@model BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration.GoogleCloudStorageConfiguration
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services, "Google Cloud Storage");
|
||||
}
|
||||
@@ -7,10 +7,6 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
@if (!ViewContext.ModelState.IsValid)
|
||||
{
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label asp-for="ContainerName"></label>
|
||||
|
||||
@@ -5,48 +5,64 @@
|
||||
|
||||
<h2 class="mb-4">@ViewData["PageTitle"]</h2>
|
||||
|
||||
<p>
|
||||
Change your <a asp-action="Services" asp-route-returnurl="@ViewData["ReturnUrl"]">external storage service</a> provider.
|
||||
<a href="https://docs.btcpayserver.org/FAQ/FAQ-ServerSettings/#how-to-upload-files-to-btcpay" target="_blank">
|
||||
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@if (Model.Files.Any())
|
||||
@if (!Model.StorageConfigured)
|
||||
{
|
||||
<table class="table table-sm table-responsive-md">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Timestamp</th>
|
||||
<th>User</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var file in Model.Files)
|
||||
{
|
||||
<tr>
|
||||
<td>@file.FileName</td>
|
||||
<td>@file.Timestamp.ToBrowserDate()</td>
|
||||
<td>@file.ApplicationUser.UserName</td>
|
||||
<td>
|
||||
<a asp-action="Files" asp-route-fileId="@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>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
Before being able to upload you first need to
|
||||
<a asp-action="storage" asp-route-forceChoice="true" asp-route-returnurl="@ViewData["ReturnUrl"]">
|
||||
choose your file storage service provider
|
||||
</a>.
|
||||
<a href="https://docs.btcpayserver.org/FAQ/FAQ-ServerSettings/#how-to-upload-files-to-btcpay" target="_blank">
|
||||
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
|
||||
</a>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-secondary mt-3">
|
||||
There are no files yet.
|
||||
<p>
|
||||
Change your <a asp-action="storage" asp-route-forceChoice="true" asp-route-returnurl="@ViewData["ReturnUrl"]">file storage service</a> provider.
|
||||
<a href="https://docs.btcpayserver.org/FAQ/FAQ-ServerSettings/#how-to-upload-files-to-btcpay" target="_blank">
|
||||
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@if (Model.Files.Any())
|
||||
{
|
||||
<table class="table table-sm table-responsive-md">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Timestamp</th>
|
||||
<th>User</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var file in Model.Files)
|
||||
{
|
||||
<tr>
|
||||
<td>@file.FileName</td>
|
||||
<td>@file.Timestamp.ToBrowserDate()</td>
|
||||
<td>@file.ApplicationUser.UserName</td>
|
||||
<td>
|
||||
<a asp-action="Files" asp-route-fileId="@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>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-secondary mt-3">
|
||||
There are no files yet.
|
||||
</p>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.SelectedFileId))
|
||||
{
|
||||
var file = Model.Files.Single(storedFile => storedFile.Id.Equals(Model.SelectedFileId, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BTCPayServer.Storage.Models
|
||||
@using BTCPayServer.Storage.Models
|
||||
@model BTCPayServer.Storage.ViewModels.ChooseStorageViewModel
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services, "Storage");
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
<div class="form-group">
|
||||
<label asp-for="Provider"></label>
|
||||
<select asp-for="Provider" asp-items="@Html.GetEnumSelectList<StorageProvider>()" class="form-control"></select>
|
||||
<select asp-for="Provider" asp-items="@Model.ProvidersList" class="form-control"></select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" name="command" value="Save">Next</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user