fix changing wallet / form reset
This commit is contained in:
parent
7f92b4125b
commit
67d140e981
6 changed files with 62 additions and 76 deletions
|
|
@ -15,7 +15,7 @@
|
|||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
<span translate>Reconnecting to Wallet Server...</span>
|
||||
<span translate>Reconnecting to Wallet Service...</span>
|
||||
</div>
|
||||
|
||||
<div class="onGoingProcess" ng-show="index.anyOnGoingProcess && !index.isOffline" ng-style="{'background-color':index.backgroundColor}">
|
||||
|
|
@ -35,6 +35,17 @@ index.onGoingProcessName == 'openingWallet'
|
|||
<span translate ng-show="index.onGoingProcessName == 'recreating'">Recreating Wallet...</span>
|
||||
</div>
|
||||
|
||||
<div class="onGoingProcess" ng-show="home.onGoingProcess && !index.anyOnGoingProcess">
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
{{home.onGoingProcess|translate}}...
|
||||
</div>
|
||||
|
||||
<div class="oh" ng-show="!index.noFocusedWallet">
|
||||
|
||||
<div id="walletHome" class="walletHome tab-view tab-in">
|
||||
|
|
@ -198,7 +209,7 @@ index.onGoingProcessName == 'openingWallet'
|
|||
<div class="row m20t" ng-if="home.addr">
|
||||
<div class="large-12 columns">
|
||||
<button class="button black expand radius" ng-click="home.newAddress()"
|
||||
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.generatingAddress || index.isOffline" translate>
|
||||
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline" translate>
|
||||
Generate new address
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -233,12 +244,7 @@ index.onGoingProcessName == 'openingWallet'
|
|||
</div>
|
||||
<div class="row m20t">
|
||||
<div class="large-12 large-centered columns">
|
||||
<div class="box-notification" ng-show="home.fetchingURL">
|
||||
<span class="text-secondary size-14" translate>
|
||||
Fetching Payment Information...
|
||||
</span>
|
||||
</div>
|
||||
<form ng-show="!home.fetchingURL" name="sendForm" ng-submit="home.submitForm(sendForm)" ng-disabled="home.blockUx" novalidate>
|
||||
<form ng-show="!home.onGoingProcess" name="sendForm" ng-submit="home.submitForm()" ng-disabled="home.blockUx" novalidate>
|
||||
<div class="box-notification" ng-show="home.error" ng-click="home.resetError()">
|
||||
<span class="text-warning">
|
||||
{{home.error|translate}}
|
||||
|
|
@ -330,12 +336,6 @@ index.onGoingProcessName == 'openingWallet'
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="home.onGoingProcess" class="text-gray text-center m10t">
|
||||
<span class="animated infinite flash">{{home.onGoingProcess|translate}}...</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row" ng-show="!home.onGoingProcess">
|
||||
<div class="large-6 medium-6 small-6 columns" ng-show="!home.blockUx && (home._paypro || home.lockAddress)">
|
||||
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray" translate>Cancel</a>
|
||||
|
|
@ -360,11 +360,9 @@ history
|
|||
|
||||
-->
|
||||
<div id="history" class="history tab-view">
|
||||
<div class="row m20t" ng-show="!index.txHistory[0]">
|
||||
<div class="row m20t" ng-show="!index.txHistory[0] && !index.updatingTxHistory">
|
||||
<div class="large-12 columns">
|
||||
<div class="oh text-center">
|
||||
<span ng-if="index.updatingTxHistory" class="text-gray animated flash infinite" translate>Getting transactions...</span>
|
||||
<span ng-if="!index.updatingTxHistory">
|
||||
<span ng-show="index.txHistoryError && !index.notAuthorized" ng-click='index.updateTxHistory()'>
|
||||
<span translate>Could not fetch transaction history</span>
|
||||
<br> <span translate>Tap to retry</span>
|
||||
|
|
@ -410,18 +408,14 @@ history
|
|||
</div>
|
||||
<div class="m20t row">
|
||||
<div class="columns">
|
||||
<button class="outline light-gray small expand" ng-disabled="index.updatingTxHistory"
|
||||
ng-click="index.updateTxHistory(index.skipHistory)" ng-show="index.txHistoryPaging">
|
||||
<span ng-show="!index.updatingTxHistory">
|
||||
<span translate>More</span> <i class="icon-arrow-down4 ng-scope"></i>
|
||||
</span>
|
||||
<span ng-show="index.updatingTxHistory" translate>
|
||||
Getting transactions...
|
||||
</span>
|
||||
<button class="outline light-gray small expand"
|
||||
ng-click="index.updateTxHistory(index.skipHistory)" ng-show="index.txHistoryPaging && !index.updatingTxHistory">
|
||||
<span translate>More</span> <i class="icon-arrow-down4 ng-scope"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1190,3 +1190,4 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
|
|||
-webkit-transform: scaleY(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,10 +217,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.txHistory = [];
|
||||
}
|
||||
self.skipHistory = skip || 0;
|
||||
$log.debug('Updating Transaction History');
|
||||
self.txHistoryError = false;
|
||||
self.updatingTxHistory = true;
|
||||
$timeout(function() {
|
||||
$log.debug('Updating Transaction History');
|
||||
self.txHistoryError = false;
|
||||
self.updatingTxHistory = true;
|
||||
$rootScope.$apply();
|
||||
fc.getTxHistory({
|
||||
skip: self.skipHistory,
|
||||
limit: self.limitHistory + 1
|
||||
|
|
|
|||
|
|
@ -40,9 +40,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
self.getAddress();
|
||||
});
|
||||
|
||||
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
||||
self.resetForm();
|
||||
});
|
||||
|
||||
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e,tab){
|
||||
switch(tab) {
|
||||
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) {
|
||||
switch (tab) {
|
||||
case 'send':
|
||||
self.resetError();
|
||||
self.setInputs();
|
||||
|
|
@ -57,6 +60,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
disableScannerListener();
|
||||
disablePaymentUriListener();
|
||||
disableTabListener();
|
||||
disableFocusListener();
|
||||
$rootScope.hideMenuBar = false;
|
||||
});
|
||||
|
||||
|
|
@ -279,14 +283,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.newAddress = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
self.generatingAddress = true;
|
||||
self.error = null;
|
||||
self.setOngoingProcess('Generating Address');
|
||||
fc.createAddress(function(err, addr) {
|
||||
self.generatingAddress = false;
|
||||
self.setOngoingProcess();
|
||||
if (err) {
|
||||
$log.debug('Creating address ERROR:', err);
|
||||
$scope.$emit('Local/ClientError', err);
|
||||
self.error = 'Could not generate address';
|
||||
} else {
|
||||
self.addr = addr.address;
|
||||
storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {});
|
||||
|
|
@ -434,16 +436,27 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.setOngoingProcess = function(name) {
|
||||
var self = this;
|
||||
$timeout(function() {
|
||||
self.onGoingProcess = name;
|
||||
$rootScope.$apply();
|
||||
})
|
||||
self.blockUx = !!name;
|
||||
|
||||
if (isCordova) {
|
||||
if (name) {
|
||||
window.plugins.spinnerDialog.show(null, name + '...', true);
|
||||
} else {
|
||||
window.plugins.spinnerDialog.hide();
|
||||
}
|
||||
} else {
|
||||
$timeout(function() {
|
||||
self.onGoingProcess = name;
|
||||
$rootScope.$apply();
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
this.submitForm = function(form) {
|
||||
this.submitForm = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
var unitToSat = this.unitToSatoshi;
|
||||
|
||||
var form = $scope.sendForm;
|
||||
if (form.$invalid) {
|
||||
this.error = 'Unable to send transaction proposal';
|
||||
return;
|
||||
|
|
@ -452,18 +465,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
if (fc.isPrivKeyEncrypted()) {
|
||||
profileService.unlockFC(function(err) {
|
||||
if (err) return self.setError(err);
|
||||
return self.submitForm(form);
|
||||
return self.submitForm();
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
self.blockUx = true;
|
||||
self.setOngoingProcess('Sending');
|
||||
|
||||
if (isCordova) {
|
||||
window.plugins.spinnerDialog.show(null, 'Creating transaction...', true);
|
||||
}
|
||||
|
||||
self.setOngoingProcess('Sending transaction');
|
||||
$timeout(function() {
|
||||
var comment = form.comment.$modelValue;
|
||||
var paypro = self._paypro;
|
||||
|
|
@ -481,24 +488,16 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
self.setOngoingProcess();
|
||||
if (err) {
|
||||
profileService.lockFC();
|
||||
if (isCordova) {
|
||||
window.plugins.spinnerDialog.hide();
|
||||
}
|
||||
self.blockUx = false;
|
||||
return self.setError(err);
|
||||
}
|
||||
|
||||
self.signAndBroadcast(txp, function(err) {
|
||||
self.setOngoingProcess();
|
||||
if (isCordova) {
|
||||
window.plugins.spinnerDialog.hide();
|
||||
}
|
||||
self.blockUx = false;
|
||||
profileService.lockFC();
|
||||
if (err) {
|
||||
profileService.lockFC();
|
||||
return self.setError(err);
|
||||
}
|
||||
self.resetForm(form);
|
||||
self.resetForm();
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -507,7 +506,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.signAndBroadcast = function(txp, cb) {
|
||||
var fc = profileService.focusedClient;
|
||||
self.setOngoingProcess('Signing');
|
||||
self.setOngoingProcess('Signing transaction');
|
||||
fc.signTxProposal(txp, function(err, signedTx) {
|
||||
profileService.lockFC();
|
||||
self.setOngoingProcess();
|
||||
|
|
@ -515,7 +514,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
if (err) return cb(err);
|
||||
|
||||
if (signedTx.status == 'accepted') {
|
||||
self.setOngoingProcess('Broadcasting');
|
||||
self.setOngoingProcess('Broadcasting transaction');
|
||||
fc.broadcastTxProposal(signedTx, function(err, btx) {
|
||||
self.setOngoingProcess();
|
||||
if (err) {
|
||||
|
|
@ -570,9 +569,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
|
||||
|
||||
this.resetForm = function(form) {
|
||||
this.resetForm = function() {
|
||||
this.resetError();
|
||||
this.fetchingURL = null;
|
||||
this._paypro = null;
|
||||
|
||||
this.lockAddress = false;
|
||||
|
|
@ -580,6 +578,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this._amount = this._address = null;
|
||||
|
||||
var form = $scope.sendForm;
|
||||
if (form && form.amount) {
|
||||
form.amount.$pristine = true;
|
||||
form.amount.$setViewValue('');
|
||||
|
|
@ -623,7 +622,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
});
|
||||
};
|
||||
|
||||
this.setFromPayPro = function(uri, form) {
|
||||
this.setFromPayPro = function(uri) {
|
||||
var fc = profileService.focusedClient;
|
||||
if (isChromeApp) {
|
||||
this.error = 'Payment Protocol not supported on Chrome App';
|
||||
|
|
@ -631,22 +630,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
}
|
||||
|
||||
var satToUnit = 1 / this.unitToSatoshi;
|
||||
this.fetchingURL = uri;
|
||||
this.blockUx = true;
|
||||
var self = this;
|
||||
self.setOngoingProcess('Fetching Payment Informantion');
|
||||
|
||||
$log.debug('Fetch PayPro Request...', uri);
|
||||
$timeout(function() {
|
||||
fc.fetchPayPro({
|
||||
payProUrl: uri,
|
||||
}, function(err, paypro) {
|
||||
$log.debug(paypro);
|
||||
self.blockUx = false;
|
||||
self.fetchingURL = null;
|
||||
self.setOngoingProcess();
|
||||
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
self.resetForm(form);
|
||||
self.resetForm();
|
||||
var msg = err.toString();
|
||||
if (msg.match('HTTP')) {
|
||||
msg = 'Could not fetch payment information';
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ angular.module('copayApp.directives')
|
|||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, elem, attrs, ctrl) {
|
||||
var networkName = profileService.focusedClient.credentials.network;
|
||||
var URI = bitcore.URI;
|
||||
var Address = bitcore.Address
|
||||
var validator = function(value) {
|
||||
var networkName = profileService.focusedClient.credentials.network;
|
||||
// Regular url
|
||||
if (/^https?:\/\//.test(value)) {
|
||||
ctrl.$setValidity('validAddress', true);
|
||||
|
|
@ -51,6 +51,7 @@ angular.module('copayApp.directives')
|
|||
return;
|
||||
}
|
||||
|
||||
console.log('[directives.js.53]', value, networkName); //TODO
|
||||
// Regular Address
|
||||
ctrl.$setValidity('validAddress', Address.isValid(value, networkName));
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -67,13 +67,6 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
|||
});
|
||||
};
|
||||
|
||||
root.home = function() {
|
||||
if ($rootScope.iden)
|
||||
root.walletHome();
|
||||
else
|
||||
root.path('signin');
|
||||
};
|
||||
|
||||
root.addWallet = function() {
|
||||
$state.go('add');
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue