diff --git a/public/views/backup.html b/public/views/backup.html index a3452e40c..0972e1097 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -19,13 +19,6 @@ -
-
- - Validating recovery phrase... -
-
-
{{wordsC.error|translate}} diff --git a/public/views/buyCoinbase.html b/public/views/buyCoinbase.html index 2c3ea385b..59e3b8fee 100644 --- a/public/views/buyCoinbase.html +++ b/public/views/buyCoinbase.html @@ -7,13 +7,6 @@
-
-
- - {{buy.loading}} -
-
-
diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index 11aa244a8..ca276ccfd 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -7,13 +7,6 @@
-
-
- - {{buy.loading}} -
-
-

Daily buy limit: diff --git a/public/views/coinbase.html b/public/views/coinbase.html index 6e93206f9..293d489bc 100644 --- a/public/views/coinbase.html +++ b/public/views/coinbase.html @@ -25,15 +25,6 @@

- -
-
- - Connecting to Coinbase... - {{index.coinbaseLoading}} -
-
-
    @@ -57,7 +48,7 @@
-
+
Testnet wallets only work with Coinbase Sandbox Accounts diff --git a/public/views/coinbaseUri.html b/public/views/coinbaseUri.html index 995454fff..5752c0873 100644 --- a/public/views/coinbaseUri.html +++ b/public/views/coinbaseUri.html @@ -6,13 +6,6 @@
-
-
- - Connecting to Coinbase... -
-
-
diff --git a/public/views/create.html b/public/views/create.html index 7f656cbab..2b32a5ae1 100644 --- a/public/views/create.html +++ b/public/views/create.html @@ -8,21 +8,6 @@ -
-
- - Creating Wallet... -
-
- -
-
- - Connecting to {{create.hwWallet}} Wallet... - Please accept to export two public keys from the Trezor app -
-
-
@@ -170,11 +155,11 @@
- - diff --git a/public/views/disclaimer.html b/public/views/disclaimer.html index f8e233397..d70ca6323 100644 --- a/public/views/disclaimer.html +++ b/public/views/disclaimer.html @@ -25,14 +25,8 @@
-
-
- - Creating Wallet... -
-
-
diff --git a/public/views/glidera.html b/public/views/glidera.html index 6c4dac255..11a4f7a66 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -8,14 +8,6 @@
-
-
- - Connecting to Glidera... - {{index.glideraLoading}} -
-
-
@@ -42,7 +34,7 @@
-
@@ -164,7 +156,7 @@

Activity

-
No activity in your account
diff --git a/public/views/glideraUri.html b/public/views/glideraUri.html index 0407880cb..82df62a0a 100644 --- a/public/views/glideraUri.html +++ b/public/views/glideraUri.html @@ -6,13 +6,6 @@
-
-
- - Connecting to Glidera... -
-
-
diff --git a/public/views/import.html b/public/views/import.html index 6ab456c69..2fd3a8d04 100644 --- a/public/views/import.html +++ b/public/views/import.html @@ -5,19 +5,6 @@
-
-
- - Importing wallet... -
-
-
-
- - Connecting to {{import.hwWallet}} Wallet... -
-
-
@@ -99,7 +86,7 @@
@@ -157,7 +144,7 @@
@@ -221,8 +208,7 @@
-
diff --git a/public/views/join.html b/public/views/join.html index ef196d60d..edd866517 100644 --- a/public/views/join.html +++ b/public/views/join.html @@ -6,21 +6,6 @@ -
-
- - Joining Wallet... -
-
- -
-
- - Connecting to {{join.hwWallet}} Wallet... - Please accept to export two public keys from the Trezor app -
-
-
@@ -137,7 +122,7 @@
+ ng-disabled="joinForm.$invalid">Join
diff --git a/public/views/paperWallet.html b/public/views/paperWallet.html index 2a3323bf7..c89a06dfe 100644 --- a/public/views/paperWallet.html +++ b/public/views/paperWallet.html @@ -6,13 +6,6 @@

-
-
- - Scanning wallet funds... - Sending funds... -
-
{{paperWallet.error|translate}}
diff --git a/public/views/preferencesDeleteWallet.html b/public/views/preferencesDeleteWallet.html index ddc53b5fd..2f7d06544 100644 --- a/public/views/preferencesDeleteWallet.html +++ b/public/views/preferencesDeleteWallet.html @@ -6,20 +6,13 @@
-
-
- - Deleting Wallet... -
-
-
Warning!
Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED
  • -
    +
    {{index.walletName}} ({{index.alias}})
    Delete wallet
    diff --git a/public/views/preferencesEmail.html b/public/views/preferencesEmail.html index 8356744c5..d2277a762 100644 --- a/public/views/preferencesEmail.html +++ b/public/views/preferencesEmail.html @@ -9,13 +9,6 @@

    -
    -
    - - Saving preferences... -
    -
    -
    diff --git a/public/views/sellCoinbase.html b/public/views/sellCoinbase.html index 5b885d915..916aa8aee 100644 --- a/public/views/sellCoinbase.html +++ b/public/views/sellCoinbase.html @@ -7,13 +7,6 @@
    -
    -
    - - {{sell.loading}} -
    -
    -
    @@ -64,11 +57,11 @@ + ng-model="amount" autocomplete="off"> + ng-model="fiat" autocomplete="off"> BTC @@ -101,7 +94,7 @@
    @@ -131,7 +124,7 @@
    @@ -187,7 +180,7 @@
    diff --git a/public/views/sellGlidera.html b/public/views/sellGlidera.html index 6dbfcd462..e2f62a9e9 100644 --- a/public/views/sellGlidera.html +++ b/public/views/sellGlidera.html @@ -7,13 +7,6 @@
    -
    -
    - - {{sell.loading}} -
    -
    -

    Daily sell limit: @@ -88,7 +81,7 @@ ng-style="{'background-color':index.backgroundColor}" type="submit" value="{{'Continue'}}" ng-disabled="index.glideraLimits.transactDisabledPendingFirstTransaction || !sell.sellPrice.qty || - !sell.selectedWalletId || sell.loading"> + !sell.selectedWalletId ">

    @@ -104,7 +97,7 @@ + type="submit" value="{{'Sell'}}" ng-disabled="sellForm.$invalid ">

    Bitcoins will be immediately sent from your wallet to Glidera. Fiat will be deposited in your bank account in 4-6 business days. diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index d06c85aaa..9dc4dd011 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -1,11 +1,10 @@ 'use strict'; angular.module('copayApp.controllers').controller('backupController', - function($rootScope, $scope, $timeout, $log, lodash, profileService, gettext, bwcService, bwsError, walletService) { + function($rootScope, $scope, $timeout, $log, lodash, profileService, gettext, bwcService, bwsError, walletService, ongoingProcess) { var self = this; var fc = profileService.focusedClient; - self.loading = false; self.customWords = []; self.walletName = fc.credentials.walletName; @@ -59,9 +58,9 @@ angular.module('copayApp.controllers').controller('backupController', finalStep(); function finalStep() { - self.loading = true; + ongoingProcess.set('validatingWords', true); confirm(function(err) { - self.loading = false; + ongoingProcess.set('validatingWords', false); if (err) { backupError(err); } @@ -144,7 +143,6 @@ angular.module('copayApp.controllers').controller('backupController', }; $scope.removeButton = function(index, item) { - if (self.loading) return; self.customWords.splice(index, 1); self.shuffledMnemonicWords[item.prevIndex].selected = false; self.shouldContinue(); @@ -194,7 +192,7 @@ angular.module('copayApp.controllers').controller('backupController', }; function backupError(err) { - self.loading = false; + ongoingProcess.set('validatingWords', false); $log.debug('Failed to verify backup: ', err); self.backupError = true; diff --git a/src/js/controllers/buyCoinbase.js b/src/js/controllers/buyCoinbase.js index bb2a9de8f..48115b4d7 100644 --- a/src/js/controllers/buyCoinbase.js +++ b/src/js/controllers/buyCoinbase.js @@ -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 { diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 207419a04..9a365ee28 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,13 +1,12 @@ 'use strict'; angular.module('copayApp.controllers').controller('buyGlideraController', - function($scope, $timeout, $modal, $ionicModal, profileService, addressService, glideraService, bwsError, lodash) { + function($scope, $timeout, $modal, $ionicModal, profileService, addressService, glideraService, bwsError, lodash, ongoingProcess) { var self = this; this.show2faCodeInput = null; this.error = null; this.success = null; - this.loading = null; this.init = function(testnet) { self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) @@ -62,10 +61,10 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.get2faCode = function(token) { var self = this; self.error = null; - self.loading = 'Sending 2FA code...'; + ongoingProcess.set('Sending 2FA code...', true); $timeout(function() { glideraService.get2faCode(token, function(err, sent) { - self.loading = null; + ongoingProcess.set('Sending 2FA code...', false); if (err) { self.error = 'Could not send confirmation code to your phone'; return; @@ -78,10 +77,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.sendRequest = function(token, permissions, twoFaCode) { var self = this; self.error = null; - self.loading = 'Buying bitcoin...'; + ongoingProcess.set('Buying Bitcoin...', true); $timeout(function() { addressService.getAddress(self.selectedWalletId, false, function(err, walletAddr) { if (err) { + ongoingProcess.set('Buying Bitcoin...', false); self.error = bwsError.cb(err, 'Could not create address'); return; } @@ -93,7 +93,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', ip: null }; glideraService.buy(token, twoFaCode, data, function(err, data) { - self.loading = null; + ongoingProcess.set('Buying Bitcoin...', false); if (err) { self.error = err; return; diff --git a/src/js/controllers/coinbase.js b/src/js/controllers/coinbase.js index 61553b3e9..9d68404b2 100644 --- a/src/js/controllers/coinbase.js +++ b/src/js/controllers/coinbase.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('coinbaseController', - function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, coinbaseService, lodash, platformInfo) { + function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, coinbaseService, lodash, platformInfo, ongoingProcess) { var isNW = platformInfo.isNW; @@ -35,11 +35,11 @@ angular.module('copayApp.controllers').controller('coinbaseController', var self = this; var coinbaseTestnet = configService.getSync().coinbase.testnet; var network = coinbaseTestnet ? 'testnet' : 'livenet'; - this.loading = true; + ongoingProcess.set('connectingCoinbase', true); this.error = null; $timeout(function() { coinbaseService.getToken(code, function(err, data) { - self.loading = null; + ongoingProcess.set('connectingCoinbase', false); if (err) { self.error = err; $timeout(function() { diff --git a/src/js/controllers/coinbaseUri.js b/src/js/controllers/coinbaseUri.js index 2aff6d1fd..f402bce93 100644 --- a/src/js/controllers/coinbaseUri.js +++ b/src/js/controllers/coinbaseUri.js @@ -1,16 +1,16 @@ 'use strict'; angular.module('copayApp.controllers').controller('coinbaseUriController', - function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go) { + function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go, ongoingProcess) { this.submitOauthCode = function(code) { var self = this; var coinbaseTestnet = configService.getSync().coinbase.testnet; var network = coinbaseTestnet ? 'testnet' : 'livenet'; - this.loading = true; + ongoingProcess.set('connectingCoinbase', true); this.error = null; $timeout(function() { coinbaseService.getToken(code, function(err, data) { - self.loading = null; + ongoingProcess.set('connectingCoinbase', false); if (err) { self.error = err; $timeout(function() { diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index c842e5127..8235fb256 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $ionicScrollDelegate, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper) { + function($scope, $ionicScrollDelegate, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) { var isChromeApp = platformInfo.isChromeApp; var isCordova = platformInfo.isCordova; @@ -147,11 +147,12 @@ angular.module('copayApp.controllers').controller('createController', account = account - 1; opts.account = account; - self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor'; + ongoingProcess.set('connecting' + self.seedSourceId, true); + var src = self.seedSourceId == 'ledger' ? ledger : trezor; src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) { - self.hwWallet = false; + ongoingProcess.set('connecting' + self.seedSourceId, false); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -167,11 +168,11 @@ angular.module('copayApp.controllers').controller('createController', }; this._create = function(opts) { - self.loading = true; + ongoingProcess.set('creatingWallet', true); $timeout(function() { profileService.createWallet(opts, function(err) { - self.loading = false; + ongoingProcess.set('creatingWallet', false); if (err) { $log.warn(err); self.error = err; diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index 8fbffcf2c..ee51ceed9 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraController', - function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, glideraService, lodash) { + function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, glideraService, lodash, ongoingProcess) { this.getAuthenticateUrl = function() { return glideraService.getOauthCodeUrl(); @@ -11,11 +11,11 @@ angular.module('copayApp.controllers').controller('glideraController', var self = this; var glideraTestnet = configService.getSync().glidera.testnet; var network = glideraTestnet ? 'testnet' : 'livenet'; - this.loading = true; + ongoingProcess.set('connectingGlidera', true); this.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { - self.loading = null; + ongoingProcess.set('connectingGlidera', false); if (err) { self.error = err; $timeout(function() { diff --git a/src/js/controllers/glideraUri.js b/src/js/controllers/glideraUri.js index d7c27f832..2c1995373 100644 --- a/src/js/controllers/glideraUri.js +++ b/src/js/controllers/glideraUri.js @@ -1,17 +1,17 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraUriController', - function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) { + function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go, ongoingProcess) { this.submitOauthCode = function(code) { $log.debug('Glidera Oauth Code:' + code); var self = this; var glideraTestnet = configService.getSync().glidera.testnet; var network = glideraTestnet ? 'testnet' : 'livenet'; - this.loading = true; + ongoingProcess.set('connectingGlidera', true); this.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { - self.loading = null; + ongoingProcess.set('connectingGlidera', false); if (err) { self.error = err; $timeout(function() { diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index d44b487f1..ca72765f2 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo, bwsError, bwcService) { + function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo, bwsError, bwcService, ongoingProcess) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -60,13 +60,13 @@ angular.module('copayApp.controllers').controller('importController', return; } - self.loading = true; + ongoingProcess.set('importingWallet', true); opts.compressed = null; opts.password = null; $timeout(function() { profileService.importWallet(str2, opts, function(err, walletId) { - self.loading = false; + ongoingProcess.set('importingWallet', false); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -80,11 +80,10 @@ angular.module('copayApp.controllers').controller('importController', }; var _importExtendedPrivateKey = function(xPrivKey, opts) { - self.loading = true; - + ongoingProcess.set('importingWallet', true); $timeout(function() { profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) { - self.loading = false; + ongoingProcess.set('importingWallet', false); if (err) { if (err instanceof errors.NOT_AUTHORIZED) { self.importErr = true; @@ -105,11 +104,11 @@ angular.module('copayApp.controllers').controller('importController', }; var _importMnemonic = function(words, opts) { - self.loading = true; + ongoingProcess.set('importingWallet', true); $timeout(function() { profileService.importMnemonic(words, opts, function(err, walletId) { - self.loading = false; + ongoingProcess.set('importingWallet', false); if (err) { if (err instanceof errors.NOT_AUTHORIZED) { @@ -232,7 +231,7 @@ angular.module('copayApp.controllers').controller('importController', this.importTrezor = function(account, isMultisig) { var self = this; trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) { - self.hwWallet = false; + ongoingProcess.clear(); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -242,11 +241,11 @@ angular.module('copayApp.controllers').controller('importController', lopts.externalSource = 'trezor'; lopts.bwsurl = $scope.bwsurl; - self.loading = true; + ongoingProcess.set('importingWallet', true); $log.debug('Import opts', lopts); profileService.importExtendedPublicKey(lopts, function(err, walletId) { - self.loading = false; + ongoingProcess.set('importingWallet', false); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -287,11 +286,11 @@ angular.module('copayApp.controllers').controller('importController', switch (self.seedSourceId) { case ('ledger'): - self.hwWallet = 'Ledger'; + ongoingProcess.set('connectingledger', true); self.importLedger(account); break; case ('trezor'): - self.hwWallet = 'Trezor'; + ongoingProcess.set('connectingtrezor', true); self.importTrezor(account, isMultisig); break; default: @@ -311,7 +310,7 @@ angular.module('copayApp.controllers').controller('importController', this.importLedger = function(account) { var self = this; ledger.getInfoForNewWallet(true, account, function(err, lopts) { - self.hwWallet = false; + ongoingProcess.clear(); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -321,11 +320,11 @@ angular.module('copayApp.controllers').controller('importController', lopts.externalSource = 'ledger'; lopts.bwsurl = $scope.bwsurl; - self.loading = true; + ongoingProcess.set('importingWallet', true); $log.debug('Import opts', lopts); profileService.importExtendedPublicKey(lopts, function(err, walletId) { - self.loading = false; + ongoingProcess.set('importingWallet', false); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 7604ab3df..f6e05baaa 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -1057,9 +1057,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r getToken(function(err, accessToken) { if (err || !accessToken) return; else { - self.glideraLoading = 'Connecting to Glidera...'; + ongoingProcess.set('connectingGlidera', true); glideraService.getAccessTokenPermissions(accessToken, function(err, p) { - self.glideraLoading = null; + ongoingProcess.set('connectingGlidera', false); if (err) { self.glideraError = err; } else { @@ -1090,24 +1090,24 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); if (permissions.transaction_history) { - self.glideraLoadingHistory = 'Getting Glidera transactions...'; + ongoingProcess.set('Fetching Glidera Transactions', true); glideraService.getTransactions(accessToken, function(err, data) { - self.glideraLoadingHistory = null; + ongoingProcess.set('Fetching Glidera Transactions', false); self.glideraTxs = data; }); } if (permissions.view_email_address && opts.fullUpdate) { - self.glideraLoadingEmail = 'Getting Glidera Email...'; + ongoingProcess.set('connectingGlidera', true); glideraService.getEmail(accessToken, function(err, data) { - self.glideraLoadingEmail = null; + ongoingProcess.set('connectingGlidera', false); self.glideraEmail = data.email; }); } if (permissions.personal_info && opts.fullUpdate) { - self.glideraLoadingPersonalInfo = 'Getting Glidera Personal Information...'; + ongoingProcess.set('connectingGlidera', true); glideraService.getPersonalInfo(accessToken, function(err, data) { - self.glideraLoadingPersonalInfo = null; + ongoingProcess.set('connectingGlidera', false); self.glideraPersonalInfo = data; }); } @@ -1142,9 +1142,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r getToken(function(err, accessToken) { if (err || !accessToken) return; else { - self.coinbaseLoading = 'Getting primary account...'; + ongoingProcess.set('Getting primary account...', true); coinbaseService.getAccounts(accessToken, function(err, a) { - self.coinbaseLoading = null; + ongoingProcess.set('Getting primary account...', false); if (err) { self.coinbaseError = err; if (err.errors[0] && err.errors[0].id == 'expired_token') { diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index f65e80d0a..9e7c56f0a 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $ionicScrollDelegate, go, notification, profileService, configService, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper) { + function($scope, $rootScope, $timeout, $ionicScrollDelegate, go, notification, profileService, configService, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -108,11 +108,11 @@ angular.module('copayApp.controllers').controller('joinController', account = account - 1; opts.account = account; - self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor'; + ongoingProcess.set('connecting' + self.seedSourceId, true); var src = self.seedSourceId == 'ledger' ? ledger : trezor; src.getInfoForNewWallet(true, account, function(err, lopts) { - self.hwWallet = false; + ongoingProcess.set('connecting' + self.seedSourceId, false); if (err) { self.error = err; $ionicScrollDelegate.scrollTop(); @@ -129,11 +129,11 @@ angular.module('copayApp.controllers').controller('joinController', }; this._join = function(opts) { - self.loading = true; + ongoingProcess.set('joiningWallet', true); $timeout(function() { profileService.joinWallet(opts, function(err) { if (err) { - self.loading = false; + ongoingProcess.set('joiningWallet', false); self.error = err; $ionicScrollDelegate.scrollTop(); $rootScope.$apply(); diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js index 1ccaffdeb..e0f7c143f 100644 --- a/src/js/controllers/paperWallet.js +++ b/src/js/controllers/paperWallet.js @@ -1,5 +1,5 @@ angular.module('copayApp.controllers').controller('paperWalletController', - function($scope, $http, $timeout, $log, configService, profileService, go, addressService, txStatus, bitcore) { + function($scope, $http, $timeout, $log, configService, profileService, go, addressService, txStatus, bitcore, ongoingProcess) { var self = this; var fc = profileService.focusedClient; var rawTx; @@ -46,14 +46,14 @@ angular.module('copayApp.controllers').controller('paperWalletController', } self.scanFunds = function() { - self.scanning = true; self.privateKey = ''; self.balanceSat = 0; self.error = ''; + ongoingProcess.set('scanning', true); $timeout(function() { self._scanFunds(function(err, privateKey, balance) { - self.scanning = false; + ongoingProcess.set('scanning', false); if (err) { $log.error(err); self.error = err.message || err.toString(); @@ -88,12 +88,13 @@ angular.module('copayApp.controllers').controller('paperWalletController', }; self.sweepWallet = function() { + ongoingProcess.set('sweepingWallet', true); self.sending = true; self.error = ''; $timeout(function() { self._sweepWallet(function(err, destinationAddress, txid) { - self.sending = false; + ongoingProcess.set('sweepingWallet', false); if (err) { self.error = err.message || err.toString(); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index e6f823580..9f6ab6fa0 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -1,11 +1,10 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', - function($scope, $rootScope, $filter, $timeout, $modal, $log, $ionicModal, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, applicationService) { + function($scope, $rootScope, $filter, $timeout, $modal, $log, $ionicModal, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, applicationService, ongoingProcess) { var isCordova = platformInfo.isCordova; this.isCordova = isCordova; this.error = null; - $scope.isDeletingWallet = false; var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?'); var accept_msg = gettextCatalog.getString('Accept'); @@ -30,14 +29,14 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro }; var doDeleteWallet = function() { - $scope.isDeletingWallet = true; + ongoingProcess.set('deletingWallet', true); var fc = profileService.focusedClient; var name = fc.credentials.walletName; var walletName = (fc.alias || '') + ' [' + name + ']'; var self = this; profileService.deleteWalletClient(fc, function(err) { - $scope.isDeletingWallet = false; + ongoingProcess.set('deletingWallet', false); if (err) { self.error = err.message || err; } else { @@ -50,7 +49,6 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro }; this.deleteWallet = function() { - if ($scope.isDeletingWallet) return; if (isCordova) { navigator.notification.confirm( delete_msg, diff --git a/src/js/controllers/preferencesEmail.js b/src/js/controllers/preferencesEmail.js index 036cb7a74..b41981e13 100644 --- a/src/js/controllers/preferencesEmail.js +++ b/src/js/controllers/preferencesEmail.js @@ -7,17 +7,14 @@ angular.module('copayApp.controllers').controller('preferencesEmailController', this.error = null; var fc = profileService.focusedClient; - this.saving = true; var email = self.email || ''; walletService.updateRemotePreferences(fc, { email: email, }, function(err) { - if (!err) $rootScope.$emit('Local/EmailUpdated', email); - self.saving = false; go.path('preferences'); }); }; diff --git a/src/js/controllers/sellCoinbase.js b/src/js/controllers/sellCoinbase.js index d66a7f359..a9023c620 100644 --- a/src/js/controllers/sellCoinbase.js +++ b/src/js/controllers/sellCoinbase.js @@ -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) { + function($rootScope, $scope, $modal, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, bwsError, configService, walletService, fingerprintService, ongoingProcess) { var self = this; var client; @@ -112,9 +112,9 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', var accountId = account.id; var data = ctx.amount; data['payment_method'] = $scope.selectedPaymentMethod.id || null; - this.loading = 'Sending request...'; + ongoingProcess.set('Sending request...', true); coinbaseService.sellRequest(token, accountId, data, function(err, sell) { - self.loading = null; + ongoingProcess.set('Sending request...', false); if (err) { self.error = err; return; @@ -127,9 +127,9 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', self.error = null; var accountId = account.id; var sellId = sell.id; - this.loading = 'Selling bitcoin...'; + ongoingProcess.set('Selling Bitcoin...', true); coinbaseService.sellCommit(token, accountId, sellId, function(err, data) { - self.loading = null; + ongoingProcess.set('Selling Bitcoin...', false); if (err) { self.error = err; return; @@ -157,12 +157,12 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', var walletSettings = configWallet.settings; - self.loading = 'Creating transaction...'; + ongoingProcess.set('Creating Transaction...', true); $timeout(function() { coinbaseService.createAddress(token, accountId, dataSrc, function(err, data) { if (err) { - self.loading = null; + ongoingProcess.set('Creating Transaction...', false); self.error = err; return; } @@ -192,7 +192,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', walletService.createTx(client, txp, function(err, createdTxp) { if (err) { $log.debug(err); - self.loading = null; + ongoingProcess.set('Creating Transaction...', false); self.error = { errors: [{ message: 'Could not create transaction: ' + err.message @@ -201,8 +201,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', $scope.$apply(); return; } + ongoingProcess.set('Creating Transaction...', false); $scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) { - self.loading = null; if (accept) { self.confirmTx(createdTxp, function(err, tx) { if (err) { @@ -213,7 +213,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', }; return; } - self.loading = 'Checking transaction...'; + ongoingProcess.set('Checking Transaction...', false); coinbaseService.getTransactions(token, accountId, function(err, ctxs) { if (err) { $log.debug(err); @@ -225,7 +225,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', self.sellRequest(token, account, ctx); } else { // Save to localstorage - self.loading = null; + ongoingProcess.clear(); ctx['price_sensitivity'] = $scope.selectedPriceSensitivity; ctx['sell_price_amount'] = self.sellPrice.amount; ctx['sell_price_currency'] = self.sellPrice.currency; @@ -264,10 +264,10 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', return cb(err); } - self.loading = 'Sending bitcoin to Coinbase...'; + ongoingProcess.set('Sending Bitcoin to Coinbase...', true); walletService.publishTx(client, txp, function(err, publishedTxp) { if (err) { - self.loading = null; + ongoingProcess.set('Sending Bitcoin to Coinbase...', false); $log.debug(err); return cb({ errors: [{ @@ -279,7 +279,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', walletService.signTx(client, publishedTxp, function(err, signedTxp) { walletService.lock(client); if (err) { - self.loading = null; + ongoingProcess.set('Sending Bitcoin to Coinbase...', false); $log.debug(err); walletService.removeTx(client, signedTxp, function(err) { if (err) $log.debug(err); @@ -292,8 +292,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', } walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) { + ongoingProcess.set('Sending Bitcoin to Coinbase...', false); if (err) { - self.loading = null; $log.debug(err); walletService.removeTx(client, broadcastedTxp, function(err) { if (err) $log.debug(err); @@ -305,7 +305,6 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', }); } $timeout(function() { - self.loading = null; return cb(null, broadcastedTxp); }, 5000); }); diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index 31afbdb91..8e203a18f 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -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) { + function($rootScope, $scope, $timeout, $ionicModal, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, walletService, fingerprintService, ongoingProcess) { var self = this; var config = configService.getSync(); @@ -9,7 +9,6 @@ angular.module('copayApp.controllers').controller('sellGlideraController', this.show2faCodeInput = null; this.success = null; this.error = null; - this.loading = null; var client; var handleEncryptedWallet = function(client, cb) { @@ -74,10 +73,10 @@ angular.module('copayApp.controllers').controller('sellGlideraController', this.get2faCode = function(token) { var self = this; - self.loading = 'Sending 2FA code...'; + ongoingProcess.set('Sending 2FA code...', true); $timeout(function() { glideraService.get2faCode(token, function(err, sent) { - self.loading = null; + ongoingProcess.set('Sending 2FA code...', false); if (err) { self.error = 'Could not send confirmation code to your phone'; } else { @@ -99,15 +98,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController', return; } + ongoingProcess.set('creatingTx', true); addressService.getAddress(client.credentials.walletId, null, function(err, refundAddress) { if (!refundAddress) { - self.loading = null; + + ongoingProcess.clear(); self.error = bwsError.msg(err, 'Could not create address'); return; } glideraService.getSellAddress(token, function(error, sellAddress) { if (!sellAddress) { - self.loading = null; + ongoingProcess.clear(); self.error = 'Could not get the destination bitcoin address'; return; } @@ -133,9 +134,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController', } }; - self.loading = 'Creating transaction...'; walletService.createTx(client, txp, function(err, createdTxp) { - self.loading = null; + ongoingProcess.clear(); if (err) { self.error = err.message ||  bwsError.msg(err); return; @@ -154,11 +154,10 @@ angular.module('copayApp.controllers').controller('sellGlideraController', return; } - self.loading = 'Signing transaction...'; - + ongoingProcess.set('signingTx', true); walletService.publishTx(client, createdTxp, function(err, publishedTxp) { if (err) { - self.loading = null; + ongoingProcess.clear(); self.error = err.message ||  bwsError.msg(err); } @@ -167,8 +166,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController', walletService.removeTx(client, signedTxp, function(err) { if (err) $log.debug(err); }); + ongoingProcess.clear(); if (err) { - self.loading = null; self.error = err.message ||  bwsError.msg(err); return; } @@ -180,9 +179,9 @@ angular.module('copayApp.controllers').controller('sellGlideraController', useCurrentPrice: self.sellPrice.priceUuid ? false : true, ip: null }; - self.loading = 'Selling bitcoin...'; + ongoingProcess.set('Seling Bitcoin', true); glideraService.sell(token, twoFaCode, data, function(err, data) { - self.loading = null; + ongoingProcess.clear(); if (err) { self.error = err.message ||  bwsError.msg(err); $timeout(function() { diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js new file mode 100644 index 000000000..ce1830b6b --- /dev/null +++ b/src/js/services/onGoingProcess.js @@ -0,0 +1,79 @@ +'use strict'; + +angular.module('copayApp.services').factory('ongoingProcess', function($log, $timeout, lodash, $ionicLoading, gettextCatalog, platformInfo) { + var root = {}; + var isCordova = platformInfo.isCordova; + + var ongoingProcess = {}; + + var processNames = { + 'openingWallet': 'Updating Wallet...', + 'updatingStatus': 'Updating Wallet...', + 'updatingBalance': 'Updating Wallet...', + 'updatingPendingTxps': 'Updating Wallet...', + 'scanning': 'Scanning Wallet funds...', + 'recreating': 'Recreating Wallet...', + 'generatingCSV': 'Generating .csv file...', + 'creatingTx': 'Creating transaction', + 'sendingTx': 'Sending transaction', + 'signingTx': 'Signing transaction', + 'broadcastingTx': 'Broadcasting transaction', + 'fetchingPayPro': 'Fetching Payment Information', + 'calculatingFee': 'Calculating fee', + 'joiningWallet': 'Joining Wallet...', + 'retrivingInputs': 'Retrieving inputs information', + 'creatingWallet': 'Creating Wallet...', + 'validationWallet': 'Validating wallet integrity...', + 'connectingledger': 'Waiting for Ledger...', + 'connectingtrezor': 'Waiting for Trezor...', + 'validatingWords': 'Validating recovery phrase...', + 'connectingCoinbase': 'Connecting to Coinbase...', + 'connectingGlidera': 'Connecting to Glidera...', + 'importingWallet': 'Importing Wallet...', + 'sweepingWallet': 'Sweeping Wallet...', + 'deletingWallet': 'Deleting Wallet...', + }; + + lodash.each(processNames, function(k, v) { + processNames[k] = gettextCatalog.getString(v); + }); + + root.clear = function() { + ongoingProcess = {}; + }; + + root.set = function(processName, isOn) { + + $log.debug('ongoingProcess', processName, isOn); + root[processName] = isOn; + ongoingProcess[processName] = isOn; + + var name; + root.any = lodash.any(ongoingProcess, function(isOn, processName) { + if (isOn) + name = name || processName; + return isOn; + }); + // The first one + root.onGoingProcessName = name; + + var showName = processNames[name] || gettextCatalog.getString(name); + if (root.onGoingProcessName) { + if (isCordova) { + window.plugins.spinnerDialog.show(null, showName, true); + } else { + $ionicLoading.show({ + template: showName, + }); + } + } else { + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } else { + $ionicLoading.hide(); + } + } + }; + + return root; +});