Fix dependency injection when minimize

This commit is contained in:
Vincent Fournier 2015-05-05 14:45:02 -04:00
parent 52d1bd0abe
commit 2237d0cf3c
6 changed files with 108 additions and 76 deletions

View File

@ -17,7 +17,14 @@ module.exports = function (grunt) {
}, },
clean: { 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 %>/'] tmp: ['<%= project.tmp %>/']
}, },
@ -152,6 +159,15 @@ module.exports = function (grunt) {
], ],
tasks: ['copy:surveil', 'sass:dev', 'jshint:all'] 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: { options: {
livereload: true livereload: true
} }
@ -168,8 +184,11 @@ module.exports = function (grunt) {
'sass', 'copy:surveil', 'jshint:all', 'watch:surveil' 'sass', 'copy:surveil', 'jshint:all', 'watch:surveil'
]); ]);
grunt.registerTask('staging:surveil', [
'production:surveil', 'watch:staging']);
grunt.registerTask('production:adagios', [ 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', [ grunt.registerTask('production:surveil', [
'clean', 'sass', 'copy:prod', 'copy:surveil', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); 'clean', 'sass', 'copy:prod', 'copy:surveil', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']);

View File

@ -18,6 +18,10 @@ daemon:
production: production:
sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho 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: kill:
sudo docker kill bansho sudo docker kill bansho

View File

@ -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 = { $scope.credentials = {
'auth': { 'auth': {
'tenantName': '', 'tenantName': '',
@ -23,7 +23,7 @@ angular.module('bansho.authentication', [])
$scope.login = function (credentials) { $scope.login = function (credentials) {
authService.login(credentials); authService.login(credentials);
}; };
}) }])
.factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) { .factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) {
var authService = {}; var authService = {};

View File

@ -338,14 +338,20 @@ angular.module('bansho.live', [])
}; };
var acknowledge = function (host_name, service_description, attrs) { var acknowledge = function (host_name, service_description, attrs) {
var data = {}; var data = {};
data.host_name = host_name; data.host_name = host_name;
data.author = attrs.author; if (attrs.sticky) {
data.comment = attrs.comment; data.sticky = parseInt(attrs.sticky, 10);
data.sticky = parseInt(attrs.sticky, 10); }
data.notify = parseInt(attrs.notify, 10);
data.persistent = parseInt(attrs.persistent, 10); if (attrs.notify) {
data.notify = parseInt(attrs.notify, 10);
}
if (attrs.persistent) {
data.persistent = parseInt(attrs.persistent, 10);
}
if (service_description !== undefined) { if (service_description !== undefined) {
data.service_description = service_description; data.service_description = service_description;

View File

@ -2,13 +2,13 @@
<form data-ng-submit="acknowledgeProblems()"> <form data-ng-submit="acknowledgeProblems()">
<div> <div>
<label for="author">Author :</label> <label for="author">Author :</label>
<input type="text" id="acknowledge-author" ng-model="acknowledgeData.author"> <input type="text" id="acknowledge-author" ng-model="attrs.author">
</div> </div>
<div> <div>
<label for="sticky">Sticky :</label> <label for="sticky">Sticky :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-sticky" id="acknowledge-sticky"
ng-model="acknowledgeData.sticky" ng-model="attrs.sticky"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div> </div>
@ -16,7 +16,7 @@
<label for="notify">Notify :</label> <label for="notify">Notify :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-notify" id="acknowledge-notify"
ng-model="acknowledgeData.notify" ng-model="attrs.notify"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div > </div >
@ -24,13 +24,13 @@
<label for="persistent">Persistent :</label> <label for="persistent">Persistent :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-persistent" id="acknowledge-persistent"
ng-model="acknowledgeData.persistent" ng-model="attrs.persistent"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div> </div>
<div> <div>
<label for="comment">Comment :</label> <label for="comment">Comment :</label>
<input type="message-text" id="acknowledge-comment" ng-model="acknowledgeData.comment"> <input type="message-text" id="acknowledge-comment" ng-model="attrs.comment">
</div> </div>
<div> <div>
<button type="button" ng-click="isShown = !isShown">Close</button> <button type="button" ng-click="isShown = !isShown">Close</button>

View File

@ -2,83 +2,86 @@
angular.module('bansho.table.actionbar') angular.module('bansho.table.actionbar')
.directive('banshoAcknowledgeForm', .directive('banshoAcknowledgeForm', function () {
['$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function($filter, tablesConfig, actionbarFilters, backendClient) {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'components/table/actionbar/actions/acknowledge_form.html', templateUrl: 'components/table/actionbar/actions/acknowledge_form.html',
scope: { scope: {
isShown: '=' isShown: '='
}, },
controller: function ($scope) { controller: 'banshoAcknowledgeFormCtrl'
$scope.acknowledgeProblems = function () { };
angular.forEach(tablesConfig, function (tableConfig) { })
var entries = $filter('filter')(tableConfig.entries,
actionbarFilters.searchFilter);
angular.forEach(entries, function (entry) { .controller('banshoAcknowledgeFormCtrl',
var service_description; ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
if (entry.is_checked) { $scope.acknowledgeProblems = function () {
if ('description' in entry) { angular.forEach(tablesConfig, function (tableConfig) {
service_description = entry.description; var entries = $filter('filter')(tableConfig.entries,
} actionbarFilters.searchFilter);
backendClient.acknowledge(entry.host_name, service_description, $scope.acknowledgeData).error(function (data) { angular.forEach(entries, function (entry) {
throw new Error('Acknowledge request failed'); 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', .directive('banshoDowntimeForm', function () {
['$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function ($filter, tablesConfig, actionbarFilters, backendClient) {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'components/table/actionbar/actions/downtime_form.html', templateUrl: 'components/table/actionbar/actions/downtime_form.html',
scope: { scope: {
isShown: '=' isShown: '='
}, },
controller: function ($scope) { controller: 'banshoDowntimeFormCtrl'
$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',
['$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"
});
});
}
});
});
};
}])