diff --git a/.gitignore b/.gitignore index 54ae1d9..7d0d51d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,9 @@ tmp app/assets/css .sass-cache/ out/ -build/ + +# Grunt generated files +dist/ +.tmp/ + +app/components/live/live.js diff --git a/Dockerfile b/Dockerfile index 30502a5..fcd2d12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,11 +32,11 @@ ADD /app /opt/adagios-frontend/app # Override those variables at runtime to point Bansho to another backend ENV BANSHO_BACKEND surveil +ENV BANSHO_PROD true ENV BANSHO_SURVEIL_URL http://surveil:8080/ ENV BANSHO_ADAGIOS_URL http://demo.kaji-project.org/ CMD ./configure.sh && \ cd /opt/adagios-frontend && \ - grunt sass && \ - grunt uglify:${BANSHO_BACKEND} && \ + bash -c "if [ $BANSHO_PROD = true ] ; then grunt production:$BANSHO_BACKEND ; fi" && \ bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" diff --git a/Gruntfile.js b/Gruntfile.js index 4a1e186..a8fca14 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,15 +2,66 @@ module.exports = function (grunt) { + require('load-grunt-tasks')(grunt); + grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), project: { - app: ['app'], - assets: ['<%= project.app %>/assets'], - css: ['<%= project.assets %>/sass/app.scss'], - build: ['<%= project.app %>/build/'] + app: 'app', + assets: '<%= project.app %>/assets', + scss: '<%= project.assets %>/sass/app.scss', + tmp: '.tmp', + dist: 'dist' + }, + + clean: { + dist: ['<%= project.dist %>/'], + tmp: ['<%= project.tmp %>/'] + }, + + copy: { + prod: { + files: [ + { + cwd: '<%= project.assets %>/css/', + expand: true, + src: ['**.*'], + dest: '<%= project.dist %>/assets/css/' + }, + { + cwd: '<%= project.app %>/', + expand: true, + src: ['**/*.html'], + dest: '<%= project.dist %>/' + }, + { + src: '<%= project.app %>/components/config/config.json', + dest: '<%= project.dist %>/components/config/config.json' + }, + { + src: '<%= project.app %>/index.html', + dest: '<%= project.dist %>/index.html' + } + ] + }, + adagios: { + files: [ + { + dest: '<%= project.app %>/components/live/live.js', + src: '<%= project.app %>/components/live/adagios.js' + } + ] + }, + surveil: { + files: [ + { + dest: '<%= project.app %>/components/live/live.js', + src: '<%= project.app %>/components/live/surveil.js' + } + ] + } }, sass: { @@ -20,31 +71,11 @@ module.exports = function (grunt) { compass: false }, files: { - '<%= project.assets %>/css/app.css' : '<%= project.css %>' + '<%= project.assets %>/css/app.css': '<%= project.scss %>' } } }, - watch: { - sass: { - files: [ - '<%= project.assets %>/sass/{,*/}*.{scss,sass}', - '<%= 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:surveil'] - } - }, - jslint: { // configure the task client: { @@ -82,237 +113,70 @@ module.exports = function (grunt) { } }, + useminPrepare: { + html: { + src: ['<%= project.app %>/index.html'] + }, + options: { + dest: '<%= project.dist %>/' + } + }, + + usemin: { + html: '<%= project.dist %>/index.html' + }, + + concat: { + generated: { + nonull: true + } + }, + // Minify and concatenate bansho in one file uglify: { - compress: { - files: [{ - '<%= project.build %>/js/bansho.min.js' : [ - '<%= project.app %>/app.js', - '<%= project.app %>/app.js', - '<%= project.app %>/components/config/config.js', - '<%= project.app %>/components/utils/promise_manager.js', - '<%= project.app %>/components/live/live.js', - '<%= project.app %>/components/live/surveil.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/actionbar/actionbar.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_host_address/cell_host_address.js', - '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', - '<%= project.app %>/components/host/host.js', - '<%= project.app %>/components/host/host_cpu/host_cpu.js', - '<%= project.app %>/components/host/host_info/host_info.js', - '<%= project.app %>/components/host/host_load/host_load.js', - '<%= project.app %>/components/host/host_main/host_main.js', - '<%= project.app %>/components/host/host_services_list/host_services_list.js', - '<%= project.app %>/components/service/service.js', - '<%= project.app %>/components/service/service_main/service_main.js', - '<%= project.app %>/components/service/service_info/service_info.js', - '<%= project.app %>/components/service/service_metrics/service_metrics.js', - '<%= project.app %>/routing_view/routing_view.js', - '<%= project.app %>/templates/dashboard/dashboard.js', - '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.app %>/templates/host/host.js', - '<%= project.app %>/templates/service/service.js' - ] - }], - options: { - mangle: true - } + generated: { + nonull: true }, + options: { + mangle: true + } + }, + + watch: { adagios: { files: [ - { - '<%= project.build %>/app.js': '<%= project.app %>/app.js', - '<%= project.build %>/components/config/config.js': '<%= project.app %>/components/config/config.js', - '<%= project.build %>/components/utils/promise_manager.js': '<%= project.app %>/components/utils/promise_manager.js', - '<%= project.build %>/components/live/live.js': '<%= project.app %>/components/live/live.js', - '<%= project.build %>/components/live/adagios.js': '<%= project.app %>/components/live/adagios.js', - '<%= project.build %>/components/ng-justgage/ng-justgage.js': '<%= project.app %>/components/ng-justgage/ng-justgage.js', - '<%= project.build %>/components/filters/filters.js': '<%= project.app %>/components/filters/filters.js', - '<%= project.build %>/components/sidebar/sidebar.js': '<%= project.app %>/components/sidebar/sidebar.js', - '<%= project.build %>/components/topbar/topbar.js': '<%= project.app %>/components/topbar/topbar.js', - '<%= project.build %>/components/tactical/tactical.js': '<%= project.app %>/components/tactical/tactical.js', - '<%= project.build %>/components/tactical/status_overview/status_overview.js': '<%= project.app %>/components/tactical/status_overview/status_overview.js', - '<%= project.build %>/components/tactical/current_health/current_health.js': '<%= project.app %>/components/tactical/current_health/current_health.js', - '<%= project.build %>/components/tactical/top_alert_producers/top_alert_producers.js': '<%= project.app %>/components/tactical/top_alert_producers/top_alert_producers.js', - '<%= project.build %>/components/table/actionbar/actionbar.js': '<%= project.app %>/components/table/actionbar/actionbar.js', - '<%= project.build %>/components/table/table.js': '<%= project.app %>/components/table/table.js', - '<%= project.build %>/components/table/cell_duration/cell_duration.js': '<%= project.app %>/components/table/cell_duration/cell_duration.js', - '<%= project.build %>/components/table/cell_host/cell_host.js': '<%= project.app %>/components/table/cell_host/cell_host.js', - '<%= project.build %>/components/table/cell_last_check/cell_last_check.js': '<%= project.app %>/components/table/cell_last_check/cell_last_check.js', - '<%= project.build %>/components/table/cell_service_check/cell_service_check.js': '<%= project.app %>/components/table/cell_service_check/cell_service_check.js', - '<%= project.build %>/components/table/cell_host_address/cell_host_address.js': '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', - '<%= project.build %>/components/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', - - '<%= project.build %>/components/host/host.js': '<%= project.app %>/components/host/host.js', - '<%= project.build %>/components/host/host_cpu/host_cpu.js': '<%= project.app %>/components/host/host_cpu/host_cpu.js', - '<%= project.build %>/components/host/host_info/host_info.js': '<%= project.app %>/components/host/host_info/host_info.js', - '<%= project.build %>/components/host/host_load/host_load.js': '<%= project.app %>/components/host/host_load/host_load.js', - '<%= project.build %>/components/host/host_main/host_main.js': '<%= project.app %>/components/host/host_main/host_main.js', - '<%= project.build %>/components/host/host_services_list/host_services_list.js': '<%= project.app %>/components/host/host_services_list/host_services_list.js', - '<%= project.build %>/components/service/service.js': '<%= project.app %>/components/service/service.js', - '<%= project.build %>/components/service/service_main/service_main.js': '<%= project.app %>/components/service/service_main/service_main.js', - '<%= project.build %>/components/service/service_info/service_info.js': '<%= project.app %>/components/service/service_info/service_info.js', - '<%= project.build %>/components/service/service_metrics/service_metrics.js': '<%= project.app %>/components/service/service_metrics/service_metrics.js', - - '<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js', - '<%= project.build %>/templates/dashboard/dashboard.js': '<%= project.app %>/templates/dashboard/dashboard.js', - '<%= project.build %>/templates/single_table/single_table.js' : '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js': '<%= project.app %>/templates/host/host.js', - '<%= project.build %>/templates/service/service.js': '<%= project.app %>/templates/service/service.js' - }, - { - '<%= project.build %>/js/bansho.min.js' : [ - '<%= project.build %>/app.js', - '<%= project.build %>/components/config/config.js', - '<%= project.build %>/components/utils/promise_manager.js', - '<%= project.build %>/components/live/live.js', - '<%= project.build %>/components/live/adagios.js', - '<%= project.build %>/components/ng-justgage/ng-justgage.js', - '<%= project.build %>/components/filters/filters.js', - '<%= project.build %>/components/sidebar/sidebar.js', - '<%= project.build %>/components/topbar/topbar.js', - '<%= project.build %>/components/tactical/tactical.js', - '<%= project.build %>/components/tactical/status_overview/status_overview.js', - '<%= project.build %>/components/tactical/current_health/current_health.js', - '<%= project.build %>/components/tactical/top_alert_producers/top_alert_producers.js', - '<%= project.build %>/components/table/actionbar/actionbar.js', - '<%= project.build %>/components/table/table.js', - '<%= project.build %>/components/table/cell_duration/cell_duration.js', - '<%= project.build %>/components/table/cell_host/cell_host.js', - '<%= project.build %>/components/table/cell_last_check/cell_last_check.js', - '<%= project.build %>/components/table/cell_service_check/cell_service_check.js', - '<%= project.build %>/components/table/cell_host_address/cell_host_address.js', - '<%= project.build %>/components/table/cell_host_status/cell_host_status.js', - '<%= project.build %>/components/host/host.js', - '<%= project.build %>/components/host/host_cpu/host_cpu.js', - '<%= project.build %>/components/host/host_info/host_info.js', - '<%= project.build %>/components/host/host_load/host_load.js', - '<%= project.build %>/components/host/host_main/host_main.js', - '<%= project.build %>/components/host/host_services_list/host_services_list.js', - '<%= project.build %>/components/service/service.js', - '<%= project.build %>/components/service/service_main/service_main.js', - '<%= project.build %>/components/service/service_info/service_info.js', - '<%= project.build %>/components/service/service_metrics/service_metrics.js', - '<%= project.build %>/routing_view/routing_view.js', - '<%= project.build %>/templates/dashboard/dashboard.js', - '<%= project.build %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js', - '<%= project.build %>/templates/service/service.js' - ] - } + '<%= project.app %>/components/live/adagios.js', + '<%= project.assets %>/sass/{,*/}*.{scss,sass}' ], - options: { - mangle: false, - beautify: true - } + tasks: ['copy:adagios', 'sass:dev'] }, surveil: { files: [ - { - '<%= project.build %>/app.js': '<%= project.app %>/app.js', - '<%= project.build %>/components/config/config.js': '<%= project.app %>/components/config/config.js', - '<%= project.build %>/components/utils/promise_manager.js': '<%= project.app %>/components/utils/promise_manager.js', - '<%= project.build %>/components/live/live.js': '<%= project.app %>/components/live/live.js', - '<%= project.build %>/components/live/surveil.js': '<%= project.app %>/components/live/surveil.js', - '<%= project.build %>/components/ng-justgage/ng-justgage.js': '<%= project.app %>/components/ng-justgage/ng-justgage.js', - '<%= project.build %>/components/filters/filters.js': '<%= project.app %>/components/filters/filters.js', - '<%= project.build %>/components/sidebar/sidebar.js': '<%= project.app %>/components/sidebar/sidebar.js', - '<%= project.build %>/components/topbar/topbar.js': '<%= project.app %>/components/topbar/topbar.js', - '<%= project.build %>/components/tactical/tactical.js': '<%= project.app %>/components/tactical/tactical.js', - '<%= project.build %>/components/tactical/status_overview/status_overview.js': '<%= project.app %>/components/tactical/status_overview/status_overview.js', - '<%= project.build %>/components/tactical/current_health/current_health.js': '<%= project.app %>/components/tactical/current_health/current_health.js', - '<%= project.build %>/components/tactical/top_alert_producers/top_alert_producers.js': '<%= project.app %>/components/tactical/top_alert_producers/top_alert_producers.js', - '<%= project.build %>/components/table/actionbar/actionbar.js': '<%= project.app %>/components/table/actionbar/actionbar.js', - '<%= project.build %>/components/table/table.js': '<%= project.app %>/components/table/table.js', - '<%= project.build %>/components/table/cell_duration/cell_duration.js': '<%= project.app %>/components/table/cell_duration/cell_duration.js', - '<%= project.build %>/components/table/cell_host/cell_host.js': '<%= project.app %>/components/table/cell_host/cell_host.js', - '<%= project.build %>/components/table/cell_last_check/cell_last_check.js': '<%= project.app %>/components/table/cell_last_check/cell_last_check.js', - '<%= project.build %>/components/table/cell_service_check/cell_service_check.js': '<%= project.app %>/components/table/cell_service_check/cell_service_check.js', - '<%= project.build %>/components/table/cell_host_address/cell_host_address.js': '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', - '<%= project.build %>/components/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', - - '<%= project.build %>/components/host/host.js': '<%= project.app %>/components/host/host.js', - '<%= project.build %>/components/host/host_cpu/host_cpu.js': '<%= project.app %>/components/host/host_cpu/host_cpu.js', - '<%= project.build %>/components/host/host_info/host_info.js': '<%= project.app %>/components/host/host_info/host_info.js', - '<%= project.build %>/components/host/host_load/host_load.js': '<%= project.app %>/components/host/host_load/host_load.js', - '<%= project.build %>/components/host/host_main/host_main.js': '<%= project.app %>/components/host/host_main/host_main.js', - '<%= project.build %>/components/host/host_services_list/host_services_list.js': '<%= project.app %>/components/host/host_services_list/host_services_list.js', - '<%= project.build %>/components/service/service.js': '<%= project.app %>/components/service/service.js', - '<%= project.build %>/components/service/service_main/service_main.js': '<%= project.app %>/components/service/service_main/service_main.js', - '<%= project.build %>/components/service/service_info/service_info.js': '<%= project.app %>/components/service/service_info/service_info.js', - '<%= project.build %>/components/service/service_metrics/service_metrics.js': '<%= project.app %>/components/service/service_metrics/service_metrics.js', - - '<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js', - '<%= project.build %>/templates/dashboard/dashboard.js': '<%= project.app %>/templates/dashboard/dashboard.js', - '<%= project.build %>/templates/single_table/single_table.js' : '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js': '<%= project.app %>/templates/host/host.js', - '<%= project.build %>/templates/service/service.js': '<%= project.app %>/templates/service/service.js' - }, - { - '<%= project.build %>/js/bansho.min.js' : [ - '<%= project.build %>/app.js', - '<%= project.build %>/components/config/config.js', - '<%= project.build %>/components/utils/promise_manager.js', - '<%= project.build %>/components/live/live.js', - '<%= project.build %>/components/live/surveil.js', - '<%= project.build %>/components/ng-justgage/ng-justgage.js', - '<%= project.build %>/components/filters/filters.js', - '<%= project.build %>/components/sidebar/sidebar.js', - '<%= project.build %>/components/topbar/topbar.js', - '<%= project.build %>/components/tactical/tactical.js', - '<%= project.build %>/components/tactical/status_overview/status_overview.js', - '<%= project.build %>/components/tactical/current_health/current_health.js', - '<%= project.build %>/components/tactical/top_alert_producers/top_alert_producers.js', - '<%= project.build %>/components/table/actionbar/actionbar.js', - '<%= project.build %>/components/table/table.js', - '<%= project.build %>/components/table/cell_duration/cell_duration.js', - '<%= project.build %>/components/table/cell_host/cell_host.js', - '<%= project.build %>/components/table/cell_last_check/cell_last_check.js', - '<%= project.build %>/components/table/cell_service_check/cell_service_check.js', - '<%= project.build %>/components/table/cell_host_address/cell_host_address.js', - '<%= project.build %>/components/table/cell_host_status/cell_host_status.js', - '<%= project.build %>/components/host/host.js', - '<%= project.build %>/components/host/host_cpu/host_cpu.js', - '<%= project.build %>/components/host/host_info/host_info.js', - '<%= project.build %>/components/host/host_load/host_load.js', - '<%= project.build %>/components/host/host_main/host_main.js', - '<%= project.build %>/components/host/host_services_list/host_services_list.js', - '<%= project.build %>/components/service/service.js', - '<%= project.build %>/components/service/service_main/service_main.js', - '<%= project.build %>/components/service/service_info/service_info.js', - '<%= project.build %>/components/service/service_metrics/service_metrics.js', - '<%= project.build %>/routing_view/routing_view.js', - '<%= project.build %>/templates/dashboard/dashboard.js', - '<%= project.build %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js', - '<%= project.build %>/templates/service/service.js' - ] - } + '<%= project.app %>/components/live/surveil.js', + '<%= project.assets %>/sass/{,*/}*.{scss,sass}' ], - options: { - mangle: false, - beautify: true - } + tasks: ['copy:surveil', 'sass:dev'] } } }); - grunt.loadNpmTasks('grunt-contrib-sass'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-jslint'); - grunt.registerTask('default', ['watch']); + + grunt.registerTask('development:adagios', [ + 'sass', 'copy:adagios', 'watch:adagios' + ]); + + grunt.registerTask('development:surveil', [ + 'sass', 'copy:surveil', 'watch:surveil' + ]); + + grunt.registerTask('production:adagios', [ + 'clean', 'sass', 'copy:prod', 'useminPrepare:html', 'concat:generated', + 'copy:adagios', + 'uglify:generated', 'usemin:html']); + + grunt.registerTask('production:surveil', [ + 'clean', 'sass', 'copy:prod', 'useminPrepare:html', 'concat:generated', + 'copy:surveil', + 'uglify:generated', 'usemin:html']); }; diff --git a/Makefile b/Makefile index b267dae..7d71895 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,17 @@ rebuild: sudo docker build --no-cache -t adg-fe . interactive: - sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v ${PWD}:/opt/adagios-frontend -i -t --name adg-fe adg-fe bash + sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/app:/opt/adagios-frontend/dist -e BANSHO_ENV=false -i -t --name adg-fe adg-fe bash daemon: - sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v ${PWD}:/opt/adagios-frontend -d -t --name adg-fe adg-fe - grunt watch + sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/app:/opt/adagios-frontend/dist -e BANSHO_PROD=false -d -t --name adg-fe adg-fe + grunt development:surveil + +production: + sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name adg-fe adg-fe kill: sudo docker kill adg-fe remove: - sudo docker rm adg-fe + sudo docker rm -f adg-fe diff --git a/app/components/host/host_cpu/host_cpu.js b/app/components/host/host_cpu/host_cpu.js index 6fa3a7a..6a140f8 100644 --- a/app/components/host/host_cpu/host_cpu.js +++ b/app/components/host/host_cpu/host_cpu.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.host.cpu', []) +angular.module('bansho.host.cpu', ['bansho.live']) .controller('HostCpuCtrl', ['$scope', 'getObjects', function ($scope, getObjects) { var hostName = $scope.hostName, diff --git a/app/components/live/adagios.js b/app/components/live/adagios.js index 91d4817..62db4ac 100644 --- a/app/components/live/adagios.js +++ b/app/components/live/adagios.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.live') +angular.module('bansho.live', []) .constant('filterSuffixes', { contains: '__contains', has_field: '__has_field', diff --git a/app/components/live/live.js b/app/components/live/live.js deleted file mode 100644 index 6694f3a..0000000 --- a/app/components/live/live.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -angular.module('bansho.live', []); diff --git a/app/components/live/surveil.js b/app/components/live/surveil.js index 61cdf69..861f19f 100644 --- a/app/components/live/surveil.js +++ b/app/components/live/surveil.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.live') +angular.module('bansho.live', []) .service('getObjects', ['$http', 'hostQueryTransform', 'hostMiddleware', 'serviceMiddleware', function ($http, hostQueryTransform, hostMiddleware, serviceMiddleware) { diff --git a/app/index.html b/app/index.html index 3b72499..2bf7402 100644 --- a/app/index.html +++ b/app/index.html @@ -12,14 +12,53 @@ - + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -38,11 +77,5 @@ - - - - - -