add configService

This commit is contained in:
Matias Alejo Garcia 2014-12-05 13:24:46 -03:00
commit e4f5862576
7 changed files with 73 additions and 43 deletions

View file

@ -0,0 +1,24 @@
'use strict';
angular.module('copayApp.services').factory('configService', function(localstorageService) {
var root = {};
root.set = function(opts, cb) {
copay.logger.setLevel(opts.logLevel);
localstorageService.getItem('config', function(err, oldOps) {
_.defaults(opts, JSON.parse(oldOps));
// TODO remove this gloval variable.
config = opts;
localstorageService.setItem('config', JSON.stringify(opts), cb);
});
};
root.reset = function(cb) {
config = copay.defaultConfig;
localstorageService.removeItem('config',cb);
};
return root;
});

View file

@ -11,10 +11,10 @@ angular.module('copayApp.services')
var root = {};
root.check = function(scope) {
copay.Identity.checkIfExistsAny({
pluginManager: pluginManager,
pluginManager: pluginManager.getInstance(config),
}, function(anyProfile) {
copay.Wallet.checkIfExistsAny({
pluginManager: pluginManager,
pluginManager: pluginManager.getInstance(config),
}, function(anyWallet) {
scope.loading = false;
scope.anyProfile = anyProfile ? true : false;
@ -47,7 +47,7 @@ angular.module('copayApp.services')
copay.Identity.create({
email: email,
password: password,
pluginManager: pluginManager,
pluginManager: pluginManager.getInstance(config),
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
@ -99,7 +99,7 @@ angular.module('copayApp.services')
var opts = {
email: email,
password: password,
pluginManager: pluginManager,
pluginManager: pluginManager.getInstance(config),
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
@ -344,7 +344,7 @@ angular.module('copayApp.services')
root.importProfile = function(str, password, cb) {
copay.Identity.importFromEncryptedFullJson(str, password, {
pluginManager: pluginManager,
pluginManager: pluginManager.getInstance(config),
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,

View file

@ -1,6 +1,10 @@
'use strict';
angular.module('copayApp.services').factory('pluginManager', function() {
var pm = new copay.PluginManager(config);
return pm;
var root = {};
root.getInstance = function(config){
return new copay.PluginManager(config);
};
return root;
});