Merge pull request #2728 from matiu/feat/email

email for notifications
This commit is contained in:
Gustavo Maximiliano Cortez 2015-05-19 15:43:49 -03:00
commit f516e84402
10 changed files with 119 additions and 43 deletions

View File

@ -16,7 +16,7 @@
"foundation-icon-fonts": "*",
"ng-lodash": "~0.2.0",
"angular-moment": "~0.9.0",
"angular-bitcore-wallet-client": "^0.0.21",
"angular-bitcore-wallet-client": "^0.0.22",
"angular-ui-router": "~0.2.13",
"qrcode-decoder-js": "*",
"fastclick": "*",

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Copayers'">
ng-init="">
</div>
<div class="content p20v" ng-controller="copayersController as copayers" ng-init="copayers.init()">

View File

@ -2,13 +2,13 @@
<div class="row">
<h1 class="text-center m20b">{{title|translate}}</h1>
<div class="large-6 medium-6 small-6 columns">
<button class="button light-gray expand outline radius" ng-disabled="loading"
<button class="button light-gray expand outline round" ng-disabled="loading"
ng-click="cancel()">
<i class="fi-x"></i> <span class="tu" translate>No</span>
</button>
</div>
<div class="large-6 medium-6 small-6 columns">
<button class="warning expand radius" ng-disabled="loading" ng-click="ok()">
<button class="button warning expand round" ng-disabled="loading" ng-click="ok()">
<i class="fi-trash"></i> <span translate>Yes</span>
</button>
</div>

View File

@ -20,6 +20,15 @@
</span>
</li>
<li class="line-b p20" ng-click="$root.go('preferencesEmail')">
<span translate>Email Notifications</span>
<span class="right text-gray">
<i class="icon-arrow-right3 size-24 right"></i>
<span ng-if="!index.preferences.email" translate>Disabled</span>
<span ng-if="index.preferences.email">{{index.preferences.email}}</span>
</span>
</li>
<li class="line-b p20" ng-click="$root.go('preferencesColor')">
<span translate>Color</span>
<span class="right text-gray">

View File

