Merge pull request #2414 from cmgustavo/bug/ux-loading-01

Fixes loading message after press a button
This commit is contained in:
Matias Alejo Garcia 2015-02-18 11:07:54 -03:00
commit 3eab8ab8e5
11 changed files with 110 additions and 85 deletions

View file

@ -127,7 +127,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
return;
}
$scope.open(form.email.$modelValue, form.password.$modelValue);
$timeout(function() {
$scope.open(form.email.$modelValue, form.password.$modelValue);
}, 100);
};
@ -165,7 +167,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
} else {
$scope.error = 'Unknown error';
}
$rootScope.starting = false;
$timeout(function() {
$rootScope.$digest();
}, 1)

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) {
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService, isCordova) {
$scope.openTxModal = function(tx) {
var ModalInstanceCtrl = function($scope, $modalInstance) {
@ -16,10 +16,16 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
};
$scope.sign = function(ntxid) {
if (isCordova) {
window.plugins.spinnerDialog.show(null, 'Signing transaction...', true);
}
$scope.loading = true;
$scope.error = null;
$timeout(function() {
w.signAndSend(ntxid, function(err, id, status) {
if (isCordova) {
window.plugins.spinnerDialog.hide();
}
$scope.loading = false;
if (err) {
$scope.error = 'Transaction could not send. Please try again.';
@ -33,10 +39,16 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
};
$scope.reject = function(ntxid) {
if (isCordova) {
window.plugins.spinnerDialog.show(null, 'Rejecting transaction...', true);
}
$scope.loading = true;
$scope.error = null;
$timeout(function() {
w.reject(ntxid, function(err, status) {
if (isCordova) {
window.plugins.spinnerDialog.hide();
}
$scope.loading = false;
if (err) {
$scope.error = err;
@ -50,10 +62,16 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
};
$scope.broadcast = function(ntxid) {
if (isCordova) {
window.plugins.spinnerDialog.show(null, 'Sending transaction...', true);
}
$scope.loading = true;
$scope.error = null;
$timeout(function() {
w.issueTx(ntxid, function(err, txid, status) {
if (isCordova) {
window.plugins.spinnerDialog.hide();
}
$scope.loading = false;
if (err) {
$scope.error = 'Transaction could not send. Please try again.';

View file

@ -70,33 +70,36 @@ angular.module('copayApp.controllers').controller('ImportController',
$rootScope.starting = true;
$scope.importOpts = {};
$timeout(function() {
var skipFields = [];
$scope.importOpts = {};
if ($scope.skipPublicKeyRing)
skipFields.push('publicKeyRing');
var skipFields = [];
if ($scope.skipTxProposals)
skipFields.push('txProposals');
if ($scope.skipPublicKeyRing)
skipFields.push('publicKeyRing');
if (skipFields)
$scope.importOpts.skipFields = skipFields;
if ($scope.skipTxProposals)
skipFields.push('txProposals');
if (backupFile) {
reader.readAsBinaryString(backupFile);
} else {
updateStatus('Importing wallet - Procesing backup...');
identityService.importWallet(backupText, $scope.password, $scope.importOpts, function(err) {
if (err) {
$rootScope.starting = false;
$scope.error = 'Could not read wallet. Please check your password';
$timeout(function() {
$rootScope.$digest();
}, 1);
}
});
}
if (skipFields)
$scope.importOpts.skipFields = skipFields;
if (backupFile) {
reader.readAsBinaryString(backupFile);
} else {
updateStatus('Importing wallet - Procesing backup...');
identityService.importWallet(backupText, $scope.password, $scope.importOpts, function(err) {
if (err) {
$rootScope.starting = false;
$scope.error = 'Could not read wallet. Please check your password';
$timeout(function() {
$rootScope.$digest();
}, 1);
}
});
}
}, 100);
};

View file

@ -70,10 +70,13 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
$rootScope.starting = true;
if (backupFile) {
reader.readAsBinaryString(backupFile);
} else {
_importBackup(backupText);
}
$timeout(function() {
if (backupFile) {
reader.readAsBinaryString(backupFile);
} else {
_importBackup(backupText);
}
}, 100);
};
});

View file

@ -163,6 +163,9 @@ angular.module('copayApp.controllers').controller('SendController',
if (msg.match('expired'))
msg = 'The payment request has expired';
if (msg.match('XMLHttpRequest'))
msg = 'Error when sending to the blockchain. Resend it from Home';
var message = 'The transaction' + ($scope.requiresMultipleSignatures ? ' proposal' : '') +
' could not be created: ' + msg;
@ -182,37 +185,45 @@ angular.module('copayApp.controllers').controller('SendController',
return;
}
if (isCordova) {
window.plugins.spinnerDialog.show(null, 'Creating transaction...', true);
}
$scope.loading = true;
$scope.creatingTX = true;
if ($scope.isWindowsPhoneApp)
$rootScope.wpInputFocused = true;
$rootScope.wpInputFocused = true;
$timeout(function () {
var comment = form.comment.$modelValue;
var merchantData = $scope._merchantData;
var address, amount;
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
var comment = form.comment.$modelValue;
var merchantData = $scope._merchantData;
var address, amount;
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
}
w.spend({
merchantData: merchantData,
toAddress: address,
amountSat: amount,
comment: comment,
}, function (err, txid, status) {
if (isCordova) {
window.plugins.spinnerDialog.hide();
}
$scope.loading = false;
if ($scope.isWindowsPhoneApp)
$rootScope.wpInputFocused = false;
w.spend({
merchantData: merchantData,
toAddress: address,
amountSat: amount,
comment: comment,
}, function (err, txid, status) {
$scope.loading = false;
$scope.creatingTX = false;
if ($scope.isWindowsPhoneApp)
$rootScope.wpInputFocused = false;
if (err)
return $scope.setError(err);
txStatus.notify(status);
$scope.resetForm();
});
}, 1);
if (err) {
$scope.setError(err);
}
else {
txStatus.notify(status);
$scope.resetForm();
}
});
}, 100);
};
// QR code Scanner