diff --git a/public/views/backup.html b/public/views/backup.html index 0972e1097..d572c9129 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -1,17 +1,17 @@ -
+
-
+
- {{wordsC.error|translate}} + {{error|translate}}
@@ -30,8 +30,8 @@ -->
-
-
+
+
Write your wallet recovery phrase
@@ -56,37 +56,37 @@
-
+
Wallet recovery phrase not available. You can still export it from Advanced > Export.
-
-

+

+

You need the wallet recovery phrase to restore this personal wallet. Write it down and keep them somewhere safe.

-
+ -
+
- {{word}}  + {{word}} 
-
-
+
+
This recovery phrase was created with a password. To recover this wallet both the recovery phrase and password are needed. @@ -96,11 +96,11 @@
@@ -110,19 +110,19 @@ ## STEP 2 --> -
+
Confirm your wallet recovery phrase

Please tap the words in order to confirm your backup phrase is correctly written.

- +
- + @@ -132,10 +132,10 @@
@@ -145,7 +145,7 @@ ## STEP 3 --> -
+
Enter your password

@@ -161,7 +161,7 @@ ng-disabled="!passphrase" ng-style="{'background-color':index.backgroundColor}" class="button round expand m0" - ng-click="wordsC.goToStep(4);" + ng-click="goToStep(4);" translate>Continue

@@ -171,8 +171,8 @@ ## STEP 4 --> -
-
+
+
@@ -185,7 +185,7 @@ @@ -201,7 +201,7 @@
-
+
@@ -222,7 +222,7 @@
diff --git a/public/views/buyCoinbase.html b/public/views/buyCoinbase.html index 59e3b8fee..3f14b6e96 100644 --- a/public/views/buyCoinbase.html +++ b/public/views/buyCoinbase.html @@ -106,7 +106,7 @@

+ href ui-sref="coinbase">OK
@@ -161,8 +161,7 @@ Bitcoin purchase completed. Coinbase has queued the transfer to your selected Copay wallet.

- +
diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index ca276ccfd..6eec1f7af 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -115,10 +115,7 @@ A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business days.

- +
diff --git a/public/views/coinbase.html b/public/views/coinbase.html index 293d489bc..f23c7fc79 100644 --- a/public/views/coinbase.html +++ b/public/views/coinbase.html @@ -11,7 +11,7 @@
- +
@@ -43,7 +43,7 @@ Reconnect
- Or go to Preferences and log out manually. + Or go to Preferences and log out manually.
@@ -102,7 +102,7 @@
  • + href ui-sref="buyCoinbase"> buy bitcoin Buy Bitcoin @@ -110,7 +110,7 @@
  • + href ui-sref="sellCoinbase"> sell bitcoin Sell Bitcoin diff --git a/public/views/export.html b/public/views/export.html index 7e8a818ab..1927e402d 100644 --- a/public/views/export.html +++ b/public/views/export.html @@ -4,17 +4,17 @@ ng-init="titleSection='Export Wallet'; goBackToState = 'preferencesAdvanced'">
-
+

-
-
+
+
Failed to export
-
+
A spending password is set for this wallet. Exporting keeps the spending password in the export archive.
@@ -26,12 +26,12 @@
- +
- +
@@ -68,25 +68,25 @@
- -

Export options

- -
@@ -94,11 +94,11 @@
-
+

Wallet Export

- +
diff --git a/public/views/glidera.html b/public/views/glidera.html index 11a4f7a66..020bbb832 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -28,7 +28,7 @@ Retry
@@ -94,7 +94,7 @@
-
+
Preferences @@ -136,7 +136,7 @@ ng-show="index.glideraStatus && index.glideraStatus.userCanTransact">
  • + href ui-sref="buyGlidera"> buy bitcoin Buy Bitcoin @@ -145,7 +145,7 @@
  • + href ui-sref="sellGlidera"> buy bitcoin Sell Bitcoin diff --git a/public/views/includes/sidebar.html b/public/views/includes/sidebar.html index 4b5675c00..4f7794a0e 100644 --- a/public/views/includes/sidebar.html +++ b/public/views/includes/sidebar.html @@ -7,18 +7,15 @@
      -
    • +
    • diff --git a/public/views/includes/topbar.html b/public/views/includes/topbar.html index c26d18381..371eaaaaa 100644 --- a/public/views/includes/topbar.html +++ b/public/views/includes/topbar.html @@ -4,14 +4,13 @@ - - {{'Back'|translate}} + + Back - {{'Close'|translate}} + Close diff --git a/public/views/paperWallet.html b/public/views/paperWallet.html index c89a06dfe..630f9a066 100644 --- a/public/views/paperWallet.html +++ b/public/views/paperWallet.html @@ -7,7 +7,7 @@

      - {{paperWallet.error|translate}} + {{paperWallet.error|translate}}
      diff --git a/public/views/preferences.html b/public/views/preferences.html index d1eff3ea9..49ac017d6 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -6,13 +6,13 @@
      -
      +

        -
      • +
      • {{index.alias||index.walletName}} @@ -20,7 +20,7 @@
        Alias
      • -
      • +
      • Disabled {{index.preferences.email}} @@ -29,7 +29,7 @@
        Email Notifications
      • -
      • +
      • @@ -39,13 +39,13 @@
      • - {{preferences.externalSource}} + {{externalSource}}
        Hardware wallet
      • -
      • +
      • Not completed @@ -55,7 +55,7 @@
        Backup
      • -
      • +
      • Advanced
      • @@ -71,14 +71,14 @@ Request Spending Password - + Scan Fingerprint
        -
      • +
      • Delete recovery phrase
      • diff --git a/public/views/preferencesAbout.html b/public/views/preferencesAbout.html index bde19af47..b1e845597 100644 --- a/public/views/preferencesAbout.html +++ b/public/views/preferencesAbout.html @@ -1,5 +1,5 @@ -
        @@ -11,30 +11,30 @@
      • Version - v{{v.version}} - + v{{v.version}} +
      • Commit hash #{{v.commitHash}} - +
      - +

        -
      • - +
      • + Terms of Use
      • -
      • - +
      • + Translators
      • -
      • - +
      • + Session log
      diff --git a/public/views/preferencesAdvanced.html b/public/views/preferencesAdvanced.html index 6cb6dfb55..6db820e7e 100644 --- a/public/views/preferencesAdvanced.html +++ b/public/views/preferencesAdvanced.html @@ -1,41 +1,41 @@ -
      -
      +

      - +
        -
      • - +
      • +
        Wallet Information
      • -
      • - +
      • +
        Sweep paper wallet
      • - -
      • - + +
      • +
        Export Wallet
      • - -
      • - + +
      • +
        Wallet Service URL
      • -
      • +
      • Transaction History
      • -
      • +
      • Delete Wallet
      • diff --git a/public/views/preferencesAlias.html b/public/views/preferencesAlias.html index 150fa4d10..1f7e4c02e 100644 --- a/public/views/preferencesAlias.html +++ b/public/views/preferencesAlias.html @@ -4,13 +4,12 @@ ng-init="titleSection='Alias'; goBackToState = 'preferences'">
      -
      - +

      - + - + diff --git a/public/views/preferencesBwsUrl.html b/public/views/preferencesBwsUrl.html index c5dabeb7c..63fb44c72 100644 --- a/public/views/preferencesBwsUrl.html +++ b/public/views/preferencesBwsUrl.html @@ -4,14 +4,12 @@ ng-init="titleSection='Wallet Service URL'; goBackToState = 'preferencesAdvanced';">
      - - -
      +

      -
      + - Set default url - + Set default url +
      diff --git a/public/views/preferencesDeleteWallet.html b/public/views/preferencesDeleteWallet.html index 2f7d06544..302a82ef1 100644 --- a/public/views/preferencesDeleteWallet.html +++ b/public/views/preferencesDeleteWallet.html @@ -4,15 +4,15 @@ ng-init="titleSection='Delete Wallet'; goBackToState = 'preferencesAdvanced'">
      - -
      +
      Warning!
      Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED
      +
        -
      • -
        +
      • +
        {{index.walletName}} ({{index.alias}})
        Delete wallet
        diff --git a/public/views/preferencesDeleteWords.html b/public/views/preferencesDeleteWords.html index 41af7ff8e..c7efc4670 100644 --- a/public/views/preferencesDeleteWords.html +++ b/public/views/preferencesDeleteWords.html @@ -5,19 +5,19 @@
      -
      +
      -
      +
      -
      - {{preferences.error|translate}} +
      + {{error|translate}}
      Warning!
      Once you have copied your wallet recovery phrase down, it is recommended to delete it from this device.
      Need to do backup
        -
      • +
      • {{index.walletName}} ({{index.alias}})
        @@ -26,7 +26,7 @@
      -
      +
      Wallet recovery phrase not available. You can still export it from Advanced > Export.
      diff --git a/public/views/preferencesEmail.html b/public/views/preferencesEmail.html index d2277a762..765586654 100644 --- a/public/views/preferencesEmail.html +++ b/public/views/preferencesEmail.html @@ -4,25 +4,22 @@ ng-init="titleSection='Email Notifications'; goBackToState = 'preferences'">
      - - -
      - +

      -
      -
      + +
      - {{prefEmail.error|translate}} + {{error|translate}}
      - + -
      Setting up email notifications could weaken your privacy, if the wallet service provider is compromised. Information available to an attacker would include your wallet addresses and its balance, but no more. +
      Setting up email notifications could weaken your privacy, if the wallet service provider is compromised. Information available to an attacker would include your wallet addresses and its balance, but no more.
      diff --git a/public/views/preferencesGlobal.html b/public/views/preferencesGlobal.html index 02f346db8..9bc443cf4 100644 --- a/public/views/preferencesGlobal.html +++ b/public/views/preferencesGlobal.html @@ -3,12 +3,12 @@ ng-init="titleSection='Global preferences'; closeToHome = true; noColor = true">
      -
      +

        -
      • +
      • - {{prefGlobal.currentLanguageName|translate}} + {{currentLanguageName|translate}}
        Language
        @@ -17,17 +17,17 @@

          -
        • +
        • - {{prefGlobal.unitName}} + {{unitName}}
          Unit
        • -
        • +
        • - {{prefGlobal.selectedAlternative.name}} + {{selectedAlternative.name}}
          Alternative Currency
          @@ -36,9 +36,9 @@

            -
          • +
          • - {{prefGlobal.feeOpts[prefGlobal.currentFeeLevel]|translate}} + {{feeOpts[currentFeeLevel]|translate}}
            Bitcoin Network Fee Policy
            @@ -49,7 +49,7 @@ Use Unconfirmed Funds -
            +

            Enable push notifications @@ -68,15 +68,15 @@

              -
            • +
            • About Copay
            -
            +
            Push notifications for Copay are currently disabled. Enable them in the Settings app.
            -
              +
              • Open Settings app
            diff --git a/public/views/preferencesHistory.html b/public/views/preferencesHistory.html index 562362f7e..afda46c85 100644 --- a/public/views/preferencesHistory.html +++ b/public/views/preferencesHistory.html @@ -3,25 +3,20 @@ ng-include="'views/includes/topbar.html'" ng-init="titleSection='Transaction History'; goBackToState = 'preferencesAdvanced'">
            -
            +

            -
              -
            • - - Export to file - - - Export to file [preparing...] - +
                +
              • + + Export to file +
              • -
              • +
              • + Export to file [preparing...] +
              • +
              • Clear cache
              diff --git a/public/views/preferencesInformation.html b/public/views/preferencesInformation.html index e8b2683d1..8d568cfbc 100644 --- a/public/views/preferencesInformation.html +++ b/public/views/preferencesInformation.html @@ -1,10 +1,10 @@ -
              -
              +

              Wallet Information

                @@ -15,8 +15,6 @@ - -
              • Wallet Name (at creation) @@ -24,7 +22,6 @@
              • -
              • Wallet Id @@ -39,8 +36,6 @@
              • - -
              • Wallet Network @@ -48,7 +43,6 @@
              • -
              • Address Type @@ -56,7 +50,6 @@
              • -
              • Derivation Strategy @@ -77,7 +70,7 @@ No private key
              • - +
              • Account ({{derivationStrategy}}) @@ -85,9 +78,7 @@
              • - - -

                Copayers

                +

                Copayers

              • {{copayer.name}} ({{'Me'|translate}}) @@ -97,7 +88,7 @@
              • -

                Extended Public Keys

                +

                Extended Public Keys

              • Copayer {{$index}}
                @@ -110,13 +101,13 @@
              - +

              Last Wallet Addresses

              • - {{a.address}} + {{a.address}}
                {{a.path}} · {{a.createdOn *1000 | amDateFormat:'MMMM Do YYYY, h:mm a' }} @@ -128,10 +119,10 @@
                  -
                • +
                • Scan addresses for funds
                • -
                • +
                • Send addresses by email
                @@ -142,17 +133,15 @@

                Balance By Address

              • - {{a.address}} + {{a.address}}
                - {{(a.amount/1e8).toFixed(8)}} BTC + {{(a.amount/1e8).toFixed(8)}} BTC
            -

            -
            diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 2e7b1db17..8b33ebf73 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -9,9 +9,9 @@
            You do not have a wallet
            - + -
            +
            @@ -269,8 +269,7 @@

            Before receiving funds, it is necessary backup your wallet. If you lose this device, it is impossible to access your funds without a backup.

            -
            diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 9dc4dd011..12356e9cf 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -1,12 +1,11 @@ 'use strict'; angular.module('copayApp.controllers').controller('backupController', - function($rootScope, $scope, $timeout, $log, lodash, profileService, gettext, bwcService, bwsError, walletService, ongoingProcess) { + function($rootScope, $scope, $timeout, $log, go, lodash, profileService, gettext, bwcService, bwsError, walletService, ongoingProcess) { - var self = this; var fc = profileService.focusedClient; - self.customWords = []; - self.walletName = fc.credentials.walletName; + $scope.customWords = []; + $scope.walletName = fc.credentials.walletName; var handleEncryptedWallet = function(client, cb) { if (!walletService.isEncrypted(client)) return cb(); @@ -17,24 +16,22 @@ angular.module('copayApp.controllers').controller('backupController', }; if (fc.isPrivKeyEncrypted() && !isDeletedSeed()) { - self.credentialsEncrypted = true; + $scope.credentialsEncrypted = true; passwordRequest(); } else { if (!isDeletedSeed()) initWords(); } - init(); - - function init() { + $scope.init = function() { $scope.passphrase = ''; - self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords); - self.customWords = []; - self.step = 1; - self.deleted = isDeletedSeed(); - self.credentialsEncrypted = false; - self.selectComplete = false; - self.backupError = false; + $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); + $scope.customWords = []; + $scope.step = 1; + $scope.deleted = isDeletedSeed(); + $scope.credentialsEncrypted = false; + $scope.selectComplete = false; + $scope.backupError = false; }; function isDeletedSeed() { @@ -43,16 +40,23 @@ angular.module('copayApp.controllers').controller('backupController', return false; }; - self.goToStep = function(n) { + $scope.backTo = function(state) { + if (state == 'walletHome') + go.walletHome(); + else + go.preferences(); + }; + + $scope.goToStep = function(n) { if (n == 1) - init(); + $scope.init(); if (n == 2) - self.step = 2; + $scope.step = 2; if (n == 3) { - if (!self.mnemonicHasPassphrase) + if (!$scope.mnemonicHasPassphrase) finalStep(); else - self.step = 3; + $scope.step = 3; } if (n == 4) finalStep(); @@ -65,7 +69,7 @@ angular.module('copayApp.controllers').controller('backupController', backupError(err); } $timeout(function() { - self.step = 4; + $scope.step = 4; return; }, 1); }); @@ -74,12 +78,12 @@ angular.module('copayApp.controllers').controller('backupController', function initWords() { var words = fc.getMnemonic(); - self.xPrivKey = fc.credentials.xPrivKey; + $scope.xPrivKey = fc.credentials.xPrivKey; walletService.lock(fc); - self.mnemonicWords = words.split(/[\u3000\s]+/); - self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords); - self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase(); - self.useIdeograms = words.indexOf("\u3000") >= 0; + $scope.mnemonicWords = words.split(/[\u3000\s]+/); + $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); + $scope.mnemonicHasPassphrase = fc.mnemonicHasPassphrase(); + $scope.useIdeograms = words.indexOf("\u3000") >= 0; }; function shuffledWords(words) { @@ -93,10 +97,10 @@ angular.module('copayApp.controllers').controller('backupController', }); }; - self.toggle = function() { - self.error = ""; + $scope.toggle = function() { + $scope.error = ""; - if (self.credentialsEncrypted) + if ($scope.credentialsEncrypted) passwordRequest(); $timeout(function() { @@ -116,12 +120,12 @@ angular.module('copayApp.controllers').controller('backupController', handleEncryptedWallet(fc, function(err) { if (err) { - self.error = bwsError.msg(err, gettext('Could not decrypt')); - $log.warn('Error decrypting credentials:', self.error); //TODO + $scope.error = bwsError.msg(err, gettext('Could not decrypt')); + $log.warn('Error decrypting credentials:', $scope.error); //TODO return; } - self.credentialsEncrypted = false; + $scope.credentialsEncrypted = false; initWords(); $timeout(function() { @@ -137,37 +141,38 @@ angular.module('copayApp.controllers').controller('backupController', word: item.word, prevIndex: index }; - self.customWords.push(newWord); - self.shuffledMnemonicWords[index].selected = true; - self.shouldContinue(); + $scope.customWords.push(newWord); + $scope.shuffledMnemonicWords[index].selected = true; + $scope.shouldContinue(); }; $scope.removeButton = function(index, item) { - self.customWords.splice(index, 1); - self.shuffledMnemonicWords[item.prevIndex].selected = false; - self.shouldContinue(); + if ($scope.loading) return; + $scope.customWords.splice(index, 1); + $scope.shuffledMnemonicWords[item.prevIndex].selected = false; + $scope.shouldContinue(); }; - self.shouldContinue = function() { - if (self.customWords.length == 12) - self.selectComplete = true; + $scope.shouldContinue = function() { + if ($scope.customWords.length == 12) + $scope.selectComplete = true; else - self.selectComplete = false; + $scope.selectComplete = false; }; function confirm(cb) { - self.backupError = false; + $scope.backupError = false; - var customWordList = lodash.pluck(self.customWords, 'word'); + var customWordList = lodash.pluck($scope.customWords, 'word'); - if (!lodash.isEqual(self.mnemonicWords, customWordList)) { + if (!lodash.isEqual($scope.mnemonicWords, customWordList)) { return cb('Mnemonic string mismatch'); } $timeout(function() { - if (self.mnemonicHasPassphrase) { + if ($scope.mnemonicHasPassphrase) { var walletClient = bwcService.getClient(); - var separator = self.useIdeograms ? '\u3000' : ' '; + var separator = $scope.useIdeograms ? '\u3000' : ' '; var customSentence = customWordList.join(separator); var passphrase = $scope.passphrase || ''; @@ -181,7 +186,7 @@ angular.module('copayApp.controllers').controller('backupController', return cb(err); } - if (walletClient.credentials.xPrivKey != self.xPrivKey) { + if (walletClient.credentials.xPrivKey != $scope.xPrivKey) { return cb('Private key mismatch'); } } @@ -194,7 +199,7 @@ angular.module('copayApp.controllers').controller('backupController', function backupError(err) { ongoingProcess.set('validatingWords', false); $log.debug('Failed to verify backup: ', err); - self.backupError = true; + $scope.backupError = true; $timeout(function() { $scope.$apply(); diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index d5110de52..5714f609e 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -2,20 +2,19 @@ angular.module('copayApp.controllers').controller('exportController', function($rootScope, $scope, $timeout, $log, backupService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) { - var self = this; var isWP = platformInfo.isWP; var isAndroid = platformInfo.isAndroid; - self.error = null; - self.success = null; + $scope.error = null; + $scope.success = null; $scope.metaDataEnabled = true; var fc = profileService.focusedClient; - self.isEncrypted = fc.isPrivKeyEncrypted(); + $scope.isEncrypted = fc.isPrivKeyEncrypted(); - self.downloadWalletBackup = function() { - self.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) { + $scope.downloadWalletBackup = function() { + $scope.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) { if (err) { - self.error = true; + $scope.error = true; return; } var opts = { @@ -24,9 +23,9 @@ angular.module('copayApp.controllers').controller('exportController', addressBook: localAddressBook }; - backupService.walletDownload(self.password, opts, function(err) { + backupService.walletDownload($scope.password, opts, function(err) { if (err) { - self.error = true; + $scope.error = true; return; } $rootScope.$emit('Local/BackupDone'); @@ -36,12 +35,12 @@ angular.module('copayApp.controllers').controller('exportController', }); }; - self.getMetaData = function(metaData, cb) { + $scope.getMetaData = function(metaData, cb) { if (metaData == false) return cb(); - self.getHistoryCache(function(err, txsFromLocal) { + $scope.getHistoryCache(function(err, txsFromLocal) { if (err) return cb(err); - self.getAddressbook(function(err, localAddressBook) { + $scope.getAddressbook(function(err, localAddressBook) { if (err) return cb(err); return cb(null, txsFromLocal, localAddressBook) @@ -49,7 +48,7 @@ angular.module('copayApp.controllers').controller('exportController', }); } - self.getHistoryCache = function(cb) { + $scope.getHistoryCache = function(cb) { storageService.getTxHistory(fc.credentials.walletId, function(err, txs) { if (err) return cb(err); @@ -66,7 +65,7 @@ angular.module('copayApp.controllers').controller('exportController', }); } - self.getAddressbook = function(cb) { + $scope.getAddressbook = function(cb) { storageService.getAddressbook(fc.credentials.network, function(err, addressBook) { if (err) return cb(err); @@ -81,10 +80,10 @@ angular.module('copayApp.controllers').controller('exportController', }); } - self.getBackup = function(cb) { - self.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) { + $scope.getBackup = function(cb) { + $scope.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) { if (err) { - self.error = true; + $scope.error = true; return cb(null); } var opts = { @@ -93,30 +92,29 @@ angular.module('copayApp.controllers').controller('exportController', addressBook: localAddressBook }; - var ew = backupService.walletExport(self.password, opts); + var ew = backupService.walletExport($scope.password, opts); if (!ew) { - self.error = true; + $scope.error = true; } else { - self.error = false; + $scope.error = false; $rootScope.$emit('Local/BackupDone'); } return cb(ew); }); } - self.viewWalletBackup = function() { - var self = this; + $scope.viewWalletBackup = function() { $timeout(function() { - self.getBackup(function(backup) { + $scope.getBackup(function(backup) { var ew = backup; if (!ew) return; - self.backupWalletPlainText = ew; + $scope.backupWalletPlainText = ew; }); }, 100); }; - self.copyWalletBackup = function() { - self.getBackup(function(backup) { + $scope.copyWalletBackup = function() { + $scope.getBackup(function(backup) { var ew = backup; if (!ew) return; window.cordova.plugins.clipboard.copy(ew); @@ -124,14 +122,14 @@ angular.module('copayApp.controllers').controller('exportController', }); }; - self.sendWalletBackup = function() { + $scope.sendWalletBackup = function() { var fc = profileService.focusedClient; window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...')); var name = (fc.credentials.walletName || fc.credentials.walletId); if (fc.alias) { name = fc.alias + ' [' + name + ']'; } - self.getBackup(function(backup) { + $scope.getBackup(function(backup) { var ew = backup; if (!ew) return; diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index 58f5f4650..f02cac712 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -3,28 +3,27 @@ angular.module('copayApp.controllers').controller('preferencesController', function($scope, $rootScope, $timeout, $log, configService, profileService, fingerprintService, walletService) { - var self = this; var fc; var config = configService.getSync(); var disableFocusListener = $rootScope.$on('Local/NewFocusedWalletReady', function() { - self.init(); + $scope.init(); }); $scope.$on('$destroy', function() { disableFocusListener(); }); - this.init = function() { + $scope.init = function() { fc = profileService.focusedClient; if (fc) { $scope.encryptEnabled = walletService.isEncrypted(fc); - this.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null; + $scope.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null; // TODO externalAccount //this.externalIndex = fc.getExternalIndex(); } - this.touchidAvailable = fingerprintService.isAvailable(); + $scope.touchidAvailable = fingerprintService.isAvailable(); $scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null; $scope.deleted = false; @@ -41,7 +40,6 @@ angular.module('copayApp.controllers').controller('preferencesController', }; $scope.encryptChange = function() { - var self = this; if (!fc) return; var val = $scope.encryptEnabled; diff --git a/src/js/controllers/preferencesAdvanced.js b/src/js/controllers/preferencesAdvanced.js deleted file mode 100644 index 30616e803..000000000 --- a/src/js/controllers/preferencesAdvanced.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -angular.module('copayApp.controllers').controller('preferencesAdvancedController', - function($scope) { - - }); \ No newline at end of file diff --git a/src/js/controllers/preferencesAlias.js b/src/js/controllers/preferencesAlias.js index 385f4e258..14cb02f25 100644 --- a/src/js/controllers/preferencesAlias.js +++ b/src/js/controllers/preferencesAlias.js @@ -2,20 +2,18 @@ angular.module('copayApp.controllers').controller('preferencesAliasController', function($scope, $timeout, configService, profileService, go) { - var config = configService.getSync(); var fc = profileService.focusedClient; var walletId = fc.credentials.walletId; - var config = configService.getSync(); - config.aliasFor = config.aliasFor || {}; - this.alias = config.aliasFor[walletId] || fc.credentials.walletName; - this.save = function() { - var self = this; + config.aliasFor = config.aliasFor || {}; + $scope.alias = config.aliasFor[walletId] || fc.credentials.walletName; + + $scope.save = function() { var opts = { aliasFor: {} }; - opts.aliasFor[walletId] = self.alias; + opts.aliasFor[walletId] = $scope.alias; configService.set(opts, function(err) { if (err) { @@ -23,10 +21,9 @@ angular.module('copayApp.controllers').controller('preferencesAliasController', return; } $scope.$emit('Local/AliasUpdated'); - $timeout(function(){ + $timeout(function() { go.path('preferences'); }, 50); }); - }; }); diff --git a/src/js/controllers/preferencesBwsUrl.js b/src/js/controllers/preferencesBwsUrl.js index d7d4afc6d..e4af513c0 100644 --- a/src/js/controllers/preferencesBwsUrl.js +++ b/src/js/controllers/preferencesBwsUrl.js @@ -1,25 +1,25 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesBwsUrlController', - function($scope, $log, configService, go, applicationService, profileService, storageService) { - this.error = null; - this.success = null; + function($scope, $log, configService, applicationService, profileService, storageService) { + $scope.error = null; + $scope.success = null; var fc = profileService.focusedClient; var walletId = fc.credentials.walletId; var defaults = configService.getDefaults(); var config = configService.getSync(); - this.bwsurl = (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url; + $scope.bwsurl = (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url; - this.resetDefaultUrl = function() { - this.bwsurl = defaults.bws.url; + $scope.resetDefaultUrl = function() { + $scope.bwsurl = defaults.bws.url; }; - this.save = function() { + $scope.save = function() { var bws; - switch (this.bwsurl) { + switch ($scope.bwsurl) { case 'prod': case 'production': bws = 'https://bws.bitpay.com/bws/api' @@ -35,16 +35,16 @@ angular.module('copayApp.controllers').controller('preferencesBwsUrlController', }; if (bws) { $log.info('Using BWS URL Alias to ' + bws); - this.bwsurl = bws; + $scope.bwsurl = bws; } var opts = { bwsFor: {} }; - opts.bwsFor[walletId] = this.bwsurl; + opts.bwsFor[walletId] = $scope.bwsurl; configService.set(opts, function(err) { - if (err) console.log(err); + if (err) $log.debug(err); storageService.setCleanAndScanAddresses(walletId, function() { applicationService.restart(); }); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index 9f6ab6fa0..5dc6cf9d4 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -3,8 +3,8 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', 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.isCordova = isCordova; + $scope.error = null; var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?'); var accept_msg = gettextCatalog.getString('Accept'); @@ -20,8 +20,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro $scope.loading = false; $ionicModal.fromTemplateUrl('views/modals/confirmation.html', { - scope: $scope, - animation: 'slide-in-up' + scope: $scope }).then(function(modal) { $scope.confirmationModal = modal; $scope.confirmationModal.show(); @@ -33,12 +32,11 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro var fc = profileService.focusedClient; var name = fc.credentials.walletName; var walletName = (fc.alias || '') + ' [' + name + ']'; - var self = this; profileService.deleteWalletClient(fc, function(err) { ongoingProcess.set('deletingWallet', false); if (err) { - self.error = err.message || err; + $scope.error = err.message || err; } else { notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', { walletName: walletName @@ -48,7 +46,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro }); }; - this.deleteWallet = function() { + $scope.deleteWallet = function() { if (isCordova) { navigator.notification.confirm( delete_msg, diff --git a/src/js/controllers/preferencesDeleteWords.js b/src/js/controllers/preferencesDeleteWords.js index 405d5d6ca..2906cea2c 100644 --- a/src/js/controllers/preferencesDeleteWords.js +++ b/src/js/controllers/preferencesDeleteWords.js @@ -1,15 +1,14 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function(confirmDialog, lodash, notification, profileService, go, gettext) { - var self = this; +angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, confirmDialog, lodash, notification, profileService, go, gettext) { var fc = profileService.focusedClient; var msg = gettext('Are you sure you want to delete the recovery phrase?'); var successMsg = gettext('Recovery phrase deleted'); if (lodash.isEmpty(fc.credentials.mnemonic) && lodash.isEmpty(fc.credentials.mnemonicEncrypted)) - self.deleted = true; + $scope.deleted = true; - self.delete = function() { + $scope.delete = function() { confirmDialog.show(msg, function(ok) { if (ok) { fc.clearMnemonic(); diff --git a/src/js/controllers/preferencesEmail.js b/src/js/controllers/preferencesEmail.js index b41981e13..9baa87599 100644 --- a/src/js/controllers/preferencesEmail.js +++ b/src/js/controllers/preferencesEmail.js @@ -1,21 +1,19 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesEmailController', - function($rootScope, go, profileService, gettext, $log, walletService) { - this.save = function(form) { - var self = this; - this.error = null; +angular.module('copayApp.controllers').controller('preferencesEmailController', function($rootScope, $scope, go, profileService, walletService) { + $scope.save = function(form) { + $scope.error = null; + $scope.saving = true; + var fc = profileService.focusedClient; + var email = $scope.email || ''; - var fc = profileService.focusedClient; - var email = self.email || ''; - - walletService.updateRemotePreferences(fc, { - email: email, - }, function(err) { - if (!err) - $rootScope.$emit('Local/EmailUpdated', email); - - go.path('preferences'); - }); - }; - }); + walletService.updateRemotePreferences(fc, { + email: email, + }, function(err) { + $scope.saving = false; + if (!err) + $rootScope.$emit('Local/EmailUpdated', email); + go.path('preferences'); + }); + }; +}); diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js index e55dac20e..3891c08b2 100644 --- a/src/js/controllers/preferencesGlobal.js +++ b/src/js/controllers/preferencesGlobal.js @@ -4,17 +4,18 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', function($scope, $rootScope, $log, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { var isCordova = platformInfo.isCordova; - this.init = function() { + + $scope.init = function() { var config = configService.getSync(); - this.unitName = config.wallet.settings.unitName; - this.currentLanguageName = uxLanguage.getCurrentLanguageName(); - this.selectedAlternative = { + $scope.unitName = config.wallet.settings.unitName; + $scope.currentLanguageName = uxLanguage.getCurrentLanguageName(); + $scope.selectedAlternative = { name: config.wallet.settings.alternativeName, isoCode: config.wallet.settings.alternativeIsoCode }; - this.feeOpts = feeService.feeOpts; - this.currentFeeLevel = feeService.getCurrentFeeLevel(); - this.usePushNotifications = isCordova && !platformInfo.isWP; + $scope.feeOpts = feeService.feeOpts; + $scope.currentFeeLevel = feeService.getCurrentFeeLevel(); + $scope.usePushNotifications = isCordova && !platformInfo.isWP; $scope.PNEnabledByUser = true; $scope.isIOSApp = platformInfo.isIOS && isCordova; if ($scope.isIOSApp) { @@ -28,7 +29,7 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', $scope.pushNotifications = config.pushNotifications.enabled; }; - this.openSettings = function() { + $scope.openSettings = function() { cordova.plugins.diagnostic.switchToSettings(function() { $log.debug('switched to settings'); }, function(err) { diff --git a/src/js/controllers/preferencesHistory.js b/src/js/controllers/preferencesHistory.js index 321e1ade2..1f988971d 100644 --- a/src/js/controllers/preferencesHistory.js +++ b/src/js/controllers/preferencesHistory.js @@ -4,26 +4,11 @@ angular.module('copayApp.controllers').controller('preferencesHistory', function($scope, $log, $timeout, storageService, go, profileService, lodash) { var fc = profileService.focusedClient; var c = fc.credentials; - this.csvReady = false; + $scope.csvReady = false; + $scope.csvHistory = function(cb) { + var allTxs = []; - this.csvHistory = function(cb) { - - function formatDate(date) { - var dateObj = new Date(date); - if (!dateObj) { - $log.debug('Error formating a date'); - return 'DateError' - } - if (!dateObj.toJSON()) { - return ''; - } - - return dateObj.toJSON(); - } - - var step = 6; - var unique = {}; function getHistory(cb) { storageService.getTxHistory(c.walletId, function(err, txs) { if (err) return cb(err); @@ -38,16 +23,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory', allTxs.push(txsFromLocal); return cb(null, lodash.flatten(allTxs)); }); - } - - var fc = profileService.focusedClient; - var c = fc.credentials; - - if (!fc.isComplete()) - return; - - var self = this; - var allTxs = []; + }; $log.debug('Generating CSV from History'); getHistory(function(err, txs) { @@ -59,12 +35,12 @@ angular.module('copayApp.controllers').controller('preferencesHistory', $log.debug('Wallet Transaction History Length:', txs.length); - self.satToUnit = 1 / self.unitToSatoshi; + $scope.satToUnit = 1 / $scope.unitToSatoshi; var data = txs; var satToBtc = 1 / 100000000; - self.csvContent = []; - self.csvFilename = 'Copay-' + (self.alias || self.walletName) + '.csv'; - self.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment']; + $scope.csvContent = []; + $scope.csvFilename = 'Copay-' + ($scope.alias || $scope.walletName) + '.csv'; + $scope.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment']; var _amount, _note, _copayers, _creator, _comment; data.forEach(function(it, index) { @@ -89,7 +65,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory', if (it.action == 'moved') _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) - self.csvContent.push({ + $scope.csvContent.push({ 'Date': formatDate(it.time * 1000), 'Destination': it.addressTo || '', 'Description': _note, @@ -103,7 +79,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory', if (it.fees && (it.action == 'moved' || it.action == 'sent')) { var _fee = (it.fees * satToBtc).toFixed(8) - self.csvContent.push({ + $scope.csvContent.push({ 'Date': formatDate(it.time * 1000), 'Destination': 'Bitcoin Network Fees', 'Description': '', @@ -116,16 +92,31 @@ angular.module('copayApp.controllers').controller('preferencesHistory', } }); - self.csvReady = true; + $scope.csvReady = true; + $timeout(function() { + $scope.$apply(); + }, 100); + if (cb) return cb(); return; - }); + + function formatDate(date) { + var dateObj = new Date(date); + if (!dateObj) { + $log.debug('Error formating a date'); + return 'DateError' + } + if (!dateObj.toJSON()) { + return ''; + } + + return dateObj.toJSON(); + }; }; - - this.clearTransactionHistory = function() { + $scope.clearTransactionHistory = function() { storageService.removeTxHistory(c.walletId, function(err) { if (err) { $log.error(err); @@ -137,5 +128,5 @@ angular.module('copayApp.controllers').controller('preferencesHistory', go.walletHome(); }, 100); }); - } + }; }); diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js index 8f31255b1..6edfa4df1 100644 --- a/src/js/controllers/preferencesInformation.js +++ b/src/js/controllers/preferencesInformation.js @@ -6,7 +6,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation', var fc = profileService.focusedClient; var c = fc.credentials; - this.init = function() { + $scope.init = function() { var basePath = c.getBaseAddressDerivationPath(); $scope.walletName = c.walletName; @@ -43,11 +43,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation', }); }; - this.sendAddrs = function() { - var self = this; - - self.loading = true; - + $scope.sendAddrs = function() { function formatDate(ts) { var dateObj = new Date(ts * 1000); if (!dateObj) { @@ -64,7 +60,6 @@ angular.module('copayApp.controllers').controller('preferencesInformation', fc.getMainAddresses({ doNotVerify: true }, function(err, addrs) { - self.loading = false; if (err) { $log.warn(err); return; diff --git a/test/controllers/backup.test.js b/test/controllers/backup.test.js index 2a62b5310..d1417e126 100644 --- a/test/controllers/backup.test.js +++ b/test/controllers/backup.test.js @@ -16,9 +16,10 @@ describe('Backup Controller', function() { it('should be defined', function() { should.exist(ctrl); }); + it('should set the mnemonic incomplete wallets', function(done) { - should.exist(ctrl); - ctrl.mnemonicWords.should.deep.equal('dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero'.split(' ')); + should.exist(scope.mnemonicWords); + scope.mnemonicWords.should.deep.equal('dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero'.split(' ')); done(); }); }); @@ -35,11 +36,11 @@ describe('Backup Controller', function() { }); it('should not set the mnemonic for complete wallets', function() { - ctrl.mnemonicWords.should.deep.equal('cheese where alarm job conduct donkey license pave congress pepper fence current'.split(' ')); + scope.mnemonicWords.should.deep.equal('cheese where alarm job conduct donkey license pave congress pepper fence current'.split(' ')); }); it('should set main wallet info', function(done) { - ctrl.walletName.should.equal('kk'); + scope.walletName.should.equal('kk'); done(); }); }); diff --git a/test/controllers/preferencesHistory.test.js b/test/controllers/preferencesHistory.test.js index 5c991f844..8c8ec6d3a 100644 --- a/test/controllers/preferencesHistory.test.js +++ b/test/controllers/preferencesHistory.test.js @@ -18,11 +18,17 @@ describe('Preferences History Controller', function() { mocks.clear({}, done); }); + it('should be defined', function() { + should.exist(ctrl); + }); + it('should export csv', function(done) { - ctrl.csvHistory(function(err) { + scope.csvHistory(function(err) { should.not.exist(err); - ctrl.csvReady.should.equal(true); - JSON.stringify(ctrl.csvContent).should.equal('[{"Date":"2016-06-03T15:54:51.000Z","Destination":"","Description":"","Amount":"0.00120000","Currency":"BTC","Txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","Creator":"","Copayers":"","Comment":"just a comment"}]'); + should.exist(scope.csvReady); + scope.csvReady.should.equal(true); + should.exist(scope.csvContent); + JSON.stringify(scope.csvContent).should.equal('[{"Date":"2016-06-03T15:54:51.000Z","Destination":"","Description":"","Amount":"0.00120000","Currency":"BTC","Txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","Creator":"","Copayers":"","Comment":"just a comment"}]'); done(); }); });