mirror of
https://github.com/ansible/awx.git
synced 2026-07-07 06:18:07 -02:30
Latest inventory detail page modifications.
This commit is contained in:
@@ -19,7 +19,7 @@ function GroupsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
|
||||
var list = GroupList;
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
var defaultUrl = GetBasePath('groups');
|
||||
var defaultUrl = GetBasePath('inventory') + $routeParams.inventory_id + '/groups/';
|
||||
var view = GenerateList;
|
||||
|
||||
var scope = view.inject(GroupList, { mode: 'select' }); // Inject our view
|
||||
@@ -29,6 +29,10 @@ function GroupsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
scope.PostRefreshRemove();
|
||||
}
|
||||
scope.PostRefresRemove = scope.$on('PostRefresh', function() {
|
||||
$("tr.success").each(function(index) {
|
||||
var ngc = $(this).attr('ng-class');
|
||||
scope[ngc] = "";
|
||||
});
|
||||
if ($routeParams.group_id) {
|
||||
// Remove the current group from the list of available groups, thus
|
||||
// preventing a group from being added to itself
|
||||
@@ -38,6 +42,7 @@ function GroupsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
}
|
||||
}
|
||||
}
|
||||
//scope.$digest();
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'groups', list: list, url: defaultUrl });
|
||||
|
||||
@@ -20,12 +20,11 @@ function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
var list = HostList
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
var base2 = $location.path().replace(/^\//,'').split('/')[2];
|
||||
var defaultUrl = GetBasePath('hosts');
|
||||
var defaultUrl = GetBasePath('inventory') + $routeParams.inventory_id + '/hosts/';
|
||||
var view = GenerateList;
|
||||
var mode = (base == 'hosts' || base2 == 'hosts') ? 'edit' : 'select';
|
||||
var scope = view.inject(list, { mode: mode }); // Inject our view
|
||||
scope.selected = [];
|
||||
|
||||
scope['inventory_id'] = $routeParams.inventory_id;
|
||||
|
||||
if (base == 'hosts' || base2 == 'hosts') {
|
||||
@@ -34,7 +33,17 @@ function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
else {
|
||||
scope['showAddButton'] = true;
|
||||
}
|
||||
|
||||
|
||||
// if (scope.PostRefreshRemove) {
|
||||
// scope.PostRefreshRemove();
|
||||
// }
|
||||
// scope.PostRefresRemove = scope.$on('PostRefresh', function() {
|
||||
// $("tr.success").each(function(index) {
|
||||
// var ngc = $(this).attr('ng-class');
|
||||
// scope[ngc] = "";
|
||||
// });
|
||||
// });
|
||||
|
||||
SearchInit({ scope: scope, set: 'hosts', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
scope.search(list.iterator);
|
||||
|
||||
@@ -226,7 +226,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
scope.inventoryLoadedRemove();
|
||||
}
|
||||
scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() {
|
||||
scope.groupName = 'All Hosts';
|
||||
scope.groupTitle = 'All Hosts';
|
||||
scope.createButtonShow = false;
|
||||
scope.search(relatedSets['hosts'].iterator);
|
||||
});
|
||||
@@ -342,44 +342,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
scope.treeController = function($node) {
|
||||
var nodeType = $($node).attr('type');
|
||||
if (nodeType == 'host') {
|
||||
return {
|
||||
edit: {
|
||||
label: 'Edit Host',
|
||||
action: function(obj) { changePath($location.path() + '/hosts/' + $(obj).attr('id')); }
|
||||
},
|
||||
delete: {
|
||||
label: 'Delete Host',
|
||||
action: function(obj) {
|
||||
var action_to_take = function() {
|
||||
var url = defaultUrl + $routeParams.id + '/hosts/';
|
||||
Rest.setUrl(url);
|
||||
Rest.post({ id: $(obj).attr('id'), disassociate: 1 })
|
||||
.success( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
$('#tree-view').jstree("delete_node",obj);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
//Force binds to work. Not working usual way.
|
||||
$('#prompt-header').text('Delete');
|
||||
$('#prompt-body').text('Are you sure you want to delete host ' + $(obj).attr('name') + '?');
|
||||
$('#prompt-action-btn').addClass('btn-danger');
|
||||
scope.promptAction = action_to_take; // for some reason this binds?
|
||||
$('#prompt-modal').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: true,
|
||||
show: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nodeType == 'inventory') {
|
||||
if (nodeType == 'inventory') {
|
||||
return {
|
||||
addGroup: {
|
||||
label: 'Add Group',
|
||||
@@ -392,22 +355,22 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
addGroup: {
|
||||
label: 'Add Subgroup',
|
||||
action: function(obj) {
|
||||
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
||||
changePath($location.path() + '/groups/' + $(obj).attr('id') + '/children');
|
||||
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('group_id'), title: $(obj).attr('name') });
|
||||
changePath($location.path() + '/groups/' + $(obj).attr('group_id') + '/children');
|
||||
},
|
||||
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||
},
|
||||
// addHost: {
|
||||
// label: 'Add Host',
|
||||
// action: function(obj) {
|
||||
// LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('id'), title: $(obj).attr('name') });
|
||||
// changePath($location.path() + '/groups/' + $(obj).attr('id') + '/hosts');
|
||||
// },
|
||||
// "_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||
// },
|
||||
addHost: {
|
||||
label: 'Add Host',
|
||||
action: function(obj) {
|
||||
LoadBreadCrumbs({ path: '/groups/' + $(obj).attr('group_id'), title: $(obj).attr('name') });
|
||||
changePath($location.path() + '/groups/' + $(obj).attr('group_id') + '/hosts');
|
||||
},
|
||||
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||
},
|
||||
edit: {
|
||||
label: 'Edit Group',
|
||||
action: function(obj) { changePath($location.path() + '/groups/' + $(obj).attr('id')); },
|
||||
action: function(obj) { changePath($location.path() + '/groups/' + $(obj).attr('group_id')); },
|
||||
separator_before: true,
|
||||
"_disabled": (nodeType == 'all-hosts-group') ? true : false
|
||||
},
|
||||
@@ -455,18 +418,22 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
if (type == 'group') {
|
||||
url = node.attr('all');
|
||||
scope.createButtonShow = true;
|
||||
scope.group_id = node.attr('id');
|
||||
scope.group_id = node.attr('group_id');
|
||||
scope.groupName = n.data;
|
||||
scope.groupTitle = 'Hosts: ' + n.data;
|
||||
scope.groupTitle += (node.attr('description')) ? ' -' + node.attr('description') : '';
|
||||
}
|
||||
else if (type == 'all-hosts-group') {
|
||||
url = node.attr('url');
|
||||
scope.createButtonShow = false;
|
||||
scope.groupName = 'All Hosts';
|
||||
scope.groupTitle = 'All Hosts';
|
||||
}
|
||||
else if (type == 'inventory-node') {
|
||||
url = node.attr('hosts');
|
||||
scope.createButtonShow = false;
|
||||
scope.groupName = 'All Hosts';
|
||||
scope.groupTitle = 'All Hosts';
|
||||
}
|
||||
relatedSets['hosts'] = { url: url, iterator: 'host' };
|
||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||
|
||||
Reference in New Issue
Block a user