mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Inventory hosts now appear in All Hosts folder. User not allowed to add hosts outside of a group (i.e. cannot add to All Hosts group). Fixed job template so that a credential can be removed.
This commit is contained in:
@@ -343,7 +343,8 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.treeController = function($node) {
|
scope.treeController = function($node) {
|
||||||
if ($($node).attr('type') == 'host') {
|
var nodeType = $($node).attr('type');
|
||||||
|
if (nodeType == 'host') {
|
||||||
return {
|
return {
|
||||||
edit: {
|
edit: {
|
||||||
label: 'Edit Host',
|
label: 'Edit Host',
|
||||||
@@ -386,7 +387,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($($node).attr('type') == 'inventory') {
|
else if (nodeType == 'inventory') {
|
||||||
return {
|
return {
|
||||||
addGroup: {
|
addGroup: {
|
||||||
label: 'Add Group',
|
label: 'Add Group',
|
||||||
@@ -411,19 +412,22 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
action: function(obj) {
|
action: function(obj) {
|
||||||
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
||||||
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/children');
|
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/children');
|
||||||
}
|
},
|
||||||
|
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||||
},
|
},
|
||||||
addHost: {
|
addHost: {
|
||||||
label: 'Add Host',
|
label: 'Add Host',
|
||||||
action: function(obj) {
|
action: function(obj) {
|
||||||
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
||||||
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/hosts');
|
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/hosts');
|
||||||
}
|
},
|
||||||
|
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||||
},
|
},
|
||||||
edit: {
|
edit: {
|
||||||
label: 'Edit Group',
|
label: 'Edit Group',
|
||||||
action: function(obj) { changePath($location.path() + '/groups/' + $(obj).attr('id')); },
|
action: function(obj) { changePath($location.path() + '/groups/' + $(obj).attr('id')); },
|
||||||
separator_before: true
|
separator_before: true,
|
||||||
|
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
label: 'Delete Group',
|
label: 'Delete Group',
|
||||||
@@ -454,7 +458,8 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
keyboard: true,
|
keyboard: true,
|
||||||
show: true
|
show: true
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||||
},
|
},
|
||||||
variables: {
|
variables: {
|
||||||
label: 'Group variables',
|
label: 'Group variables',
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
Rest.setUrl(defaultUrl + $routeParams.id);
|
Rest.setUrl(defaultUrl + $routeParams.id + '/');
|
||||||
var data = {}
|
var data = {}
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
|||||||
var postAction = params.postAction //action to perform post user selection
|
var postAction = params.postAction //action to perform post user selection
|
||||||
|
|
||||||
|
|
||||||
// Show pop-up to select user
|
// Show pop-up
|
||||||
var name = list.iterator.charAt(0).toUpperCase() + list.iterator.substring(1);
|
var name = list.iterator.charAt(0).toUpperCase() + list.iterator.substring(1);
|
||||||
var defaultUrl = (list.name == 'inventories') ? GetBasePath('inventory') : GetBasePath(list.name);
|
var defaultUrl = (list.name == 'inventories') ? GetBasePath('inventory') : GetBasePath(list.name);
|
||||||
var hdr = (params.hdr) ? params.hdr : 'Select ' + name;
|
var hdr = (params.hdr) ? params.hdr : 'Select ' + name;
|
||||||
|
|||||||
@@ -149,14 +149,14 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load inventory top-level hosts
|
// Load inventory all hosts
|
||||||
Rest.setUrl(hosts + '?order_by=name');
|
Rest.setUrl(hosts + '?order_by=name');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success ( function(data, status, headers, config) {
|
.success ( function(data, status, headers, config) {
|
||||||
treeData = [];
|
treeData = [];
|
||||||
treeData.push({
|
treeData.push({
|
||||||
data: {
|
data: {
|
||||||
title: inventory_name,
|
title: inventory_name
|
||||||
},
|
},
|
||||||
attr: {
|
attr: {
|
||||||
type: 'inventory',
|
type: 'inventory',
|
||||||
@@ -168,8 +168,22 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
|||||||
state: 'open',
|
state: 'open',
|
||||||
children:[]
|
children:[]
|
||||||
});
|
});
|
||||||
|
//treeData[0].children.push({
|
||||||
|
var all_hosts_node = {
|
||||||
|
data: {
|
||||||
|
title: 'All Hosts'
|
||||||
|
},
|
||||||
|
attr: {
|
||||||
|
type: 'all-hosts-group',
|
||||||
|
id: 'all-hosts-group',
|
||||||
|
url: hosts + '?order_by=name',
|
||||||
|
name: 'All Hosts'
|
||||||
|
},
|
||||||
|
state: 'closed',
|
||||||
|
children: []
|
||||||
|
};
|
||||||
for (var i=0; i < data.results.length; i++ ) {
|
for (var i=0; i < data.results.length; i++ ) {
|
||||||
treeData[0].children.push({
|
all_hosts_node.children.push({
|
||||||
data: {
|
data: {
|
||||||
title: data.results[i].name,
|
title: data.results[i].name,
|
||||||
icon: '/'
|
icon: '/'
|
||||||
@@ -186,6 +200,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
treeData[0].children.push(all_hosts_node);
|
||||||
scope.$emit('hostsLoaded');
|
scope.$emit('hostsLoaded');
|
||||||
})
|
})
|
||||||
.error ( function(data, status, headers, config) {
|
.error ( function(data, status, headers, config) {
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ angular.module('JobsListDefinition', [])
|
|||||||
desc: true,
|
desc: true,
|
||||||
searchType: 'int'
|
searchType: 'int'
|
||||||
},
|
},
|
||||||
created: {
|
|
||||||
label: 'Creation Date',
|
|
||||||
link: true
|
|
||||||
},
|
|
||||||
name: {
|
name: {
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
link: true,
|
link: true,
|
||||||
},
|
},
|
||||||
|
created: {
|
||||||
|
label: 'Creation Date',
|
||||||
|
link: true
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
label: 'Status',
|
label: 'Status',
|
||||||
icon: 'icon-circle',
|
icon: 'icon-circle',
|
||||||
|
|||||||
@@ -101,25 +101,32 @@ angular.module('AWDirectives', ['RestServices'])
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift( function(viewValue) {
|
ctrl.$parsers.unshift( function(viewValue) {
|
||||||
url = elm.attr('data-url');
|
if (viewValue !== '') {
|
||||||
url = url.replace(/\:value/,escape(viewValue));
|
url = elm.attr('data-url');
|
||||||
scope[elm.attr('data-source')] = null;
|
url = url.replace(/\:value/,escape(viewValue));
|
||||||
Rest.setUrl(url);
|
scope[elm.attr('data-source')] = null;
|
||||||
Rest.get().then( function(data) {
|
Rest.setUrl(url);
|
||||||
var results = data.data.results;
|
Rest.get().then( function(data) {
|
||||||
if (results.length > 0) {
|
var results = data.data.results;
|
||||||
scope[elm.attr('data-source')] = results[0].id;
|
if (results.length > 0) {
|
||||||
scope[elm.attr('name')] = results[0].name;
|
scope[elm.attr('data-source')] = results[0].id;
|
||||||
ctrl.$setValidity('required', true);
|
scope[elm.attr('name')] = results[0].name;
|
||||||
ctrl.$setValidity('awlookup', true);
|
ctrl.$setValidity('required', true);
|
||||||
return viewValue;
|
ctrl.$setValidity('awlookup', true);
|
||||||
}
|
return viewValue;
|
||||||
else {
|
}
|
||||||
ctrl.$setValidity('required', true);
|
else {
|
||||||
ctrl.$setValidity('awlookup', false);
|
ctrl.$setValidity('required', true);
|
||||||
return undefined;
|
ctrl.$setValidity('awlookup', false);
|
||||||
}
|
return undefined;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ctrl.$setValidity('awlookup', true);
|
||||||
|
scope[elm.attr('data-source')] = null;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user