mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Fixed sorting on job_hosts page.
This commit is contained in:
parent
29aa175a59
commit
26211dbcfb
@ -12,51 +12,24 @@
|
|||||||
|
|
||||||
function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList, GenerateList,
|
function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList, GenerateList,
|
||||||
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Refresh,
|
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Refresh,
|
||||||
JobStatusToolTip, Wait) {
|
JobStatusToolTip) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
var list = JobHostList,
|
var list = JobHostList,
|
||||||
defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_host_summaries/',
|
defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_host_summaries/',
|
||||||
view = GenerateList;
|
view = GenerateList,
|
||||||
|
inventory;
|
||||||
// When viewing all summaries for a particular host, show job ID, otherwise row ID.
|
|
||||||
//if (base === 'hosts') {
|
|
||||||
// list.index = false;
|
|
||||||
//} else {
|
|
||||||
// list.index = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
$scope.selected = [];
|
|
||||||
|
|
||||||
// control enable/disable/show of job specific view elements
|
|
||||||
//if (base === 'hosts') {
|
|
||||||
//$scope.job_id = null;
|
|
||||||
//$scope.host_id = $routeParams.id;
|
|
||||||
//} else {
|
|
||||||
//}
|
|
||||||
|
|
||||||
$scope.job_id = $routeParams.id;
|
$scope.job_id = $routeParams.id;
|
||||||
$scope.host_id = null;
|
$scope.host_id = null;
|
||||||
|
|
||||||
if ($scope.RemoveSetHostLink) {
|
|
||||||
$scope.RemoveSetHostLink();
|
|
||||||
}
|
|
||||||
$scope.RemoveSetHostLink = $scope.$on('setHostLink', function (e, inventory_id) {
|
|
||||||
for (var i = 0; i < $scope.jobhosts.length; i++) {
|
|
||||||
$scope.jobhosts[i].hostLinkTo = '/#/inventories/' + inventory_id + '/?host_name=' +
|
|
||||||
encodeURI($scope.jobhosts[i].summary_fields.host.name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// After a refresh, populate any needed summary field values on each row
|
// After a refresh, populate any needed summary field values on each row
|
||||||
if ($scope.removePostRefresh) {
|
if ($scope.removePostRefresh) {
|
||||||
$scope.removePostRefresh();
|
$scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
|
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
|
||||||
|
|
||||||
view.inject(list, { mode: 'edit', scope: $scope });
|
|
||||||
|
|
||||||
// Set status, tooltips, badges icons, etc.
|
// Set status, tooltips, badges icons, etc.
|
||||||
$scope.jobhosts.forEach(function(element, i) {
|
$scope.jobhosts.forEach(function(element, i) {
|
||||||
$scope.jobhosts[i].host_name = ($scope.jobhosts[i].summary_fields.host) ? $scope.jobhosts[i].summary_fields.host.name : '';
|
$scope.jobhosts[i].host_name = ($scope.jobhosts[i].summary_fields.host) ? $scope.jobhosts[i].summary_fields.host.name : '';
|
||||||
@ -72,78 +45,68 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//if ($scope.job_id !== null && $scope.job_id !== undefined && $scope.job_id !== '') {
|
for (var i = 0; i < $scope.jobhosts.length; i++) {
|
||||||
// need job_status so we can show/hide refresh button
|
$scope.jobhosts[i].hostLinkTo = '/#/inventories/' + inventory + '/?host_name=' +
|
||||||
Rest.setUrl(GetBasePath('jobs') + $scope.job_id + '/');
|
encodeURI($scope.jobhosts[i].summary_fields.host.name);
|
||||||
Rest.get()
|
}
|
||||||
.success(function (data) {
|
|
||||||
LoadBreadCrumbs({
|
|
||||||
path: '/job_host_summaries/' + $scope.job_id,
|
|
||||||
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
|
|
||||||
altPath: '/jobs'
|
|
||||||
});
|
|
||||||
$rootScope.breadcrumbs = [{
|
|
||||||
path: '/jobs',
|
|
||||||
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
|
|
||||||
}];
|
|
||||||
$scope.job_status = data.status;
|
|
||||||
if (!(data.status === 'pending' || data.status === 'waiting' || data.status === 'running')) {
|
|
||||||
if ($rootScope.timer) {
|
|
||||||
clearInterval($rootScope.timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$scope.$emit('setHostLink', data.inventory);
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to get job status for job: ' + $scope.job_id + '. GET status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//} else {
|
|
||||||
// Make the host name appear in breadcrumbs
|
|
||||||
// LoadBreadCrumbs({
|
|
||||||
// path: '/hosts/' + $scope.host_id,
|
|
||||||
// title: (($scope.jobhosts.length > 0) ? $scope.jobhosts[0].summary_fields.host.name : 'Host')
|
|
||||||
// });
|
|
||||||
// if ($routeParams.inventory) {
|
|
||||||
// $scope.$emit('setHostLink', $routeParams.inventory);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({
|
if ($scope.removeJobReady) {
|
||||||
scope: $scope,
|
$scope.removeJobReady();
|
||||||
set: 'jobhosts',
|
|
||||||
list: list,
|
|
||||||
url: defaultUrl
|
|
||||||
});
|
|
||||||
|
|
||||||
PaginateInit({
|
|
||||||
scope: $scope,
|
|
||||||
list: list,
|
|
||||||
url: defaultUrl
|
|
||||||
});
|
|
||||||
|
|
||||||
// Called from Inventories tab, host failed events link:
|
|
||||||
if ($routeParams.host_name) {
|
|
||||||
$scope[list.iterator + 'SearchField'] = 'host';
|
|
||||||
$scope[list.iterator + 'SearchValue'] = $routeParams.host_name;
|
|
||||||
$scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label;
|
|
||||||
}
|
}
|
||||||
|
$scope.removeJobReady = $scope.$on('JobReady', function() {
|
||||||
|
view.inject(list, { mode: 'edit', scope: $scope });
|
||||||
|
|
||||||
$scope.search(list.iterator);
|
SearchInit({
|
||||||
|
scope: $scope,
|
||||||
|
set: 'jobhosts',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
PaginateInit({
|
||||||
|
scope: $scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
// Called from Inventories tab, host failed events link:
|
||||||
|
if ($routeParams.host_name) {
|
||||||
|
$scope[list.iterator + 'SearchField'] = 'host';
|
||||||
|
$scope[list.iterator + 'SearchValue'] = $routeParams.host_name;
|
||||||
|
$scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label;
|
||||||
|
}
|
||||||
|
$scope.search(list.iterator);
|
||||||
|
});
|
||||||
|
|
||||||
|
Rest.setUrl(GetBasePath('jobs') + $scope.job_id);
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
inventory = data.inventory;
|
||||||
|
LoadBreadCrumbs({
|
||||||
|
path: '/job_host_summaries/' + $scope.job_id,
|
||||||
|
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
|
||||||
|
altPath: '/jobs'
|
||||||
|
});
|
||||||
|
$rootScope.breadcrumbs = [{
|
||||||
|
path: '/jobs',
|
||||||
|
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
|
||||||
|
}];
|
||||||
|
$scope.job_status = data.status;
|
||||||
|
$scope.$emit('JobReady');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to get job status for job: ' + $scope.job_id + '. GET status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$scope.showEvents = function (host_name, last_job) {
|
$scope.showEvents = function (host_name, last_job) {
|
||||||
// When click on !Failed Events link, redirect to latest job/job_events for the host
|
// When click on !Failed Events link, redirect to latest job/job_events for the host
|
||||||
Rest.setUrl(last_job);
|
Rest.setUrl(last_job);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
LoadBreadCrumbs({
|
$location.url('/jobs_events/' + data.id + '/?host=' + encodeURI(host_name));
|
||||||
path: '/jobs/' + data.id,
|
|
||||||
title: data.name
|
|
||||||
});
|
|
||||||
$location.url('/jobs/' + data.id + '/job_events/?host=' + encodeURI(host_name));
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job +
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job +
|
||||||
@ -151,22 +114,8 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showJob = function (id) {
|
|
||||||
$location.path('/jobs/' + id);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.refresh = function () {
|
$scope.refresh = function () {
|
||||||
if ($scope.host_id === null) {
|
$scope.search(list.iterator);
|
||||||
$scope.jobSearchSpin = true;
|
|
||||||
$scope.jobLoading = true;
|
|
||||||
Wait('start');
|
|
||||||
Refresh({
|
|
||||||
scope: $scope,
|
|
||||||
set: 'jobhosts',
|
|
||||||
iterator: 'jobhost',
|
|
||||||
url: $scope.current_url
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ angular.module('JobEventsListDefinition', [])
|
|||||||
editTitle: 'Job Events',
|
editTitle: 'Job Events',
|
||||||
index: false,
|
index: false,
|
||||||
hover: true,
|
hover: true,
|
||||||
|
"class": "condensed",
|
||||||
hasChildren: true,
|
hasChildren: true,
|
||||||
filterBy: '{ show: true }',
|
filterBy: '{ show: true }',
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ angular.module('JobHostDefinition', [])
|
|||||||
name: 'jobhosts',
|
name: 'jobhosts',
|
||||||
iterator: 'jobhost',
|
iterator: 'jobhost',
|
||||||
editTitle: 'All summaries',
|
editTitle: 'All summaries',
|
||||||
|
"class": "table-condensed",
|
||||||
index: true,
|
index: true,
|
||||||
hover: true,
|
hover: true,
|
||||||
|
|
||||||
@ -40,13 +41,6 @@ angular.module('JobHostDefinition', [])
|
|||||||
},
|
},
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
job: {
|
|
||||||
label: 'Job ID',
|
|
||||||
ngClick: "showJob(jobhost.job)",
|
|
||||||
columnShow: 'host_id !== null',
|
|
||||||
key: true,
|
|
||||||
desc: true
|
|
||||||
},
|
|
||||||
host: {
|
host: {
|
||||||
label: 'Host',
|
label: 'Host',
|
||||||
key: true,
|
key: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user