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: {
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']);

View File

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

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 = {
'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 = {};

View File

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

View File

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

View File

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