new onGoingProcess
This commit is contained in:
parent
c294097c1d
commit
90dad5b2a8
33 changed files with 200 additions and 267 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
||||
function($scope, $modal, $log, $ionicModal, $timeout, lodash, profileService, coinbaseService, bwsError, addressService) {
|
||||
function($scope, $modal, $log, $ionicModal, $timeout, lodash, profileService, coinbaseService, bwsError, addressService, ongoingProcess) {
|
||||
var self = this;
|
||||
|
||||
this.init = function(testnet) {
|
||||
|
|
@ -73,9 +73,9 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
currency: currency,
|
||||
payment_method: $scope.selectedPaymentMethod.id || null
|
||||
};
|
||||
this.loading = 'Sending request...';
|
||||
ongoingProcess.set('Sending request...', true);
|
||||
coinbaseService.buyRequest(token, accountId, dataSrc, function(err, data) {
|
||||
self.loading = null;
|
||||
ongoingProcess.set('Sending request...', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
return;
|
||||
|
|
@ -88,9 +88,9 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
self.error = null;
|
||||
var accountId = account.id;
|
||||
var buyId = buy.id;
|
||||
this.loading = 'Buying bitcoin...';
|
||||
ongoingProcess.set('Buying Bitcoin...', true);
|
||||
coinbaseService.buyCommit(token, accountId, buyId, function(err, b) {
|
||||
self.loading = null;
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
return;
|
||||
|
|
@ -98,12 +98,12 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
var tx = b.data.transaction;
|
||||
if (!tx) return;
|
||||
|
||||
self.loading = 'Getting transaction...';
|
||||
ongoingProcess.set('Fetching transaction...', true);
|
||||
coinbaseService.getTransaction(token, accountId, tx.id, function(err, updatedTx) {
|
||||
ongoingProcess.set('Fetching transaction...', false);
|
||||
if (err) $log.debug(err);
|
||||
addressService.getAddress(self.selectedWalletId, false, function(err, addr) {
|
||||
if (err) {
|
||||
self.loading = null;
|
||||
self.error = {
|
||||
errors: [{
|
||||
message: 'Could not create address'
|
||||
|
|
@ -113,7 +113,6 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
}
|
||||
updatedTx.data['toAddr'] = addr;
|
||||
coinbaseService.savePendingTransaction(updatedTx.data, {}, function(err) {
|
||||
self.loading = null;
|
||||
if (err) $log.debug(err);
|
||||
if (updatedTx.data.status == 'completed') {
|
||||
self.sendToCopay(token, account, updatedTx.data);
|
||||
|
|
@ -134,7 +133,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
self.error = null;
|
||||
var accountId = account.id;
|
||||
|
||||
self.loading = 'Sending funds to Copay...';
|
||||
ongoingProcess.set('Sending funds to Copay...', true);
|
||||
var data = {
|
||||
to: tx.toAddr,
|
||||
amount: tx.amount.amount,
|
||||
|
|
@ -142,7 +141,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
|
|||
description: 'Copay Wallet: ' + self.selectedWalletName
|
||||
};
|
||||
coinbaseService.sendTo(token, accountId, data, function(err, res) {
|
||||
self.loading = null;
|
||||
ongoingProcess.set('Sending funds to Copay...', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue