Coinbase connection issues and logout from tab-setting
This commit is contained in:
parent
1533428fb0
commit
539583a2af
9 changed files with 130 additions and 127 deletions
|
|
@ -1,20 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('coinbaseConfirmationController', function($scope, $timeout, coinbaseService, applicationService) {
|
|
||||||
|
|
||||||
$scope.ok = function() {
|
|
||||||
|
|
||||||
coinbaseService.logout($scope.network, function() {
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
applicationService.restart();
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
$scope.cancel();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.cancel = function() {
|
|
||||||
$scope.coinbaseConfirmationModal.hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -1,18 +1,42 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesCoinbaseController',
|
angular.module('copayApp.controllers').controller('preferencesCoinbaseController', function($scope, $timeout, $state, $ionicHistory, lodash, ongoingProcess, popupService, coinbaseService) {
|
||||||
function($scope, $timeout, $ionicModal, applicationService, coinbaseService) {
|
|
||||||
|
|
||||||
this.revokeToken = function(testnet) {
|
$scope.revokeToken = function() {
|
||||||
$scope.network = testnet ? 'testnet' : 'livenet';
|
popupService.showConfirm('Coinbase', 'Are you sure you would like to log out of your Coinbase account?', null, null, function(res) {
|
||||||
|
if (res) {
|
||||||
|
coinbaseService.logout(function() {
|
||||||
|
$ionicHistory.clearHistory();
|
||||||
|
$timeout(function() {
|
||||||
|
$state.go('tabs.home');
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$ionicModal.fromTemplateUrl('views/modals/coinbase-confirmation.html', {
|
$scope.$on("$ionicView.enter", function(event, data){
|
||||||
scope: $scope,
|
coinbaseService.setCredentials();
|
||||||
animation: 'slide-in-up'
|
$scope.network = coinbaseService.getEnvironment();
|
||||||
}).then(function(modal) {
|
ongoingProcess.set('connectingCoinbase', true);
|
||||||
$scope.coinbaseConfirmationModal = modal;
|
coinbaseService.init($scope.accessToken, function(err, data) {
|
||||||
$scope.coinbaseConfirmationModal.show();
|
ongoingProcess.set('connectingCoinbase', false);
|
||||||
|
if (err || lodash.isEmpty(data)) {
|
||||||
|
ongoingProcess.set('connectingCoinbase', false);
|
||||||
|
if (err) {
|
||||||
|
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var accessToken = data.accessToken;
|
||||||
|
var accountId = data.accountId;
|
||||||
|
coinbaseService.getAccount(accessToken, accountId, function(err, account) {
|
||||||
|
$scope.coinbaseAccount = account.data;
|
||||||
});
|
});
|
||||||
};
|
coinbaseService.getCurrentUser(accessToken, function(err, user) {
|
||||||
|
$scope.coinbaseUser = user.data;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, gettextCatalog) {
|
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $window, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, coinbaseService, gettextCatalog) {
|
||||||
|
|
||||||
var updateConfig = function() {
|
var updateConfig = function() {
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
|
|
@ -26,6 +26,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
||||||
|
|
||||||
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
|
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
|
||||||
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
|
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
|
||||||
|
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
|
||||||
|
|
||||||
if ($scope.bitpayCardEnabled) {
|
if ($scope.bitpayCardEnabled) {
|
||||||
bitpayCardService.getBitpayDebitCards(function(err, cards) {
|
bitpayCardService.getBitpayDebitCards(function(err, cards) {
|
||||||
|
|
@ -41,6 +42,14 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($scope.coinbaseEnabled) {
|
||||||
|
coinbaseService.setCredentials();
|
||||||
|
storageService.getCoinbaseToken(coinbaseService.getEnvironment(), function(err, token) {
|
||||||
|
if (err) $log.error(err);
|
||||||
|
$scope.coinbaseToken = token;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -926,24 +926,25 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.state('tabs.buyandsell.coinbase', {
|
.state('tabs.buyandsell.coinbase', {
|
||||||
url: '/coinbase',
|
url: '/coinbase',
|
||||||
views: {
|
views: {
|
||||||
'tab-home@tabs': {
|
|
||||||
controller: 'coinbaseController',
|
|
||||||
controllerAs: 'coinbase',
|
|
||||||
templateUrl: 'views/coinbase.html'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.state('tabs.buyandsell.coinbase.preferences', {
|
|
||||||
url: '/preferences',
|
|
||||||
'tab-home@tabs': {
|
'tab-home@tabs': {
|
||||||
controller: 'preferencesCoinbaseController',
|
controller: 'coinbaseController',
|
||||||
controllerAs: 'coinbase',
|
controllerAs: 'coinbase',
|
||||||
|
templateUrl: 'views/coinbase.html'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.state('tabs.preferences.coinbase', {
|
||||||
|
url: '/coinbase',
|
||||||
|
views: {
|
||||||
|
'tab-settings@tabs': {
|
||||||
|
controller: 'preferencesCoinbaseController',
|
||||||
templateUrl: 'views/preferencesCoinbase.html'
|
templateUrl: 'views/preferencesCoinbase.html'
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
.state('tabs.buyandsell.coinbase.buy', {
|
.state('tabs.buyandsell.coinbase.buy', {
|
||||||
url: '/buy',
|
url: '/buy',
|
||||||
'tab-home@tabs': {
|
'tab-home@tabs': {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,10 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
_refreshToken(refreshToken, function(err, newToken) {
|
_refreshToken(refreshToken, function(err, newToken) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
return cb(null, {accessToken: newToken, accountId: accountId});
|
_getMainAccountId(newToken, function(err, accountId) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
return cb(null, {accessToken: newToken, accountId: accountId});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,6 @@
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
<ion-nav-title>Coinbase</ion-nav-title>
|
<ion-nav-title>Coinbase</ion-nav-title>
|
||||||
<ion-nav-buttons side="secondary">
|
|
||||||
<button ng-show="accountId" class="button no-border" ui-sref="tabs.buyandsell.coinbase.preferences">
|
|
||||||
<i class="icon ion-ios-settings"></i>
|
|
||||||
</button>
|
|
||||||
</ion-nav-buttons>
|
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<ion-modal-view ng-controller="coinbaseConfirmationController">
|
|
||||||
<div class="m20tp text-center">
|
|
||||||
<div class="row">
|
|
||||||
<h1 class="text-center m20b p20h">Are you sure you would like to log out of your Coinbase account?</h1>
|
|
||||||
<p class="text-gray p20h">You will need to log back in to buy or sell bitcoin in Copay.</p>
|
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
|
||||||
<button class="button light-gray expand outline round" ng-click="cancel()">
|
|
||||||
<i class="fi-arrow-left"></i> <span class="tu">Back</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
|
||||||
<button class="button warning expand round" ng-click="ok()">
|
|
||||||
<span>Log out</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ion-modal-view>
|
|
||||||
|
|
@ -1,60 +1,62 @@
|
||||||
<div
|
<ion-view>
|
||||||
class="topbar-container"
|
<ion-nav-bar class="bar-royal">
|
||||||
ng-include="'views/includes/topbar.html'"
|
<ion-nav-back-button>
|
||||||
ng-init="titleSection='Preferences'; goBackToState = 'coinbase'; noColor = true">
|
</ion-nav-back-button>
|
||||||
</div>
|
<ion-nav-title>Preferences</ion-nav-title>
|
||||||
|
</ion-nav-bar>
|
||||||
|
|
||||||
<div class="content coinbase-preferences" ng-controller="preferencesCoinbaseController as coinbase">
|
<ion-content>
|
||||||
|
|
||||||
<ul ng-if="index.coinbaseAccount && !index.coinbaseError" class="no-bullet m0">
|
<ul ng-if="coinbaseAccount && !error" class="list">
|
||||||
<h4 class="title m0">Account</h4>
|
<div class="item item-divider">
|
||||||
<li>
|
Account
|
||||||
<span>ID</span>
|
</div>
|
||||||
<span class="right text-gray enable_text_select">
|
<li class="item">
|
||||||
{{index.coinbaseAccount.id}}
|
<span>ID</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseAccount.id}}
|
||||||
<li>
|
</span>
|
||||||
<span>Name</span>
|
</li>
|
||||||
<span class="right text-gray">
|
<li class="item">
|
||||||
{{index.coinbaseAccount.name}}
|
<span>Name</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseAccount.name}}
|
||||||
<li>
|
</span>
|
||||||
<span>Balance</span>
|
</li>
|
||||||
<span class="right text-gray">
|
<li class="item">
|
||||||
{{index.coinbaseAccount.balance.amount}} {{index.coinbaseAccount.balance.currency}}
|
<span>Balance</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseAccount.balance.amount}} {{coinbaseAccount.balance.currency}}
|
||||||
<li>
|
</span>
|
||||||
<span>Native Balance</span>
|
</li>
|
||||||
<span class="right text-gray">
|
<li class="item">
|
||||||
{{index.coinbaseAccount.native_balance.amount}} {{index.coinbaseAccount.native_balance.currency}}
|
<span>Native Balance</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseAccount.native_balance.amount}} {{coinbaseAccount.native_balance.currency}}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
<h4 class="title m0">User Information</h4>
|
<div class="item item-divider">
|
||||||
<li>
|
User Information
|
||||||
<span>ID</span>
|
</div>
|
||||||
<span class="right text-gray enable_text_select">
|
<li class="item">
|
||||||
{{index.coinbaseUser.id}}
|
<span>ID</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseUser.id}}
|
||||||
<li>
|
</span>
|
||||||
<span>Email</span>
|
</li>
|
||||||
<span class="right text-gray">
|
<li class="item">
|
||||||
{{index.coinbaseUser.email}}
|
<span>Email</span>
|
||||||
</span>
|
<span class="item-note">
|
||||||
</li>
|
{{coinbaseUser.email}}
|
||||||
</ul>
|
</span>
|
||||||
<ul class="no-bullet m0">
|
</li>
|
||||||
<h4></h4>
|
|
||||||
<li ng-click="coinbase.revokeToken(index.coinbaseTestnet)">
|
|
||||||
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
|
||||||
<span class="text-warning">Log out</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<h4></h4>
|
|
||||||
|
|
||||||
</div>
|
<div class="item item-divider"></div>
|
||||||
<div class="extra-margin-bottom"></div>
|
<li class="item" ng-click="revokeToken()">
|
||||||
|
<span>Log out</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</ion-content>
|
||||||
|
</ion-view>
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,13 @@
|
||||||
<i class="icon bp-arrow-right"></i>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a class="item item-icon-right"
|
||||||
|
ng-if="coinbaseEnabled && coinbaseToken"
|
||||||
|
ui-sref="tabs.preferences.coinbase">
|
||||||
|
<img src="img/coinbase-logo.png" width="90"/>
|
||||||
|
<i class="icon bp-arrow-right"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="item item-divider"></div>
|
<div class="item item-divider"></div>
|
||||||
|
|
||||||
<a class="item item-icon-right item-icon-left" href ui-sref="tabs.advanced">
|
<a class="item item-icon-right item-icon-left" href ui-sref="tabs.advanced">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue