mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 08:57:33 -02:30
AC-378 applied new sort routine to inventory groups page.
This commit is contained in:
@@ -39,6 +39,8 @@ angular.module('InventoryHostsFormDefinition', [])
|
|||||||
"class": "btn-sm",
|
"class": "btn-sm",
|
||||||
//ngDisabled: 'host.last_job == null',
|
//ngDisabled: 'host.last_job == null',
|
||||||
options: [
|
options: [
|
||||||
|
{ ngClick: 'allJobs()', label: 'All jobs', ngShow: 'host.last_job' },
|
||||||
|
{ ngClick: 'allSummaries()', label: 'All host summaries', ngShow: 'host.last_job' },
|
||||||
{ ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' },
|
{ ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' },
|
||||||
{ ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " +
|
{ ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " +
|
||||||
"'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events', ngShow: 'host.last_job' },
|
"'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events', ngShow: 'host.last_job' },
|
||||||
|
|||||||
@@ -281,15 +281,15 @@ angular.module('JobFormDefinition', [])
|
|||||||
label: 'Refresh',
|
label: 'Refresh',
|
||||||
icon: 'icon-refresh',
|
icon: 'icon-refresh',
|
||||||
ngClick: "refresh()",
|
ngClick: "refresh()",
|
||||||
"class": 'btn-small btn-success',
|
"class": 'btn-sm btn-success',
|
||||||
awToolTip: 'Refresh job status & output',
|
awToolTip: 'Refresh job status & output',
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
label: 'Hosts',
|
label: 'Hosts',
|
||||||
icon: 'icon-th-large',
|
icon: 'icon-laptop',
|
||||||
ngClick: "jobSummary()",
|
ngClick: "jobSummary()",
|
||||||
"class": 'btn btn-default btn-small',
|
"class": 'btn btn-default btn-sm',
|
||||||
awToolTip: 'View host summary',
|
awToolTip: 'View host summary',
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
},
|
},
|
||||||
@@ -297,7 +297,7 @@ angular.module('JobFormDefinition', [])
|
|||||||
label: 'Events',
|
label: 'Events',
|
||||||
icon: 'icon-list-ul',
|
icon: 'icon-list-ul',
|
||||||
ngClick: "jobEvents()",
|
ngClick: "jobEvents()",
|
||||||
"class": 'btn btn-default btn-small',
|
"class": 'btn btn-default btn-sm',
|
||||||
awToolTip: 'Edit job events',
|
awToolTip: 'Edit job events',
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,20 +468,39 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
var inventory_id = params.inventory_id;
|
var inventory_id = params.inventory_id;
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
|
function sortNodes(data) {
|
||||||
|
//Sort nodes by name
|
||||||
|
var names = [];
|
||||||
|
var newData = [];
|
||||||
|
for (var i=0; i < data.length; i++) {
|
||||||
|
names.push(data[i].name);
|
||||||
|
}
|
||||||
|
names.sort();
|
||||||
|
for (var j=0; j < names.length; j++) {
|
||||||
|
for (i=0; i < data.length; i++) {
|
||||||
|
if (data[i].name == names[j]) {
|
||||||
|
newData.push(data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newData;
|
||||||
|
}
|
||||||
|
|
||||||
function buildHTML(tree_data) {
|
function buildHTML(tree_data) {
|
||||||
html += (tree_data.length > 0) ? "<ul>\n" : "";
|
var sorted = sortNodes(tree_data);
|
||||||
for(var i=0; i < tree_data.length; i++) {
|
html += (sorted.length > 0) ? "<ul>\n" : "";
|
||||||
html += "<li id=\"search-node-1000\" data-state=\"opened\" data-hosts=\"" + tree_data[i].related.hosts + "\" " +
|
for(var i=0; i < sorted.length; i++) {
|
||||||
"data-description=\"" + tree_data[i].description + "\" " +
|
html += "<li id=\"search-node-1000\" data-state=\"opened\" data-hosts=\"" + sorted[i].related.hosts + "\" " +
|
||||||
"data-failures=\"" + tree_data[i].has_active_failures + "\" " +
|
"data-description=\"" + sorted[i].description + "\" " +
|
||||||
"data-groups=\"" + tree_data[i].related.groups + "\" " +
|
"data-failures=\"" + sorted[i].has_active_failures + "\" " +
|
||||||
"data-name=\"" + tree_data[i].name + "\" " +
|
"data-groups=\"" + sorted[i].related.groups + "\" " +
|
||||||
"data-group-id=\"" + tree_data[i].id + "\" " +
|
"data-name=\"" + sorted[i].name + "\" " +
|
||||||
|
"data-group-id=\"" + sorted[i].id + "\" " +
|
||||||
"><a href=\"\" class=\"expand\"><i class=\"icon-caret-down\"></i></a> " +
|
"><a href=\"\" class=\"expand\"><i class=\"icon-caret-down\"></i></a> " +
|
||||||
"<i class=\"field-badge icon-failures-" + tree_data[i].has_active_failures + "\"></i> " +
|
"<i class=\"field-badge icon-failures-" + sorted[i].has_active_failures + "\"></i> " +
|
||||||
"<a href=\"\" class=\"activate\">" + tree_data[i].name + "</a> ";
|
"<a href=\"\" class=\"activate\">" + sorted[i].name + "</a> ";
|
||||||
if (tree_data[i].children.length > 0) {
|
if (sorted[i].children.length > 0) {
|
||||||
buildHTML(tree_data[i].children);
|
buildHTML(sorted[i].children);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
html += "</li>\n";
|
html += "</li>\n";
|
||||||
@@ -609,6 +628,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
if (scope.buildGroupListRemove) {
|
if (scope.buildGroupListRemove) {
|
||||||
scope.buildGroupListRemove();
|
scope.buildGroupListRemove();
|
||||||
}
|
}
|
||||||
@@ -617,18 +637,21 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
Rest.setUrl(groups_url);
|
Rest.setUrl(groups_url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
|
var groups = [];
|
||||||
for (var i=0; i < data.results.length; i++) {
|
for (var i=0; i < data.results.length; i++) {
|
||||||
scope.inventory_groups.push({
|
groups.push({
|
||||||
id: data.results[i].id,
|
id: data.results[i].id,
|
||||||
description: data.results[i].description,
|
description: data.results[i].description,
|
||||||
name: data.results[i].name });
|
name: data.results[i].name });
|
||||||
}
|
}
|
||||||
|
scope.inventory_groups = sortNodes(groups);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to get groups for inventory: ' + inventory_id + '. GET returned: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to get groups for inventory: ' + inventory_id + '. GET returned: ' + status });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ angular.module('JobEventsListDefinition', [])
|
|||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
label: 'Hosts',
|
label: 'Hosts',
|
||||||
icon: 'icon-th-large',
|
icon: 'icon-laptop',
|
||||||
ngClick: "jobSummary()",
|
ngClick: "jobSummary()",
|
||||||
"class": 'btn btn-default btn-sm',
|
"class": 'btn btn-default btn-sm',
|
||||||
awToolTip: 'View host summary',
|
awToolTip: 'View host summary',
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ angular.module('JobsListDefinition', [])
|
|||||||
fieldActions: {
|
fieldActions: {
|
||||||
summary: {
|
summary: {
|
||||||
label: 'Hosts',
|
label: 'Hosts',
|
||||||
icon: 'icon-th-large',
|
icon: 'icon-laptop',
|
||||||
ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.name \}\}')",
|
ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.name \}\}')",
|
||||||
"class": 'btn btn-default btn-xs',
|
"class": 'btn btn-default btn-xs',
|
||||||
awToolTip: 'View host summary',
|
awToolTip: 'View host summary',
|
||||||
|
|||||||
Reference in New Issue
Block a user