1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Merge pull request #160 from jlmitch5/linkOutInvSrcStdout

fix link out to inventory source on standard out page
This commit is contained in:
jlmitch5 2017-08-03 13:56:57 -04:00 committed by GitHub
commit 430473f01e
2 changed files with 12 additions and 44 deletions

View File

@ -9,7 +9,8 @@
return function(params) {
var url = params.url,
scope_var = params.scope_var,
scope = params.scope;
scope = params.scope,
callback = params.callback;
Rest.setUrl(url);
Rest.get()
.success(function(data) {
@ -19,6 +20,10 @@
if (!Empty(data.name)) {
scope[scope_var + '_name'] = data.name;
}
if (callback) {
scope.$emit(callback, data);
}
})
.error(function(data, status) {
if (status === 403 && params.ignore_403) {

View File

@ -83,6 +83,10 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
$scope.variables = ParseVariableString(data.extra_vars);
}
$scope.$on('getInventorySource', function(e, d) {
$scope.inv_manage_group_link = '/#/inventories/inventory/' + d.inventory + '/inventory_sources/edit/' + d.id;
});
// If we have a source then we have to go get the source choices from the server
if (!Empty(data.source)) {
if ($scope.removeChoicesReady) {
@ -152,7 +156,8 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
LookUpName({
scope: $scope,
scope_var: 'inventory_source',
url: GetBasePath('inventory_sources') + data.inventory_source + '/'
url: GetBasePath('inventory_sources') + data.inventory_source + '/',
callback: 'getInventorySource'
});
}
@ -164,47 +169,6 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
});
}
if ($scope.job.type === 'inventory_update' && !$scope.inv_manage_group_link) {
var groupWatcher = $scope.$watch('group', function(group){
if(group) {
// The group's been set by the LookUpName call on inventory_source
var ancestorGroupIds = [];
// Remove the watcher
groupWatcher();
// Function that we'll call recursively to go out and get a groups parent(s)
var getGroupParent = function(groupId) {
Rest.setUrl(GetBasePath('base') + 'groups/?children__id=' + groupId);
Rest.get()
.success(function(data) {
if(data.results && data.results.length > 0) {
ancestorGroupIds.push(data.results[0].id);
// Go get this groups first parent
getGroupParent(data.results[0].id);
}
else {
// We've run out of ancestors to traverse - lets build a link (note that $scope.inventory is
// set in the lookup-name factory just like $scope.group)
$scope.inv_manage_group_link = '/#/inventories/' + $scope.inventory + '/manage';
for(var i=ancestorGroupIds.length; i > 0; i--) {
$scope.inv_manage_group_link += (i === ancestorGroupIds.length ? '?' : '&') + 'group=' + ancestorGroupIds[i-1];
}
}
})
.error(function(data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve group parent(s): ' + groupId + '. GET returned: ' + status });
});
};
// Trigger the recursive chain of parent group gathering
getGroupParent(group);
}
});
}
// If the job isn't running we want to clear out the interval that goes out and checks for stdout updates.
// This interval is defined in the standard out log directive controller.
if (data.status === 'successful' || data.status === 'failed' || data.status === 'error' || data.status === 'canceled') {
@ -245,7 +209,6 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
$scope.toggleStdoutFullscreenTooltip = i18n._("Collapse Output");
} else if ($scope.stdoutFullScreen === false) {
$scope.toggleStdoutFullscreenTooltip = i18n._("Expand Output");
}
};