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">
|
<div class="panel text-center" ng-if="!payment.uri">
|
||||||
<h1 translate>Bitcoin URI is NOT valid!</h1>
|
<h1 translate>Bitcoin URI is NOT valid!</h1>
|
||||||
</div>
|
</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>
|
<h1 translate>Make a payment to</h1>
|
||||||
<div class="panel size-14">
|
<div class="panel size-14">
|
||||||
<div class="ellipsis"><b translate>Address</b>: {{payment.uri.address.toString()}}</div>
|
<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.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 ng-show="payment.uri.network == 'testnet'"><b translate>Network</b>: {{payment.uri.network}}</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 translate>Select a wallet</h2>
|
<div ng-if="!wallets || !wallets.length">
|
||||||
<ul class="no-bullet" ng-init="wallets = payment.getWallets(payment.uri.network)">
|
<div class="box-notification">
|
||||||
<li class="panel" ng-repeat="w in wallets">
|
<span class="text-warning" translate>
|
||||||
<a ng-click="payment.selectWallet(w.id)">
|
There are not wallets to make this payment
|
||||||
<div class="avatar-wallet"
|
<span ng-show="payment.uri.network == 'testnet'">[testnet]</span>
|
||||||
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
</span>
|
||||||
<div class="ellipsis">{{w.name || w.id}}</div>
|
</div>
|
||||||
<div class="size-12">{{w.m}} of {{w.n}}
|
</div>
|
||||||
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
|
||||||
</div>
|
<div ng-if="wallets.length">
|
||||||
</a>
|
<h2 translate>Select a wallet</h2>
|
||||||
</li>
|
<ul class="no-bullet">
|
||||||
</ul>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -38,24 +38,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getWallets = function(network) {
|
this.getWallets = function(network) {
|
||||||
if (!profileService.profile) return;
|
return profileService.getWallets(network);
|
||||||
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');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectWallet = function(wid) {
|
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;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue