Merge pull request #46 from savoirfairelinux/acknowledge
Actionbar now has "acknowledge" feature
This commit is contained in:
commit
76cf0a556d
@ -373,3 +373,28 @@ angular.module('bansho.live', [])
|
||||
return responsePromise.promise;
|
||||
};
|
||||
}])
|
||||
|
||||
.service('acknowledge', ['$http', function($http) {
|
||||
return function (host_name, service_description, attrs) {
|
||||
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 (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="ackFormIsOpen = !ackFormIsOpen">
|
||||
<span class="visuallyhidden">Acknowledge</span>
|
||||
<i class="ico-thumbs-up"></i>
|
||||
</button>
|
||||
@ -88,4 +88,51 @@
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Acknowledgement form -->
|
||||
<div ng-show="ackFormIsOpen">
|
||||
<div>
|
||||
<h4 id="acknowledgeModalLabel">Acknowlege</h4>
|
||||
</div>
|
||||
<div>
|
||||
<form>
|
||||
<div>
|
||||
<label for="author">Author :</label>
|
||||
<input type="text" id="acknowledge-author" ng-model="acknowledgeData.author">
|
||||
</div>
|
||||
<div>
|
||||
<label for="sticky">Sticky :</label>
|
||||
<input type="checkbox"
|
||||
id="acknowledge-sticky"
|
||||
ng-model="acknowledgeData.sticky"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
</div>
|
||||
<div>
|
||||
<label for="notify">Notify :</label>
|
||||
<input type="checkbox"
|
||||
id="acknowledge-notify"
|
||||
ng-model="acknowledgeData.notify"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
</div >
|
||||
<div>
|
||||
<label for="persistent">Persistent :</label>
|
||||
<input type="checkbox"
|
||||
id="acknowledge-persistent"
|
||||
ng-model="acknowledgeData.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">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" ng-click="ackFormIsOpen = !ackFormIsOpen">Close</button>
|
||||
<button type="button" ng-click="acknowledgeProblems()">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
</menu>
|
||||
|
@ -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,14 +28,45 @@ angular.module('bansho.table.actionbar', [])
|
||||
return actionbarFilters;
|
||||
})
|
||||
|
||||
.controller('TableActionbarCtrl', ['$scope', 'actionbarFilters', function ($scope, actionbarFilters) {
|
||||
$scope.actionbarFilters = actionbarFilters;
|
||||
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[0];
|
||||
.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.ackFormIsOpen = false;
|
||||
|
||||
$scope.activateFilter = function (item) {
|
||||
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[item];
|
||||
};
|
||||
}])
|
||||
$scope.acknowledgeData = {};
|
||||
$scope.acknowledgeData.author = 'anonymous';
|
||||
$scope.acknowledgeData.comment = 'No comment';
|
||||
$scope.acknowledgeData.sticky = '1';
|
||||
$scope.acknowledgeData.notify = '0';
|
||||
$scope.acknowledgeData.persistent = '1';
|
||||
|
||||
$scope.acknowledgeProblems = 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, $scope.acknowledgeData)
|
||||
.error(function (data) {
|
||||
throw new Error('Acknowledge request failed');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.activateFilter = function (item) {
|
||||
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[item];
|
||||
};
|
||||
}])
|
||||
|
||||
.filter('actionbarSelectFilter', function () {
|
||||
return function (items, activeFilter) {
|
||||
|
@ -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