backup control

This commit is contained in:
JDonadio 2017-03-30 17:45:57 -03:00
commit 8bd7b9fb47
2 changed files with 38 additions and 9 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('lockController', function($state, $scope, $timeout, $log, configService, popupService, gettextCatalog, appConfigService, fingerprintService) {
angular.module('copayApp.controllers').controller('lockController', function($state, $scope, $timeout, $log, configService, popupService, gettextCatalog, appConfigService, fingerprintService, profileService, lodash) {
$scope.$on("$ionicView.beforeEnter", function(event) {
var config = configService.getSync();
@ -12,21 +12,46 @@ angular.module('copayApp.controllers').controller('lockController', function($st
$scope.useFingerprint = {
enabled: config.lock && config.lock.method == 'fingerprint' ? true : false
};
processWallets();
});
function processWallets() {
var wallets = profileService.getWallets();
var singleLivenetWallet = wallets.length == 1 && wallets[0].network == 'livenet' && wallets[0].needsBackup;
var atLeastOneLivenetWallet = lodash.any(wallets, function(w) {
return w.network == 'livenet' && w.needsBackup;
});
if (singleLivenetWallet) {
$scope.errorMsg = gettextCatalog.getString('Backup your wallet before using this function');
} else if (atLeastOneLivenetWallet) {
$scope.errorMsg = gettextCatalog.getString('Backup all livenet wallets before using this function');
} else $scope.errorMsg = null;
$timeout(function() {
$scope.$apply();
});
};
$scope.usePinChange = function() {
$state.go('tabs.lock.pin', {
$scope.usePin.enabled = !$scope.usePin.enabled;
$state.transitionTo('tabs.lock.pin', {
fromSettings: true,
locking: $scope.usePin.enabled
locking: !$scope.usePin.enabled
}).then(function() {
$timeout(function() {
$scope.usePin.enabled = !$scope.usePin.enabled;
}, 1000);
});
};
$scope.useFingerprintChange = function() {
if ($scope.usePin.enabled) {
var message = gettextCatalog.getString('{{appName}} is protected by Pin Code. Are you sure you want to disable it?', {
var message = gettextCatalog.getString('{{appName}} is protected by Pin. Are you sure you want to disable it?', {
appName: appConfigService.nameCase
});
var okText = gettextCatalog.getString('Yes');
var okText = gettextCatalog.getString('Continue');
var cancelText = gettextCatalog.getString('Cancel');
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
if (!ok) {

View file

@ -6,14 +6,18 @@
</ion-nav-bar>
<ion-content>
<ion-toggle ng-model="usePin.enabled" toggle-class="toggle-balanced" ng-change="usePinChange()">
<span class="toggle-label" translate>Enable Pin</span>
<ion-toggle ng-model="usePin.enabled" toggle-class="toggle-balanced" ng-change="usePinChange()" ng-disabled="errorMsg && !usePin.enabled">
<span class="toggle-label" ng-class="{'disabled': errorMsg && !usePin.enabled}" translate>Enable Pin</span>
</ion-toggle>
<div ng-show="fingerprintAvailable">
<ion-toggle ng-model="useFingerprint.enabled" toggle-class="toggle-balanced" ng-change="useFingerprintChange()">
<span class="toggle-label" translate>Enable Fingerprint</span>
<ion-toggle ng-model="useFingerprint.enabled" toggle-class="toggle-balanced" ng-change="useFingerprintChange()" ng-disabled="errorMsg && !useFingerprint.enabled">
<span class="toggle-label" ng-class="{'disabled': errorMsg && !useFingerprint.enabled}" translate>Enable Fingerprint</span>
</ion-toggle>
</div>
<div class="assertive" style="text-align: center; margin: 4rem" ng-if="errorMsg && !usePin.enabled && !useFingerprint.enabled">
{{errorMsg}}
</div>
</ion-content>
</ion-view>