view logs in UX
This commit is contained in:
parent
6723cba56a
commit
f47d6b0564
16 changed files with 188 additions and 47 deletions
|
|
@ -1,10 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('configService', function(localStorageService, fileStorageService, isCordova, lodash, bwcService) {
|
||||
angular.module('copayApp.services').factory('configService', function(storageService, lodash) {
|
||||
var root = {};
|
||||
|
||||
var storage = isCordova ? fileStorageService : localStorageService;
|
||||
|
||||
var defaultConfig = {
|
||||
// wallet limits
|
||||
limits: {
|
||||
|
|
@ -17,18 +15,6 @@ angular.module('copayApp.services').factory('configService', function(localStora
|
|||
url: 'https://bws.bitpay.com/bws/api',
|
||||
},
|
||||
|
||||
// insight
|
||||
insight: {
|
||||
testnet: {
|
||||
url: 'https://test-insight.bitpay.com:443',
|
||||
transports: ['polling'],
|
||||
},
|
||||
livenet: {
|
||||
url: 'https://insight.bitpay.com:443',
|
||||
transports: ['polling'],
|
||||
},
|
||||
},
|
||||
|
||||
// wallet default config
|
||||
wallet: {
|
||||
requiredCopayers: 2,
|
||||
|
|
@ -46,12 +32,6 @@ angular.module('copayApp.services').factory('configService', function(localStora
|
|||
}
|
||||
},
|
||||
|
||||
// local encryption/security config
|
||||
passphraseConfig: {
|
||||
iterations: 5000,
|
||||
storageSalt: 'mjuBtGybi/4=',
|
||||
},
|
||||
|
||||
rates: {
|
||||
url: 'https://insight.bitpay.com:443/api/rates',
|
||||
},
|
||||
|
|
@ -68,7 +48,7 @@ angular.module('copayApp.services').factory('configService', function(localStora
|
|||
};
|
||||
|
||||
root.get = function(cb) {
|
||||
storage.get('config', function(err, localConfig) {
|
||||
storageService.getConfig(function(err, localConfig) {
|
||||
if (localConfig) {
|
||||
configCache = JSON.parse(localConfig);
|
||||
|
||||
|
|
@ -90,7 +70,7 @@ angular.module('copayApp.services').factory('configService', function(localStora
|
|||
|
||||
root.set = function(newOpts, cb) {
|
||||
var config = defaultConfig;
|
||||
storage.get('config', function(err, oldOpts) {
|
||||
storageService.getConfig(function(err, oldOpts) {
|
||||
if (lodash.isString(oldOpts)) {
|
||||
oldOpts = JSON.parse(oldOpts);
|
||||
}
|
||||
|
|
@ -103,23 +83,19 @@ angular.module('copayApp.services').factory('configService', function(localStora
|
|||
lodash.merge(config, oldOpts, newOpts);
|
||||
configCache = config;
|
||||
|
||||
storage.set('config', JSON.stringify(config), cb);
|
||||
storageService.setConfig(JSON.stringify(config), cb);
|
||||
});
|
||||
};
|
||||
|
||||
root.reset = function(cb) {
|
||||
storage.remove('config', cb);
|
||||
configCache = lodash.clone(defaultConfig);
|
||||
storageService.removeConfig(cb);
|
||||
};
|
||||
|
||||
root.getDefaults = function() {
|
||||
return defaultConfig;
|
||||
return lodash.clone(defaultConfig);
|
||||
};
|
||||
|
||||
root.get(function(err, c) {
|
||||
if (err) throw Error(err);
|
||||
bwcService.setBaseUrl(c.bws.url);
|
||||
bwcService.setTransports(['polling']);
|
||||
});
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
19
src/js/services/historicLog.js
Normal file
19
src/js/services/historicLog.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
var logs = [];
|
||||
angular.module('copayApp.services')
|
||||
.factory('historicLog', function historicLog() {
|
||||
var root = {};
|
||||
|
||||
root.add = function(level, msg) {
|
||||
logs.push({
|
||||
level: level,
|
||||
msg: msg,
|
||||
});
|
||||
};
|
||||
|
||||
root.get = function() {
|
||||
return logs;
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
@ -110,11 +110,20 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
|
||||
root.applyConfig = function() {
|
||||
var config = configService.getSync();
|
||||
$log.debug('Applying preferences');
|
||||
bwcService.setBaseUrl(config.bws.url);
|
||||
bwcService.setTransports(['polling']);
|
||||
};
|
||||
|
||||
root.bindProfile = function(profile, cb) {
|
||||
root.profile = profile;
|
||||
|
||||
configService.get(function(err) {
|
||||
$log.debug('Preferences read');
|
||||
if (err) return cb(err);
|
||||
root.applyConfig();
|
||||
$rootScope.$emit('Local/DefaultLanguage');
|
||||
root.setWalletClients();
|
||||
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
||||
|
|
@ -124,7 +133,6 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
root.loadAndBindProfile = function(cb) {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (err) {
|
||||
|
|
@ -132,6 +140,7 @@ angular.module('copayApp.services')
|
|||
return cb(err);
|
||||
}
|
||||
if (!profile) return cb(new Error('NOPROFILE: No profile'));
|
||||
$log.debug('Profile read');
|
||||
|
||||
return root.bindProfile(profile, cb);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -111,5 +111,17 @@ angular.module('copayApp.services')
|
|||
storage.get('backup-' + walletId, cb);
|
||||
};
|
||||
|
||||
root.getConfig = function(cb) {
|
||||
storage.get('config', cb);
|
||||
};
|
||||
|
||||
root.storeConfig = function(val, cb) {
|
||||
storage.set('config', val, cb);
|
||||
};
|
||||
|
||||
root.clearConfig = function(cb) {
|
||||
storage.remove('config', cb);
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue