Merge pull request #2455 from btcpayserver/feat/improving-files-page

Improving File Storage page
This commit is contained in:
Nicolas Dorier
2021-04-20 11:06:14 +09:00
committed by GitHub
8 changed files with 70 additions and 58 deletions

View File

@@ -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
});