mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 17:48:10 -03:30
Merge pull request #2883 from leigh-johnson/2858_2859_2761
Consolidate Job Detail > Host Events filter/search requests
This commit is contained in:
@@ -18,93 +18,49 @@
|
|||||||
|
|
||||||
$scope.search = function(){
|
$scope.search = function(){
|
||||||
Wait('start');
|
Wait('start');
|
||||||
if ($scope.searchStr === undefined){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//http://docs.ansible.com/ansible-tower/latest/html/towerapi/intro.html#filtering
|
//http://docs.ansible.com/ansible-tower/latest/html/towerapi/intro.html#filtering
|
||||||
// SELECT WHERE host_name LIKE str OR WHERE play LIKE str OR WHERE task LIKE str AND host_name NOT ""
|
// SELECT WHERE host_name LIKE str OR WHERE play LIKE str OR WHERE task LIKE str AND host_name NOT ""
|
||||||
// selecting non-empty host_name fields prevents us from displaying non-runner events, like playbook_on_task_start
|
// selecting non-empty host_name fields prevents us from displaying non-runner events, like playbook_on_task_start
|
||||||
JobDetailService.getRelatedJobEvents($stateParams.id, {
|
var params = {
|
||||||
or__host_name__icontains: $scope.searchStr,
|
host_name: $scope.hostName,
|
||||||
or__play__icontains: $scope.searchStr,
|
};
|
||||||
or__task__icontains: $scope.searchStr,
|
if ($scope.searchStr && $scope.searchStr !== ''){
|
||||||
not__host_name: "" ,
|
params.or__play__icontains = $scope.searchStr;
|
||||||
page_size: $scope.pageSize})
|
params.or__task__icontains = $scope.searchStr;
|
||||||
.success(function(res){
|
}
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
switch($scope.activeFilter){
|
||||||
});
|
case 'skipped':
|
||||||
|
params.event = 'runner_on_skipped';
|
||||||
|
break;
|
||||||
|
case 'unreachable':
|
||||||
|
params.event = 'runner_on_unreachable';
|
||||||
|
break;
|
||||||
|
case 'ok':
|
||||||
|
params.event = 'runner_on_ok';
|
||||||
|
break;
|
||||||
|
case 'failed':
|
||||||
|
params.failed = true;
|
||||||
|
break;
|
||||||
|
case 'changed':
|
||||||
|
params.changed = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
JobDetailService.getRelatedJobEvents($stateParams.id, params)
|
||||||
|
.success(function(res){
|
||||||
|
$scope.results = res.results;
|
||||||
|
Wait('stop');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.filters = ['all', 'changed', 'failed', 'ok', 'unreachable', 'skipped'];
|
$scope.filters = ['all', 'changed', 'failed', 'ok', 'unreachable', 'skipped'];
|
||||||
|
|
||||||
var filter = function(filter){
|
|
||||||
Wait('start');
|
|
||||||
|
|
||||||
if (filter === 'all'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
page_size: $scope.pageSize})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// handle runner cases
|
|
||||||
if (filter === 'skipped'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
event: 'runner_on_skipped'})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (filter === 'unreachable'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
event: 'runner_on_unreachable'})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (filter === 'ok'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
event__startswith: 'runner_on_ok'
|
|
||||||
})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// handle convience properties .changed .failed
|
|
||||||
if (filter === 'changed'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
changed: true})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (filter === 'failed'){
|
|
||||||
return JobDetailService.getRelatedJobEvents($stateParams.id, {
|
|
||||||
host_name: $stateParams.hostName,
|
|
||||||
failed: true,
|
|
||||||
event__startswith: 'runner_on_failed'
|
|
||||||
})
|
|
||||||
.success(function(res){
|
|
||||||
$scope.results = res.results;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// watch select2 for changes
|
// watch select2 for changes
|
||||||
$('.HostEvents-select').on("select2:select", function () {
|
$('.HostEvents-select').on("select2:select", function () {
|
||||||
filter($('.HostEvents-select').val());
|
$scope.activeFilter = $('.HostEvents-select').val();
|
||||||
|
$scope.search();
|
||||||
});
|
});
|
||||||
|
|
||||||
var init = function(){
|
var init = function(){
|
||||||
@@ -116,12 +72,9 @@
|
|||||||
});
|
});
|
||||||
// process the filter if one was passed
|
// process the filter if one was passed
|
||||||
if ($stateParams.filter){
|
if ($stateParams.filter){
|
||||||
Wait('start');
|
$scope.activeFilter = $stateParams.filter;
|
||||||
filter($stateParams.filter).success(function(res){
|
$scope.search();
|
||||||
$scope.results = res.results;
|
$('#HostEvents').modal('show');
|
||||||
Wait('stop');
|
|
||||||
$('#HostEvents').modal('show');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$scope.results = hosts.data.results;
|
$scope.results = hosts.data.results;
|
||||||
|
|||||||
Reference in New Issue
Block a user