From 8f6048191d1ec76601da82e46a171cff6652dfb5 Mon Sep 17 00:00:00 2001 From: rockstardev <5191402+rockstardev@users.noreply.github.com> Date: Sun, 11 Apr 2021 14:05:47 -0500 Subject: [PATCH 1/5] Improving navigation between files and storage services and rewording info text --- .../Controllers/ServerController.Storage.cs | 5 +- BTCPayServer/Views/Server/Files.cshtml | 86 +++++++++++-------- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/BTCPayServer/Controllers/ServerController.Storage.cs b/BTCPayServer/Controllers/ServerController.Storage.cs index 5bd148bef..18b470b30 100644 --- a/BTCPayServer/Controllers/ServerController.Storage.cs +++ b/BTCPayServer/Controllers/ServerController.Storage.cs @@ -30,13 +30,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()) != null - }); + }; + return View(model); } [HttpGet("server/files/{fileId}/delete")] diff --git a/BTCPayServer/Views/Server/Files.cshtml b/BTCPayServer/Views/Server/Files.cshtml index dfb7c6616..5f5de22ca 100644 --- a/BTCPayServer/Views/Server/Files.cshtml +++ b/BTCPayServer/Views/Server/Files.cshtml @@ -5,48 +5,64 @@

@ViewData["PageTitle"]

-

- Change your external storage service provider. - - - -

- -@if (Model.Files.Any()) +@if (!Model.StorageConfigured) { - - - - - - - - - - - @foreach (var file in Model.Files) - { - - - - - - - } - -
NameTimestampUser
@file.FileName@file.Timestamp.ToBrowserDate()@file.ApplicationUser.UserName - Get Link - - Get Temp Link - - Remove -
+

+ Before being able to upload you first need to + + choose your external storage service provider + . + + + +

} else { -

- There are no files yet. +

+ Change your external storage service provider. + + +

+ + @if (Model.Files.Any()) + { + + + + + + + + + + + @foreach (var file in Model.Files) + { + + + + + + + } + +
NameTimestampUser
@file.FileName@file.Timestamp.ToBrowserDate()@file.ApplicationUser.UserName + Get Link + - Get Temp Link + - Remove +
+ } + else + { +

+ There are no files yet. +

+ } } + @if (!string.IsNullOrEmpty(Model.SelectedFileId)) { var file = Model.Files.Single(storedFile => storedFile.Id.Equals(Model.SelectedFileId, StringComparison.InvariantCultureIgnoreCase)); From 99dd6f3e5027bde26340d31cfeb3d2af4fc58250 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 13 Apr 2021 09:27:29 +0200 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Zaxounette <51208677+Zaxounette@users.noreply.github.com> --- BTCPayServer/Views/Server/Files.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTCPayServer/Views/Server/Files.cshtml b/BTCPayServer/Views/Server/Files.cshtml index 5f5de22ca..99bdb90e5 100644 --- a/BTCPayServer/Views/Server/Files.cshtml +++ b/BTCPayServer/Views/Server/Files.cshtml @@ -10,7 +10,7 @@

Before being able to upload you first need to - choose your external storage service provider + choose your file storage service provider . From 04a29ece3b3ce7185be92899a201db21e2ff51b3 Mon Sep 17 00:00:00 2001 From: rockstardev <5191402+rockstardev@users.noreply.github.com> Date: Sun, 18 Apr 2021 14:03:22 -0500 Subject: [PATCH 3/5] Only display storage providers that can actually be set in dropdown --- BTCPayServer/Controllers/ServerController.Storage.cs | 8 ++++++++ BTCPayServer/Storage/ViewModels/ChooseStorageViewModel.cs | 3 +++ BTCPayServer/Views/Server/Storage.cshtml | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Controllers/ServerController.Storage.cs b/BTCPayServer/Controllers/ServerController.Storage.cs index 18b470b30..495a884a9 100644 --- a/BTCPayServer/Controllers/ServerController.Storage.cs +++ b/BTCPayServer/Controllers/ServerController.Storage.cs @@ -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 @@ -175,8 +178,13 @@ namespace BTCPayServer.Controllers var savedSettings = await _SettingsRepository.GetSettingAsync(); 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 }); diff --git a/BTCPayServer/Storage/ViewModels/ChooseStorageViewModel.cs b/BTCPayServer/Storage/ViewModels/ChooseStorageViewModel.cs index 9346f7aea..844c01d1c 100644 --- a/BTCPayServer/Storage/ViewModels/ChooseStorageViewModel.cs +++ b/BTCPayServer/Storage/ViewModels/ChooseStorageViewModel.cs @@ -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 ProvidersList { get; set; } public StorageProvider Provider { get; set; } public bool ShowChangeWarning { get; set; } } diff --git a/BTCPayServer/Views/Server/Storage.cshtml b/BTCPayServer/Views/Server/Storage.cshtml index d7a258977..6c4bf7187 100644 --- a/BTCPayServer/Views/Server/Storage.cshtml +++ b/BTCPayServer/Views/Server/Storage.cshtml @@ -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 @@ }

