Merge pull request #27 from Freddrickk/uglify

Add uglify to project
This commit is contained in:
Frédéric Vachon 2015-02-20 16:36:10 -05:00
commit 90c1933d3d
21 changed files with 100 additions and 84 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ tmp
app/assets/css
.sass-cache/
out/
build/

View File

@ -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']);
};

View File

@ -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');
});
};

View File

@ -2,7 +2,7 @@
angular.module('adagios.live')
.factory('getProblems', ['$http', function ($http) {
.factory('getProblems', [function () {
var problem_number = 44;
return problem_number;

View File

@ -14,7 +14,7 @@ angular.module("ngJustGage", [])
options: '='
},
template: '<div id="{{id}}-justgage" class="{{class}}"></div>',
link: function (scope, element, attrs) {
link: function (scope) {
$timeout(function () {
var options, key, graph;

View File

@ -2,7 +2,7 @@
angular.module('adagios.sidebar', [])
.controller('SideBarCtrl', ['$scope', '$http', function ($scope, $http) {
.controller('SideBarCtrl', [function () {
angular.noop();
}])

View File

@ -2,7 +2,7 @@
angular.module('adagios.table.cell_duration', ['adagios.table'])
.controller('CellDurationCtrl', ['$scope', function ($scope) {
.controller('CellDurationCtrl', [function () {
angular.noop();
}])

View File

@ -2,7 +2,7 @@
angular.module('adagios.table.cell_host_address', ['adagios.table'])
.controller('CellHostAddressCtrl', ['$scope', function ($scope) {
.controller('CellHostAddressCtrl', [function () {
angular.noop();
}])

View File

@ -2,7 +2,7 @@
angular.module('adagios.table.cell_hosts_host', ['adagios.table'])
.controller('CellHostsHostCtrl', ['$scope', function ($scope) {
.controller('CellHostsHostCtrl', [function () {
angular.noop();
}])

View File

@ -2,7 +2,7 @@
angular.module('adagios.table.cell_last_check', ['adagios.table'])
.controller('CellLastCheckCtrl', ['$scope', function ($scope) {
.controller('CellLastCheckCtrl', [function () {
angular.noop();
}])

View File

@ -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',
};
}
};
});
}]);

View File

@ -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('<adg-cell type="' + cell + '"></adg-cell>');
var elem = angular.element('<td adg-cell cell-name="' + cell + '"></td>');
$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('<adg-table cells="host,service_check,duration,last_check" api-name="services"></adg-table>');
var elem = angular.element('<adg-table cells-name="host,service_check,duration,last_check" cells-text="Host,Service Check,Duration,Last check" api-name="services"></adg-table>');
$compile(elem)($rootScope);
$httpBackend.expectGET('components/table/table.html').respond('');
$httpBackend.flush();

View File

@ -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;
}])

View File

@ -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

View File

@ -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

View File

@ -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",

View File

@ -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;
}])

View File

@ -16,51 +16,14 @@
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<!-- Application -->
<script src="app.js"></script>
<script src="components/config/config.js"></script>
<!-- COMPONENTS -->
<script src="components/live/live.js"></script>
<script src="components/live/notifications.js"></script>
<script src="components/live/get_services.js"></script>
<script src="components/ng-justgage/ng-justgage.js"></script>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="components/filters/filters.js"></script>
<!-- MODULES -->
<script src="components/sidebar/sidebar.js"></script>
<script src="components/topbar/topbar.js"></script>
<script src="components/tactical/tactical.js"></script>
<script src="components/tactical/status_overview/status_overview.js"></script>
<script src="components/tactical/current_health/current_health.js"></script>
<script src="components/tactical/top_alert_producers/top_alert_producers.js"></script>
<script src="components/table/table.js"></script>
<script src="components/table/cell_duration/cell_duration.js"></script>
<script src="components/table/cell_host/cell_host.js"></script>
<script src="components/table/cell_last_check/cell_last_check.js"></script>
<script src="components/table/cell_service_check/cell_service_check.js"></script>
<script src="components/table/cell_hosts_host/cell_hosts_host.js"></script>
<script src="components/table/cell_host_address/cell_host_address.js"></script>
<script src="components/table/cell_host_status/cell_host_status.js"></script>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script src="bower_components/moment/moment.js"></script>
<!-- VIEWS -->
<script src="dashboard/dashboard.js"></script>
<script src="hosts/hosts.js"></script>
<script src="services/services.js"></script>
<script src="custom_views/custom_views.js"></script>
<script src="build/js/compressed.js"></script>
</head>
<body class="layout color-scheme--dark">
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!--[if lt IE 7]> <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> <![endif]-->
<div class="layout__container">
<aside class="layout__aside sidebar-wrapper collapse" id="sidebarWrapper">
<adg-sidebar></adg-sidebar>

View File

@ -6,6 +6,7 @@ module.exports = function (config) {
basePath : './',
files : [
'app/bower_components/jquery/dist/jquery.min.js',
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',

View File

@ -16,7 +16,8 @@
"karma": "~0.10",
"karma-junit-reporter": "^0.2.2",
"protractor": "^1.1.1",
"shelljs": "^0.2.6"
"shelljs": "^0.2.6",
"grunt-contrib-uglify": "~0.8.0"
},
"scripts": {
"postinstall": "bower install",

View File

@ -20,7 +20,8 @@ Installation
Dev
===
To watch for sass files change and auto-refresh css run :
You must leave grunt running in the background to automatically compile css
and minify/compress js files when source code changes
::
@ -32,6 +33,12 @@ To compile css files run :
grunt sass
To compile js files run :
::
grunt uglify
If you wish to develop in a docker container, here is how to proceed (assuming
you already have docker installed) :