From 9027243052ad55ce07a37cc220a44941f77c2237 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Tue, 13 May 2014 14:19:37 -0300 Subject: [PATCH] added the settings page --- config.template.js | 17 +++++++++++-- index.html | 51 +++++++++++++++++++++++++++++++++++++- js/app.js | 4 ++- js/controllers/settings.js | 29 ++++++++++++++++++++++ js/routes.js | 4 +++ 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 js/controllers/settings.js diff --git a/config.template.js b/config.template.js index 0628849f0..f97bc0ae8 100644 --- a/config.template.js +++ b/config.template.js @@ -1,6 +1,7 @@ 'use strict'; -var config = { +var localConfig = JSON.parse(localStorage.getItem('config')); +var defaultConfig = { networkName: 'testnet', network: { // key: 'lwjd5qra8257b9', //Copay API key for public PeerJS server @@ -11,7 +12,7 @@ var config = { //path: '/', // key: 'g23ihfh82h35rf', // api key for the peerjs server - host: '162.242.219.26', // peerjs server + host: '162.242.245.33', // peerjs server port: 10009, path: '/', maxPeers: 15, @@ -105,6 +106,18 @@ var config = { verbose: 1, }; +var config = defaultConfig; + +// Merge localConfig +if (localConfig) { + var count = 0; + for (name in localConfig) { + if (localConfig.hasOwnProperty(name)) { + config[name] = localConfig[name]; + } + } +} + var log = function() { if (config.verbose) console.log(arguments); } diff --git a/index.html b/index.html index 5e168f9f1..33efc8f02 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,8 @@ + @@ -196,6 +198,7 @@
+ Settings · Create a new wallet · @@ -559,7 +562,7 @@ + + + @@ -626,6 +674,7 @@ + diff --git a/js/app.js b/js/app.js index db15e356c..30a55782e 100644 --- a/js/app.js +++ b/js/app.js @@ -21,7 +21,8 @@ var copayApp = window.copayApp = angular.module('copay',[ 'copay.directives', 'copay.video', 'copay.import', - 'copay.passphrase' + 'copay.passphrase', + 'copay.settings' ]); angular.module('copay.header', []); @@ -39,4 +40,5 @@ angular.module('copay.directives', []); angular.module('copay.video', []); angular.module('copay.import', []); angular.module('copay.passphrase', []); +angular.module('copay.settings', []); diff --git a/js/controllers/settings.js b/js/controllers/settings.js new file mode 100644 index 000000000..4db60ffd5 --- /dev/null +++ b/js/controllers/settings.js @@ -0,0 +1,29 @@ +'use strict'; + +angular.module('copay.settings').controller('SettingsController', + function($scope, $rootScope, $window) { + $scope.title = 'Settings'; + + $scope.networkName = config.networkName; + $scope.blockchainHost = config.blockchain.host; + $scope.blockchainPort = config.blockchain.port; + $scope.socketHost = config.socket.host; + $scope.socketPort = config.socket.port; + + $scope.save = function() { + localStorage.setItem('config', JSON.stringify({ + networkName: $scope.networkName, + blockchain: { + host: $scope.blockchainHost, + port: $scope.blockchainPort + }, + socket: { + host: $scope.socketHost, + port: $scope.socketPort + } + }) + ); + + $window.location.reload(); + }; + }); diff --git a/js/routes.js b/js/routes.js index 36ed4654b..3f445a1fa 100644 --- a/js/routes.js +++ b/js/routes.js @@ -42,6 +42,10 @@ angular templateUrl: 'backup.html', validate: true }) + .when('/settings', { + templateUrl: 'settings.html', + validate: false + }) .otherwise({ templateUrl: '404.html' });