Merge pull request #3419 from cmgustavo/ref/global-preferences-sidebar

Moves the global preferences to the sidebar
This commit is contained in:
Matias Alejo Garcia 2015-11-16 11:00:52 -03:00
commit 95217cef02
21 changed files with 201 additions and 141 deletions

View File

@ -36,5 +36,15 @@
<div>Glidera</div>
</a>
</li>
<li>
<a ng-click="$root.go('preferencesGlobal')" class="oh">
<i class="icon-arrow-right3 size-18 right m10t"></i>
<i class="fi-widget size-24 icon"></i>
<div class="tu text-bold">
<span class="size-12">Settings</span>
</div>
<div>Global preferences</div>
</a>
</li>
</ul>
</nav>

View File

@ -2,7 +2,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Preferences'; closeToHome = true">
ng-init="titleSection='Wallet Preferences'; closeToHome = true">
</div>
@ -17,7 +17,7 @@
{{index.alias||index.walletName}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Wallet Alias</div>
<div translate>Alias</div>
</li>
<li ng-click="$root.go('preferencesEmail')">
@ -50,7 +50,7 @@
<li ng-click="$root.go('backup')" ng-hide="index.isPrivKeyExternal">
<div class="right text-gray">
<span class="text-warning" ng-show="index.needsBackup">
<i class="fi-alert"></i><span translate>Still not done</span>
<i class="fi-alert"></i> <span translate>Still not done</span>
</span>
<i class="icon-arrow-right3 size-24 text-gray"></i>
</div>
@ -77,62 +77,6 @@
</li>
</ul>
</div>
<ul class="no-bullet m0 ">
<h4 translate>Global settings</h4>
<li ng-show="!index.noFocusedWallet" ng-click="$root.go('preferencesLanguage')">
<div class="right text-gray">
{{preferences.currentLanguageName|translate}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Language</div>
</li>
<li ng-show="!index.noFocusedWallet" ng-click="$root.go('preferencesUnit')">
<div class="right text-gray">
{{preferences.unitName}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Unit</div>
</li>
<li ng-show="!index.noFocusedWallet" ng-click="$root.go('preferencesAltCurrency')">
<div class="right text-gray">
{{preferences.selectedAlternative.name}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Alternative Currency</div>
</li>
<li ng-show="!index.noFocusedWallet" ng-click="$root.go('preferencesFee')"
ng-show="(index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)">
<div class="right text-gray">
{{index.feeOpts[index.currentFeeLevel]|translate}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Bitcoin Network Fee Policy</div>
</li>
<li ng-show="!index.noFocusedWallet">
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
<div translate>Use Unconfirmed Funds</div>
</li>
<li ng-show="!index.noFocusedWallet">
<switch id="glidera-enabled" name="glideraEnabled" ng-model="glideraEnabled" class="green right"></switch>
<div>Enable Glidera Service</div>
</li>
<!-- Disabled for testnet
<li ng-show="!index.noFocusedWallet && glideraEnabled">
<span>Glidera Sandbox</span>
<switch id="glidera-testnet" name="glideraTestnet" ng-model="glideraTestnet" class="green right"></switch>
</li>
-->
<li ng-click="$root.go('about')">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<div translate>About Copay</div>
</li>
</ul>
<h4></h4>
</div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='About Copay'; goBackToState = 'preferences'">
ng-init="titleSection='About Copay'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>
<div class="content preferences" ng-controller="preferencesAbout as about">

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferences'; noColor = true">
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Bitcoin Network Fee Policy'; goBackToState = 'preferences'; noColor = true">
ng-init="titleSection='Bitcoin Network Fee Policy'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>
<div class="content preferences" ng-controller="preferencesFeeController as prefFee">
<h4></h4>

View File

@ -0,0 +1,78 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Global Preferences'; closeToHome = true; noColor = true">
</div>
<div class="content preferences" ng-controller="preferencesGlobalController as prefGlobal" ng-init="prefGlobal.init()">
<ul class="no-bullet m0 ">
<h4></h4>
<li ng-click="$root.go('preferencesLanguage')">
<div class="right text-gray">
{{prefGlobal.currentLanguageName|translate}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Language</div>
</li>
</ul>
<ul class="no-bullet m0 ">
<h4></h4>
<li ng-click="$root.go('preferencesUnit')">
<div class="right text-gray">
{{prefGlobal.unitName}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Unit</div>
</li>
<li ng-click="$root.go('preferencesAltCurrency')">
<div class="right text-gray">
{{prefGlobal.selectedAlternative.name}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Alternative Currency</div>
</li>
</ul>
<ul class="no-bullet m0 ">
<h4></h4>
<li ng-click="$root.go('preferencesFee')"
ng-show="(index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)">
<div class="right text-gray">
{{index.feeOpts[index.currentFeeLevel]|translate}}
<i class="icon-arrow-right3 size-24"></i>
</div>
<div translate>Bitcoin Network Fee Policy</div>
</li>
<li>
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
<div translate>Use Unconfirmed Funds</div>
</li>
</ul>
<ul class="no-bullet m0 ">
<h4></h4>
<li>
<switch id="glidera-enabled" name="glideraEnabled" ng-model="glideraEnabled" class="green right"></switch>
<div>Enable Glidera Service</div>
</li>
<!-- Disabled for testnet
<li ng-show="glideraEnabled">
<span>Glidera Sandbox</span>
<switch id="glidera-testnet" name="glideraTestnet" ng-model="glideraTestnet" class="green right"></switch>
</li>
-->
</ul>
<ul class="no-bullet m0">
<h4></h4>
<li ng-click="$root.go('about')">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<div translate>About Copay</div>
</li>
</ul>
<h4></h4>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Language'; goBackToState = 'preferences'; noColor = true">
ng-init="titleSection='Language'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Session log'; goBackToState = 'about'">
ng-init="titleSection='Session log'; goBackToState = 'about'; noColor = true">
</div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Unit'; goBackToState = 'preferences'; noColor = true">
ng-init="titleSection='Unit'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Translators'; goBackToState = 'about'">
ng-init="titleSection='Translators'; goBackToState = 'about'; noColor = true">
</div>
<div class="content preferences">

View File

@ -11,8 +11,8 @@
</div>
<button class="button black round expand" ng-click="$root.go('add')" translate>Create</button>
<div class="text-center text-gray p20v" ng-click="$root.go('preferences')">
<button class=" outline round dark-gray tiny" translate> Preferences </button>
<div class="text-center text-gray p20v" ng-click="$root.go('preferencesGlobal')">
<button class=" outline round dark-gray tiny" translate>Settings</button>
</div>
</div>

View File

@ -868,6 +868,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateHistory = function() {
var fc = profileService.focusedClient;
if (!fc) return;
var walletId = fc.credentials.walletId;
if (!fc.isComplete() || self.updatingTxHistory[walletId]) return;

View File

@ -1,20 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService, uxLanguage) {
function($scope, $rootScope, $timeout, $log, configService, profileService) {
this.init = function() {
var config = configService.getSync();
this.unitName = config.wallet.settings.unitName;
this.bwsurl = config.bws.url;
this.currentLanguageName = uxLanguage.getCurrentLanguageName();
this.selectedAlternative = {
name: config.wallet.settings.alternativeName,
isoCode: config.wallet.settings.alternativeIsoCode
};
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.glideraTestnet = config.glidera.testnet;
var fc = profileService.focusedClient;
if (fc) {
$scope.encrypt = fc.hasPrivKeyEncrypted();
@ -31,20 +21,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
}
};
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
wallet: {
spendUnconfirmed: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/SpendUnconfirmedUpdated');
if (err) $log.debug(err);
});
});
var unwatch = $scope.$watch('encrypt', function(val) {
var unwatchEncrypt = $scope.$watch('encrypt', function(val) {
var fc = profileService.focusedClient;
if (!fc) return;
@ -80,32 +57,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
}
});
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
enabled: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
testnet: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchRequestTouchid = $scope.$watch('touchid', function(newVal, oldVal) {
if (newVal == oldVal || $scope.touchidError) {
$scope.touchidError = false;
@ -139,10 +90,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
});
$scope.$on('$destroy', function() {
unwatch();
unwatchSpendUnconfirmed();
unwatchGlideraEnabled();
unwatchGlideraTestnet();
unwatchEncrypt();
unwatchRequestTouchid();
});
});

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
function($scope, $rootScope, configService, go, rateService, lodash) {
function($scope, $timeout, $log, configService, rateService, lodash, go) {
this.hideAdv = true;
this.hidePriv = true;
this.hideSecret = true;
@ -48,8 +48,12 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
};
configService.set(opts, function(err) {
if (err) console.log(err);
if (err) $log.warn(err);
go.preferencesGlobal();
$scope.$emit('Local/UnitSettingUpdated');
$timeout(function() {
$scope.$apply();
}, 100);
});
};

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesColorController',
function($scope, configService, profileService, go) {
function($scope, $timeout, $log, configService, profileService, go) {
var config = configService.getSync();
this.colorOpts = [
'#DD4B39',
@ -33,12 +33,12 @@ angular.module('copayApp.controllers').controller('preferencesColorController',
opts.colorFor[walletId] = color;
configService.set(opts, function(err) {
if (err) {
$scope.$emit('Local/DeviceError', err);
return;
}
self.color = color;
if (err) $log.warn(err);
go.preferences();
$scope.$emit('Local/ColorUpdated');
$timeout(function() {
$scope.$apply();
}, 100);
});
};

View File

@ -0,0 +1,63 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesGlobalController',
function($scope, $rootScope, $log, configService, uxLanguage) {
this.init = function() {
var config = configService.getSync();
this.unitName = config.wallet.settings.unitName;
this.currentLanguageName = uxLanguage.getCurrentLanguageName();
this.selectedAlternative = {
name: config.wallet.settings.alternativeName,
isoCode: config.wallet.settings.alternativeIsoCode
};
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.glideraTestnet = config.glidera.testnet;
};
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
wallet: {
spendUnconfirmed: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/SpendUnconfirmedUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
enabled: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
testnet: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
$scope.$on('$destroy', function() {
unwatchSpendUnconfirmed();
unwatchGlideraEnabled();
unwatchGlideraTestnet();
});
});

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesLanguageController',
function($scope, $log, $timeout, configService, go, uxLanguage) {
function($scope, $log, $timeout, configService, uxLanguage, go) {
this.availableLanguages = uxLanguage.getLanguages();
@ -17,9 +17,10 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController
configService.set(opts, function(err) {
if (err) $log.warn(err);
go.preferencesGlobal();
$scope.$emit('Local/LanguageSettingUpdated');
$timeout(function() {
go.preferences();
$scope.$apply();
}, 100);
});
};

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesUnitController',
function($rootScope, $scope, $log, configService, go) {
function($scope, $timeout, $log, configService, go) {
var config = configService.getSync();
this.unitName = config.wallet.settings.unitName;
this.unitOpts = [
@ -52,8 +52,11 @@ angular.module('copayApp.controllers').controller('preferencesUnitController',
configService.set(opts, function(err) {
if (err) $log.warn(err);
go.preferencesGlobal();
$scope.$emit('Local/UnitSettingUpdated');
go.preferences();
$timeout(function() {
$scope.$apply();
}, 100);
});
};

View File

@ -433,11 +433,14 @@ angular
},
}
})
.state('settings', {
url: '/settings',
controller: 'settingsController',
templateUrl: 'views/settings.html',
needProfile: false
.state('preferencesGlobal', {
url: '/preferencesGlobal',
needProfile: true,
views: {
'main': {
templateUrl: 'views/preferencesGlobal.html',
},
}
})
.state('warning', {
url: '/warning',

View File

@ -21,6 +21,7 @@ angular.module('copayApp.services').factory('animationService', function(isCordo
uriglidera: -1,
preferences: 11,
preferencesGlobal: 11,
glidera: 11,
preferencesColor: 12,
backup: 12,
@ -151,4 +152,4 @@ angular.module('copayApp.services').factory('animationService', function(isCordo
}
return root;
});
});

View File

@ -79,6 +79,10 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
$state.go('preferences');
};
root.preferencesGlobal = function() {
$state.go('preferencesGlobal');
};
root.reload = function() {
$state.reload();
};