From 092e8308b022a68f129d913d3fef9d60f514ddbd Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 31 Aug 2016 16:43:52 -0300 Subject: [PATCH] Fix Glidera URI. Uses showAlert service --- public/views/buyGlidera.html | 31 +---- public/views/glidera.html | 114 +++++++----------- public/views/glideraUri.html | 36 +++--- public/views/modals/glidera-tx-details.html | 53 ++++---- public/views/sellGlidera.html | 30 ++--- src/js/controllers/bitpayCard.js | 14 +-- src/js/controllers/buyAmazon.js | 4 +- src/js/controllers/buyGlidera.js | 68 +++-------- src/js/controllers/glidera.js | 21 ++-- src/js/controllers/glideraUri.js | 27 ++--- .../controllers/modals/amazonCardDetails.js | 9 +- src/js/controllers/preferencesGlidera.js | 18 +-- src/js/controllers/sellGlidera.js | 107 ++++++---------- src/js/routes.js | 2 +- src/js/services/incomingData.js | 14 +-- src/sass/main.scss | 8 ++ 16 files changed, 216 insertions(+), 340 deletions(-) diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index a447eff9b..78621413b 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -10,12 +10,11 @@ -
- +
Testnet wallets only work with Glidera Sandbox Accounts
-
+
Daily buy limit: {{limits.dailyBuy|currency:'':2}} {{limits.currency}} (remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}}) @@ -23,7 +22,7 @@ Monthly buy limit: {{limits.monthlyBuy|currency:'':2}} {{limits.currency}} (remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}}) -
+
@@ -37,21 +36,6 @@ ng-submit="buy.get2faCode(token)" novalidate>
- - - - + +
@@ -99,7 +85,7 @@ @@ -128,11 +114,6 @@

-
- - {{buy.error}} - -

Purchase initiated

diff --git a/public/views/glidera.html b/public/views/glidera.html index b626ad29d..b086db3ea 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -10,38 +10,14 @@ -

- +
Testnet wallets only work with Glidera Sandbox Accounts
-
-
- {{error}} -
-
-
- -
- - -
-
-
+
-
+
@@ -70,9 +46,6 @@
-
- {{error}} -
-
- +
+
@@ -133,54 +107,56 @@ -
-

Activity

+
+
+ Activity +
+ class="item"> No activity in your account
-
diff --git a/public/views/glideraUri.html b/public/views/glideraUri.html index 82df62a0a..626118f94 100644 --- a/public/views/glideraUri.html +++ b/public/views/glideraUri.html @@ -1,22 +1,24 @@ -
-
+ + + + + + Glidera + -
+ -
-
-
- -
+
+ Testnet wallets only work with Glidera Sandbox Accounts +
-
-
{{glidera.error}}
- +
+ +
+ Connecting...
-
-
+ + diff --git a/public/views/modals/glidera-tx-details.html b/public/views/modals/glidera-tx-details.html index 8696edc71..bc19dc485 100644 --- a/public/views/modals/glidera-tx-details.html +++ b/public/views/modals/glidera-tx-details.html @@ -1,5 +1,5 @@ - + @@ -122,11 +115,6 @@

-
- - {{sell.error}} - -

Sale initiated

diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index 443f3fff1..d04118af0 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -83,7 +83,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.transactionHistory(dateRange, function(err, history) { $scope.loadingHistory = false; if (err) { - popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Getting transactions')); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions')); return; } @@ -120,7 +120,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { $log.info('No signing proposal: No private key'); - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY')); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY')); return; } @@ -140,7 +140,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.topUp(dataSrc, function(err, invoiceId) { if (err) { ongoingProcess.set('Processing Transaction...', false); - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err)); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } @@ -169,12 +169,12 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi walletService.createTx(wallet, txp, function(err, createdTxp) { if (err) { - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err)); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } walletService.publishAndSign(wallet, createdTxp, function(err, tx) { if (err) { - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err)); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } self.update(); @@ -203,7 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.authenticate(data, function(err, auth) { self.authenticating = false; if (err && err.data && err.data.error && !err.data.error.twoFactorPending) { - popupService.showAler(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error'); + popupService.showAlert(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error'); return; } @@ -224,7 +224,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.authenticate2FA(data, function(err, auth) { self.authenticating = false; if (err) { - popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error')); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error')); return; } diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js index c441f8159..61409d6ef 100644 --- a/src/js/controllers/buyAmazon.js +++ b/src/js/controllers/buyAmazon.js @@ -39,7 +39,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { $log.info('No signing proposal: No private key'); - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY')); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY')); return; } @@ -59,7 +59,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) { if (err) { ongoingProcess.set('Processing Transaction...', false); - popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err)); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 0c92b3adc..9da07038c 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,19 +1,26 @@ 'use strict'; angular.module('copayApp.controllers').controller('buyGlideraController', - function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) { + function($scope, $timeout, $log, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess, popupService, gettextCatalog) { var wallet; var self = this; this.show2faCodeInput = null; - this.error = null; this.success = null; + $scope.$on('Wallet/Changed', function(event, w) { + if (lodash.isEmpty(w)) { + $log.debug('No wallet provided'); + return; + } + wallet = w; + $log.debug('Wallet changed: ' + w.name); + }); + $scope.init = function(accessToken) { $scope.network = glideraService.getEnvironment(); $scope.token = accessToken; - $scope.error = null; $scope.permissions = null; $scope.email = null; $scope.personalInfo = null; @@ -25,7 +32,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', glideraService.init($scope.token, function(err, glidera) { ongoingProcess.set('connectingGlidera'); if (err || !glidera) { - $scope.error = err; + if (err) popupService.showAlert(gettextCatalog.getString('Error'), err); return; } $scope.token = glidera.token; @@ -33,21 +40,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController', $scope.update({fullUpdate: true}); }); - self.allWallets = profileService.getWallets({ + $scope.wallets = profileService.getWallets({ network: $scope.network, n: 1, onlyComplete: true }); - if (lodash.isEmpty(self.allWallets)) return; - - wallet = self.allWallets[0]; - if (wallet) { - $timeout(function() { - self.selectedWalletId = wallet.credentials.walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - } }; $scope.update = function(opts) { @@ -84,33 +81,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController', } }; - $scope.openWalletsModal = function(wallets) { - self.error = null; - - $scope.type = 'BUY'; - $scope.wallets = wallets; - $scope.noColor = true; - $scope.self = self; - - $ionicModal.fromTemplateUrl('views/modals/wallets.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function(modal) { - $scope.walletsModal = modal; - $scope.walletsModal.show(); - }); - - $scope.$on('walletSelected', function(ev, walletId) { - $timeout(function() { - wallet = profileService.getClient(walletId); - self.selectedWalletId = walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - $scope.walletsModal.hide(); - }); - }; - this.getBuyPrice = function(token, price) { var self = this; this.error = null; @@ -122,7 +92,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', glideraService.buyPrice(token, price, function(err, buyPrice) { self.gettingBuyPrice = false; if (err) { - self.error = 'Could not get exchange information. Please, try again.'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again')); return; } self.buyPrice = buyPrice; @@ -131,13 +101,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.get2faCode = function(token) { var self = this; - self.error = null; ongoingProcess.set('Sending 2FA code...', true); $timeout(function() { glideraService.get2faCode(token, function(err, sent) { ongoingProcess.set('Sending 2FA code...', false); if (err) { - self.error = 'Could not send confirmation code to your phone'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone')); return; } self.show2faCodeInput = sent; @@ -147,13 +116,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.sendRequest = function(token, permissions, twoFaCode) { var self = this; - self.error = null; ongoingProcess.set('Buying Bitcoin...', true); $timeout(function() { walletService.getAddress(wallet, false, function(err, walletAddr) { if (err) { ongoingProcess.set('Buying Bitcoin...', false); - self.error = bwcError.cb(err, 'Could not create address'); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address')); return; } var data = { @@ -166,11 +134,13 @@ angular.module('copayApp.controllers').controller('buyGlideraController', glideraService.buy(token, twoFaCode, data, function(err, data) { ongoingProcess.set('Buying Bitcoin...', false); if (err) { - self.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } self.success = data; - $scope.$emit('Local/GlideraTx'); + $timeout(function() { + $scope.$digest(); + }); }); }); }, 100); diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index db9fb51a9..8eaac6558 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -1,11 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraController', - function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) { - - if (platformInfo.isCordova && StatusBar.isVisible) { - StatusBar.backgroundColorByHexString("#4B6178"); - } + function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, nodeWebkit, popupService, gettextCatalog) { $scope.openExternalLink = function(url, target) { if (platformInfo.isNW) { @@ -20,7 +16,6 @@ angular.module('copayApp.controllers').controller('glideraController', $scope.network = glideraService.getEnvironment(); $scope.token = null; - $scope.error = null; $scope.permissions = null; $scope.email = null; $scope.personalInfo = null; @@ -32,7 +27,7 @@ angular.module('copayApp.controllers').controller('glideraController', glideraService.init($scope.token, function(err, glidera) { ongoingProcess.set('connectingGlidera'); if (err || !glidera) { - $scope.error = err; + if (err) popupService.showAlert(gettextCatalog.getString('Error'), err); return; } $scope.token = glidera.token; @@ -81,15 +76,11 @@ angular.module('copayApp.controllers').controller('glideraController', this.submitOauthCode = function(code) { ongoingProcess.set('connectingGlidera', true); - $scope.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { ongoingProcess.set('connectingGlidera', false); if (err) { - $scope.error = err; - $timeout(function() { - $scope.$apply(); - }, 100); + popupService.showAlert(gettextCatalog.getString('Error'), err); } else if (data && data.access_token) { storageService.setGlideraToken($scope.network, data.access_token, function() { $scope.init(data.access_token); @@ -108,7 +99,11 @@ angular.module('copayApp.controllers').controller('glideraController', $scope.self = self; $scope.tx = tx; - glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) { + glideraService.getTransaction(token, tx.transactionUuid, function(err, tx) { + if (err) { + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions')); + return; + } $scope.tx = tx; }); diff --git a/src/js/controllers/glideraUri.js b/src/js/controllers/glideraUri.js index b7dfde22b..7d10d9562 100644 --- a/src/js/controllers/glideraUri.js +++ b/src/js/controllers/glideraUri.js @@ -1,41 +1,34 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraUriController', - function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) { + function($scope, $log, $stateParams, $timeout, glideraService, storageService, $state, ongoingProcess, popupService, gettextCatalog) { - this.submitOauthCode = function(code) { + var submitOauthCode = function(code) { $log.debug('Glidera Oauth Code:' + code); - var self = this; - var glideraTestnet = configService.getSync().glidera.testnet; - var network = glideraTestnet ? 'testnet' : 'livenet'; + $scope.network = glideraService.getEnvironment(); ongoingProcess.set('connectingGlidera', true); - this.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { ongoingProcess.set('connectingGlidera', false); if (err) { - self.error = err; - $timeout(function() { - $scope.$apply(); - }, 100); + popupService.showAlert(gettextCatalog.getString('Error'), err); } else if (data && data.access_token) { - storageService.setGlideraToken(network, data.access_token, function() { - $scope.$emit('Local/GlideraUpdated', data.access_token); + storageService.setGlideraToken($scope.network, data.access_token, function() { $timeout(function() { - $state.go('glidera'); + $state.go('glidera.main'); $scope.$apply(); - }, 100); + }, 500); }); } }); }, 100); }; - this.checkCode = function() { + $scope.checkCode = function() { if ($stateParams.url) { var match = $stateParams.url.match(/code=(.+)/); if (match && match[1]) { - this.code = match[1]; - return this.submitOauthCode(this.code); + submitOauthCode(match[1]); + return; } } $log.error('Bad state: ' + JSON.stringify($stateParams)); diff --git a/src/js/controllers/modals/amazonCardDetails.js b/src/js/controllers/modals/amazonCardDetails.js index 432d32a0d..9cadccb10 100644 --- a/src/js/controllers/modals/amazonCardDetails.js +++ b/src/js/controllers/modals/amazonCardDetails.js @@ -1,13 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess) { +angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog) { $scope.cancelGiftCard = function() { ongoingProcess.set('Canceling gift card...', true); amazonService.cancelGiftCard($scope.card, function(err, data) { ongoingProcess.set('Canceling gift card...', false); if (err) { - $scope.error = bwcError.msg(err); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } $scope.card.cardStatus = data.cardStatus; @@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController', $scope.refreshGiftCard = function() { amazonService.getPendingGiftCards(function(err, gcds) { if (err) { - self.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } lodash.forEach(gcds, function(dataFromStorage) { @@ -37,8 +37,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController', $log.debug("creating gift card"); amazonService.createGiftCard(dataFromStorage, function(err, giftCard) { if (err) { - self.error = bwcError.msg(err); - $log.debug(bwcError.msg(err)); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); return; } if (!lodash.isEmpty(giftCard)) { diff --git a/src/js/controllers/preferencesGlidera.js b/src/js/controllers/preferencesGlidera.js index e47c24c3b..ca372a67d 100644 --- a/src/js/controllers/preferencesGlidera.js +++ b/src/js/controllers/preferencesGlidera.js @@ -1,13 +1,12 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesGlideraController', - function($scope, $log, $ionicModal, ongoingProcess, glideraService) { + function($scope, $log, $timeout, $state, ongoingProcess, glideraService, popupService, gettextCatalog) { $scope.init = function(accessToken) { $scope.network = glideraService.getEnvironment(); $scope.token = accessToken; - $scope.error = null; $scope.permissions = null; $scope.email = null; $scope.personalInfo = null; @@ -19,7 +18,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController' glideraService.init($scope.token, function(err, glidera) { ongoingProcess.set('connectingGlidera'); if (err || !glidera) { - $scope.error = err; + if (err) popupService.showAlert(gettextCatalog.getString('Error'), err); return; } $scope.token = glidera.token; @@ -63,11 +62,14 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController' }; $scope.revokeToken = function() { - $ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', { - scope: $scope - }).then(function(modal) { - $scope.glideraConfirmationModal = modal; - $scope.glideraConfirmationModal.show(); + popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', function(res) { + if (res) { + glideraService.removeToken(function() { + $timeout(function() { + $state.go('glidera.main'); + }, 100); + }); + } }); }; diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index e50757128..644b27687 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -1,28 +1,27 @@ 'use strict'; angular.module('copayApp.controllers').controller('sellGlideraController', - function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) { + function($scope, $timeout, $log, profileService, glideraService, bwcError, lodash, walletService, configService, ongoingProcess, popupService, gettextCatalog) { var self = this; this.data = {}; this.show2faCodeInput = null; this.success = null; - this.error = null; var wallet; - var handleEncryptedWallet = function(wallet, cb) { - if (!walletService.isEncrypted(wallet)) return cb(); - $rootScope.$emit('Local/NeedsPassword', false, function(err, password) { - if (err) return cb(err); - return cb(walletService.unlock(wallet, password)); - }); - }; + $scope.$on('Wallet/Changed', function(event, w) { + if (lodash.isEmpty(w)) { + $log.debug('No wallet provided'); + return; + } + wallet = w; + $log.debug('Wallet changed: ' + w.name); + }); $scope.init = function(accessToken) { $scope.network = glideraService.getEnvironment(); $scope.token = accessToken; - $scope.error = null; $scope.permissions = null; $scope.email = null; $scope.personalInfo = null; @@ -34,7 +33,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', glideraService.init($scope.token, function(err, glidera) { ongoingProcess.set('connectingGlidera'); if (err || !glidera) { - $scope.error = err; + if (err) popupService.showAlert(gettextCatalog.getString('Error'), err); return; } $scope.token = glidera.token; @@ -42,21 +41,11 @@ angular.module('copayApp.controllers').controller('sellGlideraController', $scope.update({fullUpdate: true}); }); - self.allWallets = profileService.getWallets({ + $scope.wallets = profileService.getWallets({ network: $scope.network, n: 1, onlyComplete: true }); - if (lodash.isEmpty(self.allWallets)) return; - - wallet = self.allWallets[0]; - if (wallet) { - $timeout(function() { - self.selectedWalletId = wallet.credentials.walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - } }; $scope.update = function(opts) { @@ -93,36 +82,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController', } }; - $scope.openWalletsModal = function(wallets) { - self.error = null; - - $scope.type = 'SELL'; - $scope.wallets = wallets; - $scope.noColor = true; - $scope.self = self; - - $ionicModal.fromTemplateUrl('views/modals/wallets.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function(modal) { - $scope.walletsModal = modal; - $scope.walletsModal.show(); - }); - - $scope.$on('walletSelected', function(ev, walletId) { - $timeout(function() { - wallet = profileService.getClient(walletId); - self.selectedWalletId = walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - $scope.walletsModal.hide(); - }); - }; - this.getSellPrice = function(token, price) { var self = this; - self.error = null; if (!price || (price && !price.qty && !price.fiat)) { self.sellPrice = null; return; @@ -131,7 +92,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', glideraService.sellPrice(token, price, function(err, sellPrice) { self.gettingSellPrice = false; if (err) { - self.error = 'Could not get exchange information. Please, try again.'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again')); return; } self.sellPrice = sellPrice; @@ -145,7 +106,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', glideraService.get2faCode(token, function(err, sent) { ongoingProcess.set('Sending 2FA code...', false); if (err) { - self.error = 'Could not send confirmation code to your phone'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone')); } else { self.show2faCodeInput = sent; } @@ -155,29 +116,27 @@ angular.module('copayApp.controllers').controller('sellGlideraController', this.createTx = function(token, permissions, twoFaCode) { var self = this; - self.error = null; var outputs = []; var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; if (!wallet) { - self.error = 'No wallet selected'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('No wallet selected')); return; } ongoingProcess.set('creatingTx', true); walletService.getAddress(wallet, null, function(err, refundAddress) { if (!refundAddress) { - ongoingProcess.clear(); - self.error = bwcError.msg(err, 'Could not create address'); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address')); return; } - glideraService.getSellAddress(token, function(error, sellAddress) { - if (!sellAddress) { + glideraService.getSellAddress(token, function(err, sellAddress) { + if (!sellAddress || err) { ongoingProcess.clear(); - self.error = 'Could not get the destination bitcoin address'; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address')); return; } var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0)); @@ -205,28 +164,30 @@ angular.module('copayApp.controllers').controller('sellGlideraController', walletService.createTx(wallet, txp, function(err, createdTxp) { ongoingProcess.clear(); if (err) { - self.error = err.message ||  bwcError.msg(err); + popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err)); return; } - walletService.prepare(wallet, txp, function(err, password) { + walletService.prepare(wallet, function(err, password) { if (err) { - self.error = err.message ||  bwcError.msg(err); + ongoingProcess.clear(); + popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err)); return; } ongoingProcess.set('signingTx', true); walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) { if (err) { ongoingProcess.clear(); - self.error = err.message ||  bwcError.msg(err); + popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err)); + return; } - walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) { - walletService.removeTx(wallet, signedTxp, function(err) { - if (err) $log.debug(err); - }); - ongoingProcess.clear(); + walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) { if (err) { - self.error = err.message ||  bwcError.msg(err); + ongoingProcess.clear(); + popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err)); + walletService.removeTx(wallet, signedTxp, function(err) { + if (err) $log.debug(err); + }); return; } var rawTx = signedTxp.raw; @@ -237,15 +198,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController', useCurrentPrice: self.sellPrice.priceUuid ? false : true, ip: null }; - ongoingProcess.set('Seling Bitcoin', true); + ongoingProcess.set('Selling Bitcoin', true); glideraService.sell(token, twoFaCode, data, function(err, data) { ongoingProcess.clear(); if (err) { - self.error = err.message ||  bwcError.msg(err); + popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err)); return; } self.success = data; - $scope.update(); + $timeout(function() { + $scope.$digest(); + }); }); }); }); diff --git a/src/js/routes.js b/src/js/routes.js index c12c61be6..5d2f931c1 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -824,7 +824,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }); $ionicPlatform.on('resume', function() { - $rootScope.$emit('Local/Resume'); + // Nothing tot do }); $ionicPlatform.on('menubutton', function() { diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 6daa50306..388d652ca 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, bitcore) { - + var root = {}; root.redir = function(data) { @@ -32,7 +32,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni data = sanitizeUri(data); - // BIP21 + // BIP21 if (bitcore.URI.isValid(data)) { var parsed = new bitcore.URI(data); @@ -52,7 +52,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni } return true; - // Plain URL + // Plain URL } else if (/^https?:\/\//.test(data)) { return $state.go('send.confirm', {paypro: data}) @@ -64,10 +64,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // copay: protocol - } else if (data.indexOf('copay:glidera')==0) { - return $state.go('send.uriglidera', {url: data}) - } else if (data.indexOf('copay:coinbase')==0) { - return $state.go('send.uricoinbase', {url: data}) + } else if (data.indexOf('copay://glidera')==0) { + return $state.go('uriglidera', {url: data}) + } else if (data.indexOf('copay://coinbase')==0) { + return $state.go('uricoinbase', {url: data}) // Join } else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) { diff --git a/src/sass/main.scss b/src/sass/main.scss index 0c45813f6..36812dedd 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -882,6 +882,14 @@ input[type=file] { text-align: left; } +.right { + float: right; +} + +.left { + float: left; +} + .input-label { max-width: none; width: inherit;