From c19a1e5aafdca0bf3b1087cb90d44da8b58abd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Tue, 13 Jan 2015 13:42:33 -0500 Subject: [PATCH 01/17] Add information to readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Vachon --- readme.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.rst b/readme.rst index 6a09933..66657aa 100644 --- a/readme.rst +++ b/readme.rst @@ -9,6 +9,7 @@ Installation :: + sudo apt-get install npm nodejs-legacy git clone https://github.com/titilambert/adagios-frontend.git cd adagios-frontend npm install From de8a385146dfe4a3975a4ec8461513fe92bb7e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Tue, 13 Jan 2015 15:02:29 -0500 Subject: [PATCH 02/17] Add informations to readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Vachon --- readme.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/readme.rst b/readme.rst index 66657aa..c11eb78 100644 --- a/readme.rst +++ b/readme.rst @@ -9,22 +9,21 @@ Installation :: - sudo apt-get install npm nodejs-legacy - git clone https://github.com/titilambert/adagios-frontend.git - cd adagios-frontend - npm install - + sudo apt-get install npm nodejs-legacy + git clone https://github.com/titilambert/adagios-frontend.git + cd adagios-frontend + npm install Dev === -Use grunt to get css files - +Auto-refresh css files :: - grunt + npm install grunt-cli + grunt Launch @@ -32,9 +31,7 @@ Launch :: - npm start + npm start Now, go on http://127.0.0.1:8000 - - From d00dc71e134d9ad71f51225238c67a7d2dce6f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 15 Jan 2015 11:54:23 -0500 Subject: [PATCH 03/17] Added coding style linter --- Gruntfile.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index c7e0252..1f02afc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,8 +1,8 @@ 'use strict'; module.exports = function(grunt) { - grunt.initConfig({ + grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), @@ -30,12 +30,43 @@ module.exports = function(grunt) { files: '<%= project.assets %>/sass/{,*/}*.{scss,sass}', tasks: ['sass:dev'] } + }, + + jslint: { // configure the task + + client: { + src: [ + 'app/app.js', + 'app/**/*.js' + ], + exclude: [ + 'app/bower_components/**/*.js', + 'app/assets/**/*' + ], + directives: { // example directives + node: true, + todo: true + }, + options: { + edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path + junit: 'out/client-junit.xml', // write the output to a JUnit XML + log: 'out/client-lint.log', + jslintXml: 'out/client-jslint.xml', + errorsOnly: true, // only display errors + failOnError: false, // defaults to true + checkstyle: 'out/client-checkstyle.xml' // write a checkstyle-XML + } } + } }); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-jslint'); + + grunt.registerTask('default', 'jslint'); grunt.registerTask('default', [ 'watch' ]); + }; From a63892aa2d492b7518cbb87a2837098ae5151a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 15 Jan 2015 14:46:34 -0500 Subject: [PATCH 04/17] Adapt code to coding standard --- app/app.js | 18 ++-- app/components/live/notifications.js | 15 +-- app/components/ng-justgage/ng-justgage.js | 92 ++++++++++--------- app/navbar/navbar.js | 20 ++-- app/sidebar/sidebar.js | 19 ++-- app/tactical/current_health/current_health.js | 28 +++--- .../status_overview/status_overview.js | 36 ++++---- app/tactical/tactical.js | 17 ++-- .../top_alert_producers.js | 39 +++++--- 9 files changed, 152 insertions(+), 132 deletions(-) diff --git a/app/app.js b/app/app.js index c83b9d5..61a5cf8 100644 --- a/app/app.js +++ b/app/app.js @@ -1,13 +1,13 @@ +/*global angular*/ 'use strict'; -// Declare app level module which depends on views, and components angular.module('adagios', [ - 'ngRoute', - 'adagios.sidebar', - 'adagios.navbar', - 'adagios.tactical' -]). + 'ngRoute', + 'adagios.sidebar', + 'adagios.navbar', + 'adagios.tactical' +]) -config(['$routeProvider', function($routeProvider) { - $routeProvider.otherwise({redirectTo: '/'}); -}]); + .config(['$routeProvider', function ($routeProvider) { + $routeProvider.otherwise({redirectTo: '/'}); + }]); diff --git a/app/components/live/notifications.js b/app/components/live/notifications.js index 0bfdc72..0e0802f 100644 --- a/app/components/live/notifications.js +++ b/app/components/live/notifications.js @@ -1,10 +1,11 @@ +/*global angular*/ 'use strict'; - angular.module('adagios.live', []) -.factory('GetProblems', ['$http', function($http) { - // $http.get("/getproblems") - var problem_number = 44; - // factory function body that constructs shinyNewServiceInstance - return problem_number; -}]); + + .factory('GetProblems', ['$http', function ($http) { + // $http.get("/getproblems") + var problem_number = 44; + // factory function body that constructs shinyNewServiceInstance + return problem_number; + }]); diff --git a/app/components/ng-justgage/ng-justgage.js b/app/components/ng-justgage/ng-justgage.js index b6f6e3c..e0a6c9c 100644 --- a/app/components/ng-justgage/ng-justgage.js +++ b/app/components/ng-justgage/ng-justgage.js @@ -1,45 +1,55 @@ +/*global angular, JustGage*/ +'use strict'; + angular.module("ngJustGage", []) - .directive('justGage', ['$timeout', function ($timeout) { - return { - restrict: 'EA', - scope: { - id: '@', - class: '@', - min: '=', - max: '=', - title: '@', - value: '=', - options: '=' - }, - template: '
', - link: function (scope,element,attrs) { - $timeout(function () { - var options = { - id: scope.id + '-justgage', - min: scope.min, - max: scope.max, - title: scope.title, - value: scope.value - } - if ( scope.options ) { - for (var key in scope.options) { - options[key]=scope.options[key]; - } - } - var graph = new JustGage(options); + .directive('justGage', ['$timeout', function ($timeout) { + return { + restrict: 'EA', + scope: { + id: '@', + class: '@', + min: '=', + max: '=', + title: '@', + value: '=', + options: '=' + }, + template: '
', + link: function (scope, element, attrs) { + $timeout(function () { + var options, key, graph; - scope.$watch('max', function (updatedMax) { - if (updatedMax !== undefined) { - graph.refresh(scope.value, updatedMax); - } - }, true); + options = { + id: scope.id + '-justgage', + min: scope.min, + max: scope.max, + title: scope.title, + value: scope.value + }; - scope.$watch('value', function (updatedValue) { - if (updatedValue !== undefined) { - graph.refresh(updatedValue); + if (scope.options) { + for (key in scope.options) { + if (scope.options.hasOwnProperty(key)) { + options[key] = scope.options[key]; + } + } + } + + graph = new JustGage(options); + + scope.$watch('max', function (updatedMax) { + if (updatedMax !== undefined) { + graph.refresh(scope.value, updatedMax); + } + }, true); + + scope.$watch('value', function (updatedValue) { + if (updatedValue !== undefined) { + graph.refresh(updatedValue); + } + }, true); + + }); } - }, true); - }); - } - }; - }]); + }; + }]); diff --git a/app/navbar/navbar.js b/app/navbar/navbar.js index 6b07b23..6d8cde2 100644 --- a/app/navbar/navbar.js +++ b/app/navbar/navbar.js @@ -1,17 +1,15 @@ +/*global angular*/ 'use strict'; angular.module('adagios.navbar', ['adagios.live']) -.controller('NavBarCtrl', ['$scope', '$http', 'GetProblems', - function($scope, $http, GetProblems) { - $scope.notifications = GetProblems; + .controller('NavBarCtrl', ['$scope', '$http', 'GetProblems', function ($scope, $http, GetProblems) { + $scope.notifications = GetProblems; }]) -.directive('navbar', function() { - return { - restrict: 'E', - templateUrl: "navbar/navbar.html" - }; -}); - - + .directive('navbar', function () { + return { + restrict: 'E', + templateUrl: "navbar/navbar.html" + }; + }); diff --git a/app/sidebar/sidebar.js b/app/sidebar/sidebar.js index 7c890a4..c7179bb 100644 --- a/app/sidebar/sidebar.js +++ b/app/sidebar/sidebar.js @@ -1,16 +1,15 @@ +/*global angular*/ 'use strict'; angular.module('adagios.sidebar', []) -.controller('SideBarCtrl', ['$scope', '$http', - function($scope, $http) { + .controller('SideBarCtrl', ['$scope', '$http', function ($scope, $http) { + }]) -.directive('sidebar', function() { - return { - restrict: 'E', - templateUrl: "sidebar/sidebar.html" - }; -}); - - + .directive('sidebar', function () { + return { + restrict: 'E', + templateUrl: "sidebar/sidebar.html" + }; + }); diff --git a/app/tactical/current_health/current_health.js b/app/tactical/current_health/current_health.js index 515bd1c..ef8e2d2 100644 --- a/app/tactical/current_health/current_health.js +++ b/app/tactical/current_health/current_health.js @@ -1,18 +1,16 @@ +/*global angular*/ +'use strict'; -angular.module('adagios.tactical.current_health', ['ngRoute', - 'ngJustGage' - ]) -.controller('TacticalCurrentHealth', ['$scope', '$http', - function($scope, $http) { - $scope.hosts = 75.2; - $scope.services = 94.4; +angular.module('adagios.tactical.current_health', ['ngRoute', 'ngJustGage' ]) + + .controller('TacticalCurrentHealth', ['$scope', '$http', function ($scope, $http) { + $scope.hosts = 75.2; + $scope.services = 94.4; }]) -.directive('currenthealth', function() { - return { - restrict: 'E', - templateUrl: "tactical/current_health/current_health.html" - }; -}); - - + .directive('currenthealth', function () { + return { + restrict: 'E', + templateUrl: "tactical/current_health/current_health.html" + }; + }); diff --git a/app/tactical/status_overview/status_overview.js b/app/tactical/status_overview/status_overview.js index 454836b..e9593e2 100644 --- a/app/tactical/status_overview/status_overview.js +++ b/app/tactical/status_overview/status_overview.js @@ -1,19 +1,23 @@ +/*global angular*/ +'use strict'; -angular.module('adagios.tactical.status_overview', ['ngRoute' - ]) -.controller('TacticalStatusOverViewCtrl', ['$scope', '$http', - function($scope, $http) { - $scope.hosts = {"count": 104, - "problems": 14}; - $scope.services = {"count": 1126, - "problems": 42}; +angular.module('adagios.tactical.status_overview', ['ngRoute' ]) + + .controller('TacticalStatusOverViewCtrl', ['$scope', '$http', function ($scope, $http) { + $scope.hosts = { + "count": 104, + "problems": 14 + }; + + $scope.services = { + "count": 1126, + "problems": 42 + }; }]) -.directive('statusoverview', function() { - return { - restrict: 'E', - templateUrl: "tactical/status_overview/status_overview.html" - }; -}); - - + .directive('statusoverview', function () { + return { + restrict: 'E', + templateUrl: "tactical/status_overview/status_overview.html" + }; + }); diff --git a/app/tactical/tactical.js b/app/tactical/tactical.js index 337b600..32d129f 100644 --- a/app/tactical/tactical.js +++ b/app/tactical/tactical.js @@ -1,3 +1,5 @@ +/*global angular*/ +'use strict'; angular.module('adagios.tactical', ['ngRoute', 'adagios.tactical.status_overview', @@ -5,13 +7,12 @@ angular.module('adagios.tactical', ['ngRoute', 'adagios.tactical.top_alert_producers' ]) -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/tactical', {templateUrl: 'tactical/tactical.html', controller: 'TacticalCtrl'}); -}]) - - - -.controller('TacticalCtrl', ['$scope', '$http', - function($scope, $http) { + .config(['$routeProvider', function ($routeProvider) { + $routeProvider.when('/tactical', { + templateUrl: 'tactical/tactical.html', + controller: 'TacticalCtrl' + }); }]) + .controller('TacticalCtrl', ['$scope', '$http', function ($scope, $http) { + }]); diff --git a/app/tactical/top_alert_producers/top_alert_producers.js b/app/tactical/top_alert_producers/top_alert_producers.js index 236c654..0508f43 100644 --- a/app/tactical/top_alert_producers/top_alert_producers.js +++ b/app/tactical/top_alert_producers/top_alert_producers.js @@ -1,18 +1,27 @@ +/*global angular*/ +'use strict'; -angular.module('adagios.tactical.top_alert_producers', ['ngRoute' - ]) -.controller('TacticalTopAlertProducers', ['$scope', '$http', - function($scope, $http) { - $scope.hosts = [{"host_name": "server-18", "problems": 10}, - {"host_name": "server-22", "problems": 5}, - {"host_name": "server-13", "problems": 3}] +angular.module('adagios.tactical.top_alert_producers', ['ngRoute' ]) + .controller('TacticalTopAlertProducers', ['$scope', '$http', function ($scope, $http) { + $scope.hosts = [ + { + "host_name": "server-18", + "problems": 10 + }, + { + "host_name": "server-22", + "problems": 5 + }, + { + "host_name": "server-13", + "problems": 3 + } + ]; }]) -.directive('topalertproducers', function() { - return { - restrict: 'E', - templateUrl: "tactical/top_alert_producers/top_alert_producers.html" - }; -}); - - + .directive('topalertproducers', function () { + return { + restrict: 'E', + templateUrl: "tactical/top_alert_producers/top_alert_producers.html" + }; + }); From e6aeebf9293c9723eaeef841f5d9b1356e05665c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 15 Jan 2015 15:29:12 -0500 Subject: [PATCH 05/17] Added unit tests --- app/navbar/navbar_test.js | 17 +++++++++++++++++ app/sidebar/sidebar_test.js | 17 +++++++++++++++++ .../current_health/current_health_test.js | 17 +++++++++++++++++ .../status_overview/status_overview_test.js | 17 +++++++++++++++++ app/tactical/tactical_test.js | 17 +++++++++++++++++ .../top_alert_producers_test.js | 17 +++++++++++++++++ karma.conf.js | 4 +++- 7 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 app/navbar/navbar_test.js create mode 100644 app/sidebar/sidebar_test.js create mode 100644 app/tactical/current_health/current_health_test.js create mode 100644 app/tactical/status_overview/status_overview_test.js create mode 100644 app/tactical/tactical_test.js create mode 100644 app/tactical/top_alert_producers/top_alert_producers_test.js diff --git a/app/navbar/navbar_test.js b/app/navbar/navbar_test.js new file mode 100644 index 0000000..3447dee --- /dev/null +++ b/app/navbar/navbar_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Navbar module', function() { + + beforeEach(module('adagios.navbar')); + + describe('NavBarCtrl', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('NavBarCtrl', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/app/sidebar/sidebar_test.js b/app/sidebar/sidebar_test.js new file mode 100644 index 0000000..5fecb73 --- /dev/null +++ b/app/sidebar/sidebar_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Sidebar module', function() { + + beforeEach(module('adagios.sidebar')); + + describe('SideBarCtrl', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('SideBarCtrl', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/app/tactical/current_health/current_health_test.js b/app/tactical/current_health/current_health_test.js new file mode 100644 index 0000000..c61e4e2 --- /dev/null +++ b/app/tactical/current_health/current_health_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Current Health tactical submodule', function() { + + beforeEach(module('adagios.tactical.current_health')); + + describe('TacticalCurrentHealth', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('TacticalCurrentHealth', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/app/tactical/status_overview/status_overview_test.js b/app/tactical/status_overview/status_overview_test.js new file mode 100644 index 0000000..8c2c4ca --- /dev/null +++ b/app/tactical/status_overview/status_overview_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Status Overview tactical submodule', function() { + + beforeEach(module('adagios.tactical.status_overview')); + + describe('TacticalStatusOverViewCtrl', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('TacticalStatusOverViewCtrl', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/app/tactical/tactical_test.js b/app/tactical/tactical_test.js new file mode 100644 index 0000000..9931073 --- /dev/null +++ b/app/tactical/tactical_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Tactical module', function() { + + beforeEach(module('adagios.tactical')); + + describe('TacticalCtrl', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('TacticalCtrl', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/app/tactical/top_alert_producers/top_alert_producers_test.js b/app/tactical/top_alert_producers/top_alert_producers_test.js new file mode 100644 index 0000000..1e3daa7 --- /dev/null +++ b/app/tactical/top_alert_producers/top_alert_producers_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('Top Alert Producer tactical submodule', function() { + + beforeEach(module('adagios.tactical.top_alert_producers')); + + describe('TacticalTopAlertProducers', function() { + + it('should be defined', inject(function($controller) { + var scope = {}; + var ctrl = $controller('TacticalTopAlertProducers', {$scope:scope}); + + expect(ctrl).toBeDefined(); + })); + + }); +}); diff --git a/karma.conf.js b/karma.conf.js index 44bb29f..70e7d37 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -8,7 +8,9 @@ module.exports = function(config){ 'app/bower_components/angular-route/angular-route.js', 'app/bower_components/angular-mocks/angular-mocks.js', 'app/components/**/*.js', - 'app/view*/**/*.js' + 'app/navbar/**/*.js', + 'app/sidebar/**/*.js', + 'app/tactical/**/*.js', ], autoWatch : true, From 16f55b012f8abc48c595cd5a779f69d14b7cb607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 15 Jan 2015 15:54:02 -0500 Subject: [PATCH 06/17] Conform unit test to coding conventions --- app/navbar/navbar_test.js | 20 ++++++++++--------- app/sidebar/sidebar_test.js | 20 ++++++++++--------- .../current_health/current_health_test.js | 20 ++++++++++--------- .../status_overview/status_overview_test.js | 20 ++++++++++--------- app/tactical/tactical_test.js | 20 ++++++++++--------- .../top_alert_producers_test.js | 20 ++++++++++--------- 6 files changed, 66 insertions(+), 54 deletions(-) diff --git a/app/navbar/navbar_test.js b/app/navbar/navbar_test.js index 3447dee..b690b53 100644 --- a/app/navbar/navbar_test.js +++ b/app/navbar/navbar_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Navbar module', function() { +describe('Navbar module', function () { - beforeEach(module('adagios.navbar')); + beforeEach(module('adagios.navbar')); - describe('NavBarCtrl', function() { + describe('NavBarCtrl', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('NavBarCtrl', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); diff --git a/app/sidebar/sidebar_test.js b/app/sidebar/sidebar_test.js index 5fecb73..ec4f534 100644 --- a/app/sidebar/sidebar_test.js +++ b/app/sidebar/sidebar_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Sidebar module', function() { +describe('Sidebar module', function () { - beforeEach(module('adagios.sidebar')); + beforeEach(module('adagios.sidebar')); - describe('SideBarCtrl', function() { + describe('SideBarCtrl', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('SideBarCtrl', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); diff --git a/app/tactical/current_health/current_health_test.js b/app/tactical/current_health/current_health_test.js index c61e4e2..d6de352 100644 --- a/app/tactical/current_health/current_health_test.js +++ b/app/tactical/current_health/current_health_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Current Health tactical submodule', function() { +describe('Current Health tactical submodule', function () { - beforeEach(module('adagios.tactical.current_health')); + beforeEach(module('adagios.tactical.current_health')); - describe('TacticalCurrentHealth', function() { + describe('TacticalCurrentHealth', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('TacticalCurrentHealth', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); diff --git a/app/tactical/status_overview/status_overview_test.js b/app/tactical/status_overview/status_overview_test.js index 8c2c4ca..53f1261 100644 --- a/app/tactical/status_overview/status_overview_test.js +++ b/app/tactical/status_overview/status_overview_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Status Overview tactical submodule', function() { +describe('Status Overview tactical submodule', function () { - beforeEach(module('adagios.tactical.status_overview')); + beforeEach(module('adagios.tactical.status_overview')); - describe('TacticalStatusOverViewCtrl', function() { + describe('TacticalStatusOverViewCtrl', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('TacticalStatusOverViewCtrl', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); diff --git a/app/tactical/tactical_test.js b/app/tactical/tactical_test.js index 9931073..a6e7379 100644 --- a/app/tactical/tactical_test.js +++ b/app/tactical/tactical_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Tactical module', function() { +describe('Tactical module', function () { - beforeEach(module('adagios.tactical')); + beforeEach(module('adagios.tactical')); - describe('TacticalCtrl', function() { + describe('TacticalCtrl', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('TacticalCtrl', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); diff --git a/app/tactical/top_alert_producers/top_alert_producers_test.js b/app/tactical/top_alert_producers/top_alert_producers_test.js index 1e3daa7..0340214 100644 --- a/app/tactical/top_alert_producers/top_alert_producers_test.js +++ b/app/tactical/top_alert_producers/top_alert_producers_test.js @@ -1,17 +1,19 @@ +/*global describe, beforeEach, it, inject, expect*/ 'use strict'; -describe('Top Alert Producer tactical submodule', function() { +describe('Top Alert Producer tactical submodule', function () { - beforeEach(module('adagios.tactical.top_alert_producers')); + beforeEach(module('adagios.tactical.top_alert_producers')); - describe('TacticalTopAlertProducers', function() { + describe('TacticalTopAlertProducers', function () { - it('should be defined', inject(function($controller) { - var scope = {}; - var ctrl = $controller('TacticalTopAlertProducers', {$scope:scope}); + it('should be defined', inject(function ($controller) { + var scope, ctrl; + scope = {}; + ctrl = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(ctrl).toBeDefined(); + })); - }); + }); }); From 6ec305ea9f0384e02d79c44d88c48cac87c1639e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 15 Jan 2015 16:56:37 -0500 Subject: [PATCH 07/17] Conform project and config files to coding convention --- .gitignore | 1 + Gruntfile.js | 73 ++++++++++--------- app/app.js | 1 - app/components/live/notifications.js | 1 - app/components/ng-justgage/ng-justgage.js | 1 - app/navbar/navbar.js | 3 +- app/navbar/navbar_test.js | 1 - app/sidebar/sidebar.js | 3 +- app/sidebar/sidebar_test.js | 1 - app/tactical/current_health/current_health.js | 1 - .../current_health/current_health_test.js | 1 - .../status_overview/status_overview.js | 1 - .../status_overview/status_overview_test.js | 1 - app/tactical/tactical.js | 2 +- app/tactical/tactical_test.js | 1 - .../top_alert_producers.js | 1 - .../top_alert_producers_test.js | 1 - karma.conf.js | 46 ++++++------ 18 files changed, 65 insertions(+), 75 deletions(-) diff --git a/.gitignore b/.gitignore index d14fffd..536fd73 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tmp *.swp app/assets/css .sass-cache/ +out/ diff --git a/Gruntfile.js b/Gruntfile.js index 1f02afc..0317723 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,10 @@ 'use strict'; -module.exports = function(grunt) { +module.exports = function (grunt) { + + grunt.loadNpmTasks('grunt-contrib-sass'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-jslint'); grunt.initConfig({ @@ -12,7 +16,6 @@ module.exports = function(grunt) { css: ['<%= project.assets %>/sass/app.scss'] }, - sass: { dev: { options: { @@ -20,7 +23,7 @@ module.exports = function(grunt) { compass: false }, files: { - '<%= project.assets %>/css/app.css':'<%= project.css %>' + '<%= project.assets %>/css/app.css' : '<%= project.css %>' } } }, @@ -32,41 +35,39 @@ module.exports = function(grunt) { } }, - jslint: { // configure the task + jslint: { // configure the task - client: { - src: [ - 'app/app.js', - 'app/**/*.js' - ], - exclude: [ - 'app/bower_components/**/*.js', - 'app/assets/**/*' - ], - directives: { // example directives - node: true, - todo: true - }, - options: { - edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path - junit: 'out/client-junit.xml', // write the output to a JUnit XML - log: 'out/client-lint.log', - jslintXml: 'out/client-jslint.xml', - errorsOnly: true, // only display errors - failOnError: false, // defaults to true - checkstyle: 'out/client-checkstyle.xml' // write a checkstyle-XML - } + client: { + src: [ + 'karma.conf.js', + 'Gruntfile.js', + 'app/app.js', + 'app/**/*.js' + ], + exclude: [ + 'app/bower_components/**/*.js', + 'app/assets/**/*' + ], + directives: { + node: true, + unparam: true, // TEMPORARY: Ignore unused params + predef: [ // Global variables + 'angular', 'inject', 'JustGage', + 'describe', 'beforeEach', 'it', 'expect' + ] + }, + options: { + edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path + junit: 'out/client-junit.xml', // write the output to a JUnit XML + log: 'out/client-lint.log', + jslintXml: 'out/client-jslint.xml', + errorsOnly: true, // only display errors + failOnError: false, // defaults to true + checkstyle: 'out/client-checkstyle.xml' // write a checkstyle-XML + } + } } - } }); - grunt.loadNpmTasks('grunt-contrib-sass'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-jslint'); - - grunt.registerTask('default', 'jslint'); - grunt.registerTask('default', [ - 'watch' - ]); - + grunt.registerTask('default', [ 'watch', 'jslint' ]); }; diff --git a/app/app.js b/app/app.js index 61a5cf8..f4deacf 100644 --- a/app/app.js +++ b/app/app.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios', [ diff --git a/app/components/live/notifications.js b/app/components/live/notifications.js index 0e0802f..25f0ab2 100644 --- a/app/components/live/notifications.js +++ b/app/components/live/notifications.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios.live', []) diff --git a/app/components/ng-justgage/ng-justgage.js b/app/components/ng-justgage/ng-justgage.js index e0a6c9c..e3a1530 100644 --- a/app/components/ng-justgage/ng-justgage.js +++ b/app/components/ng-justgage/ng-justgage.js @@ -1,4 +1,3 @@ -/*global angular, JustGage*/ 'use strict'; angular.module("ngJustGage", []) diff --git a/app/navbar/navbar.js b/app/navbar/navbar.js index 6d8cde2..89d634e 100644 --- a/app/navbar/navbar.js +++ b/app/navbar/navbar.js @@ -1,10 +1,9 @@ -/*global angular*/ 'use strict'; angular.module('adagios.navbar', ['adagios.live']) .controller('NavBarCtrl', ['$scope', '$http', 'GetProblems', function ($scope, $http, GetProblems) { - $scope.notifications = GetProblems; + $scope.notifications = GetProblems; }]) .directive('navbar', function () { diff --git a/app/navbar/navbar_test.js b/app/navbar/navbar_test.js index b690b53..078072a 100644 --- a/app/navbar/navbar_test.js +++ b/app/navbar/navbar_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Navbar module', function () { diff --git a/app/sidebar/sidebar.js b/app/sidebar/sidebar.js index c7179bb..8c46e1a 100644 --- a/app/sidebar/sidebar.js +++ b/app/sidebar/sidebar.js @@ -1,10 +1,9 @@ -/*global angular*/ 'use strict'; angular.module('adagios.sidebar', []) .controller('SideBarCtrl', ['$scope', '$http', function ($scope, $http) { - + return; }]) .directive('sidebar', function () { diff --git a/app/sidebar/sidebar_test.js b/app/sidebar/sidebar_test.js index ec4f534..f56664b 100644 --- a/app/sidebar/sidebar_test.js +++ b/app/sidebar/sidebar_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Sidebar module', function () { diff --git a/app/tactical/current_health/current_health.js b/app/tactical/current_health/current_health.js index ef8e2d2..8340e51 100644 --- a/app/tactical/current_health/current_health.js +++ b/app/tactical/current_health/current_health.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios.tactical.current_health', ['ngRoute', 'ngJustGage' ]) diff --git a/app/tactical/current_health/current_health_test.js b/app/tactical/current_health/current_health_test.js index d6de352..7e3fe9c 100644 --- a/app/tactical/current_health/current_health_test.js +++ b/app/tactical/current_health/current_health_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Current Health tactical submodule', function () { diff --git a/app/tactical/status_overview/status_overview.js b/app/tactical/status_overview/status_overview.js index e9593e2..596c8d5 100644 --- a/app/tactical/status_overview/status_overview.js +++ b/app/tactical/status_overview/status_overview.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios.tactical.status_overview', ['ngRoute' ]) diff --git a/app/tactical/status_overview/status_overview_test.js b/app/tactical/status_overview/status_overview_test.js index 53f1261..28ca5d6 100644 --- a/app/tactical/status_overview/status_overview_test.js +++ b/app/tactical/status_overview/status_overview_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Status Overview tactical submodule', function () { diff --git a/app/tactical/tactical.js b/app/tactical/tactical.js index 32d129f..a034283 100644 --- a/app/tactical/tactical.js +++ b/app/tactical/tactical.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios.tactical', ['ngRoute', @@ -15,4 +14,5 @@ angular.module('adagios.tactical', ['ngRoute', }]) .controller('TacticalCtrl', ['$scope', '$http', function ($scope, $http) { + return; }]); diff --git a/app/tactical/tactical_test.js b/app/tactical/tactical_test.js index a6e7379..5cce4e1 100644 --- a/app/tactical/tactical_test.js +++ b/app/tactical/tactical_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Tactical module', function () { diff --git a/app/tactical/top_alert_producers/top_alert_producers.js b/app/tactical/top_alert_producers/top_alert_producers.js index 0508f43..74d99ca 100644 --- a/app/tactical/top_alert_producers/top_alert_producers.js +++ b/app/tactical/top_alert_producers/top_alert_producers.js @@ -1,4 +1,3 @@ -/*global angular*/ 'use strict'; angular.module('adagios.tactical.top_alert_producers', ['ngRoute' ]) diff --git a/app/tactical/top_alert_producers/top_alert_producers_test.js b/app/tactical/top_alert_producers/top_alert_producers_test.js index 0340214..1118944 100644 --- a/app/tactical/top_alert_producers/top_alert_producers_test.js +++ b/app/tactical/top_alert_producers/top_alert_producers_test.js @@ -1,4 +1,3 @@ -/*global describe, beforeEach, it, inject, expect*/ 'use strict'; describe('Top Alert Producer tactical submodule', function () { diff --git a/karma.conf.js b/karma.conf.js index 70e7d37..df0fac5 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,35 +1,37 @@ -module.exports = function(config){ - config.set({ +'use strict'; - basePath : './', +module.exports = function (config) { + config.set({ - files : [ - 'app/bower_components/angular/angular.js', - 'app/bower_components/angular-route/angular-route.js', - 'app/bower_components/angular-mocks/angular-mocks.js', - 'app/components/**/*.js', - 'app/navbar/**/*.js', - 'app/sidebar/**/*.js', - 'app/tactical/**/*.js', - ], + basePath : './', - autoWatch : true, + files : [ + 'app/bower_components/angular/angular.js', + 'app/bower_components/angular-route/angular-route.js', + 'app/bower_components/angular-mocks/angular-mocks.js', + 'app/components/**/*.js', + 'app/navbar/**/*.js', + 'app/sidebar/**/*.js', + 'app/tactical/**/*.js' + ], - frameworks: ['jasmine'], + autoWatch : true, - browsers : ['Chrome'], + frameworks: ['jasmine'], - plugins : [ + browsers : ['Chrome'], + + plugins : [ 'karma-chrome-launcher', 'karma-firefox-launcher', 'karma-jasmine', 'karma-junit-reporter' - ], + ], - junitReporter : { - outputFile: 'test_out/unit.xml', - suite: 'unit' - } + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } - }); + }); }; From ae16c14e84106291e7854e60c8dd4466b5ce0555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 16 Jan 2015 11:18:32 -0500 Subject: [PATCH 08/17] Unit tests bugfix --- app/sidebar/sidebar_test.js | 2 +- app/tactical/current_health/current_health_test.js | 2 +- app/tactical/status_overview/status_overview_test.js | 2 +- app/tactical/tactical_test.js | 2 +- app/tactical/top_alert_producers/top_alert_producers_test.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/sidebar/sidebar_test.js b/app/sidebar/sidebar_test.js index f56664b..90c5293 100644 --- a/app/sidebar/sidebar_test.js +++ b/app/sidebar/sidebar_test.js @@ -9,7 +9,7 @@ describe('Sidebar module', function () { it('should be defined', inject(function ($controller) { var scope, ctrl; scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + ctrl = $controller('SideBarCtrl', { $scope : scope }); expect(ctrl).toBeDefined(); })); diff --git a/app/tactical/current_health/current_health_test.js b/app/tactical/current_health/current_health_test.js index 7e3fe9c..f717900 100644 --- a/app/tactical/current_health/current_health_test.js +++ b/app/tactical/current_health/current_health_test.js @@ -9,7 +9,7 @@ describe('Current Health tactical submodule', function () { it('should be defined', inject(function ($controller) { var scope, ctrl; scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + ctrl = $controller('TacticalCurrentHealth', { $scope : scope }); expect(ctrl).toBeDefined(); })); diff --git a/app/tactical/status_overview/status_overview_test.js b/app/tactical/status_overview/status_overview_test.js index 28ca5d6..031d7ff 100644 --- a/app/tactical/status_overview/status_overview_test.js +++ b/app/tactical/status_overview/status_overview_test.js @@ -9,7 +9,7 @@ describe('Status Overview tactical submodule', function () { it('should be defined', inject(function ($controller) { var scope, ctrl; scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + ctrl = $controller('TacticalStatusOverViewCtrl', { $scope : scope }); expect(ctrl).toBeDefined(); })); diff --git a/app/tactical/tactical_test.js b/app/tactical/tactical_test.js index 5cce4e1..9ca3023 100644 --- a/app/tactical/tactical_test.js +++ b/app/tactical/tactical_test.js @@ -9,7 +9,7 @@ describe('Tactical module', function () { it('should be defined', inject(function ($controller) { var scope, ctrl; scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + ctrl = $controller('TacticalCtrl', { $scope : scope }); expect(ctrl).toBeDefined(); })); diff --git a/app/tactical/top_alert_producers/top_alert_producers_test.js b/app/tactical/top_alert_producers/top_alert_producers_test.js index 1118944..4cbcf54 100644 --- a/app/tactical/top_alert_producers/top_alert_producers_test.js +++ b/app/tactical/top_alert_producers/top_alert_producers_test.js @@ -9,7 +9,7 @@ describe('Top Alert Producer tactical submodule', function () { it('should be defined', inject(function ($controller) { var scope, ctrl; scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + ctrl = $controller('TacticalTopAlertProducers', { $scope : scope }); expect(ctrl).toBeDefined(); })); From ef829181918da10df85f902f3a2f4ed983e3a45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 16 Jan 2015 16:34:47 -0500 Subject: [PATCH 09/17] Update Gruntfile.js --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index 0317723..127ce44 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,6 +51,7 @@ module.exports = function (grunt) { directives: { node: true, unparam: true, // TEMPORARY: Ignore unused params + nomen: true, predef: [ // Global variables 'angular', 'inject', 'JustGage', 'describe', 'beforeEach', 'it', 'expect' From a638ec445e33242931382c3f04cf5f85736aaebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 16 Jan 2015 16:35:27 -0500 Subject: [PATCH 10/17] Update unit tests --- app/navbar/navbar_test.js | 37 ++++++++++++++++--- app/sidebar/sidebar_test.js | 33 ++++++++++++++--- .../current_health/current_health_test.js | 29 ++++++++++++++- .../status_overview/status_overview_test.js | 31 +++++++++++++++- .../top_alert_producers_test.js | 31 +++++++++++++++- 5 files changed, 144 insertions(+), 17 deletions(-) diff --git a/app/navbar/navbar_test.js b/app/navbar/navbar_test.js index 078072a..7523696 100644 --- a/app/navbar/navbar_test.js +++ b/app/navbar/navbar_test.js @@ -1,18 +1,43 @@ 'use strict'; describe('Navbar module', function () { + var $compile, + $rootScope, + $controller, + $httpBackend; beforeEach(module('adagios.navbar')); + beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + $controller = _$controller_; + $httpBackend = _$httpBackend_; + + $httpBackend.expectGET('navbar/navbar.html').respond('{{ notifications }}'); + })); + describe('NavBarCtrl', function () { - it('should be defined', inject(function ($controller) { - var scope, ctrl; - scope = {}; - ctrl = $controller('NavBarCtrl', { $scope : scope }); + it('should be defined', function () { + var scope = $rootScope.$new(), + navbar = $controller('NavBarCtrl', { $scope : scope }); - expect(ctrl).toBeDefined(); - })); + expect(navbar).toBeDefined(); + }); + + }); + + describe('Navbar directive', function () { + + it('should insert the number of warnings', function () { + var element = $compile('')($rootScope); + $httpBackend.flush(); + $rootScope.notifications = 44; + $rootScope.$digest(); + + expect(element.text()).toBe('44'); + }); }); }); diff --git a/app/sidebar/sidebar_test.js b/app/sidebar/sidebar_test.js index 90c5293..ca3c19e 100644 --- a/app/sidebar/sidebar_test.js +++ b/app/sidebar/sidebar_test.js @@ -1,18 +1,41 @@ 'use strict'; describe('Sidebar module', function () { + var $compile, + $rootScope, + $controller, + $httpBackend; beforeEach(module('adagios.sidebar')); + beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + $controller = _$controller_; + $httpBackend = _$httpBackend_; + + $httpBackend.expectGET('sidebar/sidebar.html').respond('
  • '); + })); + describe('SideBarCtrl', function () { - it('should be defined', inject(function ($controller) { - var scope, ctrl; - scope = {}; - ctrl = $controller('SideBarCtrl', { $scope : scope }); + it('should be defined', function () { + var scope = $rootScope.$new(), + ctrl = $controller('SideBarCtrl', { $scope : scope }); expect(ctrl).toBeDefined(); - })); + }); + + }); + + describe('Sidebar directive', function () { + + it('should send a GET request', function () { + var element = $compile('')($rootScope); + $httpBackend.flush(); + + expect(element.html()).toBe('
  • '); + }); }); }); diff --git a/app/tactical/current_health/current_health_test.js b/app/tactical/current_health/current_health_test.js index f717900..fe1ffb3 100644 --- a/app/tactical/current_health/current_health_test.js +++ b/app/tactical/current_health/current_health_test.js @@ -1,18 +1,43 @@ 'use strict'; describe('Current Health tactical submodule', function () { + var $compile, + $rootScope, + $controller, + $httpBackend; beforeEach(module('adagios.tactical.current_health')); + beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + $controller = _$controller_; + $httpBackend = _$httpBackend_; + + $httpBackend.expectGET('tactical/current_health/current_health.html') + .respond('Current Health'); + })); + describe('TacticalCurrentHealth', function () { - it('should be defined', inject(function ($controller) { + it('should be defined', function () { var scope, ctrl; scope = {}; ctrl = $controller('TacticalCurrentHealth', { $scope : scope }); expect(ctrl).toBeDefined(); - })); + }); + + }); + + describe('Current health directive', function () { + + it('should send a GET request', function () { + var element = $compile("")($rootScope); + $httpBackend.flush(); + + expect(element.text()).toBe('Current Health'); + }); }); }); diff --git a/app/tactical/status_overview/status_overview_test.js b/app/tactical/status_overview/status_overview_test.js index 031d7ff..6ae4f6e 100644 --- a/app/tactical/status_overview/status_overview_test.js +++ b/app/tactical/status_overview/status_overview_test.js @@ -1,18 +1,45 @@ 'use strict'; describe('Status Overview tactical submodule', function () { + var $compile, + $rootScope, + $controller, + $httpBackend; beforeEach(module('adagios.tactical.status_overview')); + beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + $controller = _$controller_; + $httpBackend = _$httpBackend_; + + $httpBackend.expectGET('tactical/status_overview/status_overview.html') + .respond('{{ problems }}'); + })); + describe('TacticalStatusOverViewCtrl', function () { - it('should be defined', inject(function ($controller) { + it('should be defined', function () { var scope, ctrl; scope = {}; ctrl = $controller('TacticalStatusOverViewCtrl', { $scope : scope }); expect(ctrl).toBeDefined(); - })); + }); + + }); + + describe('Status overview directive', function () { + + it('should insert the number of warnings', function () { + var element = $compile('')($rootScope); + $httpBackend.flush(); + $rootScope.problems = 31; + $rootScope.$digest(); + + expect(element.text()).toBe('31'); + }); }); }); diff --git a/app/tactical/top_alert_producers/top_alert_producers_test.js b/app/tactical/top_alert_producers/top_alert_producers_test.js index 4cbcf54..97a6b64 100644 --- a/app/tactical/top_alert_producers/top_alert_producers_test.js +++ b/app/tactical/top_alert_producers/top_alert_producers_test.js @@ -1,18 +1,45 @@ 'use strict'; describe('Top Alert Producer tactical submodule', function () { + var $compile, + $rootScope, + $controller, + $httpBackend; beforeEach(module('adagios.tactical.top_alert_producers')); + beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + $controller = _$controller_; + $httpBackend = _$httpBackend_; + + $httpBackend.expectGET('tactical/top_alert_producers/top_alert_producers.html') + .respond('{{ problems }}'); + })); + describe('TacticalTopAlertProducers', function () { - it('should be defined', inject(function ($controller) { + it('should be defined', function () { var scope, ctrl; scope = {}; ctrl = $controller('TacticalTopAlertProducers', { $scope : scope }); expect(ctrl).toBeDefined(); - })); + }); + + }); + + describe('Status overview directive', function () { + + it('should insert the number of warnings', function () { + var element = $compile('')($rootScope); + $httpBackend.flush(); + $rootScope.problems = 31; + $rootScope.$digest(); + + expect(element.text()).toBe('31'); + }); }); }); From 8cc9dafdd2a48040c731134478a9e4bcdb8bb8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 16 Jan 2015 17:12:59 -0500 Subject: [PATCH 11/17] Rename navbar to topbar --- app/app.js | 2 +- app/index.html | 8 ++++---- app/navbar/navbar.js | 14 -------------- app/{navbar/navbar.css => topbar/topbar.css} | 18 +++++++++--------- app/{navbar/navbar.html => topbar/topbar.html} | 7 +++---- app/topbar/topbar.js | 14 ++++++++++++++ .../navbar_test.js => topbar/topbar_test.js} | 16 ++++++++-------- 7 files changed, 39 insertions(+), 40 deletions(-) delete mode 100644 app/navbar/navbar.js rename app/{navbar/navbar.css => topbar/topbar.css} (69%) rename app/{navbar/navbar.html => topbar/topbar.html} (84%) create mode 100644 app/topbar/topbar.js rename app/{navbar/navbar_test.js => topbar/topbar_test.js} (64%) diff --git a/app/app.js b/app/app.js index f4deacf..b7ffa1a 100644 --- a/app/app.js +++ b/app/app.js @@ -3,7 +3,7 @@ angular.module('adagios', [ 'ngRoute', 'adagios.sidebar', - 'adagios.navbar', + 'adagios.topbar', 'adagios.tactical' ]) diff --git a/app/index.html b/app/index.html index ea51d8d..174a89d 100644 --- a/app/index.html +++ b/app/index.html @@ -28,9 +28,9 @@ > - - - + + + @@ -54,7 +54,7 @@ - +
    diff --git a/app/navbar/navbar.js b/app/navbar/navbar.js deleted file mode 100644 index 89d634e..0000000 --- a/app/navbar/navbar.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -angular.module('adagios.navbar', ['adagios.live']) - - .controller('NavBarCtrl', ['$scope', '$http', 'GetProblems', function ($scope, $http, GetProblems) { - $scope.notifications = GetProblems; - }]) - - .directive('navbar', function () { - return { - restrict: 'E', - templateUrl: "navbar/navbar.html" - }; - }); diff --git a/app/navbar/navbar.css b/app/topbar/topbar.css similarity index 69% rename from app/navbar/navbar.css rename to app/topbar/topbar.css index ef5aa9e..db739ed 100644 --- a/app/navbar/navbar.css +++ b/app/topbar/topbar.css @@ -1,4 +1,4 @@ -nav#navbar { +nav#topbar { top: 0%; margin-left: 300px; background-color: #353d48; @@ -10,22 +10,22 @@ nav#navbar { } -nav#navbar div.container-fluid{ +nav#topbar div.container-fluid{ padding-left: 0px; } -nav#navbar .navbar-brand{ padding: 0px 30px;font-size: 1.5em;line-height: 80px; } -nav#navbar .navbar-nav > li > a { padding: 0px 30px; line-height: 80px; font-size: 1.5em; } -nav#navbar .navbar-nav > li > form div { +nav#topbar .navbar-brand{ padding: 0px 30px;font-size: 1.5em;line-height: 80px; } +nav#topbar .navbar-nav > li > a { padding: 0px 30px; line-height: 80px; font-size: 1.5em; } +nav#topbar .navbar-nav > li > form div { line-height: 55px; font-size: 1.5em; } -nav#navbar .navbar-nav > li > form input { +nav#topbar .navbar-nav > li > form input { height: 60px; } -nav#navbar div.navbar-collapse { +nav#topbar div.navbar-collapse { padding-left: 0px; } @@ -52,12 +52,12 @@ a#toggle-sidebar i { } -nav#navbar li { +nav#topbar li { border-color: #252b37; border-style: solid; border-width: 1px; } -nav#navbar li a#search { +nav#topbar li a#search { float: left; } diff --git a/app/navbar/navbar.html b/app/topbar/topbar.html similarity index 84% rename from app/navbar/navbar.html rename to app/topbar/topbar.html index 60ab46b..bc5f6cc 100644 --- a/app/navbar/navbar.html +++ b/app/topbar/topbar.html @@ -1,8 +1,8 @@ -