mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 22:05:07 -02:30
Merge pull request #160 from jlmitch5/linkOutInvSrcStdout
fix link out to inventory source on standard out page
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
return function(params) {
|
return function(params) {
|
||||||
var url = params.url,
|
var url = params.url,
|
||||||
scope_var = params.scope_var,
|
scope_var = params.scope_var,
|
||||||
scope = params.scope;
|
scope = params.scope,
|
||||||
|
callback = params.callback;
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
@@ -19,6 +20,10 @@
|
|||||||
if (!Empty(data.name)) {
|
if (!Empty(data.name)) {
|
||||||
scope[scope_var + '_name'] = data.name;
|
scope[scope_var + '_name'] = data.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
scope.$emit(callback, data);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
if (status === 403 && params.ignore_403) {
|
if (status === 403 && params.ignore_403) {
|
||||||
|
|||||||
@@ -83,6 +83,10 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
|
|||||||
$scope.variables = ParseVariableString(data.extra_vars);
|
$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 we have a source then we have to go get the source choices from the server
|
||||||
if (!Empty(data.source)) {
|
if (!Empty(data.source)) {
|
||||||
if ($scope.removeChoicesReady) {
|
if ($scope.removeChoicesReady) {
|
||||||
@@ -152,7 +156,8 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
|
|||||||
LookUpName({
|
LookUpName({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
scope_var: 'inventory_source',
|
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.
|
// 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.
|
// This interval is defined in the standard out log directive controller.
|
||||||
if (data.status === 'successful' || data.status === 'failed' || data.status === 'error' || data.status === 'canceled') {
|
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");
|
$scope.toggleStdoutFullscreenTooltip = i18n._("Collapse Output");
|
||||||
} else if ($scope.stdoutFullScreen === false) {
|
} else if ($scope.stdoutFullScreen === false) {
|
||||||
$scope.toggleStdoutFullscreenTooltip = i18n._("Expand Output");
|
$scope.toggleStdoutFullscreenTooltip = i18n._("Expand Output");
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user