mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
Navigate to Job Template/Workflow Job Template specific resource streams
This commit is contained in:
parent
ece5299a74
commit
2128d34d50
@ -12,7 +12,12 @@ export default ['templateUrl', 'i18n', function(templateUrl, i18n) {
|
||||
templateUrl: templateUrl('activity-stream/streamDropdownNav/stream-dropdown-nav'),
|
||||
controller: ['$scope', '$state', '$stateParams','CreateSelect2', function($scope, $state, $stateParams, CreateSelect2) {
|
||||
|
||||
$scope.streamTarget = ($state.params && $state.params.target) ? $state.params.target : 'dashboard';
|
||||
if($state.params && $state.params.target) {
|
||||
$scope.streamTarget = ($state.params.target === 'job_template' || $state.params.target === 'workflow_job_template') ? 'template' : $state.params.target;
|
||||
}
|
||||
else {
|
||||
$scope.streamTarget = 'dashboard';
|
||||
}
|
||||
|
||||
$scope.options = [
|
||||
{label: i18n._('All Activity'), value: 'dashboard'},
|
||||
@ -40,12 +45,14 @@ export default ['templateUrl', 'i18n', function(templateUrl, i18n) {
|
||||
$state.go('activityStream', {target: null, activity_search: {page_size:"20", order_by: '-timestamp'}});
|
||||
}
|
||||
else {
|
||||
let search = _.merge($stateParams.activity_search, {
|
||||
let search = {
|
||||
or__object1__in: $scope.streamTarget && $scope.streamTarget === 'template' ? 'job_template,workflow_job_template' : $scope.streamTarget,
|
||||
or__object2__in: $scope.streamTarget && $scope.streamTarget === 'template' ? 'job_template,workflow_job_template' : $scope.streamTarget
|
||||
});
|
||||
or__object2__in: $scope.streamTarget && $scope.streamTarget === 'template' ? 'job_template,workflow_job_template' : $scope.streamTarget,
|
||||
page_size: '20',
|
||||
order_by: '-timestamp'
|
||||
};
|
||||
// Attach the taget to the query parameters
|
||||
$state.go('activityStream', {target: $scope.streamTarget, activity_search: search});
|
||||
$state.go('activityStream', {target: $scope.streamTarget, id: null, activity_search: search});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -41,9 +41,10 @@ export default
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
if(streamConfig.activityStreamTarget) {
|
||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||
let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget);
|
||||
stateGoParams.activity_search = {
|
||||
or__object1__in: streamConfig.activityStreamTarget === 'template' ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
or__object2__in: streamConfig.activityStreamTarget === 'template' ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
order_by: '-timestamp',
|
||||
page_size: '20',
|
||||
};
|
||||
|
||||
@ -219,8 +219,8 @@ export default ['$injector', '$stateExtender', '$log', 'i18n', function($injecto
|
||||
};
|
||||
if (params.data && params.data.activityStreamTarget) {
|
||||
formNodeState.data = {};
|
||||
formNodeState.data.activityStreamId = params.data.activityStreamTarget + '_id';
|
||||
|
||||
formNodeState.data.activityStreamId = params.data.activityStreamId ? params.data.activityStreamId : params.data.activityStreamTarget + '_id';
|
||||
formNodeState.data.activityStreamTarget = params.data.activityStreamTarget;
|
||||
}
|
||||
formNode = $stateExtender.buildDefinition(formNodeState);
|
||||
|
||||
|
||||
@ -53,6 +53,11 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
form: 'JobTemplateForm',
|
||||
controllers: {
|
||||
edit: 'JobTemplateEdit'
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'job_template',
|
||||
activityStreamId: 'job_template_id'
|
||||
}
|
||||
});
|
||||
|
||||
@ -73,6 +78,11 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
form: 'WorkflowForm',
|
||||
controllers: {
|
||||
edit: 'WorkflowEdit'
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'workflow_job_template',
|
||||
activityStreamId: 'workflow_job_template_id'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -258,138 +258,16 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
|
||||
.factory('Stream', ['$rootScope', '$location', '$state', 'Rest', 'GetBasePath',
|
||||
'ProcessErrors', 'Wait', 'StreamList', 'generateList', 'FormatDate', 'BuildDescription',
|
||||
'ShowDetail', 'i18n',
|
||||
'ShowDetail',
|
||||
function ($rootScope, $location, $state, Rest, GetBasePath, ProcessErrors,
|
||||
Wait, StreamList, GenerateList, FormatDate,
|
||||
BuildDescription, ShowDetail, i18n) {
|
||||
BuildDescription, ShowDetail) {
|
||||
return function (params) {
|
||||
|
||||
var list = _.cloneDeep(StreamList),
|
||||
defaultUrl = GetBasePath('activity_stream'),
|
||||
scope = params.scope,
|
||||
url = (params && params.url) ? params.url : null;
|
||||
var scope = params.scope;
|
||||
|
||||
$rootScope.flashMessage = null;
|
||||
|
||||
if (url) {
|
||||
defaultUrl = url;
|
||||
} else {
|
||||
|
||||
if($state.params && $state.params.target) {
|
||||
if($state.params.id) {
|
||||
// We have a type and an ID
|
||||
defaultUrl += '?' + $state.params.target + '__id=' + $state.params.id;
|
||||
}
|
||||
else {
|
||||
// We just have a type
|
||||
if ($state.params.target === 'inventory_script') {
|
||||
defaultUrl += '?or__object1__in=custom_inventory_script&or__object2__in=custom_inventory_script';
|
||||
} else if ($state.params.target === 'management_job') {
|
||||
defaultUrl += '?or__object1__in=job&or__object2__in=job';
|
||||
} else if ($state.params.target === 'template') {
|
||||
defaultUrl += '?or__object1__in=job_template,workflow_job_template&or__object2__in=job_template,workflow_job_template';
|
||||
} else {
|
||||
defaultUrl += '?or__object1__in=' + $state.params.target + '&or__object2__in=' + $state.params.target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($state.params.target === 'credential') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Credential'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'credential',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'host') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Host'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'host',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'inventory') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Inventory'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'inventory',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'inventory_script') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Inventory Script'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'custom_inventory_script',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'job_template') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Job Template'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'job_template',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'job') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Job'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'job',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'organization') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Organization'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'organization',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'project') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Project'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'project',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'schedule') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Schedule'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'schedule',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'team') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('Team'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'team',
|
||||
sourceField: 'name'
|
||||
};
|
||||
} else if ($state.params.target === 'user') {
|
||||
list.fields.customSearchField = {
|
||||
label: i18n._('User'),
|
||||
searchType: 'text',
|
||||
searchOnly: 'true',
|
||||
sourceModel: 'user',
|
||||
sourceField: 'username'
|
||||
};
|
||||
}
|
||||
|
||||
list.basePath = defaultUrl;
|
||||
|
||||
// Generate the list
|
||||
//view.inject(list, { mode: 'edit', id: 'stream-content', searchSize: 'col-lg-4 col-md-4 col-sm-12 col-xs-12', secondWidget: true, activityStream: true, scope: scope });
|
||||
|
||||
// descriptive title describing what AS is showing
|
||||
scope.streamTitle = (params && params.title) ? params.title : null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user