Storing the backup flag
This commit is contained in:
parent
d0c5e16865
commit
52fb680658
6 changed files with 34 additions and 98 deletions
|
|
@ -14,7 +14,7 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
|||
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
|
||||
$scope.hideViewProfileBackup = true;
|
||||
};
|
||||
|
||||
|
||||
$scope.deleteWallet = function(w) {
|
||||
if (!w) return;
|
||||
identityService.deleteWallet(w, function(err) {
|
||||
|
|
@ -28,8 +28,8 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
|||
|
||||
$scope.init = function() {
|
||||
if ($rootScope.quotaPerItem) {
|
||||
$scope.perItem = $filter('noFractionNumber')($rootScope.quotaPerItem/1000,1);
|
||||
$scope.nrWallets =parseInt($rootScope.quotaItems) - 1;
|
||||
$scope.perItem = $filter('noFractionNumber')($rootScope.quotaPerItem / 1000, 1);
|
||||
$scope.nrWallets = parseInt($rootScope.quotaItems) - 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -37,13 +37,13 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
|||
if (!$rootScope.iden) return;
|
||||
|
||||
var wallets = $rootScope.iden.listWallets();
|
||||
var max =$rootScope.quotaPerItem;
|
||||
var max = $rootScope.quotaPerItem;
|
||||
|
||||
_.each(wallets, function(w) {
|
||||
var bits = w.sizes().total;
|
||||
w.kb = $filter('noFractionNumber')(bits/1000, 1);
|
||||
w.kb = $filter('noFractionNumber')(bits / 1000, 1);
|
||||
if (max) {
|
||||
w.usage = $filter('noFractionNumber')(bits/max * 100, 0);
|
||||
w.usage = $filter('noFractionNumber')(bits / max * 100, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -73,15 +73,15 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
|||
});
|
||||
};
|
||||
|
||||
$scope.deleteProfile = function () {
|
||||
identityService.deleteProfile(function (err, res) {
|
||||
$scope.deleteProfile = function() {
|
||||
identityService.deleteProfile(function(err, res) {
|
||||
if (err) {
|
||||
log.warn(err);
|
||||
notification.error('Error', 'Could not delete profile');
|
||||
return;
|
||||
}
|
||||
$location.path('/');
|
||||
setTimeout(function () {
|
||||
$location.path('/');
|
||||
setTimeout(function() {
|
||||
notification.error('Success', 'Profile successfully deleted');
|
||||
}, 1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -274,10 +274,17 @@ Identity.prototype.toObj = function() {
|
|||
|
||||
Identity.prototype.exportEncryptedWithWalletInfo = function(opts) {
|
||||
var crypto = opts.cryptoUtil || cryptoUtil;
|
||||
this.backupNeeded = false;
|
||||
|
||||
return crypto.encrypt(this.password, this.exportWithWalletInfo(opts));
|
||||
};
|
||||
|
||||
Identity.prototype.setBackupDone = function() {
|
||||
this.backupNeeded = false;
|
||||
this.store({
|
||||
noWallets: true
|
||||
}, function() {});
|
||||
}
|
||||
|
||||
Identity.prototype.exportWithWalletInfo = function(opts) {
|
||||
return _.extend({
|
||||
wallets: _.map(this.wallets, function(wallet) {
|
||||
|
|
@ -295,12 +302,13 @@ Identity.prototype.exportWithWalletInfo = function(opts) {
|
|||
Identity.prototype.store = function(opts, cb) {
|
||||
var self = this;
|
||||
opts = opts || {};
|
||||
opts.backupNeeded = false;
|
||||
|
||||
var storeFunction = opts.failIfExists ? self.storage.createItem : self.storage.setItem;
|
||||
|
||||
storeFunction.call(self.storage, this.getId(), this.toObj(), function(err) {
|
||||
if (err) return cb(err);
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (opts.noWallets)
|
||||
return cb();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ BackupService.prototype.profileEncrypted = function(iden) {
|
|||
|
||||
BackupService.prototype.profileDownload = function(iden) {
|
||||
var ew = this.profileEncrypted(iden);
|
||||
iden.setBackupDone();
|
||||
var name = iden.fullName;
|
||||
var filename = name + '-profile.json';
|
||||
this._download(ew, name, filename)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ angular.module('copayApp.services')
|
|||
passphraseConfig: config.passphraseConfig,
|
||||
failIfExists: true,
|
||||
}, function(err, iden) {
|
||||
|
||||
if (err) return cb(err);
|
||||
preconditions.checkState(iden);
|
||||
root.bind(iden);
|
||||
|
|
@ -68,19 +69,19 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.setServerStatus = function(headers) {
|
||||
if (!headers)
|
||||
if (!headers)
|
||||
return;
|
||||
|
||||
if (headers['X-Email-Needs-Validation'])
|
||||
$rootScope.needsEmailConfirmation = true;
|
||||
if (headers['X-Email-Needs-Validation'])
|
||||
$rootScope.needsEmailConfirmation = true;
|
||||
else
|
||||
$rootScope.needsEmailConfirmation = null;
|
||||
$rootScope.needsEmailConfirmation = null;
|
||||
|
||||
if (headers['X-Quota-Per-Item'])
|
||||
$rootScope.quotaPerItem = parseInt(headers['X-Quota-Per-Item']);
|
||||
if (headers['X-Quota-Per-Item'])
|
||||
$rootScope.quotaPerItem = parseInt(headers['X-Quota-Per-Item']);
|
||||
|
||||
if (headers['X-Quota-Items-Limit'])
|
||||
$rootScope.quotaItems = parseInt(headers['X-Quota-Items-Limit']);
|
||||
if (headers['X-Quota-Items-Limit'])
|
||||
$rootScope.quotaItems = parseInt(headers['X-Quota-Items-Limit']);
|
||||
};
|
||||
|
||||
root.open = function(email, password, cb) {
|
||||
|
|
@ -102,7 +103,7 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.deleteProfile = function (cb) {
|
||||
root.deleteProfile = function(cb) {
|
||||
$rootScope.iden.remove(null, cb);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue