Merge pull request #4433 from cmgustavo/bug/spinner-glidera-coinbase-modals-02

Fix: modal choose wallet. Sell in Coinbase and Glidera. Spinner
This commit is contained in:
Matias Alejo Garcia 2016-06-17 09:26:17 -03:00 committed by GitHub
commit ff74376bc5
11 changed files with 93 additions and 59 deletions

View file

@ -85,14 +85,13 @@
</li>
</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">
<p class="text-center size-12 text-gray">
This action will remove the transaction.
</p>
<button class="button outline round dark-gray expand tiny"
ng-click="remove();"
ng-disabled="loading">
ng-click="remove()">
<i class="fi-x"></i>
Remove
</button>

View file

@ -11,8 +11,11 @@
</h1>
</ion-header-bar>
<ion-content class="m20t" overflow-scroll="true">
<div class="modal-content m20t">
<ion-content overflow-scroll="true">
<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'">
<h4 class="title m0 oh">
<div class="left">
@ -29,12 +32,18 @@
</div>
<ul class="no-bullet">
<li class="line-b" ng-repeat="w in wallets">
<a ng-click="selectWallet(w.id, w.name)" class="db oh">
<a ng-click="selectWallet(w.id)" class="db oh">
<div class="avatar-wallet"
ng-style="{'background-color':w.color}">
<i class="icon-wallet size-21"></i>
</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}}
<span ng-show="w.network=='testnet'">[Testnet]</span>
</div>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,6 +32,11 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
root.clear = function() {
ongoingProcess = {};
if (isCordova) {
window.plugins.spinnerDialog.hide();
} else {
$ionicLoading.hide();
}
};
root.get = function(processName) {
@ -58,7 +63,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
if (isCordova) {
window.plugins.spinnerDialog.show(null, showName, true);
} else {
var tmpl = '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>' + showName;
$ionicLoading.show({
template: tmpl