use scope only - preferences (advanced)

This commit is contained in:
Javier 2016-06-13 16:13:35 -03:00
parent fb56ad7505
commit 9163127dca
22 changed files with 239 additions and 306 deletions

View File

@ -1,17 +1,17 @@
<div class="backup" ng-controller="backupController as backupC">
<div class="backup" ng-controller="backupController" ng-init="init()">
<nav class="tab-bar">
<section class="left-small" ng-show="(backupC.step != 1 && backupC.step != 4)">
<a ng-click="backupC.goToStep(1);">
<section class="left-small" ng-show="(step != 1 && step != 4)">
<a ng-click="goToStep(1);">
<i class="icon-arrow-left3 icon-back"></i>
</a>
</section>
<section class="middle tab-bar-section" ng-style="{'color':index.backgroundColor}">
<span>{{backupC.walletName}}</span>
<span>{{walletName}}</span>
</section>
<section class="right-small">
<a class="p10" ng-click="backupC.backTo(index.prevState)">
<a class="p10" ng-click="backTo(index.prevState)">
<span class="text-close">
<i class="fi-x size-24"></i>
</span>
@ -19,20 +19,9 @@
</section>
</nav>
<<<<<<< 41f76292fef879856ea30ae58291f333a5e83415
<div class="box-notification" ng-show="wordsC.error">
=======
<div class="onGoingProcess" ng-show="backupC.loading">
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
<span translate>Validating recovery phrase...</span>
</div>
</div>
<div class="box-notification" ng-show="backupC.error">
>>>>>>> Replace $root.go directive for href ui-sref
<div class="box-notification" ng-show="error">
<span class="text-warning">
{{backupC.error|translate}}
{{error|translate}}
</span>
</div>
@ -41,8 +30,8 @@
-->
<div class="content preferences text-center">
<div ng-show="backupC.step == 1">
<div ng-show="backupC.mnemonicWords || (backupC.credentialsEncrypted && !backupC.deleted)" class="row">
<div ng-show="step == 1">
<div ng-show="mnemonicWords || (credentialsEncrypted && !deleted)" class="row">
<h5 class="text-center" translate>Write your wallet recovery phrase</h5>
<div class="size-14 text-gray columns" ng-show="(index.n>1 && index.m != index.n )">
<span translate>
@ -67,37 +56,37 @@
</div>
</div>
<div class="row m20t" ng-show="backupC.deleted">
<div class="row m20t" ng-show="deleted">
<div class="columns size-14 text-gray text-center" translate>
Wallet recovery phrase not available. You can still export it from Advanced &gt; Export.
</div>
</div>
<div ng-show="backupC.mnemonicWords || (backupC.credentialsEncrypted && !backupC.deleted)">
<p class="text-center columns text-gray" ng-show="index.n==1 && backupC.step == 1">
<div ng-show="mnemonicWords || (credentialsEncrypted && !deleted)">
<p class="text-center columns text-gray" ng-show="index.n==1 && step == 1">
<span translate>
You need the wallet recovery phrase to restore this personal wallet. Write it down and keep them somewhere safe.
</span>
</p>
<div class="row" ng-show="backupC.credentialsEncrypted">
<div class="row" ng-show="credentialsEncrypted">
<div class="m10t columns">
<a class="button outline light-gray expand tiny" ng-click="backupC.toggle()">
<a class="button outline light-gray expand tiny" ng-click="toggle()">
<i class="fi-widget m3r"></i>
<span translate ng-hide="backupC.show">Show Wallet Recovery Phrase</span>
<span translate ng-hide="show">Show Wallet Recovery Phrase</span>
</a>
</div>
</div>
<div class="row" ng-show="!backupC.credentialsEncrypted">
<div class="row" ng-show="!credentialsEncrypted">
<div class="columns">
<div class="panel" ng-class="{'enable_text_select': index.network == 'testnet'}">
<span ng-repeat="word in backupC.mnemonicWords track by $index"><span style="white-space:nowrap">{{word}}</span><span ng-show="backupC.useIdeograms">&#x3000;</span> </span>
<span ng-repeat="word in mnemonicWords track by $index"><span style="white-space:nowrap">{{word}}</span><span ng-show="useIdeograms">&#x3000;</span> </span>
</div>
</div>
</div>
</div>
<div class="columns extra-padding-bottom" ng-show="!backupC.credentialsEncrypted">
<div class="line-t p10 size-10 text-gray text-center" ng-show="backupC.mnemonicHasPassphrase">
<div class="columns extra-padding-bottom" ng-show="!credentialsEncrypted">
<div class="line-t p10 size-10 text-gray text-center" ng-show="mnemonicHasPassphrase">
<i class="fi-alert"></i>
<span translate>
This recovery phrase was created with a password. To recover this wallet both the recovery phrase and password are needed.
@ -107,11 +96,11 @@
<div class="button-box">
<button
ng-show="!backupC.deleted"
ng-disabled="backupC.credentialsEncrypted || backupC.error"
ng-show="!deleted"
ng-disabled="credentialsEncrypted || error"
class="round expand m0"
ng-style="{'background-color':index.backgroundColor}"
ng-click="backupC.goToStep(2);"
ng-click="goToStep(2);"
translate>Continue
</button>
</div>
@ -121,19 +110,19 @@
## STEP 2
-->
<div ng-show="backupC.step == 2">
<div ng-show="step == 2">
<div class="columns text-center extra-padding-bottom">
<h5 translate>Confirm your wallet recovery phrase</h5>
<p class="text-gray m0" translate>
Please tap the words in order to confirm your backup phrase is correctly written.
</p>
<div class="panel words text-left">
<span ng-repeat="cword in backupC.customWords track by $index" ng-show="backupC.customWords[$index]">
<span ng-repeat="cword in customWords track by $index" ng-show="customWords[$index]">
<button class="button radius tiny words" ng-click="removeButton($index, cword)">{{cword.word}}</button>
</span>
</div>
<div class="text-left">
<span ng-repeat="shuffledWord in backupC.shuffledMnemonicWords track by $index">
<span ng-repeat="shuffledWord in shuffledMnemonicWords track by $index">
<button class="button radius tiny words" ng-click="addButton($index, shuffledWord)"
ng-disabled="shuffledWord.selected">{{shuffledWord.word}}
</button>
@ -143,10 +132,10 @@
<div class="button-box">
<button
ng-disabled="!backupC.selectComplete"
ng-disabled="!selectComplete"
class="round expand m0"
ng-style="{'background-color':index.backgroundColor}"
ng-click="backupC.goToStep(3);"
ng-click="goToStep(3);"
translate>Continue
</button>
</div>
@ -156,7 +145,7 @@
## STEP 3
-->
<div ng-show="backupC.step == 3">
<div ng-show="step == 3">
<div class="columns text-center">
<h5 translate>Enter your password</h5>
<p class="text-gray m0" translate>
@ -172,7 +161,7 @@
ng-disabled="!passphrase"
ng-style="{'background-color':index.backgroundColor}"
class="button round expand m0"
ng-click="backupC.goToStep(4);"
ng-click="goToStep(4);"
translate>Continue
</button>
</div>
@ -182,8 +171,8 @@
## STEP 4
-->
<div ng-show="backupC.step == 4">
<div class="row m10t m10b text-center" ng-show="!backupC.backupError">
<div ng-show="step == 4">
<div class="row m10t m10b text-center" ng-show="!backupError">
<div class="circle-icon">
<i class="fi-like size-48"></i>
</div>
@ -212,7 +201,7 @@
</div>
</div>
</div>
<div class="row m10t m10b text-center" ng-show="backupC.backupError">
<div class="row m10t m10b text-center" ng-show="backupError">
<div class="circle-icon">
<i class="fi-dislike size-48"></i>
</div>
@ -233,7 +222,7 @@
<button
ng-style="{'background-color':index.backgroundColor}"
class="button round expand m0"
ng-click="backupC.goToStep(1);"
ng-click="goToStep(1);"
translate>Try again
</button>
</div>

View File

@ -4,17 +4,17 @@
ng-init="titleSection='Export Wallet'; goBackToState = 'preferencesAdvanced'">
</div>
<div class="content preferences" ng-controller="exportController as exportC">
<div class="content preferences" ng-controller="exportController">
<h4></h4>
<div ng-show="!exportC.backupWalletPlainText">
<div class="text-warning size-14 m20b" ng-show="exportC.error">
<div ng-show="!backupWalletPlainText">
<div class="text-warning size-14 m20b" ng-show="error">
<i class="fi-alert size-12"></i>
<span translate> Failed to export </span>
</div>
<div class="row">
<div class="columns">
<div class="text-warning size-14 m20b" ng-show="exportC.isEncrypted">
<div class="text-warning size-14 m20b" ng-show="isEncrypted">
<i class="fi-alert size-12"></i>
<span translate> A spending password is set for this wallet. Exporting keeps the spending password in the export archive.</span>
</div>
@ -26,12 +26,12 @@
<div class="columns">
<label for="password" translate>Set up a password </label>
<div class="input">
<input type="password" class="form-control" placeholder="{{'Your password'|translate}}" name="password" ng-model="exportC.password">
<input type="password" class="form-control" placeholder="{{'Your password'|translate}}" name="password" ng-model="password">
</div>
<label for="password" translate>Repeat the password</label>
<div class="input">
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="exportC.repeatpassword">
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="repeatpassword">
</div>
</div>
</div>
@ -68,25 +68,25 @@
<div class="row">
<div class="columns">
<button class="black round expand m20t" ng-click="exportC.downloadWalletBackup()"
ng-disabled="(!exportC.password || exportC.password != exportC.repeatpassword)"
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-show="!index.isSafari && !index.isCordova"><i class="fi-download"></i>
<span translate>Download</span></button>
<button class="black round expand m20t" ng-click="exportC.viewWalletBackup()"
ng-disabled="(!exportC.password || exportC.password != exportC.repeatpassword)"
<button class="black round expand m20t" ng-click="viewWalletBackup()"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-show="index.isSafari && !index.isCordova"><i class="fi-eye"></i>
<span translate>View</span></button>
<div ng-show="index.isCordova">
<h4 translate>Export options</h4>
<button class="black round expand" ng-disabled="(!exportC.password || exportC.password != exportC.repeatpassword)"
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="exportC.copyWalletBackup()"><i class="fi-clipboard-pencil"></i>
ng-click="copyWalletBackup()"><i class="fi-clipboard-pencil"></i>
<span translate>Copy to clipboard</span></button>
<button class="black round expand" ng-disabled="(!exportC.password || exportC.password != exportC.repeatpassword)"
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="exportC.sendWalletBackup()"><i class="fi-mail"></i>
ng-click="sendWalletBackup()"><i class="fi-mail"></i>
<span translate>Send by email</span></button>
</div>
</div>
@ -94,11 +94,11 @@
</div>
<div class="row" ng-show="exportC.backupWalletPlainText">
<div class="row" ng-show="backupWalletPlainText">
<div class="large-12 columns">
<h3 translate>Wallet Export</h3>
<div class="input">
<textarea rows="12">{{exportC.backupWalletPlainText}}</textarea>
<textarea rows="12">{{backupWalletPlainText}}</textarea>
</div>
<div class="size-12 text-gray text-right">
<i class="icon-compose"></i>

View File

@ -6,7 +6,7 @@
</div>
<div class="content preferences" ng-controller="preferencesController as preferences" ng-init="preferences.init()">
<div class="content preferences" ng-controller="preferencesController" ng-init="init()">
<h4></h4>
@ -39,7 +39,7 @@
<li ng-show="index.isPrivKeyExternal">
<div class="right text-gray">
{{preferences.externalSource}}
{{externalSource}}
<!-- (Accont {{preferences.externalAccount}}) -->
</div>
<div translate>Hardware wallet</div>
@ -71,7 +71,7 @@
<span class="toggle-label" translate>Request Spending Password</span>
</ion-toggle>
<ion-toggle ng-model="touchidEnabled" toggle-class="toggle-balanced" ng-change="touchidChange()" ng-show="preferences.touchidAvailable">
<ion-toggle ng-model="touchidEnabled" toggle-class="toggle-balanced" ng-change="touchidChange()" ng-show="touchidAvailable">
<span class="toggle-label" translate>Scan Fingerprint</span>
</ion-toggle>
</div>

View File

@ -4,7 +4,7 @@
ng-init="titleSection='Advanced'; goBackToState = 'preferences'">
</div>
<div class="content preferences" ng-controller="preferencesAdvancedController as preferences">
<div class="content preferences">
<h4></h4>
@ -20,7 +20,7 @@
<div translate>Sweep paper wallet</div>
</li>
<li href ui-sref="export">
<li href ui-sref="export">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<div translate>Export Wallet</div>
</li>

View File

@ -4,13 +4,12 @@
ng-init="titleSection='Alias'; goBackToState = 'preferences'">
</div>
<div class="content preferences" ng-controller="preferencesAliasController as prefAlias">
<div class="content preferences" ng-controller="preferencesAliasController">
<h4></h4>
<form name="settingsAliasForm" ng-submit="prefAlias.save()" class="columns">
<form name="settingsAliasForm" ng-submit="save()" class="columns">
<label><span translate>Alias for <i>{{index.walletName}}</i></span></label>
<input type="text" id="alias2" type="text" name="alias2" ng-model="prefAlias.alias">
<input type="text" id="alias2" type="text" name="alias2" ng-model="alias">
<input type="submit" class="button expand black round" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}">
</form>

View File

@ -4,14 +4,12 @@
ng-init="titleSection='Wallet Service URL'; goBackToState = 'preferencesAdvanced';">
</div>
<div class="content preferences" ng-controller="preferencesBwsUrlController as prefBwsUrl">
<div class="content preferences" ng-controller="preferencesBwsUrlController">
<h4></h4>
<form name="settingsBwsUrlForm" ng-submit="prefBwsUrl.save()" class="columns">
<form name="settingsBwsUrlForm" ng-submit="save()" class="columns">
<label class="left">Wallet Service URL</label>
<a class="right size-12" ng-click="prefBwsUrl.resetDefaultUrl()" translate> Set default url</a>
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="prefBwsUrl.bwsurl">
<a class="right size-12" ng-click="resetDefaultUrl()" translate> Set default url</a>
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="bwsurl">
<input type="submit" class="button expand black round" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}">
</form>

View File

@ -4,15 +4,15 @@
ng-init="titleSection='Delete Wallet'; goBackToState = 'preferencesAdvanced'">
</div>
<div class="content preferences" ng-controller="preferencesDeleteWalletController as preferences">
<div class="content preferences" ng-controller="preferencesDeleteWalletController">
<div class="text-center text-gray m20t size-12">
<div class="text-warning size-18 m10b" translate>Warning!</div>
<div class="m20b" translate>Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED</div>
</div>
<ul class="no-bullet m0">
<li ng-click="preferences.deleteWallet()">
<div class="right" ng-style="{'color':index.backgroundColor}">
<li ng-click="deleteWallet()">
<div class="right" ng-style="{'color':index.backgroundColor}" ng-show="!isDeletingWallet">
{{index.walletName}} <span ng-show="index.alias">({{index.alias}})</span>
</div>
<div translate>Delete wallet</div>

View File

@ -5,19 +5,19 @@
</div>
<div class="content preferences" ng-controller="preferencesDeleteWordsController as preferences">
<div class="content preferences" ng-controller="preferencesDeleteWordsController">
<div ng-show="!preferences.deleted">
<div ng-show="!deleted">
<div class="text-center text-gray m20t size-12">
<div class="box-notification text-warning" ng-show="preferences.error" >
{{preferences.error|translate}}
<div class="box-notification text-warning" ng-show="error" >
{{error|translate}}
</div>
<div class="text-warning size-18 m10b" translate>Warning!</div>
<div class="m15" ng-show="!index.needsBackup" translate>Once you have copied your wallet recovery phrase down, it is recommended to delete it from this device.</div>
<div class="m15" ng-show="index.needsBackup" translate>Need to do backup</div>
</div>
<ul class="no-bullet m0" ng-show="!index.needsBackup">
<li ng-click="preferences.delete()">
<li ng-click="delete()">
<div class="right" ng-style="{'color':index.backgroundColor}">
{{index.walletName}} <span ng-show="index.alias">({{index.alias}})</span>
</div>
@ -26,7 +26,7 @@
</ul>
</div>
<div class="row m20t" ng-show="preferences.deleted">
<div class="row m20t" ng-show="deleted">
<div class="columns size-14 text-gray text-center" translate>
Wallet recovery phrase not available. You can still export it from Advanced &gt; Export.
</div>

View File

@ -4,25 +4,22 @@
ng-init="titleSection='Email Notifications'; goBackToState = 'preferences'">
</div>
<div class="content preferences" ng-controller="preferencesEmailController as prefEmail">
<div class="content preferences" ng-controller="preferencesEmailController">
<h4></h4>
<form name="emailForm" ng-submit="prefEmail.save(emailForm)" class="columns" novalidate ng-init="prefEmail.email = index.preferences.email">
<div class="box-notification" ng-show="prefEmail.error">
<form name="emailForm" ng-submit="save(emailForm)" class="columns" novalidate ng-init="email = index.preferences.email">
<div class="box-notification" ng-show="error">
<span class="text-warning size-14">
{{prefEmail.error|translate}}
{{error|translate}}
</span>
</div>
<label translate>Email for wallet notifications</label>
<input type="email" id="email" name="email" ng-model="prefEmail.email" required>
<input type="email" id="email" name="email" ng-model="email" required>
<input type="submit" class="button expand black round" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}" ng-disabled="emailForm.$invalid && !index.preferences.email">
</form>
<div class="text-gray size-12 text-center" translate>Setting up email notifications could weaken your privacy, if the wallet service provider is compromised. Information available to an attacker would include your wallet addresses and its balance, but no more.
<div class="text-gray size-12 text-center" translate>Setting up email notifications could weaken your privacy, if the wallet service provider is compromised. Information available to an attacker would include your wallet addresses and its balance, but no more.
</div>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -3,25 +3,18 @@
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Transaction History'; goBackToState = 'preferencesAdvanced'">
</div>
<div class="content preferences" ng-controller="preferencesHistory as history">
<div class="content preferences" ng-controller="preferencesHistory">
<h4></h4>
<ul class="no-bullet m0">
<li ng-if="!index.isCordova" ng-init="history.csvHistory()">
<a style="color:#444"
ng-csv="history.csvContent"
csv-header="history.csvHeader"
ng-show="history.csvReady"
filename="Copay-{{index.alias || index.walletName}}.csv" translate>
Export to file
</a>
<a style="color:#777"
ng-show="!history.csvReady"
translate>
Export to file [preparing...]
</a>
<ul class="no-bullet m0" ng-if="!index.isCordova" ng-init="csvHistory(index.updatingTxHistory)">
<li ng-if="csvReady">
<a ng-csv="csvContent" csv-header="csvHeader" ng-style="{'color':index.backgroundColor}"
filename="Copay-{{index.alias || index.walletName}}.csv" translate>Export to file</a>
</li>
<li ng-click="history.clearTransactionHistory();" translate>
<li ng-if="!csvReady">
<span translate>Export to file [preparing...]</span>
</li>
<li ng-click="clearTransactionHistory()" ng-style="{'color':index.backgroundColor}" translate>
Clear cache
</li>
</ul>

View File

@ -4,7 +4,7 @@
ng-init="titleSection='Wallet Information'; goBackToState = 'preferencesAdvanced'">
</div>
<div class="content preferences" ng-controller="preferencesInformation as info" ng-init="info.init()">
<div class="content preferences" ng-controller="preferencesInformation" ng-init="init()">
<h4 class="title m0" translate>Wallet Information</h4>
<ul class="no-bullet m0 size-14">
@ -15,8 +15,6 @@
</span>
</li>
<li class="line-b p20 oh">
<span translate>Wallet Name (at creation)</span>
<span class="right text-gray">
@ -24,7 +22,6 @@
</span>
</li>
<li class="line-b p20 oh">
<span translate>Wallet Id</span>
<span class="right text-gray enable_text_select">
@ -39,8 +36,6 @@
</span>
</li>
<li class="line-b p20 oh">
<span translate>Wallet Network</span>
<span class="right text-gray">
@ -48,7 +43,6 @@
</span>
</li>
<li class="line-b p20 oh">
<span translate>Address Type</span>
<span class="right text-gray">
@ -56,7 +50,6 @@
</span>
</li>
<li class="line-b p20 oh">
<span translate>Derivation Strategy</span>
<span class="right text-gray">
@ -85,9 +78,7 @@
</span>
</li>
<h4 class="title m0" translate>Copayers</h4>
<h4 class="title m0" translate>Copayers</h4>
<li ng-repeat="copayer in index.copayers">
<span class="size-12" ng-show="copayer.id == index.copayerId">
<i class="icon-contact size-24 m10r"></i> {{copayer.name}} ({{'Me'|translate}}) <i class="fi-check m5 right"></i>
@ -97,7 +88,7 @@
</span>
</li>
<h4 class="title m0" translate>Extended Public Keys</h4>
<h4 class="title m0" translate>Extended Public Keys</h4>
<li ng-repeat="pk in pubKeys">
<div class="row collapse">
<div class="small-4 columns">Copayer {{$index}}</div>
@ -131,7 +122,7 @@
<li ng-style="{'color':index.backgroundColor}" href ui-sref="walletHome" ng-click="index.retryScan()" translate>
Scan addresses for funds
</li>
<li ng-style="{'color':index.backgroundColor}" ng-show="index.isCordova" ng-click="info.sendAddrs()" translate>
<li ng-style="{'color':index.backgroundColor}" ng-show="index.isCordova" ng-click="sendAddrs()" translate>
Send addresses by email
</li>
</ul>
@ -151,8 +142,6 @@
</div>
</ul>
<h4></h4>
<div class="extra-margin-bottom"></div>
</div>

View File

@ -3,10 +3,9 @@
angular.module('copayApp.controllers').controller('backupController',
function($rootScope, $scope, $timeout, $log, lodash, profileService, gettext, bwcService, bwsError, walletService, ongoingProcess) {
var self = this;
var fc = profileService.focusedClient;
self.customWords = [];
self.walletName = fc.credentials.walletName;
$scope.customWords = [];
$scope.walletName = fc.credentials.walletName;
var handleEncryptedWallet = function(client, cb) {
if (!walletService.isEncrypted(client)) return cb();
@ -17,24 +16,22 @@ angular.module('copayApp.controllers').controller('backupController',
};
if (fc.isPrivKeyEncrypted() && !isDeletedSeed()) {
self.credentialsEncrypted = true;
$scope.credentialsEncrypted = true;
passwordRequest();
} else {
if (!isDeletedSeed())
initWords();
}
init();
function init() {
$scope.init = function() {
$scope.passphrase = '';
self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords);
self.customWords = [];
self.step = 1;
self.deleted = isDeletedSeed();
self.credentialsEncrypted = false;
self.selectComplete = false;
self.backupError = false;
$scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords);
$scope.customWords = [];
$scope.step = 1;
$scope.deleted = isDeletedSeed();
$scope.credentialsEncrypted = false;
$scope.selectComplete = false;
$scope.backupError = false;
};
function isDeletedSeed() {
@ -43,7 +40,7 @@ angular.module('copayApp.controllers').controller('backupController',
return false;
};
self.backTo = function(state) {
$scope.backTo = function(state) {
console.log(state);
if (state == 'walletHome')
go.walletHome();
@ -51,16 +48,16 @@ angular.module('copayApp.controllers').controller('backupController',
go.preferences();
};
self.goToStep = function(n) {
$scope.goToStep = function(n) {
if (n == 1)
init();
$scope.init();
if (n == 2)
self.step = 2;
$scope.step = 2;
if (n == 3) {
if (!self.mnemonicHasPassphrase)
if (!$scope.mnemonicHasPassphrase)
finalStep();
else
self.step = 3;
$scope.step = 3;
}
if (n == 4)
finalStep();
@ -73,7 +70,7 @@ angular.module('copayApp.controllers').controller('backupController',
backupError(err);
}
$timeout(function() {
self.step = 4;
$scope.step = 4;
return;
}, 1);
});
@ -82,12 +79,12 @@ angular.module('copayApp.controllers').controller('backupController',
function initWords() {
var words = fc.getMnemonic();
self.xPrivKey = fc.credentials.xPrivKey;
$scope.xPrivKey = fc.credentials.xPrivKey;
walletService.lock(fc);
self.mnemonicWords = words.split(/[\u3000\s]+/);
self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords);
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
self.useIdeograms = words.indexOf("\u3000") >= 0;
$scope.mnemonicWords = words.split(/[\u3000\s]+/);
$scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords);
$scope.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
$scope.useIdeograms = words.indexOf("\u3000") >= 0;
};
function shuffledWords(words) {
@ -101,10 +98,10 @@ angular.module('copayApp.controllers').controller('backupController',
});
};
self.toggle = function() {
self.error = "";
$scope.toggle = function() {
$scope.error = "";
if (self.credentialsEncrypted)
if ($scope.credentialsEncrypted)
passwordRequest();
$timeout(function() {
@ -124,12 +121,12 @@ angular.module('copayApp.controllers').controller('backupController',
handleEncryptedWallet(fc, function(err) {
if (err) {
self.error = bwsError.msg(err, gettext('Could not decrypt'));
$log.warn('Error decrypting credentials:', self.error); //TODO
$scope.error = bwsError.msg(err, gettext('Could not decrypt'));
$log.warn('Error decrypting credentials:', $scope.error); //TODO
return;
}
self.credentialsEncrypted = false;
$scope.credentialsEncrypted = false;
initWords();
$timeout(function() {
@ -145,37 +142,38 @@ angular.module('copayApp.controllers').controller('backupController',
word: item.word,
prevIndex: index
};
self.customWords.push(newWord);
self.shuffledMnemonicWords[index].selected = true;
self.shouldContinue();
$scope.customWords.push(newWord);
$scope.shuffledMnemonicWords[index].selected = true;
$scope.shouldContinue();
};
$scope.removeButton = function(index, item) {
self.customWords.splice(index, 1);
self.shuffledMnemonicWords[item.prevIndex].selected = false;
self.shouldContinue();
if ($scope.loading) return;
$scope.customWords.splice(index, 1);
$scope.shuffledMnemonicWords[item.prevIndex].selected = false;
$scope.shouldContinue();
};
self.shouldContinue = function() {
if (self.customWords.length == 12)
self.selectComplete = true;
$scope.shouldContinue = function() {
if ($scope.customWords.length == 12)
$scope.selectComplete = true;
else
self.selectComplete = false;
$scope.selectComplete = false;
};
function confirm(cb) {
self.backupError = false;
$scope.backupError = false;
var customWordList = lodash.pluck(self.customWords, 'word');
var customWordList = lodash.pluck($scope.customWords, 'word');
if (!lodash.isEqual(self.mnemonicWords, customWordList)) {
if (!lodash.isEqual($scope.mnemonicWords, customWordList)) {
return cb('Mnemonic string mismatch');
}
$timeout(function() {
if (self.mnemonicHasPassphrase) {
if ($scope.mnemonicHasPassphrase) {
var walletClient = bwcService.getClient();
var separator = self.useIdeograms ? '\u3000' : ' ';
var separator = $scope.useIdeograms ? '\u3000' : ' ';
var customSentence = customWordList.join(separator);
var passphrase = $scope.passphrase || '';
@ -189,7 +187,7 @@ angular.module('copayApp.controllers').controller('backupController',
return cb(err);
}
if (walletClient.credentials.xPrivKey != self.xPrivKey) {
if (walletClient.credentials.xPrivKey != $scope.xPrivKey) {
return cb('Private key mismatch');
}
}
@ -202,7 +200,7 @@ angular.module('copayApp.controllers').controller('backupController',
function backupError(err) {
ongoingProcess.set('validatingWords', false);
$log.debug('Failed to verify backup: ', err);
self.backupError = true;
$scope.backupError = true;
$timeout(function() {
$scope.$apply();

View File

@ -2,20 +2,19 @@
angular.module('copayApp.controllers').controller('exportController',
function($rootScope, $scope, $timeout, $log, backupService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) {
var self = this;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
self.error = null;
self.success = null;
$scope.error = null;
$scope.success = null;
$scope.metaDataEnabled = true;
var fc = profileService.focusedClient;
self.isEncrypted = fc.isPrivKeyEncrypted();
$scope.isEncrypted = fc.isPrivKeyEncrypted();
self.downloadWalletBackup = function() {
self.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) {
$scope.downloadWalletBackup = function() {
$scope.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) {
if (err) {
self.error = true;
$scope.error = true;
return;
}
var opts = {
@ -24,9 +23,9 @@ angular.module('copayApp.controllers').controller('exportController',
addressBook: localAddressBook
};
backupService.walletDownload(self.password, opts, function(err) {
backupService.walletDownload($scope.password, opts, function(err) {
if (err) {
self.error = true;
$scope.error = true;
return;
}
$rootScope.$emit('Local/BackupDone');
@ -36,12 +35,12 @@ angular.module('copayApp.controllers').controller('exportController',
});
};
self.getMetaData = function(metaData, cb) {
$scope.getMetaData = function(metaData, cb) {
if (metaData == false) return cb();
self.getHistoryCache(function(err, txsFromLocal) {
$scope.getHistoryCache(function(err, txsFromLocal) {
if (err) return cb(err);
self.getAddressbook(function(err, localAddressBook) {
$scope.getAddressbook(function(err, localAddressBook) {
if (err) return cb(err);
return cb(null, txsFromLocal, localAddressBook)
@ -49,7 +48,7 @@ angular.module('copayApp.controllers').controller('exportController',
});
}
self.getHistoryCache = function(cb) {
$scope.getHistoryCache = function(cb) {
storageService.getTxHistory(fc.credentials.walletId, function(err, txs) {
if (err) return cb(err);
@ -66,7 +65,7 @@ angular.module('copayApp.controllers').controller('exportController',
});
}
self.getAddressbook = function(cb) {
$scope.getAddressbook = function(cb) {
storageService.getAddressbook(fc.credentials.network, function(err, addressBook) {
if (err) return cb(err);
@ -81,10 +80,10 @@ angular.module('copayApp.controllers').controller('exportController',
});
}
self.getBackup = function(cb) {
self.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) {
$scope.getBackup = function(cb) {
$scope.getMetaData($scope.metaDataEnabled, function(err, txsFromLocal, localAddressBook) {
if (err) {
self.error = true;
$scope.error = true;
return cb(null);
}
var opts = {
@ -93,30 +92,29 @@ angular.module('copayApp.controllers').controller('exportController',
addressBook: localAddressBook
};
var ew = backupService.walletExport(self.password, opts);
var ew = backupService.walletExport($scope.password, opts);
if (!ew) {
self.error = true;
$scope.error = true;
} else {
self.error = false;
$scope.error = false;
$rootScope.$emit('Local/BackupDone');
}
return cb(ew);
});
}
self.viewWalletBackup = function() {
var self = this;
$scope.viewWalletBackup = function() {
$timeout(function() {
self.getBackup(function(backup) {
$scope.getBackup(function(backup) {
var ew = backup;
if (!ew) return;
self.backupWalletPlainText = ew;
$scope.backupWalletPlainText = ew;
});
}, 100);
};
self.copyWalletBackup = function() {
self.getBackup(function(backup) {
$scope.copyWalletBackup = function() {
$scope.getBackup(function(backup) {
var ew = backup;
if (!ew) return;
window.cordova.plugins.clipboard.copy(ew);
@ -124,14 +122,14 @@ angular.module('copayApp.controllers').controller('exportController',
});
};
self.sendWalletBackup = function() {
$scope.sendWalletBackup = function() {
var fc = profileService.focusedClient;
window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...'));
var name = (fc.credentials.walletName || fc.credentials.walletId);
if (fc.alias) {
name = fc.alias + ' [' + name + ']';
}
self.getBackup(function(backup) {
$scope.getBackup(function(backup) {
var ew = backup;
if (!ew) return;

View File

@ -3,28 +3,27 @@
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $timeout, $log, configService, profileService, fingerprintService, walletService) {
var self = this;
var fc;
var config = configService.getSync();
var disableFocusListener = $rootScope.$on('Local/NewFocusedWalletReady', function() {
self.init();
$scope.init();
});
$scope.$on('$destroy', function() {
disableFocusListener();
});
this.init = function() {
$scope.init = function() {
fc = profileService.focusedClient;
if (fc) {
$scope.encryptEnabled = walletService.isEncrypted(fc);
this.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null;
$scope.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null;
// TODO externalAccount
//this.externalIndex = fc.getExternalIndex();
}
this.touchidAvailable = fingerprintService.isAvailable();
$scope.touchidAvailable = fingerprintService.isAvailable();
$scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null;
$scope.deleted = false;
@ -41,7 +40,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
};
$scope.encryptChange = function() {
var self = this;
if (!fc) return;
var val = $scope.encryptEnabled;

View File

@ -1,6 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAdvancedController',
function($scope) {
});

View File

@ -2,20 +2,18 @@
angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, configService, profileService, go) {
var config = configService.getSync();
var fc = profileService.focusedClient;
var walletId = fc.credentials.walletId;
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
this.alias = config.aliasFor[walletId] || fc.credentials.walletName;
this.save = function() {
var self = this;
config.aliasFor = config.aliasFor || {};
$scope.alias = config.aliasFor[walletId] || fc.credentials.walletName;
$scope.save = function() {
var opts = {
aliasFor: {}
};
opts.aliasFor[walletId] = self.alias;
opts.aliasFor[walletId] = $scope.alias;
configService.set(opts, function(err) {
if (err) {
@ -23,10 +21,9 @@ angular.module('copayApp.controllers').controller('preferencesAliasController',
return;
}
$scope.$emit('Local/AliasUpdated');
$timeout(function(){
$timeout(function() {
go.path('preferences');
}, 50);
});
};
});

View File

@ -2,24 +2,24 @@
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
function($scope, $log, configService, go, applicationService, profileService, storageService) {
this.error = null;
this.success = null;
$scope.error = null;
$scope.success = null;
var fc = profileService.focusedClient;
var walletId = fc.credentials.walletId;
var defaults = configService.getDefaults();
var config = configService.getSync();
this.bwsurl = (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url;
$scope.bwsurl = (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url;
this.resetDefaultUrl = function() {
this.bwsurl = defaults.bws.url;
$scope.resetDefaultUrl = function() {
$scope.bwsurl = defaults.bws.url;
};
this.save = function() {
$scope.save = function() {
var bws;
switch (this.bwsurl) {
switch ($scope.bwsurl) {
case 'prod':
case 'production':
bws = 'https://bws.bitpay.com/bws/api'
@ -35,13 +35,13 @@ angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
};
if (bws) {
$log.info('Using BWS URL Alias to ' + bws);
this.bwsurl = bws;
$scope.bwsurl = bws;
}
var opts = {
bwsFor: {}
};
opts.bwsFor[walletId] = this.bwsurl;
opts.bwsFor[walletId] = $scope.bwsurl;
configService.set(opts, function(err) {
if (err) console.log(err);

View File

@ -3,8 +3,8 @@
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $rootScope, $filter, $timeout, $modal, $log, $ionicModal, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, applicationService, ongoingProcess) {
var isCordova = platformInfo.isCordova;
this.isCordova = isCordova;
this.error = null;
$scope.isCordova = isCordova;
$scope.error = null;
var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?');
var accept_msg = gettextCatalog.getString('Accept');
@ -20,8 +20,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
$scope.loading = false;
$ionicModal.fromTemplateUrl('views/modals/confirmation.html', {
scope: $scope,
animation: 'slide-in-up'
scope: $scope
}).then(function(modal) {
$scope.confirmationModal = modal;
$scope.confirmationModal.show();
@ -33,12 +32,11 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
var fc = profileService.focusedClient;
var name = fc.credentials.walletName;
var walletName = (fc.alias || '') + ' [' + name + ']';
var self = this;
profileService.deleteWalletClient(fc, function(err) {
ongoingProcess.set('deletingWallet', false);
if (err) {
self.error = err.message || err;
$scope.error = err.message || err;
} else {
notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {
walletName: walletName
@ -48,7 +46,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
});
};
this.deleteWallet = function() {
$scope.deleteWallet = function() {
if (isCordova) {
navigator.notification.confirm(
delete_msg,

View File

@ -1,15 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function(confirmDialog, lodash, notification, profileService, go, gettext) {
var self = this;
var fc = profileService.focusedClient;
var msg = gettext('Are you sure you want to delete the recovery phrase?');
var successMsg = gettext('Recovery phrase deleted');
if (lodash.isEmpty(fc.credentials.mnemonic) && lodash.isEmpty(fc.credentials.mnemonicEncrypted))
self.deleted = true;
$scope.deleted = true;
self.delete = function() {
$scope.delete = function() {
confirmDialog.show(msg, function(ok) {
if (ok) {
fc.clearMnemonic();

View File

@ -1,21 +1,19 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesEmailController',
function($rootScope, go, profileService, gettext, $log, walletService) {
this.save = function(form) {
var self = this;
this.error = null;
angular.module('copayApp.controllers').controller('preferencesEmailController', function($rootScope, go, profileService, walletService) {
$scope.save = function(form) {
$scope.error = null;
$scope.saving = true;
var fc = profileService.focusedClient;
var email = $scope.email || '';
var fc = profileService.focusedClient;
var email = self.email || '';
walletService.updateRemotePreferences(fc, {
email: email,
}, function(err) {
if (!err)
$rootScope.$emit('Local/EmailUpdated', email);
go.path('preferences');
});
};
});
walletService.updateRemotePreferences(fc, {
email: email,
}, function(err) {
$scope.saving = false;
if (!err)
$rootScope.$emit('Local/EmailUpdated', email);
go.path('preferences');
});
};
});

View File

@ -4,26 +4,13 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $timeout, storageService, go, profileService, lodash) {
var fc = profileService.focusedClient;
var c = fc.credentials;
this.csvReady = false;
$scope.csvReady = false;
$scope.csvHistory = function(isUpdating, cb) {
if (isUpdating) return;
this.csvHistory = function(cb) {
var allTxs = [];
function formatDate(date) {
var dateObj = new Date(date);
if (!dateObj) {
$log.debug('Error formating a date');
return 'DateError'
}
if (!dateObj.toJSON()) {
return '';
}
return dateObj.toJSON();
}
var step = 6;
var unique = {};
function getHistory(cb) {
storageService.getTxHistory(c.walletId, function(err, txs) {
if (err) return cb(err);
@ -38,16 +25,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
allTxs.push(txsFromLocal);
return cb(null, lodash.flatten(allTxs));
});
}
var fc = profileService.focusedClient;
var c = fc.credentials;
if (!fc.isComplete())
return;
var self = this;
var allTxs = [];
};
$log.debug('Generating CSV from History');
getHistory(function(err, txs) {
@ -59,12 +37,12 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
$log.debug('Wallet Transaction History Length:', txs.length);
self.satToUnit = 1 / self.unitToSatoshi;
$scope.satToUnit = 1 / $scope.unitToSatoshi;
var data = txs;
var satToBtc = 1 / 100000000;
self.csvContent = [];
self.csvFilename = 'Copay-' + (self.alias || self.walletName) + '.csv';
self.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment'];
$scope.csvContent = [];
$scope.csvFilename = 'Copay-' + ($scope.alias || $scope.walletName) + '.csv';
$scope.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment'];
var _amount, _note, _copayers, _creator, _comment;
data.forEach(function(it, index) {
@ -89,7 +67,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
if (it.action == 'moved')
_note += ' Moved:' + (it.amount * satToBtc).toFixed(8)
self.csvContent.push({
$scope.csvContent.push({
'Date': formatDate(it.time * 1000),
'Destination': it.addressTo || '',
'Description': _note,
@ -103,7 +81,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
if (it.fees && (it.action == 'moved' || it.action == 'sent')) {
var _fee = (it.fees * satToBtc).toFixed(8)
self.csvContent.push({
$scope.csvContent.push({
'Date': formatDate(it.time * 1000),
'Destination': 'Bitcoin Network Fees',
'Description': '',
@ -116,16 +94,31 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
}
});
self.csvReady = true;
$scope.csvReady = true;
$timeout(function() {
$scope.$apply();
}, 100);
if (cb)
return cb();
return;
});
function formatDate(date) {
var dateObj = new Date(date);
if (!dateObj) {
$log.debug('Error formating a date');
return 'DateError'
}
if (!dateObj.toJSON()) {
return '';
}
return dateObj.toJSON();
};
};
this.clearTransactionHistory = function() {
$scope.clearTransactionHistory = function() {
storageService.removeTxHistory(c.walletId, function(err) {
if (err) {
$log.error(err);
@ -137,5 +130,5 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
go.walletHome();
}, 100);
});
}
};
});

View File

@ -6,7 +6,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
var fc = profileService.focusedClient;
var c = fc.credentials;
this.init = function() {
$scope.init = function() {
var basePath = c.getBaseAddressDerivationPath();
$scope.walletName = c.walletName;
@ -43,11 +43,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
});
};
this.sendAddrs = function() {
var self = this;
self.loading = true;
$scope.sendAddrs = function() {
function formatDate(ts) {
var dateObj = new Date(ts * 1000);
if (!dateObj) {
@ -64,7 +60,6 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
fc.getMainAddresses({
doNotVerify: true
}, function(err, addrs) {
self.loading = false;
if (err) {
$log.warn(err);
return;