refactor getWallet in profile
Signed-off-by: Matias Alejo Garcia <ematiu@gmail.com>
This commit is contained in:
parent
ad8f5d3fd1
commit
707acfaf64
3 changed files with 50 additions and 32 deletions
|
|
@ -9,7 +9,7 @@
|
|||
<div class="panel text-center" ng-if="!payment.uri">
|
||||
<h1 translate>Bitcoin URI is NOT valid!</h1>
|
||||
</div>
|
||||
<div ng-if="payment.uri">
|
||||
<div ng-if="payment.uri" ng-init="wallets = payment.getWallets(payment.uri.network)">
|
||||
<h1 translate>Make a payment to</h1>
|
||||
<div class="panel size-14">
|
||||
<div class="ellipsis"><b translate>Address</b>: {{payment.uri.address.toString()}}</div>
|
||||
|
|
@ -17,19 +17,30 @@
|
|||
<div ng-show="payment.uri.message"><b translate>Message</b>: {{payment.uri.message}}</div>
|
||||
<div ng-show="payment.uri.network == 'testnet'"><b translate>Network</b>: {{payment.uri.network}}</div>
|
||||
</div>
|
||||
<h2 translate>Select a wallet</h2>
|
||||
<ul class="no-bullet" ng-init="wallets = payment.getWallets(payment.uri.network)">
|
||||
<li class="panel" ng-repeat="w in wallets">
|
||||
<a ng-click="payment.selectWallet(w.id)">
|
||||
<div class="avatar-wallet"
|
||||
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
||||
<div class="ellipsis">{{w.name || w.id}}</div>
|
||||
<div class="size-12">{{w.m}} of {{w.n}}
|
||||
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-if="!wallets || !wallets.length">
|
||||
<div class="box-notification">
|
||||
<span class="text-warning" translate>
|
||||
There are not wallets to make this payment
|
||||
<span ng-show="payment.uri.network == 'testnet'">[testnet]</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="wallets.length">
|
||||
<h2 translate>Select a wallet</h2>
|
||||
<ul class="no-bullet">
|
||||
<li class="panel" ng-repeat="w in wallets">
|
||||
<a ng-click="payment.selectWallet(w.id)">
|
||||
<div class="avatar-wallet"
|
||||
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
||||
<div class="ellipsis">{{w.name || w.id}}</div>
|
||||
<div class="size-12">{{w.m}} of {{w.n}}
|
||||
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,24 +38,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
|
|||
};
|
||||
|
||||
this.getWallets = function(network) {
|
||||
if (!profileService.profile) return;
|
||||
var config = configService.getSync();
|
||||
config.colorFor = config.colorFor || {};
|
||||
config.aliasFor = config.aliasFor || {};
|
||||
var ret = lodash.map(profileService.profile.credentials, function(c) {
|
||||
return {
|
||||
m: c.m,
|
||||
n: c.n,
|
||||
name: config.aliasFor[c.walletId] || c.walletName,
|
||||
id: c.walletId,
|
||||
network: c.network,
|
||||
color: config.colorFor[c.walletId] || '#2C3E50'
|
||||
};
|
||||
});
|
||||
ret = lodash.filter(ret, function(w) {
|
||||
return (w.network == network);
|
||||
});
|
||||
return lodash.sortBy(ret, 'name');
|
||||
return profileService.getWallets(network);
|
||||
};
|
||||
|
||||
this.selectWallet = function(wid) {
|
||||
|
|
|
|||
|
|
@ -396,5 +396,29 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.getWallets = function(network) {
|
||||
if (!root.profile) return [];
|
||||
|
||||
var config = configService.getSync();
|
||||
config.colorFor = config.colorFor || {};
|
||||
config.aliasFor = config.aliasFor || {};
|
||||
var ret = lodash.map(root.profile.credentials, function(c) {
|
||||
return {
|
||||
m: c.m,
|
||||
n: c.n,
|
||||
name: config.aliasFor[c.walletId] || c.walletName,
|
||||
id: c.walletId,
|
||||
network: c.network,
|
||||
color: config.colorFor[c.walletId] || '#2C3E50'
|
||||
};
|
||||
});
|
||||
ret = lodash.filter(ret, function(w) {
|
||||
return (w.network == network);
|
||||
});
|
||||
return lodash.sortBy(ret, 'name');
|
||||
};
|
||||
|
||||
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue