Actionbar: Acknowledge implemented
This commit is contained in:
parent
91c5f0dc3f
commit
ed2ffa3dc4
@ -373,3 +373,23 @@ angular.module('bansho.live', [])
|
||||
return responsePromise.promise;
|
||||
};
|
||||
}])
|
||||
|
||||
.service('acknowledge', ['$http', function($http) {
|
||||
return function (host_name, service_description) {
|
||||
var data = {};
|
||||
|
||||
data.host_name = host_name;
|
||||
|
||||
if (service_description !== undefined) {
|
||||
data.service_description = service_description;
|
||||
}
|
||||
|
||||
return $http({
|
||||
url: '/surveil/v2/actions/acknowledge/',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
}).error(function () {
|
||||
throw new Error('acknowledge : POST Request failed');
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
@ -28,7 +28,7 @@
|
||||
</li>
|
||||
<li class="filters__item filters__item--acknowledge"
|
||||
data-mover="true">
|
||||
<button class="filters__button" type="button">
|
||||
<button class="filters__button" type="button" ng-click="acknowledge()">
|
||||
<span class="visuallyhidden">Acknowledge</span>
|
||||
<i class="ico-thumbs-up"></i>
|
||||
</button>
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('bansho.table.actionbar', [])
|
||||
angular.module('bansho.table.actionbar', ['bansho.table',
|
||||
'bansho.live'])
|
||||
|
||||
.factory('actionbarFilters', function () {
|
||||
var actionbarFilters = {
|
||||
@ -27,10 +28,33 @@ angular.module('bansho.table.actionbar', [])
|
||||
return actionbarFilters;
|
||||
})
|
||||
|
||||
.controller('TableActionbarCtrl', ['$scope', 'actionbarFilters', function ($scope, actionbarFilters) {
|
||||
.controller('TableActionbarCtrl', ['$scope', '$filter', 'acknowledge', 'actionbarFilters', 'tablesConfig',
|
||||
function ($scope, $filter, acknowledge, actionbarFilters, tablesConfig, actionbarSelectFilter) {
|
||||
$scope.actionbarFilters = actionbarFilters;
|
||||
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[0];
|
||||
|
||||
$scope.acknowledge = function () {
|
||||
angular.forEach(tablesConfig, function (tableConfig) {
|
||||
var entries = $filter('filter')(tableConfig.entries,
|
||||
$scope.actionbarFilters.searchFilter);
|
||||
|
||||
angular.forEach(entries, function (entry) {
|
||||
var service_description = undefined;
|
||||
|
||||
if (entry.is_checked) {
|
||||
if ('description' in entry) {
|
||||
service_description = entry.description;
|
||||
}
|
||||
|
||||
acknowledge(entry.host_name, service_description)
|
||||
.error(function (data) {
|
||||
throw new Error('Acknowledge request failed');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.activateFilter = function (item) {
|
||||
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[item];
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<tbody class="{{entry.child_class}}" ng-repeat="entry in entries | actionbarSelectFilter:actionbarFilters.activeFilter | filter:actionbarFilters.searchFilter | noRepeat:this | wrappableStyle:this">
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td><input type="checkbox" ng-model="entry.is_checked"></td>
|
||||
<td bansho-cell cell-name="{{cell}}" ng-repeat="cell in cellsName"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -42,6 +42,7 @@ angular.module('bansho.table', ['bansho.live',
|
||||
var promise = getTableData(requestFields, filters, apiName, additionnalFields);
|
||||
promise.then(function (data) {
|
||||
$scope.entries = data;
|
||||
conf.entries = data;
|
||||
}, function (reason) {
|
||||
throw new Error('getTableData : Query failed');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user