1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 18:21:12 +03:00

Lates UI changes

This commit is contained in:
chouseknecht 2013-09-03 08:38:10 -04:00
parent cde035f06d
commit 011545035d
2 changed files with 37 additions and 53 deletions

View File

@ -460,34 +460,16 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
}])
.factory('LoadSearchTree', ['Rest', 'GetBasePath', 'ProcessErrors', '$compile', '$rootScope', 'Wait',
function(Rest, GetBasePath, ProcessErrors, $compile, $rootScope, Wait) {
.factory('LoadSearchTree', ['Rest', 'GetBasePath', 'ProcessErrors', '$compile', '$rootScope', 'Wait', 'SortNodes',
function(Rest, GetBasePath, ProcessErrors, $compile, $rootScope, Wait, SortNodes) {
return function(params) {
var scope = params.scope;
var inventory_id = params.inventory_id;
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) {
var sorted = sortNodes(tree_data);
var sorted = SortNodes(tree_data);
html += (sorted.length > 0) ? "<ul>\n" : "";
for(var i=0; i < sorted.length; i++) {
html += "<li id=\"search-node-1000\" data-state=\"opened\" data-hosts=\"" + sorted[i].related.hosts + "\" " +

View File

@ -14,8 +14,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
'InventoryFormDefinition', 'ParseHelper'
])
.factory('LoadTreeData', ['Alert', 'Rest', 'Authorization', '$http', 'Wait',
function(Alert, Rest, Authorization, $http, Wait) {
.factory('LoadTreeData', ['Alert', 'Rest', 'Authorization', '$http', 'Wait', 'SortNodes',
function(Alert, Rest, Authorization, $http, Wait, SortNodes) {
return function(params) {
var scope = params.scope;
@ -48,26 +48,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
children:[]
}];
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 addNodes(tree, data) {
var sorted = sortNodes(data);
var sorted = SortNodes(data);
for (var i=0; i < sorted.length; i++) {
tree.children.push({
data: {
@ -96,17 +78,17 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
}
}
Rest.setUrl(scope.treeData);
Rest.get()
.success( function(data, status, headers, config) {
var sorted = sortNodes(data);
addNodes(treeData[0], sorted);
scope.$emit('buildTree', treeData, idx, group_idx);
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve inventory tree data. GET returned status: ' + status });
});
Rest.setUrl(scope.treeData);
Rest.get()
.success( function(data, status, headers, config) {
var sorted = SortNodes(data);
addNodes(treeData[0], sorted);
scope.$emit('buildTree', treeData, idx, group_idx);
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve inventory tree data. GET returned status: ' + status });
});
}
}])
@ -666,5 +648,25 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
{ hdr: 'Error!', msg: 'Failed to retrieve inventory groups. GET returned status: ' + status });
});
}
}])
.factory('SortNodes', [ function() {
return function(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;
}
}]);