Bitpay Card: uses common widget for selecting wallet. Minor fixes
This commit is contained in:
parent
77e0d26f82
commit
6e1b7ec620
6 changed files with 61 additions and 90 deletions
|
|
@ -9,6 +9,15 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
StatusBar.backgroundColorByHexString("#293C92");
|
||||
}
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
wallet = w;
|
||||
$log.debug('Wallet changed: ' + w.name);
|
||||
});
|
||||
|
||||
var processTransactions = function(invoices, history) {
|
||||
for (var i = 0; i < invoices.length; i++) {
|
||||
var matched = false;
|
||||
|
|
@ -63,7 +72,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.isAuthenticated(function(err, bpSession) {
|
||||
self.loadingSession = false;
|
||||
if (err) {
|
||||
self.error = err.data.error || 'Incorrect email or password';
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +87,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.transactionHistory(dateRange, function(err, history) {
|
||||
$scope.loadingHistory = false;
|
||||
if (err) {
|
||||
self.error = err.error || err;
|
||||
self.error = 'Error getting transactions';
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -98,60 +106,24 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
$scope.dateRange = 'last30Days';
|
||||
|
||||
$scope.network = bitpayCardService.getEnvironment();
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
|
||||
self.update();
|
||||
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
wallet = $scope.wallets[0];
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
|
||||
if (wallet.credentials.n > 1)
|
||||
if (wallet && wallet.credentials.n > 1)
|
||||
self.isMultisigWallet = true;
|
||||
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.isMultisigWallet = false;
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
if (wallet.credentials.n > 1)
|
||||
self.isMultisigWallet = true;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.sendFunds = function() {
|
||||
self.error = null;
|
||||
|
||||
if (lodash.isEmpty(wallet)) return;
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
|
||||
|
|
@ -297,8 +269,8 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
self.authenticating = true;
|
||||
bitpayCardService.authenticate(data, function(err, auth) {
|
||||
self.authenticating = false;
|
||||
if (err && !err.data.error.twoFactorPending) {
|
||||
self.error = 'Authentiation error';
|
||||
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
|
||||
self.error = err.statusText || err.data.error || 'Authentiation error';
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
};
|
||||
|
||||
var _setError = function(msg, e) {
|
||||
$log.error(msg);
|
||||
return e;
|
||||
};
|
||||
|
||||
var _getUser = function(cb) {
|
||||
_setCredentials();
|
||||
storageService.getBitpayCard(credentials.NETWORK, function(err, user) {
|
||||
|
|
@ -53,8 +58,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
bpSession = data.data.data;
|
||||
return cb(null, bpSession);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Get Session: ERROR ' + data.data.error);
|
||||
return cb(data.data.error);
|
||||
return cb(_setError('BitPay Card Error: Get Session', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -97,8 +101,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay TopUp: SUCCESS');
|
||||
return cb(null, data.data.data.invoice);
|
||||
}, function(data) {
|
||||
$log.error('BitPay TopUp: ERROR ' + data.data.error);
|
||||
return cb(data.data.error);
|
||||
return cb(_setError('BitPay Card Error: TopUp', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -113,8 +116,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay Get Transaction History: SUCCESS');
|
||||
return cb(null, data.data.data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Get Transaction History: ERROR ' + data.data);
|
||||
return cb(data.data);
|
||||
return cb(_setError('BitPay Card Error: Get Transaction History', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -123,8 +125,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay Get Invoice History: SUCCESS');
|
||||
return cb(null, data.data.data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Get Invoice History: ERROR ' + data.data);
|
||||
return cb(data.data);
|
||||
return cb(_setError('BitPay Card Error: Get Invoice History', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -133,8 +134,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay Get Invoice: SUCCESS');
|
||||
return cb(null, data.data.data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Get Invoice: ERROR ' + data.data.error);
|
||||
return cb(data.data.error);
|
||||
return cb(_setError('BitPay Card Error: Get Invoice', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -147,8 +147,8 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
return cb(null, session);
|
||||
});
|
||||
}, function(data) {
|
||||
$log.error('BitPay Authenticate: ERROR');
|
||||
if (data.data.error.twoFactorPending) {
|
||||
if (data && data.data && data.data.error.twoFactorPending) {
|
||||
$log.error('BitPay Card needs 2FA Authentication');
|
||||
_getSession(function(err, session) {
|
||||
if (err) return cb(err);
|
||||
return cb(null, session);
|
||||
|
|
@ -165,8 +165,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay 2FA: SUCCESS');
|
||||
return cb(null, data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay 2FA: ERROR');
|
||||
return cb(data);
|
||||
return cb(_setError('BitPay Card Error: 2FA', data));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -195,8 +194,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
$log.info('BitPay Logout: SUCCESS');
|
||||
return cb(data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Logout: ERROR ' + data.data.error);
|
||||
return cb(data.data.error);
|
||||
return cb(_setError('BitPay Card Error: Logout ', data));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -426,6 +426,21 @@ ul.wallet-selection.wallets {
|
|||
}
|
||||
}
|
||||
|
||||
// POSTFIX
|
||||
|
||||
.postfix {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
background-color: #f8f8f8;
|
||||
color: #444;
|
||||
border-radius: 4px;
|
||||
padding: 2px 10px;
|
||||
cursor: pointer;
|
||||
label &{
|
||||
top: 38px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
}
|
||||
|
||||
// QR Code
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue