delete words option + confirmDialog refactor

This commit is contained in:
Matias Alejo Garcia 2015-08-08 10:58:30 -03:00
commit 04c0d20525
10 changed files with 115 additions and 57 deletions

View file

@ -8,7 +8,7 @@
<div class="content p20v" ng-controller="wordsController as wordsC"> <div class="content p20v" ng-controller="wordsController as wordsC">
<div class="row"> <div class="row">
<div class="m10 size-14 text-gray" translate> <div class="m10t columns size-14 text-gray" translate>
<span translate> <span translate>
In order to restore your Copay wallet you will need these 12 backup words. In order to restore your Copay wallet you will need these 12 backup words.
</span> </span>
@ -17,7 +17,13 @@
</span> </span>
</div> </div>
</div> </div>
<div class="row m20t" ng-show="!wordsC.mywords">
<div class="columns size-14 text-gray" translate>
The backup words had been deleted from this device
</div>
</div>
<div ng-show="wordsC.mywords">
<div class="row"> <div class="row">
<div class="m10t oh" ng-init="show=false"> <div class="m10t oh" ng-init="show=false">
<a class="button outline light-gray expand tiny" ng-click="show=!show"> <a class="button outline light-gray expand tiny" ng-click="show=!show">
@ -30,24 +36,34 @@
</div> </div>
</div> </div>
<div class="row" ng-show="show" ng-init="words = wordsC.getMnemonic()"> <div class="row" ng-show="show" >
<span class="m10" ng-repeat="word in words"> <span class="m10" ng-repeat="word in wordsC.mywords">
{{word}} {{word}}
</span> </span>
<div class="m10 text-center"> <div class="m10 text-center">
<div class="m10 size-14 text-gray" translate> <div class="m10 size-14 text-gray" translate>
<span translate> <span translate>
Once you have wrote your backup words, it is recommended to delete them from Copay. Once you have wrote your backup words, it is recommended to delete them from this device.
</span> </span>
</div> </div>
<button class="button outline round dark-gray tiny" translate>DELETE WORDS</button> <button class="button outline round dark-gray tiny" ng-click="wordsC.delete()">
</div> <i class="fi-trash"></i>
</div> <span translate>
<div class="row text-center m20t" > DELETE WORDS
<button class="button outline round dark-gray tiny" ng-click="$root.openExternalLink('https://github.com/bitpay/copay#backups')"> </span>
<span class="text-gray" translate>Learn more about Copay backups</span>
</button> </button>
</div>
</div>
<div class="row m20t">
<div class="columns size-14 text-gray" translate>
You can safely install your backup on another device and use your wallet from multiple devices at the same time. <a href="#" ng-click="$root.openExternalLink('https://github.com/bitpay/copay#backups')">
<span translate>Learn more about Copay backups</span>
</a>
</div> </div>
</div>
</div>
</div> </div>
<div class="extra-margin-bottom"></div> <div class="extra-margin-bottom"></div>

View file

@ -1,7 +1,7 @@
<div <div
class="topbar-container" class="topbar-container"
ng-include="'views/includes/topbar.html'" ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Export'; goBackToState = 'preferences'"> ng-init="titleSection='Export'; goBackToState = 'preferencesAdvanced'">
</div> </div>
@ -35,16 +35,7 @@
</div> </div>
<div class="m10t oh" ng-init="hideAdv=true"> <div class="row">
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
<i class="fi-widget m3r"></i>
<span translate ng-hide="!hideAdv">Show Advanced options</span>
<span translate ng-hide="hideAdv">Hide Advanced options</span>
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div ng-hide="hideAdv" class="row">
<div class="large-12 columns"> <div class="large-12 columns">
<label for="no-sign" class="line-b oh"> <label for="no-sign" class="line-b oh">
<span translate>Do not include private key</span> <span translate>Do not include private key</span>
@ -96,11 +87,5 @@
</div> </div>
</div> </div>
<div class="row m10t">
<div class="columns size-14 text-gray" translate>
* You can safely install your backup on another device and use your wallet from multiple devices at the same time.
</div>
</div>
</div> </div>
<div class="extra-margin-bottom"></div> <div class="extra-margin-bottom"></div>

View file

@ -57,10 +57,11 @@
</li> </li>
<h4 class="title m0">&nbsp;</h4> <h4 class="title m0">&nbsp;</h4>
<li class="line-b p20" ng-click="$root.go('export')"> <li class="line-b p20" ng-click="$root.go('export')" ng-hide="preferences.externalIndex >= 0">
<i class="icon-arrow-right3 size-24 right text-gray"></i> <i class="icon-arrow-right3 size-24 right text-gray"></i>
<span translate>Export</span> <span translate>Export</span>
</li> </li>
<li class="line-b p20" ng-click="$root.go('preferencesAdvanced')"> <li class="line-b p20" ng-click="$root.go('preferencesAdvanced')">
<i class="icon-arrow-right3 size-24 right text-gray"></i> <i class="icon-arrow-right3 size-24 right text-gray"></i>
<span translate>Advanced</span> <span translate>Advanced</span>

View file

@ -17,6 +17,11 @@
<span translate>Scan addresses for funds</span> <span translate>Scan addresses for funds</span>
</li> </li>
<li class="line-b p20" ng-click="$root.go('export')">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<span translate>Export</span>
</li>
<li class="line-b p20" ng-click="$root.go('delete')"> <li class="line-b p20" ng-click="$root.go('delete')">
<i class="icon-arrow-right3 size-24 right text-gray"></i> <i class="icon-arrow-right3 size-24 right text-gray"></i>
<span translate>Delete Wallet</span> <span translate>Delete Wallet</span>

View file

@ -1,7 +1,11 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('wordsController', angular.module('copayApp.controllers').controller('wordsController',
function($rootScope, $scope, $timeout, profileService, go, gettext) { function($rootScope, $scope, $timeout, profileService, go, gettext, confirmDialog, notification) {
var msg = gettext('Are you to delete the backup words?');
var successMsg = gettext('Backup words deleted');
this.getMnemonic = function() { this.getMnemonic = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var words = fc.getMnemonic(); var words = fc.getMnemonic();
@ -12,4 +16,19 @@ angular.module('copayApp.controllers').controller('wordsController',
this.done = function() { this.done = function() {
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
}; };
this.delete = function() {
var fc = profileService.focusedClient;
confirmDialog.show(msg,function(ok){
if (ok) {
fc.clearMnemonic();
profileService.updateCredentialsFC(function() {
notification.success(successMsg);
go.walletHome();
});
}
});
};
this.mywords = this.getMnemonic();
}); });

View file

@ -773,7 +773,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
}); });
}; };
self.recreate = function(cb) { self.recreate = function(cb) {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, feeService, bwsError, utilService) { angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, feeService, bwsError, confirmDialog, utilService) {
var self = this; var self = this;
$rootScope.hideMenuBar = false; $rootScope.hideMenuBar = false;
@ -1138,6 +1138,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.setForm(null, amount, null, feeRate); this.setForm(null, amount, null, feeRate);
}; };
// TODO: showPopup alike
this.confirmDialog = function(msg, cb) { this.confirmDialog = function(msg, cb) {
if (isCordova) { if (isCordova) {
navigator.notification.confirm( navigator.notification.confirm(

View file

@ -577,6 +577,7 @@ angular
preferencesBwsUrl: 12, preferencesBwsUrl: 12,
preferencesAlias: 12, preferencesAlias: 12,
preferencesEmail: 12, preferencesEmail: 12,
export: 13,
logs: 13, logs: 13,
information: 13, information: 13,
translators: 13, translators: 13,

View file

@ -0,0 +1,37 @@
'use strict';
angular.module('copayApp.services').factory('confirmDialog', function($log, profileService, configService, gettextCatalog, isCordova, isChromeApp) {
var root = {};
var acceptMsg = gettextCatalog.getString('Accept');
var cancelMsg = gettextCatalog.getString('Cancel');
var confirmMsg = gettextCatalog.getString('Confirm');
root.show = function(msg, cb) {
if (isCordova) {
navigator.notification.confirm(
msg,
function(buttonIndex) {
if (buttonIndex == 1) {
$timeout(function() {
return cb(true);
}, 1);
} else {
return cb(false);
}
},
confirmMsg, [acceptMsg, cancelMsg]
);
} else if (isChromeApp) {
// No feedback, alert/confirm not supported.
return cb(true);
} else {
return cb(confirm(msg));
}
};
return root;
});

View file

@ -174,14 +174,8 @@ angular.module('copayApp.services')
var walletClient = bwcService.getClient(); var walletClient = bwcService.getClient();
// TODO LANG... // TODO LANG...
// TODO... // TODO...
log.warn("TODO LANG!")
walletClient.seedFromRandomWithMnemonic('livenet'); walletClient.seedFromRandomWithMnemonic('livenet');
console.log('[profileService.js.200:walletClient:]',walletClient); //TODO
console.log('[profileService.js.180]'); //TODO
console.log('[profileService.js.180]'); //TODO
console.log('[profileService.js.180]'); //TODO
console.log('[profileService.js.180]'); //TODO
console.log('[profileService.js.180]'); //TODO
walletClient.createWallet('Personal Wallet', 'me', 1, 1, { walletClient.createWallet('Personal Wallet', 'me', 1, 1, {
network: 'livenet' network: 'livenet'
@ -213,8 +207,8 @@ console.log('[profileService.js.180]'); //TODO
} }
// TODO LANG... // TODO LANG...
// TODO... // TODO...
log.warn("TODO LANG!")
walletClient.seedFromRandomWithMnemonic(opts.networkName); walletClient.seedFromRandomWithMnemonic(opts.networkName);
console.log('[profileService.js.200:walletClient:]',walletClient); //TODO
walletClient.createWallet(opts.name, opts.myName || 'me', opts.m, opts.n, { walletClient.createWallet(opts.name, opts.myName || 'me', opts.m, opts.n, {
network: opts.networkName network: opts.networkName