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 _ = require('lodash');
|
||||
var config = defaultConfig;
|
||||
var LS = require('../js/plugins/LocalStorage');
|
||||
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) {
|
||||
var localConfig;
|
||||
try {
|
||||
localConfig = JSON.parse(data);
|
||||
} catch(e) {};
|
||||
if (localConfig) {
|
||||
var cmv = copay.version.split('.')[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 defaults = JSON.parse(JSON.stringify(copay.defaultConfig));
|
||||
copayApp.value('defaults', defaults);
|
||||
|
||||
copayApp.config(function($sceDelegateProvider) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'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;
|
||||
|
||||
|
@ -50,7 +50,6 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.selectStorage = function (storage) {
|
||||
$scope.useLocalstorage = storage == 'local';
|
||||
$timeout(function() {
|
||||
|
@ -58,16 +57,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
}, 1);
|
||||
};
|
||||
|
||||
$scope.setStorage = function(useLocalstorage) {
|
||||
console.log('[createProfile.js.53:useLocalstorage:]', useLocalstorage); //TODO
|
||||
$scope.goToEmail = function() {
|
||||
console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO
|
||||
//settingsService.save({...})
|
||||
$scope.createStep = 'email';
|
||||
$scope.useEmail = !useLocalstorage;
|
||||
$scope.useLocalstorage = useLocalstorage;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 1);
|
||||
$scope.useEmail = !$scope.useLocalstorage;
|
||||
};
|
||||
|
||||
$scope.setEmailOrUsername = function(form) {
|
||||
|
@ -97,14 +90,12 @@ 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;
|
||||
identityService.create( $scope.userOrEmail, form.password.$modelValue, function(err) {
|
||||
|
||||
$scope._doCreateProfile = function(emailOrUsername, password) {
|
||||
preconditions.checkArgument(_.isString(emailOrUsername));
|
||||
preconditions.checkArgument(_.isString(password));
|
||||
|
||||
identityService.create(emailOrUsername, password, function(err) {
|
||||
$scope.loading = false;
|
||||
|
||||
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() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
removeWatch();
|
||||
w.removeListener('txProposalEvent', _updateTxs);
|
||||
};
|
||||
});
|
||||
|
||||
$scope.setAlternativeAmount = function(w, tx, cb) {
|
||||
|
|
|
@ -4,14 +4,25 @@ angular.module('copayApp.services').factory('configService', function(localstora
|
|||
var root = {};
|
||||
|
||||
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.
|
||||
config = opts;
|
||||
localstorageService.setItem('config', JSON.stringify(opts), cb);
|
||||
config = newOpts;
|
||||
|
||||
localstorageService.setItem('config', JSON.stringify(newOpts), cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
<span class="text-gray">Email address confirmation needed</span>
|
||||
</div>
|
||||
</tab>
|
||||
|
||||
<tab style="width: 50%;" select="selectStorage('local')">
|
||||
<tab-heading>
|
||||
<div class="m5t text-bold">In this Device </div>
|
||||
|
@ -82,17 +81,11 @@
|
|||
</tab>
|
||||
</tabset>
|
||||
|
||||
<button ng-show="!useLocalstorage" translate class="button primary radius expand m0" ng-click="setStorage(useLocalstorage)">
|
||||
Create in the cloud
|
||||
<button translate class="button primary radius expand m0" ng-click="goToEmail()">
|
||||
<span ng-if="!useLocalstorage"> Create in the cloud</span>
|
||||
<span ng-if="useLocalstorage"> Create in this device</span>
|
||||
</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="left">
|
||||
<a class="text-gray" href="#!/">
|
||||
|
|
Loading…
Reference in New Issue