add notification saying backup was created

This commit is contained in:
Manuel Araoz 2014-06-17 11:33:43 -03:00
commit 718ae69576
2 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,8 @@
'use strict'; 'use strict';
var BackupService = function() {}; var BackupService = function($notification) {
this.notifications = $notification;
};
BackupService.prototype.getName = function(wallet) { BackupService.prototype.getName = function(wallet) {
return (wallet.name ? (wallet.name+'-') : '') + wallet.id; return (wallet.name ? (wallet.name+'-') : '') + wallet.id;
@ -11,6 +13,7 @@ BackupService.prototype.download = function(wallet) {
var timestamp = +(new Date()); var timestamp = +(new Date());
var walletName = this.getName(wallet); var walletName = this.getName(wallet);
var filename = walletName + '-' + timestamp + '-keybackup.json.aes'; var filename = walletName + '-' + timestamp + '-keybackup.json.aes';
this.notifications.success('Backup created', 'Encrypted backup file saved.');
var blob = new Blob([ew], { var blob = new Blob([ew], {
type: 'text/plain;charset=utf-8' type: 'text/plain;charset=utf-8'
}); });
@ -44,4 +47,4 @@ BackupService.prototype.sendEmail = function(email, wallet) {
} }
}; };
angular.module('copayApp.services').value('backupService', new BackupService()); angular.module('copayApp.services').service('backupService', BackupService);

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('notifications', []). angular.module('notifications', []).
factory('$notification', ['$timeout',function($timeout){ factory('$notification', ['$timeout',function($timeout, $rootScope){
var notifications = JSON.parse(localStorage.getItem('$notifications')) || [], var notifications = JSON.parse(localStorage.getItem('$notifications')) || [],
queue = []; queue = [];
@ -197,7 +197,9 @@ angular.module('notifications', []).
clear: function(){ clear: function(){
notifications = []; notifications = [];
this.save(); this.save();
} },
init: function() {}
}; };
}]). }]).