diff --git a/app/components/live/surveil.js b/app/components/live/surveil.js index 10e2135..591a66b 100644 --- a/app/components/live/surveil.js +++ b/app/components/live/surveil.js @@ -361,8 +361,6 @@ angular.module('bansho.live', []) url: '/surveil/v2/actions/acknowledge/', method: 'POST', data: data - }).error(function () { - throw new Error('acknowledge : POST Request failed'); }); }; diff --git a/app/components/notifications/notifications.js b/app/components/notifications/notifications.js new file mode 100644 index 0000000..b03ed63 --- /dev/null +++ b/app/components/notifications/notifications.js @@ -0,0 +1,21 @@ +'use strict'; + +angular.module('bansho.notifications', []) + .service('notifications', [ + function () { + var push = function (type, title, message) { + $(function(){ + new PNotify({ + type: type, + title: title, + text: message, + styling: {}, + }); + }); + }; + + return { + "push": push + }; + + }]); diff --git a/app/components/table/actionbar/actionbar.js b/app/components/table/actionbar/actionbar.js index bae53c3..120975b 100644 --- a/app/components/table/actionbar/actionbar.js +++ b/app/components/table/actionbar/actionbar.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live']) +angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live', 'bansho.notifications']) .service('actionbarFilters', function () { var actionbarFilters = { diff --git a/app/components/table/actionbar/actions/actions.js b/app/components/table/actionbar/actions/actions.js index 3fbbd1e..b82e6f0 100644 --- a/app/components/table/actionbar/actions/actions.js +++ b/app/components/table/actionbar/actions/actions.js @@ -14,28 +14,34 @@ angular.module('bansho.table.actionbar') }) .controller('banshoAcknowledgeFormCtrl', - ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', - function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { + ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications', + function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) { $scope.acknowledgeProblems = function () { - angular.forEach(tablesConfig, function (tableConfig) { - var entries = $filter('filter')(tableConfig.entries, + angular.forEach(tablesConfig, function (table) { + var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter); + table.isCheckAll = false; angular.forEach(entries, function (entry) { var service_description; if (entry.is_checked) { + entry.is_checked = false; 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'); - }); + backendClient.acknowledge(entry.host_name, service_description, $scope.attrs).then(function (data) { + notifications.push('success', 'Acknowledgement', 'Acknowledged ' + entry.host_name); + }, + function (error) { + notifications.push('error', 'Acknowledgement', 'Could not acknowledge ' + entry.host_name); + }); } }); }); + $scope.isShown = false; }; }]) @@ -51,39 +57,33 @@ angular.module('bansho.table.actionbar') }) .controller('banshoDowntimeFormCtrl', - ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', - function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { - - $scope.messages = []; + ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications', + function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) { $scope.sendDowntime = function () { angular.forEach(tablesConfig, function (table) { var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter); + table.isCheckAll = false; angular.forEach(entries, function (entry) { var service_description; if (entry.is_checked) { + entry.is_checked = false; 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" - }); - $scope.isShown = false; + notifications.push('success', 'Downtime', 'Added downtime for ' + entry.host_name); }, function (error) { - $scope.messages.push({ - text: entry.host_name + " error", - type: "error" - }); + notifications.push('error', 'Downtime', 'Could not add downtime for ' + entry.host_name); }); } }); }); + $scope.isShown = false; }; }]) @@ -91,42 +91,33 @@ angular.module('bansho.table.actionbar') return { restrict: 'E', templateUrl: 'components/table/actionbar/actions/recheck_button.html', - scope: { - isShown: '=' - }, controller: 'banshoRecheckButtonCtrl' }; }) .controller('banshoRecheckButtonCtrl', - ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', - function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { - - $scope.messages = []; + ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications', + function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) { $scope.sendRecheck = function () { angular.forEach(tablesConfig, function (table) { var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter); + table.isCheckAll = false; angular.forEach(entries, function (entry) { var service_description; if (entry.is_checked) { + entry.is_checked = false; if ('description' in entry) { service_description = entry.description; } backendClient.recheck(entry.host_name, service_description).then(function (data) { - $scope.messages.push({ - text: entry.host_name + " success ", - type: "success" - }); + notifications.push('success', 'Recheck', 'Scheduled recheck for ' + entry.host_name); }, function (error) { - $scope.messages.push({ - text: entry.host_name + " error", - type: "error" - }); + notifications.push('error', 'Recheck', 'Could not schedule recheck for ' + entry.host_name); }); } }); diff --git a/app/components/table/actionbar/actions/downtime_form.html b/app/components/table/actionbar/actions/downtime_form.html index f0ab68b..902e233 100644 --- a/app/components/table/actionbar/actions/downtime_form.html +++ b/app/components/table/actionbar/actions/downtime_form.html @@ -1,4 +1,3 @@ -