btcpayserver/BTCPayServer/Views/Wallets/WalletTransactions.cshtml
2020-07-24 21:39:30 -07:00

276 lines
13 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model ListTransactionsViewModel
@{
Layout = "../Shared/_NavLayout.cshtml";
ViewData["Title"] = "Manage wallet";
ViewData.SetActivePageAndTitle(WalletsNavPages.Transactions);
}
<style type="text/css">
.smMaxWidth {
max-width: 200px;
}
@@media (min-width: 768px) {
.smMaxWidth {
max-width: 400px;
}
}
.unconf > * {
opacity: 0.5;
}
.switchTimeFormat {
display: block;
max-width: 150px;
width: 150px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.transactionLabel:not(:last-child) {
margin-bottom: 4px;
}
.removeTransactionLabelForm {
display: inline;
position: absolute;
right: 4px;
}
.removeTransactionLabelForm button {
color: #212529;
cursor: pointer;
display: inline;
padding: 0;
background-color: transparent;
border: 0;
}
</style>
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-md-12 text-center">
<partial name="_StatusMessage" />
</div>
</div>
}
<div class="row">
<div class="col-md-12">
If BTCPay Server shows you an invalid balance, <a asp-action="WalletRescan" asp-route-walletId="@this.Context.GetRouteValue("walletId")">rescan your wallet</a>. <br />
If some transactions appear in BTCPay Server, but are missing on Electrum or another wallet, <a href="https://docs.btcpayserver.org/FAQ/FAQ-Wallet/#missing-payments-in-my-software-or-hardware-wallet">follow those instructions</a>.
</div>
</div>
@if (Model.Labels.Any())
{
<div class="row mt-4">
<div class="col-md-12">
<div class="d-flex flex-row card card-body p-2">
<span class="mr-2">Filter by label:</span>
@foreach (var label in Model.Labels)
{
<a asp-route-labelFilter="@label.Value" class="badge mr-2 my-1 position-relative text-white d-block"
style="background-color: @label.Color;"><span class="text-white">@label.Value</span></a>
}
</div>
</div>
</div>
}
<div class="row">
<div class="col-md-12">
<table class="table table-sm table-responsive-lg">
<thead class="thead-inverse">
<tr>
<th style="min-width: 90px;" class="col-md-auto">
Date
<a href="javascript:switchTimeFormat()">
<span class="fa fa-clock-o" title="Switch date format"></span>
</a>
</th>
<th class="text-left">Label</th>
<th>Transaction Id</th>
<th class="text-right">Balance</th>
<th class="text-right"></th>
</tr>
</thead>
<tbody>
@foreach (var transaction in Model.Transactions)
{
<tr>
<td>
<span class="switchTimeFormat" data-switch="@transaction.Timestamp.ToTimeAgo()">
@transaction.Timestamp.ToBrowserDate()
</span>
</td>
<td class="text-left">
@foreach (var label in transaction.Labels)
{
<div
class="badge transactionLabel position-relative text-white d-block"
style="background-color: @label.Color; padding-right: 16px;"
data-toggle="tooltip"
title="@label.Tooltip">
<a asp-route-labelFilter="@label.Value" class="text-white">@label.Value</a>
@if (!string.IsNullOrEmpty(label.Link))
{
<a href="@label.Link" target="_blank"> <span class="fa fa-info-circle"></span></a>
}
<form
asp-route-walletId="@this.Context.GetRouteValue("walletId")"
asp-action="ModifyTransaction"
method="post"
class="removeTransactionLabelForm">
<input type="hidden" name="transactionId" value="@transaction.Id"/>
<button
name="removelabel"
type="submit"
value="@label.RawValue">
<span class="fa fa-close"></span>
</button>
</form>
</div>
}
</td>
<td class="smMaxWidth text-truncate @(transaction.IsConfirmed ? "" : "unconf")">
<a href="@transaction.Link" target="_blank">
@transaction.Id
</a>
</td>
@if (transaction.Positive)
{
<td style="text-align:right; color:green;" class="text-right">@transaction.Balance</td>
}
else
{
<td style="text-align:right; color:red;" class="text-right">@transaction.Balance</td>
}
<td class="text-right">
<div class="dropdown d-inline-block" >
<span class="fa fa-tags" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
<div class="dropdown-menu">
<form asp-action="ModifyTransaction" method="post"
asp-route-walletId="@this.Context.GetRouteValue("walletId")">
<input type="hidden" name="transactionId" value="@transaction.Id" />
<div class="input-group p-2">
<input name="addlabel" placeholder="Label name" maxlength="20" type="text" class="form-control form-control-sm" />
<div class="input-group-append">
<button type="submit" class="btn btn-primary btn-sm"><span class="fa fa-plus"></span></button>
</div>
</div>
@if (Model.Labels.Count > 0)
{
<div class="dropdown-divider"></div>
@foreach (var label in Model.Labels)
{
@if (transaction.Labels.Contains(label))
{
<button name="removelabel" class="btn btn-sm" type="submit" value="@label.Value"><span class="badge" style="display:block;background-color:@label.Color;color:white;text-align:left;"><span class="fa fa-check"></span> @label.Value</span></button>
}
else
{
<button name="addlabelclick" class="btn btn-sm" type="submit" value="@label.Value"><span class="badge" style="display:block;background-color:@label.Color;color:white;text-align:left;">@label.Value</span></button>
}
}
}
</form>
</div>
</div>
<div class="dropdown d-inline-block">
@if (string.IsNullOrEmpty(transaction.Comment))
{
<span class="fa fa-comment" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
}
else
{
<span class="fa fa-commenting" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
}
<div class="dropdown-menu">
<form asp-action="ModifyTransaction" method="post"
asp-route-walletId="@this.Context.GetRouteValue("walletId")">
<input type="hidden" name="transactionId" value="@transaction.Id" />
<div class="input-group p-2">
<textarea name="addcomment" maxlength="200" rows="2" cols="20" class="form-control form-control-sm">@transaction.Comment</textarea>
</div>
<div class="p-2">
<button type="submit" class="btn btn-primary">Save comment</button>
</div>
</form>
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
<nav class="w-100">
@if (Model.Total != 0)
{
<ul class="pagination float-left">
<li class="page-item @(Model.Skip == 0 ? "disabled" : null)">
<a class="page-link" tabindex="-1" href="@ListTransactionsPage(-1, Model.Count)">&laquo;</a>
</li>
<li class="page-item disabled">
@if (Model.Total <= Model.Count)
{
<span class="page-link">
1@Model.Transactions.Count
</span>
}
else
{
<span class="page-link">
@(Model.Skip + 1)@(Model.Skip + Model.Transactions.Count), Total: @Model.Total
</span>
}
</li>
<li class="page-item @(Model.Total > (Model.Skip + Model.Transactions.Count) ? null : "disabled")">
<a class="page-link" href="@ListTransactionsPage(1, Model.Count)">&raquo;</a>
</li>
</ul>
}
<ul class="pagination float-right">
<li class="page-item disabled">
<span class="page-link">Page Size:</span>
</li>
<li class="page-item @(Model.Count == 50 ? "active" : null)">
<a class="page-link" href="@ListTransactionsPage(0, 50)">50</a>
</li>
<li class="page-item @(Model.Count == 100 ? "active" : null)">
<a class="page-link" href="@ListTransactionsPage(0, 100)">100</a>
</li>
<li class="page-item @(Model.Count == 250 ? "active" : null)">
<a class="page-link" href="@ListTransactionsPage(0, 250)">250</a>
</li>
<li class="page-item @(Model.Count == 500 ? "active" : null)">
<a class="page-link" href="@ListTransactionsPage(0, 500)">500</a>
</li>
</ul>
</nav>
@{
string ListTransactionsPage(int prevNext, int count)
{
var skip = Model.Skip;
if (prevNext == -1)
{
skip = Math.Max(0, Model.Skip - Model.Count);
}
else if (prevNext == 1)
{
skip = Model.Skip + count;
}
var act = Url.Action("WalletTransactions", new
{
labelFilter = Context.Request.Query["labelFilter"],
skip = skip,
count = count,
});
return act;
}
}
</div>
</div>