Added page and controller to select wallet
This commit is contained in:
parent
f1005625dd
commit
bacea69cb3
6 changed files with 97 additions and 2 deletions
25
js/controllers/paymentIntent.js
Normal file
25
js/controllers/paymentIntent.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var bitcore = require('bitcore');
|
||||||
|
|
||||||
|
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $routeParams, $timeout, $location, controllerUtils) {
|
||||||
|
|
||||||
|
|
||||||
|
$rootScope.title = 'Select the wallet that you will use to spend your bitcoins';
|
||||||
|
$scope.wallets = [];
|
||||||
|
|
||||||
|
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
|
||||||
|
_.each(wids, function(wid) {
|
||||||
|
var w = $rootScope.iden.getWalletById(wid);
|
||||||
|
$scope.wallets.push(w);
|
||||||
|
controllerUtils.updateBalance(w, function() {
|
||||||
|
$rootScope.$digest();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.switchWallet = function(wid) {
|
||||||
|
//go to send page
|
||||||
|
controllerUtils.setPaymentWallet(wid);
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -4,6 +4,34 @@ var preconditions = require('preconditions').singleton();
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SendController',
|
angular.module('copayApp.controllers').controller('SendController',
|
||||||
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) {
|
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) {
|
||||||
|
|
||||||
|
controllerUtils.redirIfNotComplete();
|
||||||
|
|
||||||
|
var w = $rootScope.wallet;
|
||||||
|
preconditions.checkState(w);
|
||||||
|
preconditions.checkState(w.settings.unitToSatoshi);
|
||||||
|
|
||||||
|
$rootScope.title = 'Send';
|
||||||
|
$scope.loading = false;
|
||||||
|
var satToUnit = 1 / w.settings.unitToSatoshi;
|
||||||
|
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
||||||
|
$scope.unitToBtc = w.settings.unitToSatoshi / bitcore.util.COIN;
|
||||||
|
$scope.unitToSatoshi = w.settings.unitToSatoshi;
|
||||||
|
|
||||||
|
$scope.alternativeName = w.settings.alternativeName;
|
||||||
|
$scope.alternativeIsoCode = w.settings.alternativeIsoCode;
|
||||||
|
|
||||||
|
$scope.isRateAvailable = false;
|
||||||
|
$scope.rateService = rateService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rateService.whenAvailable(function() {
|
||||||
|
$scope.isRateAvailable = true;
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting the two related amounts as properties prevents an infinite
|
* Setting the two related amounts as properties prevents an infinite
|
||||||
* recursion for watches while preserving the original angular updates
|
* recursion for watches while preserving the original angular updates
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ angular.module('copayApp.controllers').controller('UriPaymentController', functi
|
||||||
$rootScope.pendingPayment = new bitcore.BIP21(bitcoinURI);
|
$rootScope.pendingPayment = new bitcore.BIP21(bitcoinURI);
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$location.path('/send');
|
console.log('Redirecting to /paymentIntent');
|
||||||
|
$location.path('/paymentIntent');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ angular
|
||||||
.when('/uri-payment/:data', {
|
.when('/uri-payment/:data', {
|
||||||
templateUrl: 'views/uri-payment.html'
|
templateUrl: 'views/uri-payment.html'
|
||||||
})
|
})
|
||||||
|
.when('/paymentIntent', {
|
||||||
|
templateUrl: 'views/paymentIntent.html',
|
||||||
|
logged: true
|
||||||
|
})
|
||||||
.when('/join', {
|
.when('/join', {
|
||||||
templateUrl: 'views/join.html',
|
templateUrl: 'views/join.html',
|
||||||
logged: true
|
logged: true
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ angular.module('copayApp.services')
|
||||||
if ($rootScope.initialConnection) {
|
if ($rootScope.initialConnection) {
|
||||||
$rootScope.initialConnection = false;
|
$rootScope.initialConnection = false;
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
$location.path('send');
|
$location.path('paymentIntent');
|
||||||
} else {
|
} else {
|
||||||
root.redirIfLogged();
|
root.redirIfLogged();
|
||||||
}
|
}
|
||||||
|
|
@ -196,6 +196,11 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.setPaymentWallet = function(w) {
|
||||||
|
root.setFocusedWallet(w);
|
||||||
|
$location.path('/send');
|
||||||
|
};
|
||||||
|
|
||||||
root.setFocusedWallet = function(w) {
|
root.setFocusedWallet = function(w) {
|
||||||
if (!_.isObject(w))
|
if (!_.isObject(w))
|
||||||
w = $rootScope.iden.getWalletById(w);
|
w = $rootScope.iden.getWalletById(w);
|
||||||
|
|
|
||||||
32
views/paymentIntent.html
Normal file
32
views/paymentIntent.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<div ng-controller="PaymentIntentController" class="large-4 columns large-centered">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- //TODO THIS SHOULD BE A POPUP -->
|
||||||
|
<ul class="side-nav wallets" ng-show="wallets.0"
|
||||||
|
ng-class="{'large':wallets.length > 4, 'medium':wallets.length > 2 && wallets.length < 5}">
|
||||||
|
<li data-ng-repeat="item in wallets track by $index" class="nav-item">
|
||||||
|
<div class="col1">
|
||||||
|
<div class="avatar-wallet">{{(item.name || item.id) | limitTo: 1}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="col2">
|
||||||
|
<a class="size-12 wallet-item" ng-click="switchWallet(item.id)">
|
||||||
|
<div class="oh">
|
||||||
|
<div class="right size-10 type-wallet">[ {{item.requiredCopayers}} of {{item.totalCopayers}} ]</div>
|
||||||
|
<div class="ellipsis name-wallet">{{item.name || item.id}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="oh">
|
||||||
|
<span ng-if="item.isReady() && item.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||||
|
<div ng-if="item.isReady() && !item.balanceInfo.updatingBalance" data-options="disable_for_touch:true">
|
||||||
|
<b class="m5r size-12">{{item.balanceInfo.totalBalance || 0 |noFractionNumber}} {{item.settings.unitName}}</b>
|
||||||
|
<span class="alt-currency size-10">{{item.balanceInfo.totalBalanceAlternative |noFractionNumber:2}} {{item.balanceInfo.alternativeIsoCode}}</span>
|
||||||
|
</div>
|
||||||
|
<span ng-if="!item.isReady()">Waiting for copayers...</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue