mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Merge pull request #6174 from jaredevantabor/source-notifications
Source notifications
This commit is contained in:
commit
6a5102d51d
@ -21,7 +21,7 @@ export default
|
||||
sourcesAdd.name,
|
||||
sourcesEdit.name
|
||||
])
|
||||
.value('SourcesFormDefinition', sourcesFormDefinition)
|
||||
.factory('SourcesFormDefinition', sourcesFormDefinition)
|
||||
.value('SourcesListDefinition', sourcesListDefinition)
|
||||
.factory('GetSyncStatusMsg', GetSyncStatusMsg)
|
||||
.factory('ViewUpdateStatus', ViewUpdateStatus)
|
||||
|
||||
@ -10,7 +10,25 @@
|
||||
* @description This form is for adding/editing a Group on the inventory page
|
||||
*/
|
||||
|
||||
export default {
|
||||
export default ['NotificationsList', 'i18n', function(NotificationsList, i18n){
|
||||
|
||||
var notifications_object = {
|
||||
name: 'notifications',
|
||||
index: false,
|
||||
basePath: "notifications",
|
||||
include: "NotificationsList",
|
||||
title: i18n._('Notifications'),
|
||||
iterator: 'notification',
|
||||
disabled: "source === undefined || source.value === ''",
|
||||
generateList: true,
|
||||
ngClick: "$state.go('inventories.edit.inventory_sources.edit.notifications')"
|
||||
// search: {
|
||||
// "or__job__inventory": ''
|
||||
// }
|
||||
};
|
||||
let clone = _.clone(NotificationsList);
|
||||
notifications_object = angular.extend(clone, notifications_object);
|
||||
return {
|
||||
addTitle: 'CREATE SOURCE',
|
||||
editTitle: '{{ name }}',
|
||||
showTitle: true,
|
||||
@ -19,9 +37,10 @@ export default {
|
||||
parent: 'inventories.edit.sources',
|
||||
// the parent node this generated state definition tree expects to attach to
|
||||
stateTree: 'inventories',
|
||||
tabs: true,
|
||||
// form generator inspects the current state name to determine whether or not to set an active (.is-selected) class on a form tab
|
||||
// this setting is optional on most forms, except where the form's edit state name is not parentStateName.edit
|
||||
activeEditState: 'inventories.edit.groups.editGroup',
|
||||
activeEditState: 'inventories.edit.inventory_sources.edit',
|
||||
detailsClick: "$state.go('inventories.edit.inventory_sources.edit')",
|
||||
well: false,
|
||||
fields: {
|
||||
@ -333,5 +352,11 @@ export default {
|
||||
ngDisabled: true,
|
||||
ngShow: '(group_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
}
|
||||
},
|
||||
|
||||
related: {
|
||||
notifications: notifications_object
|
||||
}
|
||||
};
|
||||
|
||||
}];
|
||||
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
name: {
|
||||
label: 'Sources',
|
||||
key: true,
|
||||
ngClick: "groupSelect(inventory_source.id)",
|
||||
ngClick: "editSource(inventory_source.id)",
|
||||
columnClass: 'col-lg-6 col-md-6 col-sm-6 col-xs-6',
|
||||
class: 'InventoryManage-breakWord',
|
||||
}
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
|
||||
'$state', '$rootScope',
|
||||
function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices, $state, $rootScope) {
|
||||
'$state', '$rootScope', '$stateParams',
|
||||
function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices, $state, $rootScope, $stateParams) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
url = params.url,
|
||||
@ -31,8 +31,22 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
|
||||
});
|
||||
|
||||
scope.addNotificationTemplate = function() {
|
||||
if (id) {
|
||||
$state.go('notifications.add', {organization_id: id});
|
||||
var org_id;
|
||||
if($stateParams.hasOwnProperty('project_id')){
|
||||
org_id = scope.$parent.project_obj.organization;
|
||||
}
|
||||
else if($stateParams.hasOwnProperty('workflow_job_template_id')){
|
||||
org_id = scope.$parent.workflow_job_template_obj.organization;
|
||||
}
|
||||
else if($stateParams.hasOwnProperty('inventory_source_id')){
|
||||
org_id = scope.$parent.summary_fields.inventory.organization_id;
|
||||
}
|
||||
else if($stateParams.hasOwnProperty('organization_id')){
|
||||
org_id = scope.$parent.organization_id;
|
||||
}
|
||||
|
||||
if (org_id) {
|
||||
$state.go('notifications.add', {organization_id: org_id});
|
||||
}
|
||||
else {
|
||||
$state.go('notifications.add');
|
||||
|
||||
@ -407,17 +407,24 @@ function($injector, $stateExtender, $log, i18n) {
|
||||
},
|
||||
views: {
|
||||
'related': {
|
||||
templateProvider: function(FormDefinition, GenerateForm) {
|
||||
let html = GenerateForm.buildCollection({
|
||||
templateProvider: function(FormDefinition, GenerateForm, $stateParams, SourcesFormDefinition) {
|
||||
var form, html;
|
||||
if($stateParams && $stateParams.inventory_source_id){
|
||||
form = SourcesFormDefinition;
|
||||
}
|
||||
else {
|
||||
form = typeof(FormDefinition) === 'function' ?
|
||||
FormDefinition() : FormDefinition;
|
||||
}
|
||||
html = GenerateForm.buildCollection({
|
||||
mode: 'edit',
|
||||
related: `${list.iterator}s`,
|
||||
form: typeof(FormDefinition) === 'function' ?
|
||||
FormDefinition() : FormDefinition
|
||||
form: form
|
||||
});
|
||||
return html;
|
||||
},
|
||||
controller: ['$scope', 'ListDefinition', 'Dataset', 'ToggleNotification', 'NotificationsListInit', 'GetBasePath', '$stateParams', 'inventorySourceData',
|
||||
function($scope, list, Dataset, ToggleNotification, NotificationsListInit, GetBasePath, $stateParams, inventorySourceData) {
|
||||
controller: ['$scope', 'ListDefinition', 'Dataset', 'ToggleNotification', 'NotificationsListInit', 'GetBasePath', '$stateParams',
|
||||
function($scope, list, Dataset, ToggleNotification, NotificationsListInit, GetBasePath, $stateParams) {
|
||||
var url , params = $stateParams, id;
|
||||
if(params.hasOwnProperty('project_id')){
|
||||
id = params.project_id;
|
||||
@ -431,8 +438,8 @@ function($injector, $stateExtender, $log, i18n) {
|
||||
id = params.workflow_job_template_id;
|
||||
url = GetBasePath('workflow_job_templates');
|
||||
}
|
||||
if(params.hasOwnProperty('inventory_id')){
|
||||
id = inventorySourceData.id;
|
||||
if(params.hasOwnProperty('inventory_source_id')){
|
||||
id = params.inventory_source_id;
|
||||
url = GetBasePath('inventory_sources');
|
||||
}
|
||||
if(params.hasOwnProperty('organization_id')){
|
||||
@ -484,15 +491,6 @@ function($injector, $stateExtender, $log, i18n) {
|
||||
ListDefinition: () => {
|
||||
return list;
|
||||
},
|
||||
inventorySourceData: ['$stateParams', //'GroupManageService',
|
||||
function($stateParams){ //, GroupManageService) {
|
||||
if($stateParams.hasOwnProperty('group_id')){
|
||||
return; //GroupManageService.getInventorySource({ group: $stateParams.group_id }).then(res => res.data.results[0]);
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
}],
|
||||
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope',
|
||||
(list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => {
|
||||
// allow related list definitions to use interpolated $rootScope / $stateParams in basePath field
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user