From 2237d0cf3c1ecd86f914507bc145766f370e688f Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Tue, 5 May 2015 14:45:02 -0400 Subject: [PATCH] Fix dependency injection when minimize --- Gruntfile.js | 23 +++- Makefile | 4 + .../authentication/authentication.js | 4 +- app/components/live/surveil.js | 18 ++- .../actionbar/actions/acknowledge_form.html | 10 +- .../table/actionbar/actions/actions.js | 125 +++++++++--------- 6 files changed, 108 insertions(+), 76 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a2a947d..0d411f4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,7 +17,14 @@ module.exports = function (grunt) { }, clean: { - dist: ['<%= project.dist %>/'], + dist: [ + '<%= project.dist %>/assets/', + '<%= project.dist %>/bower_components/', + '<%= project.dist %>/components/', + '<%= project.dist %>/js/', + '<%= project.dist %>/templates/', + '<%= project.dist %>/index.html' + ], tmp: ['<%= project.tmp %>/'] }, @@ -152,6 +159,15 @@ module.exports = function (grunt) { ], tasks: ['copy:surveil', 'sass:dev', 'jshint:all'] }, + staging: { + files: [ + '<%= project.app %>/**/*.js', + '<%= project.app %>/**/*.html', + '<%= project.app %>/components/live/surveil.js', + '<%= project.assets %>/sass/{,*/}*.{scss,sass}' + ], + tasks: ['production:surveil'] + }, options: { livereload: true } @@ -168,8 +184,11 @@ module.exports = function (grunt) { 'sass', 'copy:surveil', 'jshint:all', 'watch:surveil' ]); + grunt.registerTask('staging:surveil', [ + 'production:surveil', 'watch:staging']); + grunt.registerTask('production:adagios', [ - 'clean', 'sass', 'copy:prod','copy:adagios', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); + 'clean', 'sass', 'copy:prod', 'copy:adagios', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); grunt.registerTask('production:surveil', [ 'clean', 'sass', 'copy:prod', 'copy:surveil', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); diff --git a/Makefile b/Makefile index 6cf60ed..310acc9 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ daemon: production: sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho +staging: + sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/dist:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho + grunt staging:surveil + kill: sudo docker kill bansho diff --git a/app/components/authentication/authentication.js b/app/components/authentication/authentication.js index 1377cd9..f4d36a6 100644 --- a/app/components/authentication/authentication.js +++ b/app/components/authentication/authentication.js @@ -9,7 +9,7 @@ angular.module('bansho.authentication', []) }); }]) - .controller('LoginController', function ($scope, $rootScope, $location, authService) { + .controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', function ($scope, $rootScope, $location, authService) { $scope.credentials = { 'auth': { 'tenantName': '', @@ -23,7 +23,7 @@ angular.module('bansho.authentication', []) $scope.login = function (credentials) { authService.login(credentials); }; - }) + }]) .factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) { var authService = {}; diff --git a/app/components/live/surveil.js b/app/components/live/surveil.js index f111acb..da4c0b8 100644 --- a/app/components/live/surveil.js +++ b/app/components/live/surveil.js @@ -338,14 +338,20 @@ angular.module('bansho.live', []) }; var acknowledge = function (host_name, service_description, attrs) { - var data = {}; + var data = {}; data.host_name = host_name; - data.author = attrs.author; - data.comment = attrs.comment; - data.sticky = parseInt(attrs.sticky, 10); - data.notify = parseInt(attrs.notify, 10); - data.persistent = parseInt(attrs.persistent, 10); + if (attrs.sticky) { + data.sticky = parseInt(attrs.sticky, 10); + } + + if (attrs.notify) { + data.notify = parseInt(attrs.notify, 10); + } + + if (attrs.persistent) { + data.persistent = parseInt(attrs.persistent, 10); + } if (service_description !== undefined) { data.service_description = service_description; diff --git a/app/components/table/actionbar/actions/acknowledge_form.html b/app/components/table/actionbar/actions/acknowledge_form.html index e3717d0..798e4ee 100644 --- a/app/components/table/actionbar/actions/acknowledge_form.html +++ b/app/components/table/actionbar/actions/acknowledge_form.html @@ -2,13 +2,13 @@
- +
@@ -16,7 +16,7 @@ @@ -24,13 +24,13 @@
- +
diff --git a/app/components/table/actionbar/actions/actions.js b/app/components/table/actionbar/actions/actions.js index eeedae5..faf37fe 100644 --- a/app/components/table/actionbar/actions/actions.js +++ b/app/components/table/actionbar/actions/actions.js @@ -2,83 +2,86 @@ angular.module('bansho.table.actionbar') - .directive('banshoAcknowledgeForm', - ['$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', - function($filter, tablesConfig, actionbarFilters, backendClient) { - + .directive('banshoAcknowledgeForm', function () { return { restrict: 'E', templateUrl: 'components/table/actionbar/actions/acknowledge_form.html', scope: { isShown: '=' }, - controller: function ($scope) { - $scope.acknowledgeProblems = function () { - angular.forEach(tablesConfig, function (tableConfig) { - var entries = $filter('filter')(tableConfig.entries, - actionbarFilters.searchFilter); + controller: 'banshoAcknowledgeFormCtrl' + }; + }) - angular.forEach(entries, function (entry) { - var service_description; + .controller('banshoAcknowledgeFormCtrl', + ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', + function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { - if (entry.is_checked) { - if ('description' in entry) { - service_description = entry.description; - } + $scope.acknowledgeProblems = function () { + angular.forEach(tablesConfig, function (tableConfig) { + var entries = $filter('filter')(tableConfig.entries, + actionbarFilters.searchFilter); - backendClient.acknowledge(entry.host_name, service_description, $scope.acknowledgeData).error(function (data) { - throw new Error('Acknowledge request failed'); - }); - } - }); - }); - }; - } + angular.forEach(entries, function (entry) { + var service_description; + + if (entry.is_checked) { + if ('description' in entry) { + service_description = entry.description; + } + + backendClient.acknowledge(entry.host_name, service_description, $scope.attrs).error(function (data) { + throw new Error('Acknowledge request failed'); + }); + } + }); + }); }; }]) - .directive('banshoDowntimeForm', - ['$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', - function ($filter, tablesConfig, actionbarFilters, backendClient) { - + .directive('banshoDowntimeForm', function () { return { restrict: 'E', templateUrl: 'components/table/actionbar/actions/downtime_form.html', scope: { isShown: '=' }, - controller: function ($scope) { - $scope.messages = []; - - $scope.sendDowntime = function () { - angular.forEach(tablesConfig, function (table) { - var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter); - - angular.forEach(entries, function (entry) { - var service_description; - - if (entry.is_checked) { - if ('description' in entry) { - service_description = entry.description; - } - - console.log($scope.attrs); - backendClient.downtime(entry.host_name, service_description, $scope.attrs).then(function (data) { - $scope.messages.push({ - text: entry.host_name + " success ", - type: "success" - }); - }, - function (error) { - $scope.messages.push({ - text: entry.host_name + " error", - type: "error" - }); - }); - } - }); - }); - }; - } + controller: 'banshoDowntimeFormCtrl' }; - }]); + }) + + .controller('banshoDowntimeFormCtrl', + ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', + function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { + + $scope.messages = []; + + $scope.sendDowntime = function () { + angular.forEach(tablesConfig, function (table) { + var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter); + + angular.forEach(entries, function (entry) { + var service_description; + + if (entry.is_checked) { + if ('description' in entry) { + service_description = entry.description; + } + + backendClient.downtime(entry.host_name, service_description, $scope.attrs).then(function (data) { + $scope.messages.push({ + text: entry.host_name + " success ", + type: "success" + }); + }, + function (error) { + $scope.messages.push({ + text: entry.host_name + " error", + type: "error" + }); + }); + } + }); + }); + }; + }])