mirror of https://github.com/BTCPrivate/copay.git
now plugins can be read on runtime
This commit is contained in:
parent
e4f5862576
commit
93b287bedc
10
js/app.js
10
js/app.js
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
var copay = require('copay');
|
var copay = require('copay');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var config = defaultConfig;
|
|
||||||
var LS = require('../js/plugins/LocalStorage');
|
var LS = require('../js/plugins/LocalStorage');
|
||||||
var ls = new LS();
|
var ls = new LS();
|
||||||
|
|
||||||
var localConfig;
|
|
||||||
var defaults = JSON.parse(JSON.stringify(defaultConfig));
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO move this to configService !
|
||||||
|
var config = copay.defaultConfig;
|
||||||
ls.getItem('config', function(err, data) {
|
ls.getItem('config', function(err, data) {
|
||||||
|
var localConfig;
|
||||||
|
try {
|
||||||
localConfig = JSON.parse(data);
|
localConfig = JSON.parse(data);
|
||||||
|
} catch(e) {};
|
||||||
if (localConfig) {
|
if (localConfig) {
|
||||||
var cmv = copay.version.split('.')[1];
|
var cmv = copay.version.split('.')[1];
|
||||||
var lmv = localConfig.version ? localConfig.version.split('.')[1] : '-1';
|
var lmv = localConfig.version ? localConfig.version.split('.')[1] : '-1';
|
||||||
|
@ -40,6 +41,7 @@ var modules = [
|
||||||
|
|
||||||
var copayApp = window.copayApp = angular.module('copayApp', modules);
|
var copayApp = window.copayApp = angular.module('copayApp', modules);
|
||||||
|
|
||||||
|
var defaults = JSON.parse(JSON.stringify(copay.defaultConfig));
|
||||||
copayApp.value('defaults', defaults);
|
copayApp.value('defaults', defaults);
|
||||||
|
|
||||||
copayApp.config(function($sceDelegateProvider) {
|
copayApp.config(function($sceDelegateProvider) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, notification, pluginManager, identityService, pinService, isMobile) {
|
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, notification, pluginManager, identityService, pinService, isMobile, configService) {
|
||||||
|
|
||||||
var _credentials, _firstpin;
|
var _credentials, _firstpin;
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.selectStorage = function (storage) {
|
$scope.selectStorage = function (storage) {
|
||||||
$scope.useLocalstorage = storage == 'local';
|
$scope.useLocalstorage = storage == 'local';
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
@ -58,16 +57,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setStorage = function(useLocalstorage) {
|
$scope.goToEmail = function() {
|
||||||
console.log('[createProfile.js.53:useLocalstorage:]', useLocalstorage); //TODO
|
|
||||||
console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO
|
console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO
|
||||||
//settingsService.save({...})
|
|
||||||
$scope.createStep = 'email';
|
$scope.createStep = 'email';
|
||||||
$scope.useEmail = !useLocalstorage;
|
$scope.useEmail = !$scope.useLocalstorage;
|
||||||
$scope.useLocalstorage = useLocalstorage;
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
}, 1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setEmailOrUsername = function(form) {
|
$scope.setEmailOrUsername = function(form) {
|
||||||
|
@ -97,14 +90,12 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.createProfile = function(form) {
|
|
||||||
$rootScope.hideNavigation = false;
|
$scope._doCreateProfile = function(emailOrUsername, password) {
|
||||||
if (form && form.$invalid) {
|
preconditions.checkArgument(_.isString(emailOrUsername));
|
||||||
$scope.error = 'Please enter the required fields';
|
preconditions.checkArgument(_.isString(password));
|
||||||
return;
|
|
||||||
}
|
identityService.create(emailOrUsername, password, function(err) {
|
||||||
$scope.loading = true;
|
|
||||||
identityService.create( $scope.userOrEmail, form.password.$modelValue, function(err) {
|
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -141,5 +132,32 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.createProfile = function(form) {
|
||||||
|
$rootScope.hideNavigation = false;
|
||||||
|
if (form && form.$invalid) {
|
||||||
|
$scope.error = 'Please enter the required fields';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
|
var plugins = config.plugins;
|
||||||
|
|
||||||
|
plugins.EncryptedLocalStorage = false;
|
||||||
|
plugins.EncryptedInsightStorage = false;
|
||||||
|
|
||||||
|
var pluginName = $scope.useLocalstorage ? 'EncryptedLocalStorage' : 'EncryptedInsightStorage';
|
||||||
|
|
||||||
|
plugins[pluginName] = true;
|
||||||
|
console.log('[createProfile.js.102:plugins:]', plugins); //TODO
|
||||||
|
|
||||||
|
configService.set({
|
||||||
|
plugins: plugins
|
||||||
|
}, function() {
|
||||||
|
$scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,8 +64,10 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
||||||
|
|
||||||
$scope.$on("$destroy", function() {
|
$scope.$on("$destroy", function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
removeWatch();
|
if (w) {
|
||||||
w.removeListener('txProposalEvent', _updateTxs);
|
removeWatch();
|
||||||
|
w.removeListener('txProposalEvent', _updateTxs);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.setAlternativeAmount = function(w, tx, cb) {
|
$scope.setAlternativeAmount = function(w, tx, cb) {
|
||||||
|
|
|
@ -4,20 +4,31 @@ angular.module('copayApp.services').factory('configService', function(localstora
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
root.set = function(opts, cb) {
|
root.set = function(opts, cb) {
|
||||||
copay.logger.setLevel(opts.logLevel);
|
|
||||||
localstorageService.getItem('config', function(err, oldOps) {
|
|
||||||
|
|
||||||
_.defaults(opts, JSON.parse(oldOps));
|
if (opts.logLevel)
|
||||||
|
copay.logger.setLevel(opts.logLevel);
|
||||||
|
|
||||||
|
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.
|
// TODO remove this gloval variable.
|
||||||
config = opts;
|
config = newOpts;
|
||||||
localstorageService.setItem('config', JSON.stringify(opts), cb);
|
|
||||||
|
localstorageService.setItem('config', JSON.stringify(newOpts), cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.reset = function(cb) {
|
root.reset = function(cb) {
|
||||||
config = copay.defaultConfig;
|
config = copay.defaultConfig;
|
||||||
localstorageService.removeItem('config',cb);
|
localstorageService.removeItem('config', cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
<span class="text-gray">Email address confirmation needed</span>
|
<span class="text-gray">Email address confirmation needed</span>
|
||||||
</div>
|
</div>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
||||||
<tab style="width: 50%;" select="selectStorage('local')">
|
<tab style="width: 50%;" select="selectStorage('local')">
|
||||||
<tab-heading>
|
<tab-heading>
|
||||||
<div class="m5t text-bold">In this Device </div>
|
<div class="m5t text-bold">In this Device </div>
|
||||||
|
@ -82,17 +81,11 @@
|
||||||
</tab>
|
</tab>
|
||||||
</tabset>
|
</tabset>
|
||||||
|
|
||||||
<button ng-show="!useLocalstorage" translate class="button primary radius expand m0" ng-click="setStorage(useLocalstorage)">
|
<button translate class="button primary radius expand m0" ng-click="goToEmail()">
|
||||||
Create in the cloud
|
<span ng-if="!useLocalstorage"> Create in the cloud</span>
|
||||||
|
<span ng-if="useLocalstorage"> Create in this device</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button ng-show="useLocalstorage" translate class="button primary radius expand m0" ng-click="setStorage(useLocalstorage)">
|
|
||||||
Create in this device
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="box-setup-footer">
|
<div class="box-setup-footer">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<a class="text-gray" href="#!/">
|
<a class="text-gray" href="#!/">
|
||||||
|
|
Loading…
Reference in New Issue