mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Merge pull request #2639 from ansible/enhancement-inv_summary
Update UJT with inv summary field and update schedule base route to include object to be scheduled
Reviewed-by: Chris Meyers
https://github.com/chrismeyersfsu
This commit is contained in:
@@ -4629,6 +4629,23 @@ class ScheduleSerializer(LaunchConfigurationBaseSerializer, SchedulePreviewSeria
|
|||||||
res['inventory'] = obj.unified_job_template.inventory.get_absolute_url(self.context.get('request'))
|
res['inventory'] = obj.unified_job_template.inventory.get_absolute_url(self.context.get('request'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_summary_fields(self, obj):
|
||||||
|
summary_fields = super(ScheduleSerializer, self).get_summary_fields(obj)
|
||||||
|
if 'inventory' in summary_fields:
|
||||||
|
return summary_fields
|
||||||
|
|
||||||
|
inventory = None
|
||||||
|
if obj.unified_job_template and getattr(obj.unified_job_template, 'inventory', None):
|
||||||
|
inventory = obj.unified_job_template.inventory
|
||||||
|
else:
|
||||||
|
return summary_fields
|
||||||
|
|
||||||
|
summary_fields['inventory'] = dict()
|
||||||
|
for field in SUMMARIZABLE_FK_FIELDS['inventory']:
|
||||||
|
summary_fields['inventory'][field] = getattr(inventory, field, None)
|
||||||
|
|
||||||
|
return summary_fields
|
||||||
|
|
||||||
def validate_unified_job_template(self, value):
|
def validate_unified_job_template(self, value):
|
||||||
if type(value) == InventorySource and value.source not in SCHEDULEABLE_PROVIDERS:
|
if type(value) == InventorySource and value.source not in SCHEDULEABLE_PROVIDERS:
|
||||||
raise serializers.ValidationError(_('Inventory Source must be a cloud resource.'))
|
raise serializers.ValidationError(_('Inventory Source must be a cloud resource.'))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default ['i18n', function(i18n) {
|
|||||||
sourceModel: 'unified_job_template',
|
sourceModel: 'unified_job_template',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
// ngBind: 'schedule.summary_fields.unified_job_template.name',
|
// ngBind: 'schedule.summary_fields.unified_job_template.name',
|
||||||
ngClick: "editSchedule(schedule)",
|
uiSref: "{{schedule.linkToDetails}}",
|
||||||
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
||||||
dataTipWatch: 'schedule.nameTip',
|
dataTipWatch: 'schedule.nameTip',
|
||||||
dataPlacement: "top",
|
dataPlacement: "top",
|
||||||
|
|||||||
@@ -101,18 +101,30 @@ export default [
|
|||||||
}
|
}
|
||||||
buildTooltips(itm);
|
buildTooltips(itm);
|
||||||
|
|
||||||
if (!$state.is('schedules')){
|
let stateParams = { schedule_id: item.id };
|
||||||
if($state.current.name.endsWith('.add')) {
|
let route = '';
|
||||||
itm.linkToDetails = `^.edit({schedule_id:schedule.id})`;
|
if (item.summary_fields.unified_job_template) {
|
||||||
}
|
if (item.summary_fields.unified_job_template.unified_job_type === 'job') {
|
||||||
else if($state.current.name.endsWith('.edit')) {
|
route = 'templates.editJobTemplate.schedules.edit';
|
||||||
itm.linkToDetails = `.({schedule_id:schedule.id})`;
|
stateParams.job_template_id = item.summary_fields.unified_job_template.id;
|
||||||
}
|
} else if (item.summary_fields.unified_job_template.unified_job_type === 'project_update') {
|
||||||
else {
|
route = 'projects.edit.schedules.edit';
|
||||||
itm.linkToDetails = `.edit({schedule_id:schedule.id})`;
|
stateParams.project_id = item.summary_fields.unified_job_template.id;
|
||||||
|
} else if (item.summary_fields.unified_job_template.unified_job_type === 'workflow_job') {
|
||||||
|
route = 'templates.editWorkflowJobTemplate.schedules.edit';
|
||||||
|
stateParams.workflow_job_template_id = item.summary_fields.unified_job_template.id;
|
||||||
|
} else if (item.summary_fields.unified_job_template.unified_job_type === 'inventory_update') {
|
||||||
|
route = 'inventories.edit.inventory_sources.edit.schedules.edit';
|
||||||
|
stateParams.inventory_id = item.summary_fields.inventory.id;
|
||||||
|
stateParams.inventory_source_id = item.summary_fields.unified_job_template.id;
|
||||||
|
} else if (item.summary_fields.unified_job_template.unified_job_type === 'system_job') {
|
||||||
|
route = 'managementJobsList.schedule';
|
||||||
|
stateParams.id = item.summary_fields.unified_job_template.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
itm.route = route;
|
||||||
|
itm.stateParams = stateParams;
|
||||||
|
itm.linkToDetails = `${route}(${JSON.stringify(stateParams)})`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,20 +169,7 @@ export default [
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.editSchedule = function(schedule) {
|
$scope.editSchedule = function(schedule) {
|
||||||
if ($state.is('schedules')){
|
$state.go(schedule.route, schedule.stateParams);
|
||||||
$state.go('schedules.edit', {schedule_id: schedule.id});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if($state.current.name.endsWith('.add')) {
|
|
||||||
$state.go('^.edit', { schedule_id: schedule.id });
|
|
||||||
}
|
|
||||||
else if($state.current.name.endsWith('.edit')) {
|
|
||||||
$state.go('.', { schedule_id: schedule.id });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$state.go('.edit', { schedule_id: schedule.id });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleSchedule = function(event, id) {
|
$scope.toggleSchedule = function(event, id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user