Uses popupService

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-01 10:56:13 -03:00
commit 92bb8e01bc
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
19 changed files with 64 additions and 164 deletions

View file

@ -11,10 +11,6 @@
<ion-content ng-controller="joinController as join"> <ion-content ng-controller="joinController as join">
<div class="padding assertive" ng-show="join.error">
{{join.error|translate}}
</div>
<form name="joinForm" ng-submit="join.join(joinForm)" novalidate> <form name="joinForm" ng-submit="join.join(joinForm)" novalidate>
<div class="list"> <div class="list">

View file

@ -25,9 +25,6 @@
</li> </li>
<li class="item"> <li class="item">
<div class="assertive" ng-show="error">
<span class="text-warning size-14">{{error|translate}}</span>
</div>
<div class="row" ng-if="tx.removed"> <div class="row" ng-if="tx.removed">
<div class="column m20t text-center text-warning size-12" translate> <div class="column m20t text-center text-warning size-12" translate>

View file

@ -10,10 +10,6 @@
<ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(1)"> <ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(1)">
<div class="padding assertive" ng-show="create.error">
{{create.error|translate}}
</div>
<form name="setupForm" ng-submit="create.create(setupForm)" novalidate> <form name="setupForm" ng-submit="create.create(setupForm)" novalidate>
<div class="list"> <div class="list">

View file

@ -10,10 +10,6 @@
<ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(3)"> <ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(3)">
<div class="padding assertive" ng-show="create.error">
{{create.error|translate}}
</div>
<form name="setupForm" ng-submit="create.create(setupForm)" novalidate> <form name="setupForm" ng-submit="create.create(setupForm)" novalidate>
<div class="list"> <div class="list">

View file

@ -10,10 +10,6 @@
<ion-content ng-controller="importController" ng-init="type='file'"> <ion-content ng-controller="importController" ng-init="type='file'">
<div class="padding assertive" ng-show="error">
{{error|translate}}
</div>
<form name="importForm" ng-submit="importBlob(importForm)" novalidate> <form name="importForm" ng-submit="importBlob(importForm)" novalidate>
<div class="list"> <div class="list">

View file

@ -10,10 +10,6 @@
<ion-content ng-controller="importController" ng-init="type='hwWallet'"> <ion-content ng-controller="importController" ng-init="type='hwWallet'">
<div class="padding assertive" ng-show="error">
{{error|translate}}
</div>
<form name="importForm3" ng-submit="importHW(importForm3)" novalidate> <form name="importForm3" ng-submit="importHW(importForm3)" novalidate>
<div class="card" ng-show="!seedOptions[0]"> <div class="card" ng-show="!seedOptions[0]">

View file

@ -10,21 +10,15 @@
<ion-content ng-controller="importController" ng-init="type='12'"> <ion-content ng-controller="importController" ng-init="type='12'">
<div ng-show="importErr || error" class="padding assertive" ng-click="importErr = error = null"> <div ng-show="importErr" class="padding assertive" ng-click="importErr = null">
<div ng-show="importErr"> <div translate>Could not access the wallet at the server. Please check:</div>
<div translate>Could not access the wallet at the server. Please check:</div> <ul>
<ul> <li translate>The password of the recovery phrase (if set)</li>
<li translate>The password of the recovery phrase (if set)</li> <li translate>The derivation path</li>
<li translate>The derivation path</li> <li translate>The wallet service URL</li>
<li translate>The wallet service URL</li> </ul>
</ul> <div translate>
<div translate> NOTE: To import a wallet from a 3rd party software, please go to Add Wallet &gt; Create Wallet, and specify the Recovery Phrase there.
NOTE: To import a wallet from a 3rd party software, please go to Add Wallet &gt; Create Wallet, and specify the Recovery Phrase there.
</div>
</div>
<div ng-show="error">
{{error|translate}}
</div> </div>
</div> </div>

View file

