replace flashmessage for notifications

This commit is contained in:
Manuel Araoz 2014-06-26 17:17:24 -03:00
commit e389a3f82c
4 changed files with 32 additions and 57 deletions

View file

@ -32,10 +32,8 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.submitForm = function(form) { $scope.submitForm = function(form) {
if (form.$invalid) { if (form.$invalid) {
$rootScope.$flashMessage = { var message = 'Unable to send transaction proposal.';
message: 'Unable to send a transaction proposal. Please, try again', notification.error('Error', message);
type: 'error'
};
return; return;
} }
@ -50,20 +48,16 @@ angular.module('copayApp.controllers').controller('SendController',
w.createTx(address, amount, commentText, function(ntxid) { w.createTx(address, amount, commentText, function(ntxid) {
if (w.totalCopayers > 1) { if (w.totalCopayers > 1) {
$scope.loading = false; $scope.loading = false;
$rootScope.$flashMessage = { var message = 'The transaction proposal has been created';
message: 'The transaction proposal has been created', notification.success('Success!', message);
type: 'success'
};
$rootScope.$digest(); $rootScope.$digest();
} else { } else {
w.sendTx(ntxid, function(txid) { w.sendTx(ntxid, function(txid) {
$rootScope.$flashMessage = txid ? { if (txid) {
type: 'success', notification.success('Transaction broadcast', 'Transaction id: ' + txid);
message: 'Transaction broadcasted. txid: ' + txid } else {
} : { notification.error('Error', 'There was an error sending the transaction.');
type: 'error', }
message: 'There was an error sending the Transaction'
};
$scope.loading = false; $scope.loading = false;
}); });
} }
@ -202,10 +196,11 @@ angular.module('copayApp.controllers').controller('SendController',
errorMsg = e.message; errorMsg = e.message;
} }
$rootScope.$flashMessage = { if (errorMsg) {
message: errorMsg ? errorMsg : 'Entry removed successful', notification.error('Error', errorMsg);
type: errorMsg ? 'error' : 'success' } else {
}; notification.success('Success', 'Entry removed successfully');
}
$rootScope.$digest(); $rootScope.$digest();
}, 500); }, 500);
}; };
@ -223,10 +218,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.submitAddressBook = function(form) { $scope.submitAddressBook = function(form) {
if (form.$invalid) { if (form.$invalid) {
$rootScope.$flashMessage = { notification.error('Form Error', 'Please complete required fields');
message: 'Complete required fields, please',
type: 'error'
};
return; return;
} }
var entry = { var entry = {
@ -255,10 +247,11 @@ angular.module('copayApp.controllers').controller('SendController',
errorMsg = e.message; errorMsg = e.message;
} }
$rootScope.$flashMessage = { if (errorMsg) {
message: errorMsg ? errorMsg : 'New entry has been created', notification.error('Error', errorMsg);
type: errorMsg ? 'error' : 'success' } else {
}; notification.success('Success', 'New entry has been created');
}
$rootScope.$digest(); $rootScope.$digest();
}, 500); }, 500);
$anchorScroll(); $anchorScroll();

View file

@ -68,10 +68,7 @@ angular.module('copayApp.controllers').controller('SetupController',
$scope.create = function(form) { $scope.create = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
$rootScope.$flashMessage = { notification.error('Error', 'Please enter the required fields');
message: 'Please, enter required fields',
type: 'error'
};
return; return;
} }
$scope.loading = true; $scope.loading = true;

View file

@ -30,7 +30,6 @@ angular.module('copayApp.directives')
link: function(scope, element, attrs, ctrl) { link: function(scope, element, attrs, ctrl) {
setTimeout(function() { setTimeout(function() {
scope.$apply(function() { scope.$apply(function() {
$rootScope.$flashMessage = {};
}); });
}, 5000); }, 5000);
} }

View file

@ -36,35 +36,27 @@ angular.module('copayApp.services')
root.onErrorDigest = function(scope, msg) { root.onErrorDigest = function(scope, msg) {
root.onError(scope); root.onError(scope);
if (msg) $rootScope.$flashMessage = { if (msg) {
type: 'error', notification.error('Error', msg);
message: msg }
};
$rootScope.$digest(); $rootScope.$digest();
}; };
root.installStartupHandlers = function(wallet, $scope) { root.installStartupHandlers = function(wallet, $scope) {
wallet.on('serverError', function(msg) { wallet.on('serverError', function(msg) {
$rootScope.$flashMessage = { notification.error('PeerJS Error', 'There was an error connecting to the PeerJS server.'
message: 'There was an error connecting to the PeerJS server.' + (msg || 'Check you settings and Internet connection.'), + (msg || 'Check you settings and Internet connection.'));
type: 'error',
};
root.onErrorDigest($scope); root.onErrorDigest($scope);
$location.path('addresses'); $location.path('addresses');
}); });
wallet.on('connectionError', function() { wallet.on('connectionError', function() {
var message = "Looks like you are already connected to this wallet, please logout from it and try importing it again."; var message = "Looks like you are already connected to this wallet, please logout and try importing it again.";
$rootScope.$flashMessage = { notification.error('PeerJS Error', message);
message: message,
type: 'error'
};
root.onErrorDigest($scope); root.onErrorDigest($scope);
}); });
wallet.on('serverError', function() { wallet.on('serverError', function() {
$rootScope.$flashMessage = { var message = 'The PeerJS server is not responding, please try again';
message: 'The PeerJS server is not responding, please try again', notification.error('PeerJS Error', message);
type: 'error'
};
root.onErrorDigest($scope); root.onErrorDigest($scope);
}); });
wallet.on('ready', function() { wallet.on('ready', function() {
@ -79,10 +71,7 @@ angular.module('copayApp.services')
$rootScope.isCollapsed = true; $rootScope.isCollapsed = true;
$rootScope.$watch('insightError', function(status) { $rootScope.$watch('insightError', function(status) {
if (status === -1) { if (status === -1) {
$rootScope.$flashMessage = { notification.success('Networking restored', 'Connection to Insight re-established');
type: 'success',
message: 'Networking Restored :)',
};
$rootScope.insightError = 0; $rootScope.insightError = 0;
} }
}); });
@ -117,10 +106,7 @@ angular.module('copayApp.services')
notification.enableHtml5Mode(); // for chrome: if support, enable it notification.enableHtml5Mode(); // for chrome: if support, enable it
w.on('badMessage', function(peerId) { w.on('badMessage', function(peerId) {
$rootScope.$flashMessage = { notification.error('Error', 'Received wrong message from peer ' + peerId);
type: 'error',
message: 'Received wrong message from peer id:' + peerId
};
}); });
w.on('ready', function(myPeerID) { w.on('ready', function(myPeerID) {
$rootScope.wallet = w; $rootScope.wallet = w;