From 71305461d454c404460ffd67eb361f73b55d6951 Mon Sep 17 00:00:00 2001 From: rockstardev <5191402+rockstardev@users.noreply.github.com> Date: Sun, 18 Apr 2021 14:05:12 -0500 Subject: [PATCH 4/5] Cleaning up edit pages for storage providers not to have summary error Error sandwich be gone --- .../Views/Server/EditAmazonS3StorageProvider.cshtml | 6 +----- .../Views/Server/EditAzureBlobStorageStorageProvider.cshtml | 6 +----- .../Views/Server/EditFilesystemStorageProvider.cshtml | 4 ---- .../Server/EditGoogleCloudStorageStorageProvider.cshtml | 6 +----- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/BTCPayServer/Views/Server/EditAmazonS3StorageProvider.cshtml b/BTCPayServer/Views/Server/EditAmazonS3StorageProvider.cshtml index e1c6570c1..9f67d60b7 100644 --- a/BTCPayServer/Views/Server/EditAmazonS3StorageProvider.cshtml +++ b/BTCPayServer/Views/Server/EditAmazonS3StorageProvider.cshtml @@ -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 @@
- @if (!ViewContext.ModelState.IsValid) - { -
- }
diff --git a/BTCPayServer/Views/Server/EditAzureBlobStorageStorageProvider.cshtml b/BTCPayServer/Views/Server/EditAzureBlobStorageStorageProvider.cshtml index 78d20ffc3..3d525ab56 100644 --- a/BTCPayServer/Views/Server/EditAzureBlobStorageStorageProvider.cshtml +++ b/BTCPayServer/Views/Server/EditAzureBlobStorageStorageProvider.cshtml @@ -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 @@
- @if (!ViewContext.ModelState.IsValid) - { -
- }
diff --git a/BTCPayServer/Views/Server/EditFilesystemStorageProvider.cshtml b/BTCPayServer/Views/Server/EditFilesystemStorageProvider.cshtml index d89c26b3b..5fdfbb37b 100644 --- a/BTCPayServer/Views/Server/EditFilesystemStorageProvider.cshtml +++ b/BTCPayServer/Views/Server/EditFilesystemStorageProvider.cshtml @@ -8,10 +8,6 @@

Any uploaded files are being saved on the same machine that hosts BTCPay; please pay attention to your storage space.

diff --git a/BTCPayServer/Views/Server/EditGoogleCloudStorageStorageProvider.cshtml b/BTCPayServer/Views/Server/EditGoogleCloudStorageStorageProvider.cshtml index ccac5c1f1..5068a1c33 100644 --- a/BTCPayServer/Views/Server/EditGoogleCloudStorageStorageProvider.cshtml +++ b/BTCPayServer/Views/Server/EditGoogleCloudStorageStorageProvider.cshtml @@ -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 @@