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('