Merge branch 'master' into bugs/ui-07

This commit is contained in:
bechi 2014-10-30 16:56:26 -03:00
commit 11ab17ec94
13 changed files with 67 additions and 81 deletions

View file

@ -2,9 +2,7 @@
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) { angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
controllerUtils.redirIfLogged(); controllerUtils.redirIfLogged();
$scope.retreiving = true; $scope.retreiving = false;
identityService.check($scope);
$scope.createProfile = function(form) { $scope.createProfile = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {

View file

@ -1,11 +1,11 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) { angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService, Compatibility) {
controllerUtils.redirIfLogged(); controllerUtils.redirIfLogged();
$scope.retreiving = true;
identityService.check($scope);
$scope.confirmedEmail = getParam('confirmed'); $scope.confirmedEmail = getParam('confirmed');
$scope.retreiving = false;
Compatibility.check($scope);
$scope.openProfile = function(form) { $scope.openProfile = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields'); notification.error('Error', 'Please enter the required fields');

View file

@ -8,6 +8,8 @@ angular.module('copayApp.controllers').controller('ImportController',
$scope.hideAdv = true; $scope.hideAdv = true;
$scope.is_iOS = isMobile.iOS(); $scope.is_iOS = isMobile.iOS();
Compatibility.check($scope);
var reader = new FileReader(); var reader = new FileReader();
var updateStatus = function(status) { var updateStatus = function(status) {
@ -65,7 +67,7 @@ angular.module('copayApp.controllers').controller('ImportController',
reader.onloadend = function(evt) { reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2 if (evt.target.readyState == FileReader.DONE) { // DONE == 2
var encryptedObj = evt.target.result; var encryptedObj = evt.target.result;
Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {}, copay.Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {},
function(err, wallet){ function(err, wallet){
if (err) { if (err) {
notification.error('Error', 'Could not read wallet. Please check your password'); notification.error('Error', 'Could not read wallet. Please check your password');
@ -91,8 +93,13 @@ angular.module('copayApp.controllers').controller('ImportController',
var backupFile = $scope.file; var backupFile = $scope.file;
var backupText = form.backupText.$modelValue; var backupText = form.backupText.$modelValue;
var backupOldWallet = form.backupOldWallet.$modelValue;
var password = form.password.$modelValue; var password = form.password.$modelValue;
if (backupOldWallet) {
backupText = backupOldWallet.value;
}
if (!backupFile && !backupText) { if (!backupFile && !backupText) {
$scope.loading = false; $scope.loading = false;
notification.error('Error', 'Please, select your backup file'); notification.error('Error', 'Please, select your backup file');
@ -104,11 +111,12 @@ angular.module('copayApp.controllers').controller('ImportController',
reader.readAsBinaryString(backupFile); reader.readAsBinaryString(backupFile);
} }
else { else {
Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {}, copay.Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {},
function(err, wallet){ function(err, wallet){
if (err) { if (err) {
notification.error('Error', 'Could not read wallet. Please check your password'); notification.error('Error', 'Could not read wallet. Please check your password');
} else { } else {
copay.Compatibility.deleteOldWallet(backupOldWallet);
controllerUtils.installWalletHandlers($scope, wallet); controllerUtils.installWalletHandlers($scope, wallet);
controllerUtils.setFocusedWallet(wallet); controllerUtils.setFocusedWallet(wallet);
return; return;
@ -118,7 +126,7 @@ angular.module('copayApp.controllers').controller('ImportController',
try { try {
_importBackup(backupText); _importBackup(backupText);
} catch(e) { } catch(e) {
Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals); copay.Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals);
} }
} }
}; };

View file

@ -20,6 +20,7 @@ Compatibility._getWalletIds = function(cb) {
preconditions.checkArgument(cb); preconditions.checkArgument(cb);
var walletIds = []; var walletIds = [];
var uniq = {}; var uniq = {};
var key;
for (key in localStorage) { for (key in localStorage) {
var split = key.split('::'); var split = key.split('::');
if (split.length == 2) { if (split.length == 2) {
@ -111,7 +112,9 @@ Compatibility.getWallets_Old = function(cb) {
Compatibility.getWallets2 = function(cb) { Compatibility.getWallets2 = function(cb) {
var self = this; var self = this;
var re = /wallet::([^_]+)(_?(.*))/; var re = /wallet::([^_]+)(_?(.*))/;
var va = /^{+/;
var key;
var keys = []; var keys = [];
for (key in localStorage) { for (key in localStorage) {
keys.push(key); keys.push(key);
@ -120,11 +123,15 @@ Compatibility.getWallets2 = function(cb) {
if (key.indexOf('wallet::') !== 0) if (key.indexOf('wallet::') !== 0)
return null; return null;
var match = key.match(re); var match = key.match(re);
var matchValue = localStorage[key].match(va);
if (match.length != 4) if (match.length != 4)
return null; return null;
if (matchValue)
return null;
return { return {
id: match[1], id: match[1],
name: match[3] ? match[3] : undefined, name: match[3] ? match[3] : undefined,
value: localStorage[key]
}; };
})); }));
@ -186,7 +193,7 @@ Compatibility.readWalletPre8 = function(walletId, password, cb) {
}; };
Compatibility.importEncryptedWallet = function(identity, cypherText, password, opts, cb) { Compatibility.importEncryptedWallet = function(identity, cypherText, password, opts, cb) {
var crypto = opts.cryptoUtil || cryptoUtils; var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
var key = crypto.kdf(password); var key = crypto.kdf(password);
var obj = crypto.decrypt(key, cypherText); var obj = crypto.decrypt(key, cypherText);
if (!obj) { if (!obj) {
@ -227,5 +234,10 @@ Compatibility.kdf = function(password) {
return sbase64; return sbase64;
}; };
Compatibility.deleteOldWallet = function(walletObj) {
localStorage.removeItem('wallet::'+walletObj.id+'_'+walletObj.name);
log.info('Old wallet ' + walletObj.name + ' deleted: ' + walletObj.id);
};
module.exports = Compatibility; module.exports = Compatibility;

View file

@ -490,20 +490,6 @@ Identity.prototype.addWallet = function(wallet, cb) {
this.storage.setItem(wallet.getStorageKey(), wallet.toObj(), cb); this.storage.setItem(wallet.getStorageKey(), wallet.toObj(), cb);
}; };
/**
* check if any profile exists on storage
* @param opts.storageOpts
* @param cb
*/
Identity.checkIfExistsAny = function(opts, cb) {
var storage = opts.storage || opts.pluginManager.get('DB');
storage.getFirst(Identity.getStoragePrefix(), {
onlyKey: true
}, function(err, v, k) {
return cb(k ? true : false);
});
};
/** /**
* @desc Checks if a version is compatible with the current version * @desc Checks if a version is compatible with the current version
* @param {string} inVersion - a version, with major, minor, and revision, period-separated (x.y.z) * @param {string} inVersion - a version, with major, minor, and revision, period-separated (x.y.z)

View file

@ -178,20 +178,6 @@ Wallet.prototype.getStorageKey = function() {
return Wallet.getStorageKey(this.getId()); return Wallet.getStorageKey(this.getId());
}; };
/**
* check if any wallet exists on storage
* @param opts.storageOpts
* @param cb
*/
Wallet.checkIfExistsAny = function(opts, cb) {
var storage = opts.storage || opts.pluginManager.get('DB');
storage.getFirst(Wallet.getStoragePrefix(), {
onlyKey: true
}, function(err, v, k) {
return cb(k ? true : false);
});
};
/* for stubbing */ /* for stubbing */
Wallet._newInsight = function(opts) { Wallet._newInsight = function(opts) {
return new Insight(opts); return new Insight(opts);

View file

@ -1,5 +1,13 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('Compatibility', function() { angular.module('copayApp.services').factory('Compatibility', function($rootScope) {
return require('copay').Compatibility; var root = {};
root.check = function (scope) {
copay.Compatibility.listWalletsPre8(function(wallets) {
scope.anyWallet = wallets.length > 0 ? true : false;
scope.oldWallets = wallets;
});
};
return root;
}); });

View file

@ -4,24 +4,6 @@ angular.module('copayApp.services')
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) { .factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
var root = {}; var root = {};
root.check = function (scope) {
copay.Identity.checkIfExistsAny({
pluginManager: pluginManager,
}, function(anyProfile) {
copay.Wallet.checkIfExistsAny({
pluginManager: pluginManager,
}, function(anyWallet) {
scope.retreiving = false;
scope.anyProfile = anyProfile ? true : false;
scope.anyWallet = anyWallet ? true : false;
if (!scope.anyProfile) {
$location.path('/createProfile');
}
});
});
};
root.create = function(scope, form) { root.create = function(scope, form) {
var iden = copay.Identity.create({ var iden = copay.Identity.create({
email: form.email.$modelValue, email: form.email.$modelValue,

View file

@ -9,15 +9,6 @@
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59"> <img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
<div ng-include="'views/includes/version.html'"></div> <div ng-include="'views/includes/version.html'"></div>
</div> </div>
<div class="p10 box-setup bg-success m10b" ng-show="anyWallet && !anyProfile">
<div class="left">
<i class="size-36 fi-alert m10r"></i>
</div>
<div class="size-12" translate>
<b>Copay now needs a profile to access wallets.</b>
You can import your current wallets after creating your frofile
</div>
</div>
<div class="box-setup"> <div class="box-setup">
<h1 translate>Create Profile</h1> <h1 translate>Create Profile</h1>
<form name="profileForm" ng-submit="createProfile(profileForm)" novalidate> <form name="profileForm" ng-submit="createProfile(profileForm)" novalidate>
@ -62,11 +53,7 @@
</form> </form>
<div class="box-setup-footer"> <div class="box-setup-footer">
<div class="left"> <div class="left">
<a ng-show="!anyProfile" class="text-gray" href="https://copay.io"> <a class="text-gray" href="#!/">
<i class="m5r fi-arrow-left"></i>
<span translate>Back to</span> copay.io
</a>
<a ng-show="anyProfile" class="text-gray" href="#!/">
<i class="fi-arrow-left"></i> <i class="fi-arrow-left"></i>
<span translate>Back</span> <span translate>Back</span>
</a> </a>

View file

@ -11,13 +11,21 @@
</div> </div>
<div class="p10 box-setup bg-success m10b" ng-show="confirmedEmail"> <div class="p10 box-setup bg-success m10b" ng-show="confirmedEmail">
<div class="left"> <div class="left">
<i class="size-36 fi-alert m10r"></i> <i class="size-36 fi-alert m10r"></i>
</div> </div>
<div class="size-12" translate> <div class="size-12">
<b>Copay now needs a confirmation.</b><br /> <b>Copay now needs a confirmation.</b><br />
You have to sign in to confirm your email You have to sign in to confirm your email
</div> </div>
</div> </div>
<div class="p10 box-setup bg-success m10b" ng-show="anyWallet">
<div class="left">
<i class="size-36 fi-alert m10r"></i>
</div>
<b>Copay now needs a profile to access wallets.</b>
You can import your current wallets after
<a class="text-white" href="#!/createProfile">creating your profile</a>
</div>
<div class="box-setup"> <div class="box-setup">
<h1><span translate>Sign in to</span> <b>Copay</b></h1> <h1><span translate>Sign in to</span> <b>Copay</b></h1>
<form name="loginForm" ng-submit="openProfile(loginForm)" novalidate> <form name="loginForm" ng-submit="openProfile(loginForm)" novalidate>

View file

@ -9,7 +9,7 @@
<h1 class="hide-for-large-up">{{$root.title}}</h1> <h1 class="hide-for-large-up">{{$root.title}}</h1>
<form name="importForm" ng-submit="import(importForm)" novalidate> <form name="importForm" ng-submit="import(importForm)" novalidate>
<div ng-show="!is_iOS"> <div ng-show="!is_iOS && !backupOldWallet">
<legend for="backupFile" class="m10b"> <legend for="backupFile" class="m10b">
<span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i> <span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i>
</legend> </legend>
@ -17,7 +17,7 @@
placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select> placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select>
</div> </div>
<div ng-show="is_iOS"> <div ng-show="is_iOS && !backupOldWallet">
<label for="backupText" class="m10b"> <label for="backupText" class="m10b">
<span translate>Paste backup plain text code</span> <i class="fi-clipboard"></i> <span translate>Paste backup plain text code</span> <i class="fi-clipboard"></i>
</label> </label>
@ -27,6 +27,16 @@
rows="5"></textarea> rows="5"></textarea>
</div> </div>
<div ng-show="anyWallet && (!backupFile || !backupText)">
<label for="backupOldWAllet" class="m10b size-14">
<span translate>You have old wallets in your localStorage. Choose one to import</span> <i class="fi-bitcoin"></i>
</label>
<select ng-model="backupOldWallet" name="backupOldWallet"
ng-options="wallet.name for wallet in oldWallets">
<option value="">-- choose wallet --</option>
</select>
</div>
<label for="password" class="m10b"><span translate>Password</span> <small translate>Required</small></label> <label for="password" class="m10b"><span translate>Password</span> <small translate>Required</small></label>
<input type="password" class="form-control" <input type="password" class="form-control"

View file

@ -39,7 +39,8 @@
<div class="col2"> <div class="col2">
<a class="size-12 wallet-item" ng-click="switchWallet(item.id)"> <a class="size-12 wallet-item" ng-click="switchWallet(item.id)">
<div class="oh"> <div class="oh">
<div class="right size-10 type-wallet">[ {{item.totalCopayers}} of {{item.requiredCopayers}} ]</div> <div class="right size-10 type-wallet">
[ {{item.requiredCopayers}} of {{item.totalCopayers}} ]</div>
<div class="ellipsis name-wallet">{{item.name || item.id}}</div> <div class="ellipsis name-wallet">{{item.name || item.id}}</div>
</div> </div>
<div class="oh"> <div class="oh">

View file

@ -5,7 +5,7 @@
</div> </div>
<div class="col2"> <div class="col2">
<div class="oh m5t m10r"> <div class="oh m5t m10r">
<div class="right size-10">[ {{$root.wallet.totalCopayers}} of {{$root.wallet.requiredCopayers}} ]</div> <div class="right size-10">[ {{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ]</div>
<div class="name-wallet"> <div class="name-wallet">
<a ng-click="refresh()"> <a ng-click="refresh()">
<i class="fi-refresh right"></i> <i class="fi-refresh right"></i>
@ -62,7 +62,7 @@
<div class="col2"> <div class="col2">
<a class="size-12 wallet-item" ng-click="switchWallet(item.id)"> <a class="size-12 wallet-item" ng-click="switchWallet(item.id)">
<div class="oh"> <div class="oh">
<div class="right size-10 type-wallet">[ {{item.totalCopayers}} of {{item.requiredCopayers}} ]</div> <div class="right size-10 type-wallet">[ {{item.requiredCopayers}} of {{item.totalCopayers}} ]</div>
<div class="ellipsis name-wallet">{{item.name || item.id}}</div> <div class="ellipsis name-wallet">{{item.name || item.id}}</div>
</div> </div>
<div class="oh"> <div class="oh">