diff --git a/app/components/live/surveil.js b/app/components/live/surveil.js index 65d1919..d95d843 100644 --- a/app/components/live/surveil.js +++ b/app/components/live/surveil.js @@ -361,11 +361,16 @@ angular.module('bansho.live', []) }; var downtime = function (host_name, service_description, attrs) { - var data = {}; + attrs.host_name = host_name; + if (service_description !== undefined) { + attrs.service_description = service_description; + } - angular.forEach(attrs, function (key, value) { - console.log(key + "; " + value); - }); + return $http({ + url: '/surveil/v2/actions/downtime/', + method: 'POST', + data: attrs + }); }; return { diff --git a/app/components/table/actionbar/actionbar.html b/app/components/table/actionbar/actionbar.html index bfc57b1..81f75e8 100644 --- a/app/components/table/actionbar/actionbar.html +++ b/app/components/table/actionbar/actionbar.html @@ -1,141 +1,139 @@ - + + + +
+
+

Acknowlege

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+ +
+ +
diff --git a/app/components/table/actionbar/actionbar.js b/app/components/table/actionbar/actionbar.js index db758ce..e9ba3af 100644 --- a/app/components/table/actionbar/actionbar.js +++ b/app/components/table/actionbar/actionbar.js @@ -1,9 +1,8 @@ 'use strict'; -angular.module('bansho.table.actionbar', ['bansho.table', - 'bansho.live']) +angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live']) - .factory('actionbarFilters', function () { + .service('actionbarFilters', function () { var actionbarFilters = { activeFilter: {}, possibleFilters: [ @@ -54,8 +53,7 @@ angular.module('bansho.table.actionbar', ['bansho.table', service_description = entry.description; } - backendClient.acknowledge(entry.host_name, service_description, $scope.acknowledgeData) - .error(function (data) { + backendClient.acknowledge(entry.host_name, service_description, $scope.acknowledgeData).error(function (data) { throw new Error('Acknowledge request failed'); }); } @@ -107,18 +105,4 @@ angular.module('bansho.table.actionbar', ['bansho.table', restrict: 'E', templateUrl: 'components/table/actionbar/actionbar.html' }; - }) - - .directive('banshoDowntimeForm', function () { - return { - restrict: 'E', - templateUrl: 'components/table/actionbar/downtime_form.html', - scope: { - isShown: '=', - selectedHosts: '=' - }, - controller: function ($scope) { - console.log($scope.isShown) - } - }; }); diff --git a/app/components/table/actionbar/actions/actions.js b/app/components/table/actionbar/actions/actions.js new file mode 100644 index 0000000..d2bc2f4 --- /dev/null +++ b/app/components/table/actionbar/actions/actions.js @@ -0,0 +1,49 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + + .directive('banshoDowntimeForm', + ['$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', + function ($filter, tablesConfig, actionbarFilters, backendClient) { + + 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 = undefined; + + 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" + }); + }); + } + }); + }); + } + } + } + }]); diff --git a/app/components/table/actionbar/actions/downtime_form.html b/app/components/table/actionbar/actions/downtime_form.html new file mode 100644 index 0000000..cb7d7e6 --- /dev/null +++ b/app/components/table/actionbar/actions/downtime_form.html @@ -0,0 +1,30 @@ +
+
{{message.text}} + {{message.type}}
+

Downtime

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/app/components/table/actionbar/downtime_form.html b/app/components/table/actionbar/downtime_form.html deleted file mode 100644 index 37fb3b2..0000000 --- a/app/components/table/actionbar/downtime_form.html +++ /dev/null @@ -1,10 +0,0 @@ -
-

Downtime form {{isShown}}

-
-
- - -
- -
-
\ No newline at end of file diff --git a/app/index.html b/app/index.html index 3fdbfe8..f9d0f6c 100644 --- a/app/index.html +++ b/app/index.html @@ -36,6 +36,7 @@ +