Merge pull request #78 from matiu/feature/signin

Feature/signin
This commit is contained in:
Gustavo Maximiliano Cortez 2014-04-17 15:23:33 -03:00
commit 805125cd54
4 changed files with 76 additions and 35 deletions

View file

@ -51,6 +51,17 @@
<a href="#" ng-click="clearFlashMessage()" class="button tiny">Dismiss</a> <a href="#" ng-click="clearFlashMessage()" class="button tiny">Dismiss</a>
</div> </div>
<div ng-if='$root.wallet && !$root.wallet.publicKeyRing.isComplete() && !loading' class="panel callout radius" >
<p class="panel panel-sign"> <i class="fi-alert size-40"></i>
NOTE: Your wallet is not complete yet.
{{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} keys are missing. Ask your copayers to join your session: <b>{{$root.wallet.network.peerId}}</b>
</p>
</div>
</div> </div>
<div class="row"> <div class="row">
@ -64,17 +75,6 @@
Connecting to wallet... Connecting to wallet...
</div> </div>
<div ng-show="!loading"> <div ng-show="!loading">
<div class="row">
<div class="large-6 columns">
<h3>Open a Existing Wallet</h3>
<select class="form-control" ng-model="selectedWalletId" ng-options="walletId for walletId in listWalletIds()">
</select>
</div>
<div class="large-3 columns">
<button class="button primary expand round" type="button" ng-click="open(selectedWalletId)">Open</button>
</div>
</div>
<hr>
<div class="row"> <div class="row">
<div class="large-6 columns"> <div class="large-6 columns">
<h3>Join a Network Wallet</h3> <h3>Join a Network Wallet</h3>
@ -84,15 +84,44 @@
<button class="button primary expand round" type="button" ng-click="join(connectionId)">Join</button> <button class="button primary expand round" type="button" ng-click="join(connectionId)">Join</button>
</div> </div>
</div> </div>
<hr> <hr>
<div class="row"> <div ng-show="!walletIds.length">
<div class="large-6 columns"> <div class="row">
<h3>Create a New Wallet</h3> <div class="large-6 columns">
<h3>Create a New Wallet</h3>
</div>
<div class="large-3 columns">
<button class="button secondary expand round" ng-click="create()">Create</button>
</div>
</div> </div>
<div class="large-3 columns"> <hr>
<button class="button secondary expand round" ng-click="create()">Create</button> <div class="row">
<div class="text-center">
<a ng-click="import()">Import from file</a>
</div>
</div> </div>
</div> </div>
<div ng-show="walletIds.length>0">
<div class="row">
<div class="large-6 columns">
<h3>Open a Existing Wallet</h3>
<select class="form-control" ng-model="selectedWalletId" ng-options="walletId for walletId in walletIds">
</select>
</div>
<div class="large-3 columns">
<button class="button primary expand round" type="button" ng-click="open(selectedWalletId)">Open</button>
</div>
</div>
<div class="row">
<div class="text-center">
<a ng-click="create()">Create a new wallet</a>
&middot; <a ng-click="import()">Import from file</a>
</div>
</div>
</div>
<hr>
</div> </div>
</div> </div>
</script> </script>
@ -127,6 +156,11 @@
</button> </button>
</div> </div>
</div> </div>
<div class="row">
<div class="text-center">
<a href="#signin">Go back</a>
</div>
</div>
</div> </div>
</div> </div>
</script> </script>
@ -143,28 +177,23 @@
<p class="panel panel-sign"> <i class="fi-page-copy size-22"></i> </p> <p class="panel panel-sign"> <i class="fi-page-copy size-22"></i> </p>
</div> </div>
</div> </div>
<ul class="no-bullet" style="font-size: 0.7rem;">
<li> [DEBUG] Pubkeys that you have: {{$root.wallet.publicKeyRing.registeredCopayers()}}
<li> [DEBUG] WalletId: {{$root.wallet.id}}
<li class="panel" style="word-wrap: break-word;" ng-repeat="pub in $root.wallet.publicKeyRing.copayersBIP32">
${{pub.extendedPublicKeyString()}}
</li>
</ul>
</div> </div>
<div class="large-6 columns p70l"> <div class="large-6 columns p70l">
<h3 class="panel-title">Copayers ({{$root.wallet.network.connectedPeers.length}}/{{$root.wallet.publicKeyRing.requiredCopayers}})</h3> <h3 class="panel-title">Online Copayers: {{$root.wallet.network.connectedPeers.length}}</h3>
<p class="panel panel-sign" ng-show="$root.wallet.publicKeyRing.requiredCopayers > $root.wallet.network.connectedPeers.length"> <i class="fi-alert size-28"></i>
{{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signning transactions
<ul class="no-bullet"> <ul class="no-bullet">
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers"> <li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers">
<span ng-if="copayer == $root.peerId"> You ({{$root.peerId}})<i class="fi-check size-24"></i></span> <span ng-if="copayer == $root.wallet.network.peerId"> You ({{copayer}})<i class="fi-check size-24"></i></span>
<span ng-if="copayer != $root.peerId">{{copayer}}</span> <span ng-if="copayer !== $root.wallet.network.peerId">{{copayer}}</span>
<span> <span>
<i class="fi-check size-16 panel-sign right p5h br100"></i> <i class="fi-check size-16 panel-sign right p5h br100"></i>
</span> </span>
</li> </li>
</ul> </ul>
<div class="text-center">
<button href="#/home" class="button secondary round right">Go to home</button>
</div>
</div> </div>
</div> </div>
</script> </script>
@ -309,6 +338,17 @@
</div> </div>
</div> </div>
</script> </script>
<div ng-show="$root.wallet" style="margin-top:200px">
<hr>
<p>
[DEBUG] WalletId: {{$root.wallet.id}}
<ul class="no-bullet">
<li class="panel" style="word-wrap: break-word;" ng-repeat="pub in $root.wallet.publicKeyRing.copayersBIP32">
${{pub.extendedPublicKeyString()}}
</ul>
</div>
<!-- / <div class="large-4 columns box-backup">Backup to Dropbox</div> <!-- / <div class="large-4 columns box-backup">Backup to Dropbox</div>
// <div class="large-4 columns box-backup">Backup to email</div> --> // <div class="large-4 columns box-backup">Backup to email</div> -->
<!-- NOT FOUND --> <!-- NOT FOUND -->

View file

@ -9,11 +9,9 @@ angular.module('copay.signin').controller('SigninController',
// $rootScope.peerId = peerData ? peerData.peerId : null; // $rootScope.peerId = peerData ? peerData.peerId : null;
$scope.loading = false; $scope.loading = false;
$scope.selectedWalletId = false; $scope.walletIds = walletFactory.getWalletIds();
$scope.listWalletIds = function() { $scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]:null;
return walletFactory.getWalletIds();
};
$scope.create = function() { $scope.create = function() {
$location.path('setup'); $location.path('setup');

View file

@ -156,7 +156,6 @@ WalletFactory.prototype.openRemote = function(peedId) {
opts.totalCopayers = totalCopayers; opts.totalCopayers = totalCopayers;
var w = new Wallet(opts); var w = new Wallet(opts);
w.store(); w.store();
this.addWalletId(w.id);
return w; return w;
}; };

View file

@ -54,13 +54,17 @@ Storage.prototype.remove = function(walletId, k) {
Storage.prototype.getWalletIds = function() { Storage.prototype.getWalletIds = function() {
var walletIds = []; var walletIds = [];
var uniq = {};
for (var i = 0; i < localStorage.length; i++) { for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i); var key = localStorage.key(i);
var split = key.split('::'); var split = key.split('::');
if (split.length == 2) { if (split.length == 2) {
var walletId = split[0]; var walletId = split[0];
walletIds.push(walletId); if (typeof uniq[walletId] === 'undefined' ) {
walletIds.push(walletId);
uniq[walletId] = 1;
}
} }
} }