add warning for old wallets

This commit is contained in:
Matias Alejo Garcia 2014-10-11 14:33:45 -03:00
parent b03a3f1391
commit dd0dc9c6ad
4 changed files with 56 additions and 7 deletions

View File

@ -2,6 +2,24 @@
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager) {
controllerUtils.redirIfLogged();
$scope.retreiving = true;
copay.Identity.anyProfile({
pluginManager: pluginManager,
}, function(anyProfile) {
copay.Identity.anyWallet({
pluginManager: pluginManager,
}, function(anyWallet) {
$scope.retreiving = false;
$scope.anyProfile = anyProfile;
console.log('[createProfile.js.15:anyProfile:]',anyProfile); //TODO
$scope.anyWallet = anyWallet;
console.log('[createProfile.js.17:anyWallet:]',anyWallet); //TODO
});
});
$scope.createProfile = function(form) {
if (form && form.$invalid) {
@ -15,7 +33,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
networkName: config.networkName,
walletDefaults: config.wallet,
passphrase: config.passphrase,
}, function(err, iden , firstWallet) {
}, function(err, iden, firstWallet) {
controllerUtils.bindProfile($scope, iden, firstWallet);
});
}

View File

@ -105,13 +105,22 @@ Identity._getStorage = function(opts, password) {
* @param opts.storageOpts
* @param cb
*/
Identity.anyProfile = function(opts, cb) {
var storage = Identity._getStorage(opts);
Profile.any(storage,cb);
};
/**
* check if any wallet exists on storage
*
* @param opts.storageOpts
* @param cb
*/
Identity.anyWallet = function(opts, cb) {
var storage = Identity._getStorage(opts);
Wallet.any(storage,cb);
};
/**
* creates and Identity
*

View File

@ -166,6 +166,19 @@ Wallet.COPAYER_PAIR_LIMITS = {
12: 1,
};
Wallet.key = function(str) {
return 'wallet::' + str;
};
Wallet.any = function(storage, cb) {
storage.getFirst(Wallet.key(''), function(err, val) {
return cb(val ? true : false);
});
};
/* for stubbing */
Wallet._newInsight = function(opts) {
return new Insight(opts);
@ -217,7 +230,7 @@ Wallet.getMaxRequiredCopayers = function(totalCopayers) {
Wallet.delete = function(walletId, storage, cb) {
preconditions.checkArgument(cb);
storage.deletePrefix('wallet::' + walletId, function(err) {
storage.deletePrefix(Wallet.key(walletId), function(err) {
if (err) return cb(err);
storage.deletePrefix(walletId + '::', function(err) {
return cb(err);
@ -245,7 +258,7 @@ Wallet.read = function(walletId, readOpts, cb) {
err;
var obj = {};
storage.getFirst('wallet::' + walletId, function(err, ret) {
storage.getFirst(Wallet.key(walletId), function(err, ret) {
if (err) return cb(err);
if (!ret)
@ -1023,7 +1036,7 @@ Wallet.prototype.store = function(cb) {
this.keepAlive();
var val = this.toObj();
var key = 'wallet::' + this.id + ((val.opts && val.opts.name) ? '_' + val.opts.name : '');
var key = Wallet.key(this.id + ((val.opts && val.opts.name) ? '_' + val.opts.name : ''));
this.storage.set(key, val, function(err) {
log.debug('Wallet:' + self.id + ' stored');
if (cb)

View File

@ -1,6 +1,15 @@
<div class="createProfile" ng-controller="CreateProfileController">
<div class="m30a" style="width:50%" ng-show="anyWallet && !anyProfile">
<div class="left">
<i class="size-36 fi-alert"></i>
</div>
<div>
Copay now needs a profile to access your wallets. <br>
You can import current your wallets after creating your profile.
</div>
</div>
<p>( TODO2: if user has wallets (wallet::) show message: Copay now needs a profile to ... , you can import your wallets after creating your profile )
<div data-alert class="loading-screen" ng-show="retreiving">
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
Retreiving information from storage...