From 8379f83c67ae1cdcf190ae9cc9de823ba9b4627c Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Tue, 14 Oct 2014 15:31:23 -0300 Subject: [PATCH 1/5] Fix for 1231, show insight-url when is not default. --- js/app.js | 5 +++++ js/controllers/create.js | 5 +++++ views/create.html | 1 + 3 files changed, 11 insertions(+) diff --git a/js/app.js b/js/app.js index e1ddb0b7a..023706eb0 100644 --- a/js/app.js +++ b/js/app.js @@ -38,6 +38,11 @@ if (Object.keys(config.plugins).length) var copayApp = window.copayApp = angular.module('copayApp', modules); +copayApp.value('defaults', { + livenetUrl: 'https://insight.bitpay.com:443', + testnetUrl: 'https://test-insight.bitpay.com:443' +}); + copayApp.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'self', diff --git a/js/controllers/create.js b/js/controllers/create.js index 448b618f7..45cd4a05f 100644 --- a/js/controllers/create.js +++ b/js/controllers/create.js @@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('CreateController', $scope.isMobile = !!window.cordova; $scope.hideAdv = true; $scope.networkName = config.networkName; + $scope.networkUrl = config.network[$scope.networkName].url; // ng-repeat defined number of times instead of repeating over array? $scope.getNumber = function(num) { @@ -31,6 +32,10 @@ angular.module('copayApp.controllers').controller('CreateController', updateRCSelect(tc); }); + $scope.$watch('networkName', function(tc) { + $scope.networkUrl = config.network[$scope.networkName].url; + }); + $scope.create = function(form) { if (form && form.$invalid) { notification.error('Error', 'Please enter the required fields'); diff --git a/views/create.html b/views/create.html index b2eef27ed..6554e561b 100644 --- a/views/create.html +++ b/views/create.html @@ -88,6 +88,7 @@ Next +

Using network: {{networkName}} at {{networkUrl}}

From 152d4b1eb6418e19b97f9f68df650443849181cd Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Tue, 14 Oct 2014 15:33:52 -0300 Subject: [PATCH 2/5] Add function showNetwork() --- js/controllers/create.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/controllers/create.js b/js/controllers/create.js index 45cd4a05f..06dff7319 100644 --- a/js/controllers/create.js +++ b/js/controllers/create.js @@ -36,6 +36,10 @@ angular.module('copayApp.controllers').controller('CreateController', $scope.networkUrl = config.network[$scope.networkName].url; }); + $scope.showNetwork = function(){ + return $scope.networkUrl != defaults.livenetUrl && $scope.networkUrl != defaults.testnetUrl; + }; + $scope.create = function(form) { if (form && form.$invalid) { notification.error('Error', 'Please enter the required fields'); From 718fb8d861835440363fa51edcaef4dd91af477e Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Tue, 14 Oct 2014 15:35:46 -0300 Subject: [PATCH 3/5] Injects "defaults" const in controller --- js/controllers/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/controllers/create.js b/js/controllers/create.js index 06dff7319..399698b85 100644 --- a/js/controllers/create.js +++ b/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('CreateController', - function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase, backupService, notification) { + function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase, backupService, notification, defaults) { controllerUtils.redirIfLogged(); $rootScope.fromSetup = true; From b25633eb7018efbc3fdafc0b00144e5d7296d157 Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Tue, 14 Oct 2014 17:03:09 -0300 Subject: [PATCH 4/5] Removed constants from app.js, now takes the values from config.js and makes the injectable. --- js/app.js | 5 +---- js/controllers/create.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/js/app.js b/js/app.js index 023706eb0..f0931f22e 100644 --- a/js/app.js +++ b/js/app.js @@ -38,10 +38,7 @@ if (Object.keys(config.plugins).length) var copayApp = window.copayApp = angular.module('copayApp', modules); -copayApp.value('defaults', { - livenetUrl: 'https://insight.bitpay.com:443', - testnetUrl: 'https://test-insight.bitpay.com:443' -}); +copayApp.value('defaults', defaultConfig); copayApp.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ diff --git a/js/controllers/create.js b/js/controllers/create.js index 399698b85..77059bb92 100644 --- a/js/controllers/create.js +++ b/js/controllers/create.js @@ -37,7 +37,7 @@ angular.module('copayApp.controllers').controller('CreateController', }); $scope.showNetwork = function(){ - return $scope.networkUrl != defaults.livenetUrl && $scope.networkUrl != defaults.testnetUrl; + return $scope.networkUrl != defaults.network.livenet.url && $scope.networkUrl != defaults.network.testnet.url; }; $scope.create = function(form) { From 2a2542f6d05a389b64fcd8529e2888e330add996 Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Tue, 14 Oct 2014 18:47:39 -0300 Subject: [PATCH 5/5] Fix for object clone (defaultConfig was being overwritten from the settings) --- js/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index f0931f22e..5209dea82 100644 --- a/js/app.js +++ b/js/app.js @@ -4,6 +4,7 @@ var copay = require('copay'); var _ = require('underscore'); var config = defaultConfig; var localConfig = JSON.parse(localStorage.getItem('config')); +var defaults = JSON.parse(JSON.stringify(defaultConfig)); if (localConfig) { var cmv = copay.version.split('.')[1]; @@ -38,7 +39,7 @@ if (Object.keys(config.plugins).length) var copayApp = window.copayApp = angular.module('copayApp', modules); -copayApp.value('defaults', defaultConfig); +copayApp.value('defaults', defaults); copayApp.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([