Wallet page is now an action link in the store settings

This commit is contained in:
nicolas.dorier
2018-03-22 01:07:11 +09:00
parent 48eaf906b0
commit c0b903d79c
9 changed files with 26 additions and 42 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<Version>1.0.1.54</Version> <Version>1.0.1.55</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn> <NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -110,15 +110,15 @@ namespace BTCPayServer.Controllers
} }
[HttpGet] [HttpGet]
[Route("{storeId}/wallet")] [Route("{storeId}/wallet/{cryptoCode}")]
public async Task<IActionResult> Wallet(string storeId) public async Task<IActionResult> Wallet(string storeId, string cryptoCode)
{ {
var store = await _Repo.FindStore(storeId, GetUserId()); var store = await _Repo.FindStore(storeId, GetUserId());
if (store == null) if (store == null)
return NotFound(); return NotFound();
WalletModel model = new WalletModel(); WalletModel model = new WalletModel();
model.ServerUrl = GetStoreUrl(storeId); model.ServerUrl = GetStoreUrl(storeId);
model.SetCryptoCurrencies(_ExplorerProvider, store.GetDefaultCrypto()); model.CryptoCurrency = cryptoCode;
return View(model); return View(model);
} }

View File

@@ -94,13 +94,13 @@ namespace BTCPayServer.Hosting
}); });
// Needed to debug U2F for ledger support // Needed to debug U2F for ledger support
//services.Configure<KestrelServerOptions>(kestrel => services.Configure<KestrelServerOptions>(kestrel =>
//{ {
// kestrel.Listen(IPAddress.Loopback, 5012, l => kestrel.Listen(IPAddress.Loopback, 5012, l =>
// { {
// l.UseHttps("devtest.pfx", "toto"); l.UseHttps("devtest.pfx", "toto");
// }); });
//}); });
} }
// Big hack, tests fails if only call AddHangfire because Hangfire fail at initializing at the second test run // Big hack, tests fails if only call AddHangfire because Hangfire fail at initializing at the second test run

View File

@@ -10,25 +10,10 @@ namespace BTCPayServer.Models.StoreViewModels
public class WalletModel public class WalletModel
{ {
public string ServerUrl { get; set; } public string ServerUrl { get; set; }
public SelectList CryptoCurrencies { get; set; }
[Display(Name = "Crypto currency")]
public string CryptoCurrency public string CryptoCurrency
{ {
get; get;
set; set;
} }
class Format
{
public string Name { get; set; }
public string Value { get; set; }
}
public void SetCryptoCurrencies(ExplorerClientProvider explorerProvider, string selectedScheme)
{
var choices = explorerProvider.GetAll().Select(o => new Format() { Name = o.Item1.CryptoCode, Value = o.Item1.CryptoCode }).ToArray();
var chosen = choices.FirstOrDefault(f => f.Name == selectedScheme) ?? choices.FirstOrDefault();
CryptoCurrencies = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
CryptoCurrency = chosen.Name;
}
} }
} }

View File

@@ -14,10 +14,8 @@ namespace BTCPayServer.Views.Stores
public static string Tokens => "Tokens"; public static string Tokens => "Tokens";
public static string Wallet => "Wallet";
public static string TokensNavClass(ViewContext viewContext) => PageNavClass(viewContext, Tokens); public static string TokensNavClass(ViewContext viewContext) => PageNavClass(viewContext, Tokens);
public static string WalletNavClass(ViewContext viewContext) => PageNavClass(viewContext, Wallet);
public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index);

View File

@@ -93,8 +93,14 @@
{ {
<tr> <tr>
<td>@scheme.Crypto</td> <td>@scheme.Crypto</td>
<td style="max-width:400px;overflow:hidden;">@scheme.Value</td> <td style="max-width:300px;overflow:hidden;">@scheme.Value</td>
<td style="text-align:right"><a asp-action="AddDerivationScheme" asp-route-cryptoCode="@scheme.Crypto">Modify</a></td> <td style="text-align:right">
@if(!string.IsNullOrWhiteSpace(scheme.Value))
{
<a asp-action="Wallet" asp-route-cryptoCode="@scheme.Crypto">Wallet</a><span> - </span>
}
<a asp-action="AddDerivationScheme" asp-route-cryptoCode="@scheme.Crypto">Modify</a>
</td>
</tr> </tr>
} }
</tbody> </tbody>

View File

@@ -2,7 +2,6 @@
@{ @{
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";
ViewData["Title"] = "Manage wallet"; ViewData["Title"] = "Manage wallet";
ViewData.AddActivePage(StoreNavPages.Wallet);
} }
<h4>@ViewData["Title"]</h4> <h4>@ViewData["Title"]</h4>
@@ -32,10 +31,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<form id="sendform" style="display:none;"> <form id="sendform" style="display:none;">
<div class="form-group"> <input type="hidden" id="cryptoCode" asp-for="CryptoCurrency" />
<label asp-for="CryptoCurrency"></label>
<select id="cryptoCurrencies" asp-for="CryptoCurrency" asp-items="Model.CryptoCurrencies" class="form-control"></select>
</div>
<div class="form-group"> <div class="form-group">
<label>Destination</label> <label>Destination</label>
<input id="destination-textbox" name="Destination" class="form-control" type="text" /> <input id="destination-textbox" name="Destination" class="form-control" type="text" />

View File

@@ -4,6 +4,5 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li class="@StoreNavPages.IndexNavClass(ViewContext)"><a asp-action="UpdateStore">Information</a></li> <li class="@StoreNavPages.IndexNavClass(ViewContext)"><a asp-action="UpdateStore">Information</a></li>
<li class="@StoreNavPages.TokensNavClass(ViewContext)"><a asp-action="ListTokens">Access Tokens</a></li> <li class="@StoreNavPages.TokensNavClass(ViewContext)"><a asp-action="ListTokens">Access Tokens</a></li>
<li class="@StoreNavPages.WalletNavClass(ViewContext)"><a asp-action="Wallet">Wallet</a></li>
</ul> </ul>

View File

@@ -3,6 +3,7 @@
var bridge = new ledgerwebsocket.LedgerWebSocketBridge(srvModel.serverUrl + "ws/ledger"); var bridge = new ledgerwebsocket.LedgerWebSocketBridge(srvModel.serverUrl + "ws/ledger");
var recommendedFees = ""; var recommendedFees = "";
var recommendedBalance = ""; var recommendedBalance = "";
var cryptoCode = $("#cryptoCode").val();
function WriteAlert(type, message) { function WriteAlert(type, message) {
$(".alert").removeClass("alert-danger"); $(".alert").removeClass("alert-danger");
@@ -37,7 +38,7 @@
} }
var args = ""; var args = "";
args += "cryptoCode=" + $("#cryptoCurrencies").val(); args += "cryptoCode=" + cryptoCode;
args += "&destination=" + $("#destination-textbox").val(); args += "&destination=" + $("#destination-textbox").val();
args += "&amount=" + $("#amount-textbox").val(); args += "&amount=" + $("#amount-textbox").val();
args += "&feeRate=" + $("#fee-textbox").val(); args += "&feeRate=" + $("#fee-textbox").val();
@@ -64,6 +65,10 @@
WriteAlert("danger", result.error); WriteAlert("danger", result.error);
} else { } else {
WriteAlert("success", 'Transaction broadcasted (' + result.transactionId + ')'); WriteAlert("success", 'Transaction broadcasted (' + result.transactionId + ')');
$("#fee-textbox").val("");
$("#amount-textbox").val("");
$("#destination-textbox").val("");
$("#substract-checkbox").prop("checked", false);
updateInfo(); updateInfo();
} }
}); });
@@ -85,15 +90,10 @@
return false; return false;
}); });
$("#cryptoCurrencies").on("change", function (elem) {
updateInfo();
});
var updateInfo = function () { var updateInfo = function () {
if (!ledgerDetected) if (!ledgerDetected)
return false; return false;
$(".crypto-info").css("display", "none"); $(".crypto-info").css("display", "none");
var cryptoCode = $("#cryptoCurrencies").val();
bridge.sendCommand("getinfo", "cryptoCode=" + cryptoCode) bridge.sendCommand("getinfo", "cryptoCode=" + cryptoCode)
.catch(function (reason) { Write('check', 'error', reason); }) .catch(function (reason) { Write('check', 'error', reason); })
.then(function (result) { .then(function (result) {