commit
5bba50b18d
21 changed files with 547 additions and 226 deletions
38
js/services/configService.js
Normal file
38
js/services/configService.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('configService', function(localstorageService, gettextCatalog) {
|
||||
var root = {};
|
||||
|
||||
root.set = function(opts, cb) {
|
||||
|
||||
if (opts.logLevel)
|
||||
copay.logger.setLevel(opts.logLevel);
|
||||
|
||||
if (opts.defaultLanguage)
|
||||
gettextCatalog.currentLanguage = opts.defaultLanguage;
|
||||
|
||||
localstorageService.getItem('config', function(err, oldOpsStr) {
|
||||
|
||||
var oldOpts = {};
|
||||
|
||||
try {
|
||||
oldOpts = JSON.parse(oldOpsStr);
|
||||
} catch (e) {};
|
||||
|
||||
var newOpts = {};
|
||||
_.extend(newOpts, copay.defaultConfig, oldOpts, opts);
|
||||
|
||||
// TODO remove this gloval variable.
|
||||
config = newOpts;
|
||||
|
||||
localstorageService.setItem('config', JSON.stringify(newOpts), cb);
|
||||
});
|
||||
};
|
||||
|
||||
root.reset = function(cb) {
|
||||
config = copay.defaultConfig;
|
||||
localstorageService.removeItem('config', cb);
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
@ -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,
|
||||
|
|
@ -348,7 +348,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,
|
||||
|
|
|
|||
|
|
@ -1,18 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('pluginManager', function(angularLoad) {
|
||||
var pm = new copay.PluginManager(config);
|
||||
var scripts = pm.scripts;
|
||||
angular.module('copayApp.services').factory('pluginManager', function() {
|
||||
var root = {};
|
||||
root.getInstance = function(config){
|
||||
return new copay.PluginManager(config);
|
||||
};
|
||||
|
||||
for(var ii in scripts){
|
||||
var src = scripts[ii].src;
|
||||
|
||||
console.log('\tLoading ',src); //TODO
|
||||
angularLoad.loadScript(src)
|
||||
.then(scripts[ii].then || null)
|
||||
.catch(function() {
|
||||
throw new Error('Loading ' + src);
|
||||
})
|
||||
}
|
||||
return pm;
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue