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>
</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 class="row">
@ -64,17 +75,6 @@
Connecting to wallet...
</div>
<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="large-6 columns">
<h3>Join a Network Wallet</h3>
@ -84,15 +84,44 @@
<button class="button primary expand round" type="button" ng-click="join(connectionId)">Join</button>
</div>
</div>
<hr>
<div class="row">
<div class="large-6 columns">
<h3>Create a New Wallet</h3>
<div ng-show="!walletIds.length">
<div class="row">
<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 class="large-3 columns">
<button class="button secondary expand round" ng-click="create()">Create</button>
<hr>
<div class="row">
<div class="text-center">
<a ng-click="import()">Import from file</a>
</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>
</script>
@ -127,6 +156,11 @@
</button>
</div>
</div>
<div class="row">
<div class="text-center">
<a href="#signin">Go back</a>
</div>
</div>
</div>
</div>
</script>
@ -143,28 +177,23 @@
<p class="panel panel-sign"> <i class="fi-page-copy size-22"></i> </p>
</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 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">
<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.peerId">{{copayer}}</span>
<span ng-if="copayer == $root.wallet.network.peerId"> You ({{copayer}})<i class="fi-check size-24"></i></span>
<span ng-if="copayer !== $root.wallet.network.peerId">{{copayer}}</span>
<span>
<i class="fi-check size-16 panel-sign right p5h br100"></i>
</span>
</li>
</ul>
<div class="text-center">
<button href="#/home" class="button secondary round right">Go to home</button>
</div>
</div>
</div>
</script>
@ -309,6 +338,17 @@
</div>
</div>
</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 email</div> -->
<!-- NOT FOUND -->

View file

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

View file

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

View file

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