@ -11,10 +11,6 @@
</div> </div>
</div> </div>
<div class="padding assertive" ng-show="error">
{{error|translate}}
</div>
<div class="list card padding text-center" ng-if="!wallets[0]"> <div class="list card padding text-center" ng-if="!wallets[0]">
<span translate>No Wallet</span> <span translate>No Wallet</span>
</div> </div>

View file

@ -83,7 +83,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
this.getBuyPrice = function(token, price) { this.getBuyPrice = function(token, price) {
var self = this; var self = this;
this.error = null;
if (!price || (price && !price.qty && !price.fiat)) { if (!price || (price && !price.qty && !price.fiat)) {
this.buyPrice = null; this.buyPrice = null;
return; return;

View file

@ -45,7 +45,7 @@ angular.module('copayApp.controllers').controller('copayersController',
profileService.deleteWalletClient(wallet, function(err) { profileService.deleteWalletClient(wallet, function(err) {
ongoingProcess.set('deletingWallet', false); ongoingProcess.set('deletingWallet', false);
if (err) { if (err) {
$scope.error = err.message || err; popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else { } else {
$state.transitionTo('tabs.home'); $state.transitionTo('tabs.home');
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('createController', angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService) { function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, profileService, configService, gettext, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
@ -92,7 +92,7 @@ angular.module('copayApp.controllers').controller('createController',
this.create = function(form) { this.create = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
this.error = gettext('Please enter the required fields'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields'));
return; return;
} }
@ -119,7 +119,7 @@ angular.module('copayApp.controllers').controller('createController',
var pathData = derivationPathHelper.parse($scope.derivationPath); var pathData = derivationPathHelper.parse($scope.derivationPath);
if (!pathData) { if (!pathData) {
this.error = gettext('Invalid derivation path'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return; return;
} }
@ -132,14 +132,14 @@ angular.module('copayApp.controllers').controller('createController',
} }
if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) {
this.error = gettext('Please enter the wallet recovery phrase'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the wallet recovery phrase'));
return; return;
} }
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
var account = $scope.account; var account = $scope.account;
if (!account || account < 1) { if (!account || account < 1) {
this.error = gettext('Invalid account number'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
return; return;
} }
@ -154,8 +154,7 @@ angular.module('copayApp.controllers').controller('createController',
src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) { src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) {
ongoingProcess.set('connecting' + self.seedSourceId, false); ongoingProcess.set('connecting' + self.seedSourceId, false);
if (err) { if (err) {
self.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.$apply();
return; return;
} }
opts = lodash.assign(lopts, opts); opts = lodash.assign(lopts, opts);
@ -174,10 +173,7 @@ angular.module('copayApp.controllers').controller('createController',
ongoingProcess.set('creatingWallet', false); ongoingProcess.set('creatingWallet', false);
if (err) { if (err) {
$log.warn(err); $log.warn(err);
self.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$timeout(function() {
$rootScope.$apply();
});
return; return;
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('exportController', angular.module('copayApp.controllers').controller('exportController',
function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams) { function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams, popupService) {
var prevState; var prevState;
var isWP = platformInfo.isWP; var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid; var isAndroid = platformInfo.isAndroid;
@ -10,7 +10,6 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.isEncrypted = wallet.isPrivKeyEncrypted(); $scope.isEncrypted = wallet.isPrivKeyEncrypted();
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.isSafari = platformInfo.isSafari; $scope.isSafari = platformInfo.isSafari;
$scope.error = null;
$scope.init = function() { $scope.init = function() {
$scope.supported = true; $scope.supported = true;
@ -51,7 +50,7 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.downloadWalletBackup = function() { $scope.downloadWalletBackup = function() {
$scope.getAddressbook(function(err, localAddressBook) { $scope.getAddressbook(function(err, localAddressBook) {
if (err) { if (err) {
$scope.error = true; popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return; return;
} }
var opts = { var opts = {
@ -61,7 +60,7 @@ angular.module('copayApp.controllers').controller('exportController',
backupService.walletDownload($scope.password, opts, function(err) { backupService.walletDownload($scope.password, opts, function(err) {
if (err) { if (err) {
$scope.error = true; popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return; return;
} }
$state.go('tabs.home'); $state.go('tabs.home');
@ -87,7 +86,7 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.getBackup = function(cb) { $scope.getBackup = function(cb) {
$scope.getAddressbook(function(err, localAddressBook) { $scope.getAddressbook(function(err, localAddressBook) {
if (err) { if (err) {
$scope.error = true; popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return cb(null); return cb(null);
} }
var opts = { var opts = {
@ -97,9 +96,7 @@ angular.module('copayApp.controllers').controller('exportController',
var ew = backupService.walletExport($scope.password, opts); var ew = backupService.walletExport($scope.password, opts);
if (!ew) { if (!ew) {
$scope.error = true; popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
} else {
$scope.error = false;
} }
return cb(ew); return cb(ew);
}); });

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('importController', angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel; var isDevel = platformInfo.isDevel;
@ -38,12 +38,11 @@ angular.module('copayApp.controllers').controller('importController',
if (!code) return; if (!code) return;
$scope.importErr = false; $scope.importErr = false;
$scope.error = null;
var parsedCode = code.split('|'); var parsedCode = code.split('|');
if (parsedCode.length != 5) { if (parsedCode.length != 5) {
/// Trying to import a malformed wallet export QR code /// Trying to import a malformed wallet export QR code
$scope.error = gettext('Incorrect code format'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Incorrect code format'));
return; return;
} }
@ -56,7 +55,7 @@ angular.module('copayApp.controllers').controller('importController',
}; };
if (info.type == 1 && info.hasPassphrase) if (info.type == 1 && info.hasPassphrase)
$scope.error = gettext('Password required. Make sure to enter your password in advanced options'); popupService.showAlert(gettextCatalog.getString('Password required. Make sure to enter your password in advanced options'));
$scope.derivationPath = info.derivationPath; $scope.derivationPath = info.derivationPath;
$scope.testnetEnabled = info.network == 'testnet' ? true : false; $scope.testnetEnabled = info.network == 'testnet' ? true : false;
@ -69,7 +68,6 @@ angular.module('copayApp.controllers').controller('importController',
$scope.setType = function(type) { $scope.setType = function(type) {
$scope.type = type; $scope.type = type;
$scope.error = null;
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
}, 1); }, 1);
@ -80,12 +78,12 @@ angular.module('copayApp.controllers').controller('importController',
try { try {
str2 = sjcl.decrypt($scope.password, str); str2 = sjcl.decrypt($scope.password, str);
} catch (e) { } catch (e) {
err = gettext('Could not decrypt file, check your password'); err = gettextCatalog.getString('Could not decrypt file, check your password');
$log.warn(e); $log.warn(e);
}; };
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
}); });
@ -100,7 +98,7 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importWallet(str2, opts, function(err, client) { profileService.importWallet(str2, opts, function(err, client) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
return; return;
} }
@ -129,7 +127,7 @@ angular.module('copayApp.controllers').controller('importController',
if (err instanceof errors.NOT_AUTHORIZED) { if (err instanceof errors.NOT_AUTHORIZED) {
$scope.importErr = true; $scope.importErr = true;
} else { } else {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
} }
return $timeout(function() { return $timeout(function() {
$scope.$apply(); $scope.$apply();
@ -190,7 +188,7 @@ angular.module('copayApp.controllers').controller('importController',
if (err instanceof errors.NOT_AUTHORIZED) { if (err instanceof errors.NOT_AUTHORIZED) {
$scope.importErr = true; $scope.importErr = true;
} else { } else {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
} }
return $timeout(function() { return $timeout(function() {
$scope.$apply(); $scope.$apply();
@ -232,10 +230,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.importBlob = function(form) { $scope.importBlob = function(form) {
if (form.$invalid) { if (form.$invalid) {
$scope.error = gettext('There is an error in the form'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('There is an error in the form'));
$timeout(function() {
$scope.$apply();
});
return; return;
} }
@ -244,11 +239,7 @@ angular.module('copayApp.controllers').controller('importController',
var password = form.password.$modelValue; var password = form.password.$modelValue;
if (!backupFile && !backupText) { if (!backupFile && !backupText) {
$scope.error = gettext('Please, select your backup file'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please, select your backup file'));
$timeout(function() {
$scope.$apply();
});
return; return;
} }
@ -263,10 +254,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.importMnemonic = function(form) { $scope.importMnemonic = function(form) {
if (form.$invalid) { if (form.$invalid) {
$scope.error = gettext('There is an error in the form'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('There is an error in the form'));
$timeout(function() {
$scope.$apply();
});
return; return;
} }
@ -276,7 +264,7 @@ angular.module('copayApp.controllers').controller('importController',
var pathData = derivationPathHelper.parse($scope.derivationPath); var pathData = derivationPathHelper.parse($scope.derivationPath);
if (!pathData) { if (!pathData) {
$scope.error = gettext('Invalid derivation path'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return; return;
} }
opts.account = pathData.account; opts.account = pathData.account;
@ -284,10 +272,9 @@ angular.module('copayApp.controllers').controller('importController',
opts.derivationStrategy = pathData.derivationStrategy; opts.derivationStrategy = pathData.derivationStrategy;
var words = form.words.$modelValue || null; var words = form.words.$modelValue || null;
$scope.error = null;
if (!words) { if (!words) {
$scope.error = gettext('Please enter the recovery phrase'); popupService.showAlert(gettextCatalog.getString('Please enter the recovery phrase'));
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) { } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words, opts); return _importExtendedPrivateKey(words, opts);
} else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) { } else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) {
@ -296,17 +283,11 @@ angular.module('copayApp.controllers').controller('importController',
var wordList = words.split(/[\u3000\s]+/); var wordList = words.split(/[\u3000\s]+/);
if ((wordList.length % 3) != 0) { if ((wordList.length % 3) != 0) {
$scope.error = gettext('Wrong number of recovery words:') + wordList.length; popupService.showAlert(gettextCatalog.getString('Wrong number of recovery words:') + wordList.length);
return;
} }
} }
if ($scope.error) {
$timeout(function() {
$scope.$apply();
});
return;
}
var passphrase = form.passphrase.$modelValue; var passphrase = form.passphrase.$modelValue;
opts.passphrase = form.passphrase.$modelValue || null; opts.passphrase = form.passphrase.$modelValue || null;
@ -317,8 +298,7 @@ angular.module('copayApp.controllers').controller('importController',
trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) { trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) {
ongoingProcess.clear(); ongoingProcess.clear();
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.$apply();
return; return;
} }
@ -330,10 +310,8 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importExtendedPublicKey(lopts, function(err, wallet) { profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
return $timeout(function() { return;
$scope.$apply();
});
} }
@ -354,13 +332,9 @@ angular.module('copayApp.controllers').controller('importController',
$scope.importHW = function(form) { $scope.importHW = function(form) {
if (form.$invalid || $scope.account < 0) { if (form.$invalid || $scope.account < 0) {
$scope.error = gettext('There is an error in the form'); popupService.showAlert(gettextCatalog.getString('There is an error in the form'));
$timeout(function() {
$scope.$apply();
});
return; return;
} }
$scope.error = '';
$scope.importErr = false; $scope.importErr = false;
var account = +$scope.account; var account = +$scope.account;
@ -400,8 +374,7 @@ angular.module('copayApp.controllers').controller('importController',
ledger.getInfoForNewWallet(true, account, function(err, lopts) { ledger.getInfoForNewWallet(true, account, function(err, lopts) {
ongoingProcess.clear(); ongoingProcess.clear();
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.$apply();
return; return;
} }
@ -413,10 +386,8 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importExtendedPublicKey(lopts, function(err, wallet) { profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
return $timeout(function() { return;
$scope.$apply();
});
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('joinController', angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams) { function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel; var isDevel = platformInfo.isDevel;
@ -14,7 +14,6 @@ angular.module('copayApp.controllers').controller('joinController',
this.onQrCodeScanned = function(data) { this.onQrCodeScanned = function(data) {
console.log('[join.js.16:data:]',data); //TODO
$scope.secret = data; $scope.secret = data;
if ($scope.joinForm) { if ($scope.joinForm) {
$scope.joinForm.secret.$setViewValue(data); $scope.joinForm.secret.$setViewValue(data);
@ -64,7 +63,7 @@ console.log('[join.js.16:data:]',data); //TODO
this.join = function(form) { this.join = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
self.error = gettext('Please enter the required fields'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields'));
return; return;
} }
@ -86,7 +85,7 @@ console.log('[join.js.16:data:]',data); //TODO
var pathData = derivationPathHelper.parse($scope.derivationPath); var pathData = derivationPathHelper.parse($scope.derivationPath);
if (!pathData) { if (!pathData) {
this.error = gettext('Invalid derivation path'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return; return;
} }
opts.account = pathData.account; opts.account = pathData.account;
@ -100,15 +99,14 @@ console.log('[join.js.16:data:]',data); //TODO
if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the wallet recovery phrase'));
this.error = gettext('Please enter the wallet recovery phrase');
return; return;
} }
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
var account = $scope.account; var account = $scope.account;
if (!account || account < 1) { if (!account || account < 1) {
this.error = gettext('Invalid account number'); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
return; return;
} }
@ -122,8 +120,7 @@ console.log('[join.js.16:data:]',data); //TODO
src.getInfoForNewWallet(true, account, function(err, lopts) { src.getInfoForNewWallet(true, account, function(err, lopts) {
ongoingProcess.set('connecting' + self.seedSourceId, false); ongoingProcess.set('connecting' + self.seedSourceId, false);
if (err) { if (err) {
self.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.$apply();
return; return;
} }
opts = lodash.assign(lopts, opts); opts = lodash.assign(lopts, opts);
@ -141,8 +138,7 @@ console.log('[join.js.16:data:]',data); //TODO
profileService.joinWallet(opts, function(err, client) { profileService.joinWallet(opts, function(err, client) {
ongoingProcess.set('joiningWallet', false); ongoingProcess.set('joiningWallet', false);
if (err) { if (err) {
self.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
$rootScope.$apply();
return; return;
} }

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService) { angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) {
var self = $scope.self; var self = $scope.self;
var tx = $scope.tx; var tx = $scope.tx;
var copayers = $scope.copayers; var copayers = $scope.copayers;
@ -25,13 +25,11 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
} }
var setSendError = function(msg) { var setSendError = function(msg) {
$scope.error = msg || gettextCatalog.getString('Could not send payment'); var error = msg || gettextCatalog.getString('Could not send payment');
popupService.showAlert(gettextCatalog.getString('Error'), error);
} }
$scope.sign = function() { $scope.sign = function() {
$scope.error = null;
$scope.loading = true; $scope.loading = true;
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) { walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
@ -42,18 +40,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
function setError(err, prefix) { function setError(err, prefix) {
$scope.loading = false; $scope.loading = false;
$scope.error = bwcError.msg(err, prefix); popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, prefix));
$timeout(function() {
$scope.$digest();
}, 10);
}; };
$scope.reject = function(txp) { $scope.reject = function(txp) {
$scope.loading = true; $scope.loading = true;
$scope.error = null;
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) { walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err) if (err)
return setError(err, gettextCatalog.getString('Could not reject payment')); return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close(txpr); $scope.close(txpr);
@ -64,7 +58,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.remove = function() { $scope.remove = function() {
$scope.loading = true; $scope.loading = true;
$scope.error = null;
$timeout(function() { $timeout(function() {
ongoingProcess.set('removeTx', true); ongoingProcess.set('removeTx', true);
@ -84,7 +77,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.broadcast = function(txp) { $scope.broadcast = function(txp) {
$scope.loading = true; $scope.loading = true;
$scope.error = null;
$timeout(function() { $timeout(function() {
ongoingProcess.set('broadcastTx', true); ongoingProcess.set('broadcastTx', true);
@ -185,7 +177,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
if (txp) { if (txp) {
var type = txStatus.notify(txp); var type = txStatus.notify(txp);
$scope.openStatusModal(type, txp, function() {}); $scope.openStatusModal(type, txp, function() {});
} }
$scope.cancel(); $scope.cancel();
}; };

View file

@ -3,7 +3,6 @@
angular.module('copayApp.controllers').controller('preferencesBwsUrlController', angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
function($scope, $log, $stateParams, $ionicNavBarDelegate, configService, applicationService, profileService, storageService) { function($scope, $log, $stateParams, $ionicNavBarDelegate, configService, applicationService, profileService, storageService) {
$ionicNavBarDelegate.title('Wallet Service URL'); $ionicNavBarDelegate.title('Wallet Service URL');
$scope.error = null;
$scope.success = null; $scope.success = null;
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);

View file

@ -1,12 +1,11 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, gettextCatalog, lodash, profileService, $state, ongoingProcess) { function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet')); $ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet'));
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' '; $scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']'; $scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.error = null;
$scope.showDeletePopup = function() { $scope.showDeletePopup = function() {
var popup = $ionicPopup.show({ var popup = $ionicPopup.show({
@ -36,7 +35,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
profileService.deleteWalletClient(wallet, function(err) { profileService.deleteWalletClient(wallet, function(err) {
ongoingProcess.set('deletingWallet', false); ongoingProcess.set('deletingWallet', false);
if (err) { if (err) {
$scope.error = err.message || err; popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else { } else {
$state.go('tabs.home'); $state.go('tabs.home');
} }

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog) { angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
@ -33,7 +33,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
if ($scope.generatingAddress) return; if ($scope.generatingAddress) return;
var wallet = wallet || $scope.wallet; var wallet = wallet || $scope.wallet;
$scope.error = null;
$scope.addr = null; $scope.addr = null;
$scope.generatingAddress = true; $scope.generatingAddress = true;
@ -41,7 +40,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
walletService.getAddress(wallet, forceNew, function(err, addr) { walletService.getAddress(wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false; $scope.generatingAddress = false;
if (err) { if (err) {
$scope.error = err; popupService.showAlert(gettextCatalog.getString('Error'), err);
} else { } else {
if (addr) if (addr)
$scope.addr = addr; $scope.addr = addr;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore) { angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
// `wallet` is a decorated version of client. // `wallet` is a decorated version of client.
var root = {}; var root = {};
@ -81,12 +81,11 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
wallet.notAuthorized = true; wallet.notAuthorized = true;
$state.go('tabs.home'); $state.go('tabs.home');
} else if (err instanceof errors.NOT_FOUND) { } else if (err instanceof errors.NOT_FOUND) {
root.showErrorPopup(gettext('Could not access Wallet Service: Not found')); popupService.showAlert(gettextCatalog.getString('Could not access Wallet Service: Not found'));
} else { } else {
var msg = "" var msg = ""
$rootScope.$emit('Local/ClientError', (err.error ? err.error : err)); $rootScope.$emit('Local/ClientError', (err.error ? err.error : err));
var msg = bwcError.msg(err, gettext('Error at Wallet Service')); popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Error at Wallet Service')));
root.showErrorPopup(msg);
} }
}; };
root.handleError = lodash.debounce(_handleError, 1000); root.handleError = lodash.debounce(_handleError, 1000);
@ -664,20 +663,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}); });
}; };
root.showErrorPopup = function(msg, cb) {
$log.warn('Showing err popup:' + msg);
// An alert dialog
var alertPopup = $ionicPopup.alert({
title: title,
template: msg
});
if (!cb) cb = function() {};
alertPopup.then(cb);
};
// walletHome // walletHome
root.recreate = function(wallet, cb) { root.recreate = function(wallet, cb) {
ongoingProcess.set('recreating', true); ongoingProcess.set('recreating', true);