add warning for old wallets

This commit is contained in:
Matias Alejo Garcia 2014-10-11 14:33:45 -03:00
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) { angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager) {
controllerUtils.redirIfLogged(); 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) { $scope.createProfile = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
@ -15,7 +33,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
networkName: config.networkName, networkName: config.networkName,
walletDefaults: config.wallet, walletDefaults: config.wallet,
passphrase: config.passphrase, passphrase: config.passphrase,
}, function(err, iden , firstWallet) { }, function(err, iden, firstWallet) {
controllerUtils.bindProfile($scope, iden, firstWallet); controllerUtils.bindProfile($scope, iden, firstWallet);
}); });
} }

View file

@ -105,13 +105,22 @@ Identity._getStorage = function(opts, password) {
* @param opts.storageOpts * @param opts.storageOpts
* @param cb * @param cb
*/ */
Identity.anyProfile = function(opts, cb) { Identity.anyProfile = function(opts, cb) {
var storage = Identity._getStorage(opts); var storage = Identity._getStorage(opts);
Profile.any(storage,cb); 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 * creates and Identity
* *

View file

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

View file

@ -1,6 +1,15 @@
<div class="createProfile" ng-controller="CreateProfileController"> <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"> <div data-alert class="loading-screen" ng-show="retreiving">
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i> <i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
Retreiving information from storage... Retreiving information from storage...