new onGoingProcess

This commit is contained in:
Matias Alejo Garcia 2016-06-13 15:25:40 -03:00
commit 90dad5b2a8
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
33 changed files with 200 additions and 267 deletions

View file

@ -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 {