diff --git a/.gitignore b/.gitignore index 74839fb3b..ed1339448 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ browser-extensions/firefox/firefox-addon browser-extensions/firefox/data browser-extensions/firefox/copay.xpi version.js +!js/controllers/version.js android/package android/*.apk diff --git a/index.html b/index.html index f09603637..1df6aa092 100644 --- a/index.html +++ b/index.html @@ -107,6 +107,7 @@ + diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js index 7606483b9..ea185383e 100644 --- a/js/controllers/sidebar.js +++ b/js/controllers/sidebar.js @@ -3,8 +3,6 @@ angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $sce, $location, $http, notification, controllerUtils) { - $scope.version = copay.version; - $scope.networkName = config.networkName; $scope.menu = [{ 'title': 'Addresses', 'icon': 'fi-address-book', @@ -62,23 +60,6 @@ angular.module('copayApp.controllers').controller('SidebarController', return new Array(num); } - $http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) { - var toInt = function(s) { - return parseInt(s); - }; - var latestVersion = data[0].name.replace('v', '').split('.').map(toInt); - var currentVersion = copay.version.split('.').map(toInt); - var title = 'Copay ' + data[0].name + ' available.'; - var content; - if (currentVersion[0] < latestVersion[0]) { - content = 'It\'s important that you update your wallet at https://copay.io'; - notification.version(title, content, true); - } else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) { - var content = 'Please update your wallet at https://copay.io'; - notification.version(title, content, false); - } - }); - // Init socket handlers (with no wallet yet) controllerUtils.setSocketHandlers(); diff --git a/js/controllers/version.js b/js/controllers/version.js new file mode 100644 index 000000000..5e886c44a --- /dev/null +++ b/js/controllers/version.js @@ -0,0 +1,26 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('VersionController', + function($scope, $rootScope, $http, notification) { + + $scope.version = copay.version; + $scope.networkName = config.networkName; + + $http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) { + var toInt = function(s) { + return parseInt(s); + }; + var latestVersion = data[0].name.replace('v', '').split('.').map(toInt); + var currentVersion = copay.version.split('.').map(toInt); + var title = 'Copay ' + data[0].name + ' available.'; + var content; + if (currentVersion[0] < latestVersion[0]) { + content = 'It\'s important that you update your wallet at https://copay.io'; + notification.version(title, content, true); + } else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) { + var content = 'Please update your wallet at https://copay.io'; + notification.version(title, content, false); + } + }); + + }); diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index ba9d9e70e..02aa8c804 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -214,7 +214,7 @@ describe("Unit: Controllers", function() { }); - describe("Unit: Sidebar Controller", function() { + describe("Unit: Version Controller", function() { var scope, $httpBackendOut; var GH = 'https://api.github.com/repos/bitpay/copay/tags'; beforeEach(inject(function($controller, $injector) { @@ -235,7 +235,7 @@ describe("Unit: Controllers", function() { beforeEach(inject(function($controller, $rootScope) { rootScope = $rootScope; scope = $rootScope.$new(); - headerCtrl = $controller('SidebarController', { + headerCtrl = $controller('VersionController', { $scope: scope, }); })); @@ -273,8 +273,24 @@ describe("Unit: Controllers", function() { scope.$apply(); }); - it('should return an array of n undefined elements', function() { + it('should return networkName', function() { $httpBackend.flush(); // need flush + var networkName = scope.networkName; + expect(networkName).equal('livenet'); + }); + }); + + describe("Unit: Sidebar Controller", function() { + var rootScope; + beforeEach(inject(function($controller, $rootScope) { + rootScope = $rootScope; + scope = $rootScope.$new(); + headerCtrl = $controller('SidebarController', { + $scope: scope, + }); + })); + + it('should return an array of n undefined elements', function() { var n = 5; var array = scope.getNumber(n); expect(array.length).equal(n); diff --git a/views/copayers.html b/views/copayers.html index e71e2d6c0..8d3d32685 100644 --- a/views/copayers.html +++ b/views/copayers.html @@ -3,6 +3,7 @@
Copay +
diff --git a/views/home.html b/views/home.html index 8b9a0119c..463f5ebbf 100644 --- a/views/home.html +++ b/views/home.html @@ -2,6 +2,7 @@
Copay +
diff --git a/views/import.html b/views/import.html index 417eab447..101b5aa04 100644 --- a/views/import.html +++ b/views/import.html @@ -6,6 +6,7 @@
Copay +
diff --git a/views/includes/sidebar-mobile.html b/views/includes/sidebar-mobile.html index 506fcc54a..ef78fecf9 100644 --- a/views/includes/sidebar-mobile.html +++ b/views/includes/sidebar-mobile.html @@ -4,9 +4,7 @@ - v{{version}} - LIVENET - TESTNET +
diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index 00e71bcd5..4896d9dc6 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -4,11 +4,7 @@ -
- v{{version}} - LIVENET - TESTNET -
+
diff --git a/views/includes/version.html b/views/includes/version.html new file mode 100644 index 000000000..664152ca4 --- /dev/null +++ b/views/includes/version.html @@ -0,0 +1,5 @@ +
+ v{{version}} + [ {{networkName}} ] +
+ diff --git a/views/join.html b/views/join.html index 6e8ee1d95..cf9383790 100644 --- a/views/join.html +++ b/views/join.html @@ -6,6 +6,7 @@
Copay +
diff --git a/views/open.html b/views/open.html index e6055ce71..f58445e24 100644 --- a/views/open.html +++ b/views/open.html @@ -6,6 +6,7 @@
Copay +
diff --git a/views/settings.html b/views/settings.html index 69be68884..328c1bd45 100644 --- a/views/settings.html +++ b/views/settings.html @@ -2,6 +2,7 @@
Copay +
diff --git a/views/setup.html b/views/setup.html index 0d5cc6dd7..99ee4c25c 100644 --- a/views/setup.html +++ b/views/setup.html @@ -8,6 +8,7 @@
Copay +
diff --git a/views/unsupported.html b/views/unsupported.html index e3df0d3a5..073e5d4b2 100644 --- a/views/unsupported.html +++ b/views/unsupported.html @@ -1,5 +1,6 @@
Copay +

Browser unsupported