Merge branch 'master' into bugs/ui-07
This commit is contained in:
commit
11ab17ec94
13 changed files with 67 additions and 81 deletions
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
|
||||
controllerUtils.redirIfLogged();
|
||||
$scope.retreiving = true;
|
||||
|
||||
identityService.check($scope);
|
||||
$scope.retreiving = false;
|
||||
|
||||
$scope.createProfile = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
'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();
|
||||
$scope.retreiving = true;
|
||||
|
||||
identityService.check($scope);
|
||||
$scope.confirmedEmail = getParam('confirmed');
|
||||
$scope.retreiving = false;
|
||||
Compatibility.check($scope);
|
||||
|
||||
$scope.openProfile = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.hideAdv = true;
|
||||
$scope.is_iOS = isMobile.iOS();
|
||||
|
||||
Compatibility.check($scope);
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
var updateStatus = function(status) {
|
||||
|
|
@ -65,7 +67,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
reader.onloadend = function(evt) {
|
||||
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
||||
var encryptedObj = evt.target.result;
|
||||
Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {},
|
||||
copay.Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {},
|
||||
function(err, wallet){
|
||||
if (err) {
|
||||
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 backupText = form.backupText.$modelValue;
|
||||
var backupOldWallet = form.backupOldWallet.$modelValue;
|
||||
var password = form.password.$modelValue;
|
||||
|
||||
if (backupOldWallet) {
|
||||
backupText = backupOldWallet.value;
|
||||
}
|
||||
|
||||
if (!backupFile && !backupText) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', 'Please, select your backup file');
|
||||
|
|
@ -104,11 +111,12 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
reader.readAsBinaryString(backupFile);
|
||||
}
|
||||
else {
|
||||
Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {},
|
||||
copay.Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {},
|
||||
function(err, wallet){
|
||||
if (err) {
|
||||
notification.error('Error', 'Could not read wallet. Please check your password');
|
||||
} else {
|
||||
copay.Compatibility.deleteOldWallet(backupOldWallet);
|
||||
controllerUtils.installWalletHandlers($scope, wallet);
|
||||
controllerUtils.setFocusedWallet(wallet);
|
||||
return;
|
||||
|
|
@ -118,7 +126,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
try {
|
||||
_importBackup(backupText);
|
||||
} catch(e) {
|
||||
Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals);
|
||||
copay.Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ Compatibility._getWalletIds = function(cb) {
|
|||
preconditions.checkArgument(cb);
|
||||
var walletIds = [];
|
||||
var uniq = {};
|
||||
var key;
|
||||
for (key in localStorage) {
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
|
|
@ -111,7 +112,9 @@ Compatibility.getWallets_Old = function(cb) {
|
|||
Compatibility.getWallets2 = function(cb) {
|
||||
var self = this;
|
||||
var re = /wallet::([^_]+)(_?(.*))/;
|
||||
var va = /^{+/;
|
||||
|
||||
var key;
|
||||
var keys = [];
|
||||
for (key in localStorage) {
|
||||
keys.push(key);
|
||||
|
|
@ -120,11 +123,15 @@ Compatibility.getWallets2 = function(cb) {
|
|||
if (key.indexOf('wallet::') !== 0)
|
||||
return null;
|
||||
var match = key.match(re);
|
||||
var matchValue = localStorage[key].match(va);
|
||||
if (match.length != 4)
|
||||
return null;
|
||||
if (matchValue)
|
||||
return null;
|
||||
return {
|
||||
id: match[1],
|
||||
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) {
|
||||
var crypto = opts.cryptoUtil || cryptoUtils;
|
||||
var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
|
||||
var key = crypto.kdf(password);
|
||||
var obj = crypto.decrypt(key, cypherText);
|
||||
if (!obj) {
|
||||
|
|
@ -227,5 +234,10 @@ Compatibility.kdf = function(password) {
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -490,20 +490,6 @@ Identity.prototype.addWallet = function(wallet, 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
|
||||
* @param {string} inVersion - a version, with major, minor, and revision, period-separated (x.y.z)
|
||||
|
|
|
|||
|
|
@ -178,20 +178,6 @@ Wallet.prototype.getStorageKey = function() {
|
|||
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 */
|
||||
Wallet._newInsight = function(opts) {
|
||||
return new Insight(opts);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('Compatibility', function() {
|
||||
return require('copay').Compatibility;
|
||||
angular.module('copayApp.services').factory('Compatibility', function($rootScope) {
|
||||
var root = {};
|
||||
|
||||
root.check = function (scope) {
|
||||
copay.Compatibility.listWalletsPre8(function(wallets) {
|
||||
scope.anyWallet = wallets.length > 0 ? true : false;
|
||||
scope.oldWallets = wallets;
|
||||
});
|
||||
};
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,24 +4,6 @@ angular.module('copayApp.services')
|
|||
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
||||
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) {
|
||||
var iden = copay.Identity.create({
|
||||
email: form.email.$modelValue,
|
||||
|
|
|
|||
|
|
@ -8,16 +8,7 @@
|
|||
<div class="logo-setup">
|
||||
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
|
||||
<div ng-include="'views/includes/version.html'"></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>
|
||||
<div class="box-setup">
|
||||
<h1 translate>Create Profile</h1>
|
||||
<form name="profileForm" ng-submit="createProfile(profileForm)" novalidate>
|
||||
|
|
@ -62,11 +53,7 @@
|
|||
</form>
|
||||
<div class="box-setup-footer">
|
||||
<div class="left">
|
||||
<a ng-show="!anyProfile" class="text-gray" href="https://copay.io">
|
||||
<i class="m5r fi-arrow-left"></i>
|
||||
<span translate>Back to</span> copay.io
|
||||
</a>
|
||||
<a ng-show="anyProfile" class="text-gray" href="#!/">
|
||||
<a class="text-gray" href="#!/">
|
||||
<i class="fi-arrow-left"></i>
|
||||
<span translate>Back</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -11,13 +11,21 @@
|
|||
</div>
|
||||
<div class="p10 box-setup bg-success m10b" ng-show="confirmedEmail">
|
||||
<div class="left">
|
||||
<i class="size-36 fi-alert m10r"></i>
|
||||
<i class="size-36 fi-alert m10r"></i>
|
||||
</div>
|
||||
<div class="size-12" translate>
|
||||
<div class="size-12">
|
||||
<b>Copay now needs a confirmation.</b><br />
|
||||
You have to sign in to confirm your email
|
||||
</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">
|
||||
<h1><span translate>Sign in to</span> <b>Copay</b></h1>
|
||||
<form name="loginForm" ng-submit="openProfile(loginForm)" novalidate>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<h1 class="hide-for-large-up">{{$root.title}}</h1>
|
||||
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||
<div ng-show="!is_iOS">
|
||||
<div ng-show="!is_iOS && !backupOldWallet">
|
||||
<legend for="backupFile" class="m10b">
|
||||
<span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i>
|
||||
</legend>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select>
|
||||
</div>
|
||||
|
||||
<div ng-show="is_iOS">
|
||||
<div ng-show="is_iOS && !backupOldWallet">
|
||||
<label for="backupText" class="m10b">
|
||||
<span translate>Paste backup plain text code</span> <i class="fi-clipboard"></i>
|
||||
</label>
|
||||
|
|
@ -27,6 +27,16 @@
|
|||
rows="5"></textarea>
|
||||
</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>
|
||||
<input type="password" class="form-control"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@
|
|||
<div class="col2">
|
||||
<a class="size-12 wallet-item" ng-click="switchWallet(item.id)">
|
||||
<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>
|
||||
<div class="oh">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
<div class="col2">
|
||||
<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">
|
||||
<a ng-click="refresh()">
|
||||
<i class="fi-refresh right"></i>
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
<div class="col2">
|
||||
<a class="size-12 wallet-item" ng-click="switchWallet(item.id)">
|
||||
<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>
|
||||
<div class="oh">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue