add change storage to settings

This commit is contained in:
Matias Alejo Garcia 2014-10-30 16:20:25 -03:00
commit d2f09291cf
7 changed files with 63 additions and 43 deletions

View file

@ -5,7 +5,6 @@ angular.module('copayApp.controllers').controller('HistoryController',
function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) {
controllerUtils.redirIfNotComplete();
var w = $rootScope.wallet;
$scope.loading = false;
@ -18,6 +17,7 @@ angular.module('copayApp.controllers').controller('HistoryController',
var satToUnit = 1 / w.settings.unitToSatoshi;
$scope.update = function() {
$scope.loading = true;
var from = ($scope.txpCurrentPage - 1) * $scope.txpItemsPerPage;
@ -31,6 +31,8 @@ angular.module('copayApp.controllers').controller('HistoryController',
}, 0);
};
$scope.show = function() {
$scope.loading = true;
setTimeout(function() {
@ -38,20 +40,15 @@ angular.module('copayApp.controllers').controller('HistoryController',
}, 10);
};
$scope.toogleLast = function() {
$scope.lastShowed = !$scope.lastShowed;
if ($scope.lastShowed) {
$scope.getTransactions();
}
};
$scope.getTransactions = function() {
var self = this;
var w = $rootScope.wallet;
if (!w) return;
$scope.blockchain_txs = w.cached_txs || [];
$scope.loading = true;
w.getTransactionHistory(function(err, res) {
if (err) throw err;
@ -77,13 +74,6 @@ angular.module('copayApp.controllers').controller('HistoryController',
$scope.getShortNetworkName = function() {
return w.getNetworkName().substring(0, 4);
};
// Autoload transactions on 1-of-1
if ($rootScope.wallet && $rootScope.wallet.totalCopayers == 1) {
$scope.lastShowed = true;
$scope.getTransactions();
}
$scope.amountAlternative = function(amount, txIndex, cb) {
var w = $rootScope.wallet;
rateService.whenAvailable(function() {
@ -92,4 +82,7 @@ angular.module('copayApp.controllers').controller('HistoryController',
return cb ? cb() : null;
});
};
// Autoload transactions
$scope.getTransactions();
});

View file

@ -8,6 +8,23 @@ angular.module('copayApp.controllers').controller('SettingsController', function
$scope.insightLivenet = config.network.livenet.url;
$scope.insightTestnet = config.network.testnet.url;
$scope.availableStorages = [{
name: 'Insight',
pluginName: 'EncryptedInsightStorage',
}, {
name: 'Localstorage',
pluginName: 'EncryptedLocalStorage',
},
// {
// name: 'GoogleDrive',
// pluginName: 'GoogleDrive',
// }
];
_.each($scope.availableStorages, function(v){
if (config.plugins[v.pluginName])
$scope.selectedStorage = v;
});
$scope.availableLanguages = [{
name: 'English',
@ -39,11 +56,14 @@ angular.module('copayApp.controllers').controller('SettingsController', function
},
}
var plugins = {};
plugins[$scope.selectedStorage.pluginName] = true;
localStorage.setItem('config', JSON.stringify({
network: insightSettings,
version: copay.version,
defaultLanguage: $scope.selectedLanguage.isoCode
defaultLanguage: $scope.selectedLanguage.isoCode,
plugins: plugins,
}));
// Go home reloading the application

View file

@ -32,22 +32,23 @@ angular.module('copayApp.services')
root.logout = function() {
if ($rootScope.iden) {
$rootScope.iden.store(null, function(){
$rootScope.iden.store(null, function() {
$rootScope.iden.close();
delete $rootScope['wallet'];
delete $rootScope['iden'];
// Clear rootScope
for (var i in $rootScope) {
if (i.charAt(0) != '$') {
delete $rootScope[i];
}
}
$location.path('/');
});
}
delete $rootScope['wallet'];
delete $rootScope['iden'];
// Clear rootScope
for (var i in $rootScope) {
if (i.charAt(0) != '$') {
delete $rootScope[i];
}
}
$location.path('/');
};
root.onError = function(scope) {