AC-503 cloud inventory- first attempt at summary information on Inventory-> Groups page. Fixed compilation bugs.

This commit is contained in:
chouseknecht
2013-10-02 02:08:04 -04:00
parent 32d3914270
commit 77e79d9917
10 changed files with 176 additions and 56 deletions

View File

@@ -32,6 +32,7 @@ angular.module('ansible', [
'InventoryHelper',
'InventoryHostsFormDefinition',
'InventoryGroupsFormDefinition',
'InventorySummaryDefinition',
'AWFilters',
'HostFormDefinition',
'HostListDefinition',

View File

@@ -10,7 +10,7 @@
function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryGroupsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt,
TreeInit, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory,
GroupsDelete, RefreshGroupName, EditInventory, SetShowGroupHelp)
GroupsDelete, RefreshGroupName, EditInventory, SetShowGroupHelp, InventoryStatus)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@@ -155,7 +155,6 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP
$('input:first').focus();
}
else if (type == 'inventory') {
$('#tree-form').hide().empty();
url = node.attr('hosts');
scope.groupAddHide = true;
scope.groupCreateHide = false;
@@ -164,6 +163,8 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP
scope.groupDeleteHide = true;
scope.createButtonShow = false;
scope.group_id = null;
InventoryStatus();
$('#tree-form').show();
}
if (!scope.$$phase) {
@@ -221,6 +222,6 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP
InventoryGroups.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryGroupsForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt',
'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory',
'GroupsDelete', 'RefreshGroupName', 'EditInventory', 'SetShowGroupHelp'
'GroupsDelete', 'RefreshGroupName', 'EditInventory', 'SetShowGroupHelp', 'InventoryStatus'
];

View File

@@ -91,7 +91,7 @@ function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $route
// Save
scope.formSave = function() {
form.clearApiErrors();s
form.clearApiErrors();
var url = GetBasePath(base);
url += (base != 'organizations') ? $routeParams['project_id'] + '/organizations/' : '';
Rest.setUrl(url);

View File

@@ -232,7 +232,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}
}])
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshGroupName', 'ParseTypeChange', 'getSourceTypeOptions',
function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
@@ -488,6 +487,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
{ hdr: 'Error!', msg: 'Failed to update group varaibles. PUT status: ' + status });
});
}
RefreshGroupName(scope['selectedNode'], data.name, data.description);
scope.$emit('formSaveSuccess', data.id);
})
.error( function(data, status, headers, config) {

View File

@@ -11,7 +11,7 @@
angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationListDefinition',
'SearchHelper', 'PaginateHelper', 'ListGenerator', 'AuthService',
'InventoryHelper', 'RelatedSearchHelper', 'RelatedPaginateHelper',
'InventoryFormDefinition', 'ParseHelper'
'InventoryFormDefinition', 'ParseHelper', 'InventorySummaryDefinition'
])
.factory('LoadTreeData', ['Alert', 'Rest', 'Authorization', '$http', 'Wait', 'SortNodes',
@@ -160,6 +160,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
$(tree_id).bind("loaded.jstree", function () {
scope['treeLoading'] = false;
Wait('stop');
$(tree_id).prepend('<div class=\"title\"><i class=\"icon-sitemap\"></i> Group Selector</div>');
scope.$emit('treeLoaded');
});
@@ -666,5 +667,65 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
}
return newData;
}
}])
.factory('InventoryStatus', [ 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventorySummary', 'GenerateList',
function(Rest, Aler, ProcessErrors, GetBasePath, FormatDate, InventorySummary, GenerateList) {
return function(params) {
//Build a summary of a given inventory
$('#tree-form').hide().empty();
var view = GenerateList;
var scope = view.inject(InventorySummary, { mode: 'summary', id: 'tree-form', breadCrumbs: false });
scope['groups'] = [];
function checkSource(url) {
Rest.setUrl(url);
Rest.get()
.success( function(data, status, headers, config) {
//console.log(data);
var last_update = (data.last_updated == null) ? 'n/a' : FormatDate(new Date(data.last_updated));
var source = 'Manual';
switch(data.source) {
case 'file':
source = 'File';
break;
case 'ec2':
source = 'Amazon EC2';
break;
case 'rackspace':
source = 'Rackspace';
break;
}
scope['groups'].push({
name: data.summary_fields.group.name,
description: data.summary_fields.group.description,
failures: data.summary_fields.group.hosts_with_active_failures,
source: source,
last_update: last_update,
status: data.status
});
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
});
}
var url = GetBasePath('inventory') + scope['inventory_id'] + '/groups/';
Rest.setUrl(url);
Rest.get()
.success( function(data, status, headers, config) {
for (var i=0; i < data.results.length; i++) {
if (data.results[i].related.inventory_source) {
checkSource(data.results[i].related.inventory_source);
}
}
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
});
}
}]);

View File

@@ -0,0 +1,44 @@
/*********************************************
* Copyright (c) 2013 AnsibleWorks, Inc.
*
* InventorySummary.js
*
* Summary of groups contained within an inventory
*
*/
angular.module('InventorySummaryDefinition', [])
.value(
'InventorySummary', {
name: 'groups',
iterator: 'group',
editTitle: 'Inventory Summary',
index: false,
hover: true,
fields: {
name: {
key: true,
label: 'Name'
},
failures: {
label: 'Hosts Failures'
},
source: {
label: 'Source'
},
last_update: {
label: 'Last Update'
},
status: {
label: 'Update Status'
}
},
actions: {
},
fieldActions: {
}
});