diff --git a/.gitignore b/.gitignore index 0a6c4c0..801e69c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ tmp app/assets/css .sass-cache/ out/ +build/ diff --git a/Gruntfile.js b/Gruntfile.js index e989bff..90ca0b9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,10 +2,6 @@ module.exports = function (grunt) { - grunt.loadNpmTasks('grunt-contrib-sass'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-jslint'); - grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), @@ -13,7 +9,8 @@ module.exports = function (grunt) { project: { app: ['app'], assets: ['<%= project.app %>/assets'], - css: ['<%= project.assets %>/sass/app.scss'] + css: ['<%= project.assets %>/sass/app.scss'], + build: ['<%= project.app %>/build/'] }, sass: { @@ -35,6 +32,16 @@ module.exports = function (grunt) { '<%= project.app %>/{,*/}*/{,*/}*.{scss,sass}' ], tasks: ['sass:dev'] + }, + uglify: { + files: [ + '<%= project.app %>/**/*.js', + '<%= project.app %>/**/*_test.js', + '!<%= project.app %>/bower_components/**', + '!<%= project.build %>/**', + '!<%= project.assets %>/**' + ], + tasks: ['uglify:compress'] } }, @@ -44,16 +51,16 @@ module.exports = function (grunt) { src: [ 'karma.conf.js', 'Gruntfile.js', - 'app/app.js', - 'app/**/*.js' + '<%= project.app %>/app.js', + '<%= project.app %>/**/*.js' ], exclude: [ - 'app/bower_components/**/*.js', - 'app/assets/**/*' + '<%= project.app %>/bower_components/**/*.js', + '<%= project.assets %>/**', + '<%= project.build %>/**' ], directives: { node: true, - unparam: true, // TEMPORARY: Ignore unused params nomen: true, predef: [ // Global variables 'document', '$', '$get', @@ -72,8 +79,53 @@ module.exports = function (grunt) { checkstyle: 'out/client-checkstyle.xml' // write a checkstyle-XML } } + }, + + // Minify and concatenate adagios in one file + uglify: { + compress: { + files: [{ + '<%= project.build %>/js/adagios.js' : [ + '<%= project.app %>/app.js', + '<%= project.app %>/components/config/config.js', + '<%= project.app %>/components/live/live.js', + '<%= project.app %>/components/live/notifications.js', + '<%= project.app %>/components/live/get_services.js', + '<%= project.app %>/components/ng-justgage/ng-justgage.js', + '<%= project.app %>/components/filters/filters.js', + '<%= project.app %>/components/sidebar/sidebar.js', + '<%= project.app %>/components/topbar/topbar.js', + '<%= project.app %>/components/tactical/tactical.js', + '<%= project.app %>/components/tactical/status_overview/status_overview.js', + '<%= project.app %>/components/tactical/current_health/current_health.js', + '<%= project.app %>/components/tactical/top_alert_producers/top_alert_producers.js', + '<%= project.app %>/components/table/table.js', + '<%= project.app %>/components/table/cell_duration/cell_duration.js', + '<%= project.app %>/components/table/cell_host/cell_host.js', + '<%= project.app %>/components/table/cell_last_check/cell_last_check.js', + '<%= project.app %>/components/table/cell_service_check/cell_service_check.js', + '<%= project.app %>/components/table/cell_hosts_host/cell_hosts_host.js', + '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', + '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', + '<%= project.app %>/dashboard/dashboard.js', + '<%= project.app %>/hosts/hosts.js', + '<%= project.app %>/services/services.js', + '<%= project.app %>/custom_views/custom_views.js', + + // Excluded files/directories + '!<%= project.app %>/bower_components/**', + '!<%= project.app %>/build/**', + '!<%= project.app %>/**/*_test.js' + ] + }] + } } }); - grunt.registerTask('default', [ 'watch', 'jslint' ]); + grunt.loadNpmTasks('grunt-contrib-sass'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-jslint'); + + grunt.registerTask('default', [ 'watch', 'jslint', 'uglify']); }; diff --git a/app/components/live/get_services.js b/app/components/live/get_services.js index 8d4da49..99fbc7b 100644 --- a/app/components/live/get_services.js +++ b/app/components/live/get_services.js @@ -13,7 +13,7 @@ angular.module('adagios.live') }) .factory('getServices', ['$http', 'filterSuffixes', - function ($http, filterSuffixes, columns, filters, apiName) { + function ($http, filterSuffixes) { return function (columns, filters, apiName) { var filtersQuery = ''; @@ -36,7 +36,7 @@ angular.module('adagios.live') filtersQuery = createFiltersQuery(filters); return $http.get('/rest/status/json/' + apiName + '/?fields=' + columns + filtersQuery) - .error(function (data, status, headers, config) { + .error(function () { throw new Error('getServices : GET Request failed'); }); }; diff --git a/app/components/live/notifications.js b/app/components/live/notifications.js index 1d3b552..8e8bdfd 100644 --- a/app/components/live/notifications.js +++ b/app/components/live/notifications.js @@ -2,7 +2,7 @@ angular.module('adagios.live') - .factory('getProblems', ['$http', function ($http) { + .factory('getProblems', [function () { var problem_number = 44; return problem_number; diff --git a/app/components/ng-justgage/ng-justgage.js b/app/components/ng-justgage/ng-justgage.js index e3a1530..d0f1859 100644 --- a/app/components/ng-justgage/ng-justgage.js +++ b/app/components/ng-justgage/ng-justgage.js @@ -14,7 +14,7 @@ angular.module("ngJustGage", []) options: '=' }, template: '
', - link: function (scope, element, attrs) { + link: function (scope) { $timeout(function () { var options, key, graph; diff --git a/app/components/sidebar/sidebar.js b/app/components/sidebar/sidebar.js index 7ffe7c2..2a8ccc4 100644 --- a/app/components/sidebar/sidebar.js +++ b/app/components/sidebar/sidebar.js @@ -2,7 +2,7 @@ angular.module('adagios.sidebar', []) - .controller('SideBarCtrl', ['$scope', '$http', function ($scope, $http) { + .controller('SideBarCtrl', [function () { angular.noop(); }]) diff --git a/app/components/table/cell_duration/cell_duration.js b/app/components/table/cell_duration/cell_duration.js index 3fd799c..e9a9ed6 100644 --- a/app/components/table/cell_duration/cell_duration.js +++ b/app/components/table/cell_duration/cell_duration.js @@ -2,7 +2,7 @@ angular.module('adagios.table.cell_duration', ['adagios.table']) - .controller('CellDurationCtrl', ['$scope', function ($scope) { + .controller('CellDurationCtrl', [function () { angular.noop(); }]) diff --git a/app/components/table/cell_host_address/cell_host_address.js b/app/components/table/cell_host_address/cell_host_address.js index d58ced5..af9c1ec 100644 --- a/app/components/table/cell_host_address/cell_host_address.js +++ b/app/components/table/cell_host_address/cell_host_address.js @@ -2,7 +2,7 @@ angular.module('adagios.table.cell_host_address', ['adagios.table']) - .controller('CellHostAddressCtrl', ['$scope', function ($scope) { + .controller('CellHostAddressCtrl', [function () { angular.noop(); }]) diff --git a/app/components/table/cell_hosts_host/cell_hosts_host.js b/app/components/table/cell_hosts_host/cell_hosts_host.js index 2fbeaa9..f7e8e58 100644 --- a/app/components/table/cell_hosts_host/cell_hosts_host.js +++ b/app/components/table/cell_hosts_host/cell_hosts_host.js @@ -2,7 +2,7 @@ angular.module('adagios.table.cell_hosts_host', ['adagios.table']) - .controller('CellHostsHostCtrl', ['$scope', function ($scope) { + .controller('CellHostsHostCtrl', [function () { angular.noop(); }]) diff --git a/app/components/table/cell_last_check/cell_last_check.js b/app/components/table/cell_last_check/cell_last_check.js index 756910a..df1268b 100644 --- a/app/components/table/cell_last_check/cell_last_check.js +++ b/app/components/table/cell_last_check/cell_last_check.js @@ -2,7 +2,7 @@ angular.module('adagios.table.cell_last_check', ['adagios.table']) - .controller('CellLastCheckCtrl', ['$scope', function ($scope) { + .controller('CellLastCheckCtrl', [function () { angular.noop(); }]) diff --git a/app/components/table/table.js b/app/components/table/table.js index 32488cd..e0021ec 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -1,22 +1,13 @@ 'use strict'; -angular.module('adagios.table', ['adagios.live', - 'adagios.filters', - 'adagios.table.cell_host', - 'adagios.table.cell_duration', - 'adagios.table.cell_service_check', - 'adagios.table.cell_last_check', - 'adagios.table.cell_hosts_host', - 'adagios.table.cell_host_address', - 'adagios.table.cell_host_status' - ]) +angular.module('adagios.table', ['adagios.live']) .value('tableConfig', { cells: { 'text': [], 'name': [] }, apiName: '', filters: {}, cellToFieldsMap: {} }) - .controller('TableCtrl', ['$scope', 'getServices', 'readConfig', 'tableConfig', function ($scope, getServices, readConfig, tableConfig) { + .controller('TableCtrl', ['$scope', 'getServices', 'tableConfig', function ($scope, getServices, tableConfig) { var requestFields = [], filters = JSON.parse(tableConfig.filters), @@ -30,7 +21,7 @@ angular.module('adagios.table', ['adagios.live', $scope.cellIndexes.push(i); } - angular.forEach($scope.cellsName, function (key, value) { + angular.forEach($scope.cellsName, function (key) { angular.forEach(tableConfig.cellToFieldsMap[key], function (_value) { requestFields.push(_value); }); @@ -72,7 +63,7 @@ angular.module('adagios.table', ['adagios.live', }; }]) - .directive('adgCell', function ($http, $compile, $templateCache) { + .directive('adgCell', ['$http', '$compile', function ($http, $compile) { return { restrict: 'A', @@ -93,4 +84,4 @@ angular.module('adagios.table', ['adagios.live', }; } }; - }); + }]); diff --git a/app/components/table/table_test.js b/app/components/table/table_test.js index 727c54f..c42bad8 100644 --- a/app/components/table/table_test.js +++ b/app/components/table/table_test.js @@ -19,7 +19,7 @@ describe('In Table module', function () { var cells = ['host', 'service_check', 'duration', 'last_check']; angular.forEach(cells, function (cell) { - var elem = angular.element(''); + var elem = angular.element(''); $compile(elem)($rootScope); $httpBackend.expectGET('components/table/cell_' + cell + '/cell_' + cell + '.html').respond(''); $httpBackend.flush(); @@ -30,7 +30,7 @@ describe('In Table module', function () { describe('adgTable directive', function () { it('should request table/table.html template', function () { - var elem = angular.element(''); + var elem = angular.element(''); $compile(elem)($rootScope); $httpBackend.expectGET('components/table/table.html').respond(''); $httpBackend.flush(); diff --git a/app/components/tactical/current_health/current_health.js b/app/components/tactical/current_health/current_health.js index 14eca90..abd023f 100644 --- a/app/components/tactical/current_health/current_health.js +++ b/app/components/tactical/current_health/current_health.js @@ -2,7 +2,7 @@ angular.module('adagios.tactical.current_health', ['ngRoute', 'ngJustGage' ]) - .controller('TacticalCurrentHealth', ['$scope', '$http', function ($scope, $http) { + .controller('TacticalCurrentHealth', ['$scope', function ($scope) { $scope.hosts = 75.2; $scope.services = 94.4; }]) diff --git a/app/components/tactical/status_overview/status_overview.js b/app/components/tactical/status_overview/status_overview.js index 3dc424f..ff84ade 100644 --- a/app/components/tactical/status_overview/status_overview.js +++ b/app/components/tactical/status_overview/status_overview.js @@ -2,7 +2,7 @@ angular.module('adagios.tactical.status_overview', ['ngRoute' ]) - .controller('TacticalStatusOverViewCtrl', ['$scope', '$http', function ($scope, $http) { + .controller('TacticalStatusOverViewCtrl', ['$scope', function ($scope) { $scope.hosts = { "count": 104, "problems": 14 diff --git a/app/components/tactical/tactical.js b/app/components/tactical/tactical.js index d5e639c..9ead358 100644 --- a/app/components/tactical/tactical.js +++ b/app/components/tactical/tactical.js @@ -5,7 +5,7 @@ angular.module('adagios.tactical', ['adagios.tactical.status_overview', 'adagios.tactical.top_alert_producers' ]) - .controller('TacticalCtrl', ['$scope', '$http', function ($scope, $http) { + .controller('TacticalCtrl', [function () { // Togglable tabs // Don't follow hyperlinks diff --git a/app/components/tactical/top_alert_producers/top_alert_producers.js b/app/components/tactical/top_alert_producers/top_alert_producers.js index e65fddd..523e587 100644 --- a/app/components/tactical/top_alert_producers/top_alert_producers.js +++ b/app/components/tactical/top_alert_producers/top_alert_producers.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('adagios.tactical.top_alert_producers', ['ngRoute' ]) - .controller('TacticalTopAlertProducers', ['$scope', '$http', function ($scope, $http) { + .controller('TacticalTopAlertProducers', ['$scope', function ($scope) { $scope.hosts = [ { "host_name": "server-18", diff --git a/app/components/topbar/topbar.js b/app/components/topbar/topbar.js index 7dacb60..ca488cd 100644 --- a/app/components/topbar/topbar.js +++ b/app/components/topbar/topbar.js @@ -2,7 +2,7 @@ angular.module('adagios.topbar', ['adagios.live']) - .controller('TopBarCtrl', ['$scope', '$http', 'getProblems', function ($scope, $http, getProblems) { + .controller('TopBarCtrl', ['$scope', 'getProblems', function ($scope, getProblems) { $scope.notifications = getProblems; }]) diff --git a/app/index.html b/app/index.html index 0afa3fa..2b64ad2 100644 --- a/app/index.html +++ b/app/index.html @@ -16,51 +16,14 @@ - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - +