Merge pull request #1769 from cmgustavo/bug/manage-profile-createWallet

Bug/manage profile create wallet
This commit is contained in:
Matias Alejo Garcia 2014-11-11 17:07:09 -03:00
commit 6926bb9b04
17 changed files with 175 additions and 165 deletions

View File

@ -128,7 +128,7 @@ header .alt-currency {
border-bottom-left-radius: 3px;
position: absolute;
right: 14px;
width: 100px;
width: 180px;
list-style-type: none;
top: 47px;nt
}

View File

@ -0,0 +1,5 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateWalletController', function($scope, $rootScope) {
$rootScope.title = 'Create Wallet';
});

View File

@ -1,36 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('ManageController', function($scope, $rootScope, $location, controllerUtils, backupService) {
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$rootScope.title = 'Manage wallets';
$scope.downloadBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewBackup = function() {
$scope.backupPlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewBackup = true;
};
$scope.getWallets = function() {
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
_.each(wids, function(wid) {
var w = $rootScope.iden.getWalletById(wid);
$scope.wallets.push(w);
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
}, true);
});
};
$scope.deleteWallet = function(w) {
if (!w) return;
$scope.loading = w.id;
controllerUtils.deleteWallet($scope, w, function() {
$scope.loading = false;
$scope.getWallets();
});
};
});

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('MoreController',
function($scope, $rootScope, $location, $filter, backupService, controllerUtils, notification, rateService) {
function($scope, $rootScope, $location, $filter, controllerUtils, notification, rateService) {
controllerUtils.redirIfNotComplete();
var w = $rootScope.wallet;
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
@ -76,26 +76,7 @@ angular.module('copayApp.controllers').controller('MoreController',
});
notification.success('Success', $filter('translate')('settings successfully updated'));
controllerUtils.updateBalance();
};
$scope.downloadBackup = function() {
backupService.walletDownload(w);
}
$scope.viewBackup = function() {
$scope.backupPlainText = backupService.walletEncrypted(w);
$scope.hideViewBackup = true;
};
$scope.deleteWallet = function() {
$scope.loading = true;
controllerUtils.deleteWallet($scope, $rootScope.wallet, function() {
$rootScope.wallet = null;
var lastFocused = $rootScope.iden.getLastFocusedWallet();
controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused);
$scope.loading = false;
});
};
};
$scope.purge = function(deleteAll) {
var removed = w.purgeTxProposals(deleteAll);

66
js/controllers/profile.js Normal file
View File

@ -0,0 +1,66 @@
'use strict';
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, controllerUtils, backupService) {
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$rootScope.title = 'Profile';
$scope.downloadProfileBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewProfileBackup = function() {
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewProfileBackup = true;
};
$scope.getWallets = function() {
if (!$rootScope.iden) return;
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
_.each(wids, function(wid) {
var w = $rootScope.iden.getWalletById(wid);
$scope.wallets.push(w);
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
}, true);
});
};
$scope.deleteWallet = function(w) {
if (!w) return;
$scope.loading = w.id;
controllerUtils.deleteWallet($scope, w, function() {
if ($rootScope.wallet.id === w.id) {
$rootScope.wallet = null;
var lastFocused = $rootScope.iden.getLastFocusedWallet();
controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused);
}
$scope.loading = false;
$scope.getWallets();
});
};
$scope.downloadWalletBackup = function(w) {
if (!w) return;
backupService.walletDownload(w);
}
$scope.viewWalletBackup = function(w) {
var ModalInstanceCtrl = function($scope, $modalInstance) {
if (!w) return;
$scope.backupWalletPlainText = backupService.walletEncrypted(w);
$scope.hideViewWalletBackup = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
$modal.open({
templateUrl: 'views/modals/backup-text.html',
windowClass: 'tiny',
controller: ModalInstanceCtrl
});
};
});

View File

