Fix: modal choose wallet. Sell in Coinbase and Glidera. Spinner

This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-16 18:29:56 -03:00
commit f08f30240a
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
13 changed files with 123 additions and 81 deletions

View file

@ -85,14 +85,13 @@
</li> </li>
</ul> </ul>
<div class="row m20t p20t line-t" ng-show="tx.status == 'error'"> <div class="row m20t" ng-show="tx.status == 'error'">
<div class="columns"> <div class="columns">
<p class="text-center size-12 text-gray"> <p class="text-center size-12 text-gray">
This action will remove the transaction. This action will remove the transaction.
</p> </p>
<button class="button outline round dark-gray expand tiny" <button class="button outline round dark-gray expand tiny"
ng-click="remove();" ng-click="remove()">
ng-disabled="loading">
<i class="fi-x"></i> <i class="fi-x"></i>
Remove Remove
</button> </button>

View file

@ -11,8 +11,11 @@
</h1> </h1>
</ion-header-bar> </ion-header-bar>
<ion-content class="m20t" overflow-scroll="true"> <ion-content overflow-scroll="true">
<div class="modal-content m20t"> <div class="modal-content">
<div class="box-notification text-center size-12 text-warning m10t" ng-show="error">
<i class="fi-error"></i> {{error}}
</div>
<div ng-show="type == 'SELL'"> <div ng-show="type == 'SELL'">
<h4 class="title m0 oh"> <h4 class="title m0 oh">
<div class="left"> <div class="left">
@ -34,7 +37,13 @@
ng-style="{'background-color':w.color}"> ng-style="{'background-color':w.color}">
<i class="icon-wallet size-21"></i> <i class="icon-wallet size-21"></i>
</div> </div>
<div class="ellipsis name-wallet text-bold">{{w.name || w.id}}</div> <div class="ellipsis name-wallet text-bold">
{{w.name || w.id}}
<span class="has-error right text-light size-12" ng-show="errorSelectedWallet[w.id]">
<i class="icon-close-circle size-14"></i>
<span class="vm">{{errorSelectedWallet[w.id]}}</span>
</span>
</div>
<div class="size-12">{{w.m}} of {{w.n}} <div class="size-12">{{w.m}} of {{w.n}}
<span ng-show="w.network=='testnet'">[Testnet]</span> <span ng-show="w.network=='testnet'">[Testnet]</span>
</div> </div>

View file

@ -94,7 +94,7 @@
</div> </div>
<div class="input m20t"> <div class="input m20t">
<a href class="button black expand round" <a href class="button black expand round"
ng-disabled=" (!amount && !fiat)" ng-disabled=" (!amount && !fiat) || !sell.sellPrice.amount"
ng-style="{'background-color': '#2b71b1'}" ng-style="{'background-color': '#2b71b1'}"
ng-click="showPriceSensitivity = true">Continue</a> ng-click="showPriceSensitivity = true">Continue</a>
</div> </div>
@ -124,7 +124,7 @@
</div> </div>
<div class="columns large-6 medium-6 small-6"> <div class="columns large-6 medium-6 small-6">
<input class="button black expand round" <input class="button black expand round"
ng-disabled="(!amount && !fiat)" ng-disabled="(!amount && !fiat) || !sell.sellPrice.amount"
ng-style="{'background-color': '#2b71b1'}" ng-style="{'background-color': '#2b71b1'}"
type="submit" value="Confirm"> type="submit" value="Confirm">
</div> </div>

View file

@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
var self = this; var self = this;
this.init = function(testnet) { this.init = function(testnet) {
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet');
var client = profileService.focusedClient; var client = profileService.focusedClient;
if (client) { if (client) {
@ -45,8 +45,6 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
$scope.openWalletsModal = function(wallets) { $scope.openWalletsModal = function(wallets) {
self.error = null; self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.type = 'BUY'; $scope.type = 'BUY';
$scope.wallets = wallets; $scope.wallets = wallets;
@ -60,6 +58,15 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
$scope.walletsModal = modal; $scope.walletsModal = modal;
$scope.walletsModal.show(); $scope.walletsModal.show();
}); });
$scope.$on('walletSelected', function(ev, obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
}; };
this.buyRequest = function(token, account) { this.buyRequest = function(token, account) {

View file

@ -9,7 +9,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
this.success = null; this.success = null;
this.init = function(testnet) { this.init = function(testnet) {
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet');
var client = profileService.focusedClient; var client = profileService.focusedClient;
if (client) { if (client) {
@ -23,8 +23,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
$scope.openWalletsModal = function(wallets) { $scope.openWalletsModal = function(wallets) {
self.error = null; self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.type = 'BUY'; $scope.type = 'BUY';
$scope.wallets = wallets; $scope.wallets = wallets;
@ -38,6 +36,15 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
$scope.walletsModal = modal; $scope.walletsModal = modal;
$scope.walletsModal.show(); $scope.walletsModal.show();
}); });
$scope.$on('walletSelected', function(ev, obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
}; };
this.getBuyPrice = function(token, price) { this.getBuyPrice = function(token, price) {

View file

@ -1060,9 +1060,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
getToken(function(err, accessToken) { getToken(function(err, accessToken) {
if (err || !accessToken) return; if (err || !accessToken) return;
else { else {
ongoingProcess.set('connectingGlidera', true);
glideraService.getAccessTokenPermissions(accessToken, function(err, p) { glideraService.getAccessTokenPermissions(accessToken, function(err, p) {
ongoingProcess.set('connectingGlidera', false);
if (err) { if (err) {
self.glideraError = err; self.glideraError = err;
} else { } else {
@ -1093,24 +1091,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
if (permissions.transaction_history) { if (permissions.transaction_history) {
ongoingProcess.set('Fetching Glidera Transactions', true);
glideraService.getTransactions(accessToken, function(err, data) { glideraService.getTransactions(accessToken, function(err, data) {
ongoingProcess.set('Fetching Glidera Transactions', false);
self.glideraTxs = data; self.glideraTxs = data;
}); });
} }
if (permissions.view_email_address && opts.fullUpdate) { if (permissions.view_email_address && opts.fullUpdate) {
ongoingProcess.set('connectingGlidera', true);
glideraService.getEmail(accessToken, function(err, data) { glideraService.getEmail(accessToken, function(err, data) {
ongoingProcess.set('connectingGlidera', false);
self.glideraEmail = data.email; self.glideraEmail = data.email;
}); });
} }
if (permissions.personal_info && opts.fullUpdate) { if (permissions.personal_info && opts.fullUpdate) {
ongoingProcess.set('connectingGlidera', true);
glideraService.getPersonalInfo(accessToken, function(err, data) { glideraService.getPersonalInfo(accessToken, function(err, data) {
ongoingProcess.set('connectingGlidera', false);
self.glideraPersonalInfo = data; self.glideraPersonalInfo = data;
}); });
} }
@ -1145,9 +1137,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
getToken(function(err, accessToken) { getToken(function(err, accessToken) {
if (err || !accessToken) return; if (err || !accessToken) return;
else { else {
ongoingProcess.set('Getting primary account...', true);
coinbaseService.getAccounts(accessToken, function(err, a) { coinbaseService.getAccounts(accessToken, function(err, a) {
ongoingProcess.set('Getting primary account...', false);
if (err) { if (err) {
self.coinbaseError = err; self.coinbaseError = err;
if (err.errors[0] && err.errors[0].id == 'expired_token') { if (err.errors[0] && err.errors[0].id == 'expired_token') {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('coinbaseTxDetailsController', function($scope, coinbaseService) { angular.module('copayApp.controllers').controller('coinbaseTxDetailsController', function($scope, $rootScope, coinbaseService) {
$scope.remove = function() { $scope.remove = function() {
coinbaseService.savePendingTransaction($scope.tx, { coinbaseService.savePendingTransaction($scope.tx, {

View file

@ -2,25 +2,24 @@
angular.module('copayApp.controllers').controller('walletsController', function($scope, bwsError, profileService) { angular.module('copayApp.controllers').controller('walletsController', function($scope, bwsError, profileService) {
var self = $scope.self;
$scope.selectWallet = function(walletId, walletName) { $scope.selectWallet = function(walletId, walletName) {
if (!profileService.getClient(walletId).isComplete()) {
self.error = bwsError.msg({ var client = profileService.getClient(walletId);
'code': 'WALLET_NOT_COMPLETE' $scope.errorSelectedWallet = {};
}, 'Could not choose the wallet');
self.error = { profileService.isReady(client, function(err) {
errors: [{ if (err) {
message: 'The Wallet could not be selected' $scope.errorSelectedWallet[walletId] = bwsError.msg(err);
}] return;
}; }
$scope.cancel();
return; var obj = {
} 'walletId': walletId,
self.selectedWalletId = walletId; 'walletName': walletName,
self.selectedWalletName = walletName; 'client': profileService.getClient(walletId)
self.fc = profileService.getClient(self.selectedWalletId); }
$scope.cancel(); $scope.$emit('walletSelected', obj);
});
}; };
$scope.cancel = function() { $scope.cancel = function() {

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('sellCoinbaseController', angular.module('copayApp.controllers').controller('sellCoinbaseController',
function($rootScope, $scope, $modal, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, bwsError, configService, walletService, fingerprintService, ongoingProcess) { function($rootScope, $scope, $modal, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, bwsError, configService, walletService, fingerprintService, ongoingProcess, go) {
var self = this; var self = this;
var client; var client;
@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1); self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1);
client = profileService.focusedClient; client = profileService.focusedClient;
if (client) { if (client && client.credentials.m == 1) {
$timeout(function() { $timeout(function() {
self.selectedWalletId = client.credentials.walletId; self.selectedWalletId = client.credentials.walletId;
self.selectedWalletName = client.credentials.walletName; self.selectedWalletName = client.credentials.walletName;
@ -79,8 +79,6 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
$scope.openWalletsModal = function(wallets) { $scope.openWalletsModal = function(wallets) {
self.error = null; self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.type = 'SELL'; $scope.type = 'SELL';
$scope.wallets = wallets; $scope.wallets = wallets;
@ -94,6 +92,16 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
$scope.walletsModal = modal; $scope.walletsModal = modal;
$scope.walletsModal.show(); $scope.walletsModal.show();
}); });
$scope.$on('walletSelected', function(ev, obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
client = obj.client;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
}; };
this.depositFunds = function(token, account) { this.depositFunds = function(token, account) {
@ -205,6 +213,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) { $scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) { if (accept) {
self.confirmTx(createdTxp, function(err, tx) { self.confirmTx(createdTxp, function(err, tx) {
ongoingProcess.clear();
if (err) { if (err) {
self.error = { self.error = {
errors: [{ errors: [{
@ -221,14 +230,14 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
} }
lodash.each(ctxs.data, function(ctx) { lodash.each(ctxs.data, function(ctx) {
if (ctx.type == 'send' && ctx.from) { if (ctx.type == 'send' && ctx.from) {
ongoingProcess.clear();
if (ctx.status == 'completed') { if (ctx.status == 'completed') {
self.sellRequest(token, account, ctx); self.sellRequest(token, account, ctx);
} else { } else {
// Save to localstorage // Save to localstorage
ongoingProcess.clear();
ctx['price_sensitivity'] = $scope.selectedPriceSensitivity; ctx['price_sensitivity'] = $scope.selectedPriceSensitivity;
ctx['sell_price_amount'] = self.sellPrice.amount; ctx['sell_price_amount'] = self.sellPrice ? self.sellPrice.amount : '';
ctx['sell_price_currency'] = self.sellPrice.currency; ctx['sell_price_currency'] = self.sellPrice ? self.sellPrice.currency : 'USD';
ctx['description'] = 'Copay Wallet: ' + client.credentials.walletName; ctx['description'] = 'Copay Wallet: ' + client.credentials.walletName;
coinbaseService.savePendingTransaction(ctx, null, function(err) { coinbaseService.savePendingTransaction(ctx, null, function(err) {
if (err) $log.debug(err); if (err) $log.debug(err);
@ -243,6 +252,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
}); });
}); });
}); });
} else {
go.path('coinbase');
} }
}); });
}); });
@ -292,8 +303,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
} }
walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) { walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) {
ongoingProcess.set('Sending Bitcoin to Coinbase...', false);
if (err) { if (err) {
ongoingProcess.set('Sending Bitcoin to Coinbase...', false);
$log.debug(err); $log.debug(err);
walletService.removeTx(client, broadcastedTxp, function(err) { walletService.removeTx(client, broadcastedTxp, function(err) {
if (err) $log.debug(err); if (err) $log.debug(err);

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController', angular.module('copayApp.controllers').controller('sellGlideraController',
function($rootScope, $scope, $timeout, $ionicModal, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, walletService, fingerprintService, ongoingProcess) { function($rootScope, $scope, $timeout, $ionicModal, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, walletService, fingerprintService, ongoingProcess, go) {
var self = this; var self = this;
var config = configService.getSync(); var config = configService.getSync();
@ -20,10 +20,10 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
}; };
this.init = function(testnet) { this.init = function(testnet) {
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1);
client = profileService.focusedClient; client = profileService.focusedClient;
if (client) { if (client && client.credentials.m == 1) {
$timeout(function() { $timeout(function() {
self.selectedWalletId = client.credentials.walletId; self.selectedWalletId = client.credentials.walletId;
self.selectedWalletName = client.credentials.walletName; self.selectedWalletName = client.credentials.walletName;
@ -32,12 +32,10 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
} }
}; };
$scope.openWalletsModal = function(wallets) { $scope.openWalletsModal = function(wallets) {
self.error = null; self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.type = 'SELL'; $scope.type = 'SELL';
$scope.wallets = wallets; $scope.wallets = wallets;
@ -51,6 +49,16 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
$scope.walletsModal = modal; $scope.walletsModal = modal;
$scope.walletsModal.show(); $scope.walletsModal.show();
}); });
$scope.$on('walletSelected', function(ev, obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
client = obj.client;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
}; };
this.getSellPrice = function(token, price) { this.getSellPrice = function(token, price) {
@ -196,6 +204,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
}); });
}); });
}); });
} else {
go.path('glidera');
} }
}); });
}); });

View file

@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$rootScope.$emit('Local/SetTab', 'send'); $rootScope.$emit('Local/SetTab', 'send');
var form = $scope.sendForm; var form = $scope.sendForm;
if (form.address.$invalid && !ongoingProcess.get('fetchingPayPro')) { if (form.address.$invalid && !ongoingProcess.isProcessing) {
self.resetForm(); self.resetForm();
self.error = gettext('Could not recognize a valid Bitcoin QR Code'); self.error = gettext('Could not recognize a valid Bitcoin QR Code');
} }

View file

@ -41,9 +41,9 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
root.getOauthCodeUrl = function() { root.getOauthCodeUrl = function() {
return credentials.HOST return credentials.HOST
+ '/oauth/authorize?response_type=code&client_id=' + '/oauth/authorize?response_type=code&client_id='
+ credentials.CLIENT_ID + credentials.CLIENT_ID
+ '&redirect_uri=' + '&redirect_uri='
+ credentials.REDIRECT_URI + credentials.REDIRECT_URI
+ '&state=SECURE_RANDOM&scope=' + '&state=SECURE_RANDOM&scope='
@ -59,7 +59,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json' 'Accept': 'application/json'
}, },
data: { data: {
grant_type : 'authorization_code', grant_type : 'authorization_code',
code: code, code: code,
client_id : credentials.CLIENT_ID, client_id : credentials.CLIENT_ID,
@ -70,7 +70,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
$http(req).then(function(data) { $http(req).then(function(data) {
$log.info('Coinbase Authorization Access Token: SUCCESS'); $log.info('Coinbase Authorization Access Token: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Authorization Access Token: ERROR ' + data.statusText); $log.error('Coinbase Authorization Access Token: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -85,18 +85,18 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json' 'Accept': 'application/json'
}, },
data: { data: {
grant_type : 'refresh_token', grant_type : 'refresh_token',
client_id : credentials.CLIENT_ID, client_id : credentials.CLIENT_ID,
client_secret: credentials.CLIENT_SECRET, client_secret: credentials.CLIENT_SECRET,
redirect_uri: credentials.REDIRECT_URI, redirect_uri: credentials.REDIRECT_URI,
refresh_token: refreshToken refresh_token: refreshToken
} }
}; };
$http(req).then(function(data) { $http(req).then(function(data) {
$log.info('Coinbase Refresh Access Token: SUCCESS'); $log.info('Coinbase Refresh Access Token: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Refresh Access Token: ERROR ' + data.statusText); $log.error('Coinbase Refresh Access Token: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -195,17 +195,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.sellPrice = function(token, currency, cb) { root.sellPrice = function(token, currency, cb) {
$http(_get('/prices/sell?currency=' + currency, token)).then(function(data) { $http(_get('/prices/sell?currency=' + currency, token)).then(function(data) {
$log.info('Coinbase Sell Price: SUCCESS'); $log.info('Coinbase Sell Price: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Sell Price: ERROR ' + data.statusText); $log.error('Coinbase Sell Price: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
}); });
}; };
root.buyPrice = function(token, currency, cb) { root.buyPrice = function(token, currency, cb) {
$http(_get('/prices/buy?currency=' + currency, token)).then(function(data) { $http(_get('/prices/buy?currency=' + currency, token)).then(function(data) {
$log.info('Coinbase Buy Price: SUCCESS'); $log.info('Coinbase Buy Price: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Buy Price: ERROR ' + data.statusText); $log.error('Coinbase Buy Price: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -215,7 +215,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.getPaymentMethods = function(token, cb) { root.getPaymentMethods = function(token, cb) {
$http(_get('/payment-methods', token)).then(function(data) { $http(_get('/payment-methods', token)).then(function(data) {
$log.info('Coinbase Get Payment Methods: SUCCESS'); $log.info('Coinbase Get Payment Methods: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Get Payment Methods: ERROR ' + data.statusText); $log.error('Coinbase Get Payment Methods: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -225,7 +225,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.getPaymentMethod = function(token, paymentMethodId, cb) { root.getPaymentMethod = function(token, paymentMethodId, cb) {
$http(_get('/payment-methods/' + paymentMethodId, token)).then(function(data) { $http(_get('/payment-methods/' + paymentMethodId, token)).then(function(data) {
$log.info('Coinbase Get Payment Method: SUCCESS'); $log.info('Coinbase Get Payment Method: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Get Payment Method: ERROR ' + data.statusText); $log.error('Coinbase Get Payment Method: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -243,7 +243,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}, },
data: data data: data
}; };
}; };
root.sellRequest = function(token, accountId, data, cb) { root.sellRequest = function(token, accountId, data, cb) {
var data = { var data = {
@ -254,7 +254,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
$http(_post('/accounts/' + accountId + '/sells', token, data)).then(function(data) { $http(_post('/accounts/' + accountId + '/sells', token, data)).then(function(data) {
$log.info('Coinbase Sell Request: SUCCESS'); $log.info('Coinbase Sell Request: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Sell Request: ERROR ' + data.statusText); $log.error('Coinbase Sell Request: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -264,12 +264,12 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.sellCommit = function(token, accountId, sellId, cb) { root.sellCommit = function(token, accountId, sellId, cb) {
$http(_post('/accounts/' + accountId + '/sells/' + sellId + '/commit', token)).then(function(data) { $http(_post('/accounts/' + accountId + '/sells/' + sellId + '/commit', token)).then(function(data) {
$log.info('Coinbase Sell Commit: SUCCESS'); $log.info('Coinbase Sell Commit: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Sell Commit: ERROR ' + data.statusText); $log.error('Coinbase Sell Commit: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
}); });
}; };
root.buyRequest = function(token, accountId, data, cb) { root.buyRequest = function(token, accountId, data, cb) {
var data = { var data = {
@ -280,7 +280,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
$http(_post('/accounts/' + accountId + '/buys', token, data)).then(function(data) { $http(_post('/accounts/' + accountId + '/buys', token, data)).then(function(data) {
$log.info('Coinbase Buy Request: SUCCESS'); $log.info('Coinbase Buy Request: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Buy Request: ERROR ' + data.statusText); $log.error('Coinbase Buy Request: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -290,7 +290,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.buyCommit = function(token, accountId, buyId, cb) { root.buyCommit = function(token, accountId, buyId, cb) {
$http(_post('/accounts/' + accountId + '/buys/' + buyId + '/commit', token)).then(function(data) { $http(_post('/accounts/' + accountId + '/buys/' + buyId + '/commit', token)).then(function(data) {
$log.info('Coinbase Buy Commit: SUCCESS'); $log.info('Coinbase Buy Commit: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Buy Commit: ERROR ' + data.statusText); $log.error('Coinbase Buy Commit: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -303,7 +303,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
$http(_post('/accounts/' + accountId + '/addresses', token, data)).then(function(data) { $http(_post('/accounts/' + accountId + '/addresses', token, data)).then(function(data) {
$log.info('Coinbase Create Address: SUCCESS'); $log.info('Coinbase Create Address: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Create Address: ERROR ' + data.statusText); $log.error('Coinbase Create Address: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -320,7 +320,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
$http(_post('/accounts/' + accountId + '/transactions', token, data)).then(function(data) { $http(_post('/accounts/' + accountId + '/transactions', token, data)).then(function(data) {
$log.info('Coinbase Create Address: SUCCESS'); $log.info('Coinbase Create Address: SUCCESS');
return cb(null, data.data); return cb(null, data.data);
}, function(data) { }, function(data) {
$log.error('Coinbase Create Address: ERROR ' + data.statusText); $log.error('Coinbase Create Address: ERROR ' + data.statusText);
return cb(data.data); return cb(data.data);
@ -328,7 +328,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
// Pending transactions // Pending transactions
root.savePendingTransaction = function(ctx, opts, cb) { root.savePendingTransaction = function(ctx, opts, cb) {
var network = configService.getSync().coinbase.testnet ? 'testnet' : 'livenet'; var network = configService.getSync().coinbase.testnet ? 'testnet' : 'livenet';
storageService.getCoinbaseTxs(network, function(err, oldTxs) { storageService.getCoinbaseTxs(network, function(err, oldTxs) {

View file

@ -30,8 +30,16 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'deletingWallet': gettext('Deleting Wallet...'), 'deletingWallet': gettext('Deleting Wallet...'),
}; };
root.isProcessing = false;
root.clear = function() { root.clear = function() {
ongoingProcess = {}; ongoingProcess = {};
root.isProcessing = false;
if (isCordova) {
window.plugins.spinnerDialog.hide();
} else {
$ionicLoading.hide();
}
}; };
root.get = function(processName) { root.get = function(processName) {
@ -55,16 +63,18 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
var showName = $filter('translate')(processNames[name] || name); var showName = $filter('translate')(processNames[name] || name);
if (root.onGoingProcessName) { if (root.onGoingProcessName) {
root.isProcessing = true;
if (isCordova) { if (isCordova) {
window.plugins.spinnerDialog.show(null, showName, true); window.plugins.spinnerDialog.show(null, showName, true);
} else { } else {
var tmpl = '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>' + showName; var tmpl = '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>' + showName;
$ionicLoading.show({ $ionicLoading.show({
template: tmpl template: tmpl
}); });
} }
} else { } else {
root.isProcessing = false;
if (isCordova) { if (isCordova) {
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
} else { } else {