BitPay Card uses popupServices

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-31 09:55:11 -03:00
commit 748c28b235
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 10 additions and 42 deletions

View file

@ -31,11 +31,6 @@
<span ng-show="!bitpayCard.bitpayCardTwoFactorPending">Login to your account</span> <span ng-show="!bitpayCard.bitpayCardTwoFactorPending">Login to your account</span>
<span ng-show="bitpayCard.bitpayCardTwoFactorPending">2-Step Verification</span> <span ng-show="bitpayCard.bitpayCardTwoFactorPending">2-Step Verification</span>
</h4> </h4>
<div class="box-notification error"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
{{bitpayCard.error}}
</div>
<form <form
ng-show="!bitpayCard.bitpayCardTwoFactorPending" ng-show="!bitpayCard.bitpayCardTwoFactorPending"
@ -121,14 +116,9 @@
<option value="all">All Activity</option> <option value="all">All Activity</option>
</select> </select>
<div class="box-notification error"
ng-show="bitpayCard.error">
{{bitpayCard.error}}
</div>
<div <div
class="oh pr m20t text-gray size-12 text-center" class="oh pr m20t text-gray size-12 text-center"
ng-show="!bitpayCard.error && !bitpayCard.bitpayCardTransactionHistory[0] && ng-show="!bitpayCard.bitpayCardTransactionHistory[0] &&
!bitpayCard.bitpayCardInvoiceHistory[0] && !loadingHistory"> !bitpayCard.bitpayCardInvoiceHistory[0] && !loadingHistory">
No transactions yet No transactions yet
</div> </div>
@ -176,11 +166,6 @@
</div> </div>
<div ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && addFunds"> <div ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && addFunds">
<div class="box-notification error"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
{{bitpayCard.error}}
</div>
<form <form
name="createInvoiceForm" name="createInvoiceForm"
ng-submit="bitpayCard.sendFunds()" ng-submit="bitpayCard.sendFunds()"
@ -215,7 +200,7 @@
<div class="col"> <div class="col">
<button class="button button-block button-stable" <button class="button button-block button-stable"
type="button" type="button"
ng-click="addFunds = false; bitpayCard.error = null"> ng-click="addFunds = false">
Cancel Cancel
</button> </button>
</div> </div>

View file

@ -1,14 +1,10 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, platformInfo) { angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService) {
var self = this; var self = this;
var wallet; var wallet;
if (platformInfo.isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#293C92");
}
$scope.$on('Wallet/Changed', function(event, w) { $scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) { if (lodash.isEmpty(w)) {
$log.debug('No wallet provided'); $log.debug('No wallet provided');
@ -87,7 +83,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.transactionHistory(dateRange, function(err, history) { bitpayCardService.transactionHistory(dateRange, function(err, history) {
$scope.loadingHistory = false; $scope.loadingHistory = false;
if (err) { if (err) {
self.error = 'Error getting transactions'; popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Getting transactions'));
return; return;
} }
@ -120,13 +116,11 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
}; };
this.sendFunds = function() { this.sendFunds = function() {
self.error = null;
if (lodash.isEmpty(wallet)) return; if (lodash.isEmpty(wallet)) return;
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key'); $log.info('No signing proposal: No private key');
self.error = bwcError.msg('MISSING_PRIVATE_KEY'); popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
return; return;
} }
@ -146,10 +140,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.topUp(dataSrc, function(err, invoiceId) { bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) { if (err) {
ongoingProcess.set('Processing Transaction...', false); ongoingProcess.set('Processing Transaction...', false);
self.error = bwcError.msg(err); popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
$timeout(function() {
$scope.$digest();
});
return; return;
} }
@ -178,18 +169,12 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
walletService.createTx(wallet, txp, function(err, createdTxp) { walletService.createTx(wallet, txp, function(err, createdTxp) {
if (err) { if (err) {
self.error = bwcError.msg(err); popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
$timeout(function() {
$scope.$digest();
});
return; return;
} }
walletService.publishAndSign(wallet, createdTxp, function(err, tx) { walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
if (err) { if (err) {
self.error = err; popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
$timeout(function() {
$scope.$digest();
});
return; return;
} }
self.update(); self.update();
@ -205,7 +190,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
}; };
this.authenticate = function() { this.authenticate = function() {
self.error = null;
var data = { var data = {
emailAddress : $scope.email, emailAddress : $scope.email,
@ -219,7 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.authenticate(data, function(err, auth) { bitpayCardService.authenticate(data, function(err, auth) {
self.authenticating = false; self.authenticating = false;
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) { if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
self.error = err.statusText || err.data.error || 'Authentiation error'; popupService.showAler(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
return; return;
} }
@ -231,7 +215,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
}; };
this.authenticate2FA = function() { this.authenticate2FA = function() {
self.error = null;
var data = { var data = {
twoFactorCode : $scope.twoFactorCode twoFactorCode : $scope.twoFactorCode
@ -241,7 +224,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.authenticate2FA(data, function(err, auth) { bitpayCardService.authenticate2FA(data, function(err, auth) {
self.authenticating = false; self.authenticating = false;
if (err) { if (err) {
self.error = 'Authentiation error'; popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
return; return;
} }