btcpayserver/BTCPayServer/Views/UIServer/Files.cshtml
d11n c56821300a
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
2022-06-15 21:06:16 +09:00

114 lines
5.1 KiB
Text

@model ViewFilesViewModel
@{
ViewData.SetActivePage(ServerNavPages.Files, "File Storage");
}
<div class="row">
<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)
{
<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/ServerSettings/#how-to-upload-files-to-btcpay" target="_blank" rel="noreferrer noopener">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
</p>
}
else
{
<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/ServerSettings/#how-to-upload-files-to-btcpay" target="_blank" rel="noreferrer noopener">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
</p>
@if (Model.StorageConfigured)
{
<form asp-action="CreateFiles" method="post" enctype="multipart/form-data">
<div class="d-flex">
<input multiple type="file" class="form-control mb-3" name="files" id="files" required>
<button class="btn btn-primary mb-3 ms-3" role="button">Upload</button>
</div>
</form>
}
@if (Model.Files.Any())
{
<table class="table table-hover table-responsive-md">
<thead>
<tr>
<th>Name</th>
<th>Timestamp</th>
<th>User</th>
<th class="text-end">Actions</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 class="text-end">
<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>
</tr>
}
</tbody>
</table>
}
else
{
<p class="text-secondary mt-3">
There are no files yet.
</p>
}
}
@if (Model.DirectUrlByFiles != null && Model.DirectUrlByFiles.Count > 0)
{
foreach (KeyValuePair<string, string> fileUrlPair in Model.DirectUrlByFiles)
{
var fileId = fileUrlPair.Key;
var fileUrl = fileUrlPair.Value;
var file = Model.Files.Single(storedFile => storedFile.Id.Equals(fileId, StringComparison.InvariantCultureIgnoreCase));
<div class="card mb-2">
<div class="card-text">
<ul class="list-group list-group-flush">
<li class="list-group-item">
@file.FileName
</li>
<li class="list-group-item">
<strong>URL:</strong>
<a asp-action="GetFile" asp-controller="UIStorage" asp-route-fileId="@fileId" target="_blank">
@Url.Action("GetFile", "UIStorage", new
{
fileId = fileId
}, Context.Request.Scheme, Context.Request.Host.ToString())
</a>
</li>
<li class="list-group-item">
<strong>Direct URL:</strong>
<a href="@fileUrl" target="_blank" rel="noreferrer noopener">@fileUrl</a>
</li>
</ul>
</div>
</div>
}
}
</div>
</div>