@ -4,15 +4,13 @@
ng-init="titleSection='Wallet Alias'; goBackToState = 'preferences'">
</div>
<div class="content preferences p20v" ng-controller="preferencesAliasController as prefAlias">
<form name="settingsAliasForm" ng-submit="prefAlias.save()" class="columns">
<label>Alias for <i>{{index.walletName}}</i></label>
<label><span translate>Alias for</span> <i>{{index.walletName}}</i></label>
<input type="text" id="alias2" type="text" name="alias2" ng-model="prefAlias.alias">
<input type="submit" class="button expand black round" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}">
</form>
<p class="text-gray text-center columns size-14"> Changing wallet alias only afects the local wallet name.
<p class="text-gray text-center columns size-14" translate>Changing wallet alias only afects the local wallet name.</p>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -0,0 +1,39 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Email Notifications'; goBackToState = 'preferences'">
</div>
<div class="content preferences p20v" ng-controller="preferencesEmailController as prefEmail">
<div class="onGoingProcess" ng-show="prefEmail.saving && !index.isOffline">
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span translate>Saving preferences...</span>
</div>
</div>
<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">
<span class="text-warning size-14">
{{prefEmail.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="submit" class="button expand black round" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}" ng-disabled="emailForm.$invalid && !index.preferences.email">
</form>
<p class="text-gray text-center columns size-14" 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.</p>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -145,6 +145,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$emit('Local/TabChanged', tab);
};
self.updatePreferences = function(cb) {
var fc = profileService.focusedClient;
fc.getPreferences(function(err, preferences) {
if (err) {
self.handleError(err);
return cb(err);
}
self.preferences = preferences;
return cb(err, preferences);
});
};
self.updateAll = function(walletStatus, untilItChanges, initBalance, tries) {
tries = tries || 0;
if (untilItChanges && lodash.isUndefined(initBalance)) {
@ -192,6 +206,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.walletStatus = walletStatus.wallet.status;
self.walletScanStatus = walletStatus.wallet.scanStatus;
self.copayers = walletStatus.wallet.copayers;
self.preferences = walletStatus.preferences;
self.setBalance(walletStatus.balance);
$rootScope.$apply();
});
@ -255,7 +270,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updatingTxHistory = false;
if (err) {
$log.debug('TxHistory ERROR:', err);
self.handleError(err);
// We do not should errors here, since history is usually
// fetched AFTER others requests.
//self.handleError(err);
self.txHistoryError = true;
} else {
$log.debug('Wallet Transaction History:', txs);
@ -343,7 +360,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
lodash.each(txs, function(tx) {
tx.ts = tx.minedTs || tx.sentTs;
// no future transaction...
if (tx.ts > now)
if (tx.ts > now)
ts.ts = now;
tx.rateTs = Math.floor((tx.ts || now) / 1000);
tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')(
@ -577,13 +594,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/UnitSettingUpdated', function(event) {
self.updateAll();
self.updateTxHistory();
});
$rootScope.$on('Local/EmailUpdated', function(event, cb) {
self.updatePreferences(cb);
});
$rootScope.$on('Local/BWSUpdated', function(event) {
profileService.applyConfig();
});
@ -663,7 +683,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var msg = 'Error at Wallet Service: ';
if (err.message) msg = msg + err.message;
else if (err.error) msg = msg + err.error;
else msg = msg + err;
else msg = msg + (lodash.isObject(err) ? JSON.stringify(err) : err);
self.clientError(msg);
}
$rootScope.$apply();
@ -682,31 +702,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setDefaultLanguage(setLang);
});
$rootScope.$on('Animation/Disable', function(event) {
$timeout(function() {
self.slideLeft = false;
self.slideRight = false;
self.slideUp = false;
self.slideDown = false;
}, 400);
});
$rootScope.$on('Animation/SlideLeft', function(event) {
self.slideLeft = true;
});
$rootScope.$on('Animation/SlideRight', function(event) {
self.slideRight = true;
});
$rootScope.$on('Animation/SlideUp', function(event) {
self.slideUp = true;
});
$rootScope.$on('Animation/SlideDown', function(event) {
self.slideDown = true;
});
$rootScope.$on('NewIncomingTx', function() {
self.updateBalance();
$timeout(function() {
@ -714,10 +709,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}, 5000);
});
// remove transactionProposalRemoved (only for compat)
lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'transactionProposalRemoved', 'TxProposalRemoved',
lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved',
'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished'
], function(eventName) {
$rootScope.$on(eventName, function(event, untilItChanges) {

View File

@ -0,0 +1,27 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesEmailController',
function($scope, go, profileService, gettext, $log) {
this.save = function(form) {
var self = this;
this.error = null;
var fc = profileService.focusedClient;
this.saving = true;
fc.savePreferences({
email: this.email
}, function(err) {
self.saving = false;
if (err) {
$log.warn(err);
$scope.$emit('Local/ClientError', err);
return;
}
$scope.$emit('Local/EmailUpdated', function(err){
go.path('preferences');
});
});
};
});

View File

@ -257,7 +257,18 @@ angular
}
})
.state('preferencesEmail', {
url: '/preferencesEmail',
templateUrl: 'views/preferencesEmail.html',
walletShouldBeComplete: true,
needProfile: true,
views: {
'main': {
templateUrl: 'views/preferencesEmail.html'
},
}
})
.state('preferencesBwsUrl', {
url: '/preferencesBwsUrl',
templateUrl: 'views/preferencesBwsUrl.html',
@ -397,6 +408,7 @@ angular
preferencesAltCurrency: 12,
preferencesBwsUrl: 12,
preferencesAlias: 12,
preferencesEmail: 12,
about: 12,
logs: 13,
add: 11,

View File

@ -390,6 +390,5 @@ angular.module('copayApp.services')
});
};
return root;
});