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