@ -66,6 +66,7 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
};
$scope.getWallets = function() {
if (!$rootScope.iden) return;
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
_.each(wids, function(wid) {

View File

@ -73,8 +73,12 @@ angular
templateUrl: 'views/warning.html',
logged: true
})
.when('/manage', {
templateUrl: 'views/manage.html',
.when('/profile', {
templateUrl: 'views/profile.html',
logged: true
})
.when('/createWallet', {
templateUrl: 'views/createWallet.html',
logged: true
});

View File

@ -229,7 +229,7 @@ angular.module('copayApp.services')
if (w) {
root.setFocusedWallet(w);
} else {
$location.path('/manage');
$location.path('/createWallet');
}
$timeout(function() {
$rootScope.$digest()

View File

@ -57,7 +57,7 @@
<div class="text-right">
<a class="back-button m20r text-primary" href="#!/manage">
<a class="back-button m20r text-primary" href="#!/createWallet">
<i class="icon-arrow-left2 vm"></i>
<span translate>Back</span>
</a>

26
views/createWallet.html Normal file
View File

@ -0,0 +1,26 @@
<div class="backup" ng-controller="CreateWalletController">
<h1 class="hide-for-large-up">{{$root.title}}</h1>
<div class="row">
<div class="large-4 columns" >
<div class="panel text-center" ui-route="{{create}}">
<div><i class="size-72 fi-plus text-gray"></i></div>
<p class="text-gray">Create a new Wallet</p>
<a href="#!/create" class="button primary radius" title="Create"> {{'Create' | translate }} </a>
</div>
</div>
<div class="large-4 columns" ui-route="{{create}}">
<div class="panel text-center">
<div><i class="size-72 fi-torsos-all text-gray"></i></div>
<p class="text-gray">Join an existent Wallet</p>
<a href="#!/join" class="button secondary radius" title="Join"> {{'Join' | translate }} </a>
</div>
</div>
<div class="large-4 columns" ui-route="{{create}}">
<div class="panel text-center">
<div><i class="size-72 fi-download text-gray"></i></div>
<p class="text-gray">Import a Wallet to Copay</p>
<a href="#!/import" class="button black radius" title="Import"> {{'Import wallet' | translate }}</a>
</div>
</div>
</div>
</div>

View File

@ -83,7 +83,7 @@
<div class="text-right m20t">
<a class="back-button m20r text-black" href="#!/manage">
<a class="back-button m20r text-black" href="#!/createWallet">
<i class="icon-arrow-left2 vm"></i>
<span translate>Back</span>
</a>

View File

@ -22,11 +22,12 @@
<i class="icon-arrow-down size-16 vm"></i>
</a>
<ul ng-show="hoverMenu" ng-class="{'hover': hoverMenu}">
<li><a class="text-gray size-16" href="#!/profile" title="Profile">
<i class="fi-torso m10r"></i> {{'Profile'|translate}}</a></li>
<li><a class="text-gray size-16" href="#!/createWallet" title="Create Wallet">
<i class="fi-plus m10r"></i> {{'Create Wallet'|translate}}</a></li>
<li><a class="text-gray size-16" href="#!/" title="Close" ng-click="signout()">
<i class="fi-power m10r"></i> {{'Close'|translate}}</a></li>
</ul>
</div>
<div class="right">
<a class="button tiny secondary radius m0" href="#!/manage" title="Manage wallets"><i class="fi-plus"></i> {{'Manage wallets' | translate }}</a>
</div>

View File

@ -56,7 +56,8 @@
</li>
</ul>
<div class="off-canvas-list" ng-click="toggleWalletSelection()">
<a href="#!/manage" class="button-setup add-wallet db p20h" title="Create"><i class="m5r fi-plus"></i> {{'Add Wallet' | translate }} </a>
<a href="#!/createWallet" class="button-setup add-wallet db p20h"
title="Create"><i class="m5r fi-plus"></i> {{'Create Wallet' | translate }} </a>
</div>
</div>
<div class="line-t" ng-show="!walletSelection" ng-click="refresh()">
@ -88,8 +89,12 @@
</a>
</li>
<li>
<a ui-route="{{create}}" href="#!/manage" class="db p20h" title="Create">
<i class="size-24 m20r fi-plus"></i> {{'Manage wallets' | translate }} </a>
<a href="#!/profile" class="db p20h" title="Profile">
<i class="size-24 m20r fi-torso"></i> {{'Profile' | translate }} </a>
</li>
<li>
<a href="#!/createWallet" class="db p20h" title="Create">
<i class="size-24 m20r fi-plus"></i> {{'Create Wallet' | translate }} </a>
</li>
<li>
<a href="#!/" class="db p20h" title="Close"

View File

@ -70,7 +70,7 @@
</div>
<div class="text-right">
<a class="back-button m20r" href="#!/manage">
<a class="back-button m20r" href="#!/createWallet">
<i class="icon-arrow-left2 vm"></i>
<span translate>Back</span>
</a>

View File

@ -0,0 +1,14 @@
<div class="text-center">
<h1>Copy backup in a safe place</h1>
<div class="show-for-large-up">
<textarea readonly rows="7">{{backupWalletPlainText}}</textarea>
<span translate class="size-12">Copy to clipboard</span>
<span class="btn-copy" clip-copy="backupWalletPlainText"> </span>
</div>
<div class="hide-for-large-up">
<textarea rows="12">{{backupWalletPlainText}}</textarea>
</div>
<div translate class="m10t size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
</div>
<a class="close-reveal-modal" ng-click="cancel()">&#215;</a>

View File

@ -18,46 +18,6 @@
</div>
</form>
</div>
<div class="line-dashed-h m20b"></div>
<div class="row">
<div class="large-6 columns">
<div class="panel">
<h2><i class="fi-download m10r"></i> <span translate>Backup</span></h2>
<p translate class="text-gray">
It's important to backup your wallet so that you can recover it in case of disaster
</p>
<a translate class="button primary m0" ng-click="downloadBackup()"
ng-show="!isSafari">Download File</a>
<a translate class="button primary m0" ng-click="viewBackup()"
ng-show="isSafari && !hideViewBackup">View Backup</a>
<div ng-show="backupPlainText">
<div class="show-for-large-up">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
</div>
<div class="hide-for-large-up">
<textarea rows="10">{{backupPlainText}}</textarea>
</div>
<div translate class="m10t size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
</div>
</div>
</div>
<div class="large-6 columns">
<div class="panel">
<h2><i class="fi-minus-circle m10r"></i> <span translate>Delete Wallet</span></h2>
<p translate class="text-gray">If all funds have been removed from your wallet and you do not wish to have the wallet data stored on your computer anymore, you can delete your wallet.</p>
<a class="button warning m0"
ng-really-message="{{'Are you sure you want to delete this wallet?'|translate}}"
ng-really-click="deleteWallet()"
ng-class="{'disabled':loading}">
<span ng-show="!loading">Delete</span>
<span ng-show="loading">Deleting...</span>
</a>
</div>
</div>
</div>
<div class="line-dashed-h m20b"></div>

View File

@ -1,33 +1,33 @@
<div class="backup" ng-controller="ManageController">
<div class="backup" ng-controller="ProfileController">
<h1 class="hide-for-large-up">{{$root.title}}</h1>
<div class="row">
<div class="large-4 columns" >
<div class="panel text-center" ui-route="{{create}}">
<div><i class="size-72 fi-plus text-gray"></i></div>
<p class="text-gray">Create a new Wallet</p>
<a href="#!/create" class="button primary radius" title="Create"> {{'Create' | translate }} </a>
</div>
</div>
<div class="large-4 columns" ui-route="{{create}}">
<div class="panel text-center">
<div><i class="size-72 fi-torsos-all text-gray"></i></div>
<p class="text-gray">Join an existent Wallet</p>
<a href="#!/join" class="button secondary radius" title="Join"> {{'Join' | translate }} </a>
</div>
</div>
<div class="large-4 columns" ui-route="{{create}}">
<div class="panel text-center">
<div><i class="size-72 fi-download text-gray"></i></div>
<p class="text-gray">Import a Wallet to Copay</p>
<a href="#!/import" class="button black radius" title="Import"> {{'Import wallet' | translate }}</a>
</div>
<div class="large-12 columns">
<div class="panel">
<h2><i class="fi-download m10r"></i> <span translate>Backup Profile</span></h2>
<p translate class="text-gray">It's important to backup your profile so that you can recover it in case of disaster. The backup will include all your profile's wallets</p>
<a translate class="button primary m0" ng-click="downloadProfileBackup()"
ng-show="!isSafari">Backup profile</a>
<a translate class="button primary m0" ng-click="viewProfileBackup()"
ng-show="isSafari && !hideViewProfileBackup">View profile backup</a>
<div ng-show="backupProfilePlainText">
<textarea rows="5">{{backupProfilePlainText}}</textarea>
<div class="show-for-large-up">
<span translate class="size-12">Copy to clipboard</span> <span
class="btn-copy" clip-copy="backupProfilePlainText"> </span>
</div>
<div class="hide-for-large-up">
<span translate class="size-12">Copy this text as it is in a safe place (notepad or email)</span>
</div>
</div>
</div>
</div>
</div>
<div class="line-dashed-h m20b"></div>
<div class="row" ng-init="getWallets()">
<div class="large-12 columns">
<h2>Manage wallets</h2>
<table width="100%" role="grid">
<thead>
<tr>
@ -42,8 +42,8 @@
<tr
data-ng-repeat="item in wallets | orderBy:'name'"
ng-init="isReady = item.isReady();
activeWallet = $root.wallet.id; networkName = item.getNetworkName()"
ng-class="{'active':activeWallet == item.id, 'deleting':loading==item.id}">
networkName = item.getNetworkName()"
ng-class="{'deleting':loading==item.id}">
<td>{{item.name || item.id }}</td>
<td width="120">{{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}}</td>
<td width="200">{{isReady ? 'Complete' : 'Waiting for copayers...'}}</td>
@ -54,41 +54,24 @@
</span>
</td>
<td width="70" class="text-center">
<a translate
class="warning"
ng-really-message="{{'Are you sure you want to delete the wallet'}} {{(item.name || item.id)}}"
ng-really-click="deleteWallet(item)"
ng-show="activeWallet != item.id && loading != item.id">Delete</a>
<div ng-show="loading != item.id">
<a title="Download Backup" ng-click="downloadWalletBackup(item)"
ng-show="!isSafari"><i class="fi-download"></i></a>
<a title="View Backup" ng-click="viewWalletBackup(item)"
ng-show="isSafari"><i class="fi-eye"></i></a>
&nbsp; &nbsp;
<a title="Delete Wallet"
class="text-warning"
ng-really-message="{{'Are you sure you want to delete the wallet'}} {{(item.name || item.id)}}"
ng-really-click="deleteWallet(item)"
ng-show="loading != item.id"><i class="fi-trash"></i></a>
</div>
<span ng-show="loading == item.id"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
<span ng-show="activeWallet == item.id">Active</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="line-dashed-h m20b"></div>
<div class="row">
<div class="large-12 columns">
<div class="panel">
<h2><i class="fi-download m10r"></i> <span translate>Backup Profile</span></h2>
<p translate class="text-gray">It's important to backup your profile so that you can recover it in case of disaster. The backup will include all your profile's wallets</p>
<a translate class="button primary m0" ng-click="downloadBackup()"
ng-show="!isSafari">Backup profile</a>
<a translate class="button primary m0" ng-click="viewBackup()"
ng-show="isSafari && !hideViewBackup">View profile backup</a>
<div ng-show="backupPlainText">
<textarea rows="5">{{backupPlainText}}</textarea>
<div class="show-for-large-up">
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
</div>
<div class="hide-for-large-up">
<span translate class="size-12">Copy this text as it is in a safe place (notepad or email)</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>