mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
AC-503 inventory->groups summary screen now in sync with latest API changes.
This commit is contained in:
@@ -137,26 +137,30 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
var view = GenerateList;
|
var view = GenerateList;
|
||||||
var list = InventorySummary;
|
var list = InventorySummary;
|
||||||
var scope = view.inject(InventorySummary, { mode: 'summary', id: 'tree-form', breadCrumbs: false });
|
var scope = view.inject(InventorySummary, { mode: 'summary', id: 'tree-form', breadCrumbs: false });
|
||||||
var defaultUrl = GetBasePath('inventory') + scope['inventory_id'] + '/inventory_sources/?group__isnull=false';
|
var defaultUrl = GetBasePath('inventory') + scope['inventory_id'] + '/groups/';
|
||||||
|
//?group__isnull=false';
|
||||||
|
|
||||||
if (scope.PostRefreshRemove) {
|
if (scope.PostRefreshRemove) {
|
||||||
scope.PostRefreshRemove();
|
scope.PostRefreshRemove();
|
||||||
}
|
}
|
||||||
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||||
for (var i=0; i < scope.groups.length; i++) {
|
for (var i=0; i < scope.groups.length; i++) {
|
||||||
var last_update = (scope.groups[i].last_updated == null) ? '' : FormatDate(new Date(scope.groups[i].last_updated));
|
var last_update = null
|
||||||
var source = 'Manual';
|
//(scope.groups[i].last_updated == null) ? '' : FormatDate(new Date(scope.groups[i].last_updated));
|
||||||
|
|
||||||
var stat, stat_class, status_tip;
|
var stat, stat_class, status_tip;
|
||||||
|
|
||||||
stat = scope.groups[i].status;
|
stat = scope.groups[i].summary_fields.inventory_source.status;
|
||||||
stat_class = stat;
|
stat_class = stat;
|
||||||
switch (scope.groups[i].status) {
|
|
||||||
|
switch (scope.groups[i].summary_fields.inventory_source.status) {
|
||||||
case 'never updated':
|
case 'never updated':
|
||||||
stat = 'never';
|
stat = 'never';
|
||||||
stat_class = 'never';
|
stat_class = 'never';
|
||||||
status_tip = 'Inventory update has not been performed. Click Update button to start it now.';
|
status_tip = 'Inventory update has not been performed. Click Update button to start it now.';
|
||||||
break;
|
break;
|
||||||
case 'none':
|
case 'none':
|
||||||
|
case '':
|
||||||
stat = 'n/a';
|
stat = 'n/a';
|
||||||
stat_class = 'na';
|
stat_class = 'na';
|
||||||
status_tip = 'Not configured for inventory update.';
|
status_tip = 'Not configured for inventory update.';
|
||||||
@@ -172,26 +176,15 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (scope.groups[i].source) {
|
if (scope.groups[i].hosts_with_active_failures > 0) {
|
||||||
case 'ec2':
|
|
||||||
source = 'Amazon EC2';
|
|
||||||
break;
|
|
||||||
case 'rackspace':
|
|
||||||
source = 'Rackspace';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scope.groups[i].summary_fields.group.hosts_with_active_failures > 0) {
|
|
||||||
scope.groups[i].active_failures_params = "/?has_active_failures=true";
|
scope.groups[i].active_failures_params = "/?has_active_failures=true";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope.groups[i].active_failures_params = '';
|
scope.groups[i].active_failures_params = "/?has_active_failures=false";
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.groups[i].hosts_with_active_failures = scope.groups[i].summary_fields.group.hosts_with_active_failures;
|
|
||||||
scope.groups[i].has_active_failures = scope.groups[i].summary_fields.group.has_active_failures;
|
|
||||||
scope.groups[i].status = stat;
|
scope.groups[i].status = stat;
|
||||||
scope.groups[i].source = source;
|
scope.groups[i].source = scope.groups[i].summary_fields.inventory_source.source;
|
||||||
scope.groups[i].last_updated = last_update;
|
scope.groups[i].last_updated = last_update;
|
||||||
scope.groups[i].status_badge_class = stat_class;
|
scope.groups[i].status_badge_class = stat_class;
|
||||||
scope.groups[i].status_badge_tooltip = status_tip;
|
scope.groups[i].status_badge_tooltip = status_tip;
|
||||||
@@ -201,10 +194,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
SearchInit({ scope: scope, set: 'groups', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'groups', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
|
||||||
if ($routeParams['status']) {
|
if (scope['inventorySummaryGroup']) {
|
||||||
// with status param post update submit
|
scope[list.iterator + 'SearchField'] = 'name';
|
||||||
|
scope[list.iterator + 'SearchType'] = 'iexact';
|
||||||
|
scope[list.iterator + 'SearchValue'] = scope['inventorySummaryGroup'];
|
||||||
|
}
|
||||||
|
else if ($routeParams['status']) {
|
||||||
|
// with status param, called post update-submit
|
||||||
scope[list.iterator + 'SearchField'] = 'status';
|
scope[list.iterator + 'SearchField'] = 'status';
|
||||||
//scope[list.iterator + 'SearchType'] = 'icontains';
|
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['status'].searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields['status'].searchOptions;
|
||||||
for (var opt in list.fields['status'].searchOptions) {
|
for (var opt in list.fields['status'].searchOptions) {
|
||||||
@@ -217,7 +214,40 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
scope.ShowUpdateStatus = ShowUpdateStatus;
|
scope.viewUpdateStatus = function(id) {
|
||||||
|
var found = false;
|
||||||
|
var group;
|
||||||
|
for (var i=0; i < scope.groups.length; i++) {
|
||||||
|
if (scope.groups[i].id == id) {
|
||||||
|
found = true;
|
||||||
|
group = scope.groups[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
if (group.summary_fields.inventory_source.source == "" || group.summary_fields.inventory_source.source == null) {
|
||||||
|
Alert('Missing Configuration', 'The selected group is not configured for inventory updates. ' +
|
||||||
|
'You must first edit the group, provide Source settings, and then run an update.', 'alert-info');
|
||||||
|
}
|
||||||
|
else if (group.summary_fields.inventory_source.status == "" || group.summary_fields.inventory_source.status == null ||
|
||||||
|
group.summary_fields.inventory_source.status == "never updated") {
|
||||||
|
Alert('No Status Available', 'The inventory update process has not run for the selected group. Start the process by ' +
|
||||||
|
'clicking the Update button.', 'alert-info');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Rest.setUrl(group.related.inventory_source);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
ShowUpdateStatus({ group_name: data.summary_fields.group.name,
|
||||||
|
last_update: data.related.last_update });
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
|
||||||
|
' POST returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Click on group name
|
// Click on group name
|
||||||
scope.GroupsEdit = function(group_id) {
|
scope.GroupsEdit = function(group_id) {
|
||||||
@@ -241,16 +271,16 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
scope.updateGroup = function(id) {
|
scope.updateGroup = function(id) {
|
||||||
for (var i=0; i < scope.groups.length; i++) {
|
for (var i=0; i < scope.groups.length; i++) {
|
||||||
if (scope.groups[i].id == id) {
|
if (scope.groups[i].id == id) {
|
||||||
if (scope.groups[i].source == "" || scope.groups[i].source == null) {
|
if (scope.groups[i].summary_fields.inventory_source.source == "" || scope.groups[i].summary_fields.inventory_source.source == null) {
|
||||||
Alert('Missing Configuration', 'The selected group is not configured for updates. You must first edit the group, provide Source settings, ' +
|
Alert('Missing Configuration', 'The selected group is not configured for updates. You must first edit the group, provide Source settings, ' +
|
||||||
'and then run an update.', 'alert-info');
|
'and then run an update.', 'alert-info');
|
||||||
}
|
}
|
||||||
else if (scope.groups[i].status == 'updating') {
|
else if (scope.groups[i].summary_fields.inventory_source.status == 'updating') {
|
||||||
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
||||||
scope.groups[i].summary_fields.group.name + '</em>. Use the Refresh button to monitor the status.', 'alert-info');
|
scope.groups[i].summary_fields.group.name + '</em>. Use the Refresh button to monitor the status.', 'alert-info');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (scope.groups[i].source == 'Amazon EC2') {
|
if (scope.groups[i].summary_fields.inventory_source.source == 'ec2') {
|
||||||
scope.sourceUsernameLabel = 'Access Key ID';
|
scope.sourceUsernameLabel = 'Access Key ID';
|
||||||
scope.sourcePasswordLabel = 'Secret Access Key';
|
scope.sourcePasswordLabel = 'Secret Access Key';
|
||||||
scope.sourcePasswordConfirmLabel = 'Confirm Secret Access Key';
|
scope.sourcePasswordConfirmLabel = 'Confirm Secret Access Key';
|
||||||
@@ -260,13 +290,22 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
scope.sourcePasswordLabel = 'Password';
|
scope.sourcePasswordLabel = 'Password';
|
||||||
scope.sourcePasswordConfirmLabel = 'Confirm Password';
|
scope.sourcePasswordConfirmLabel = 'Confirm Password';
|
||||||
}
|
}
|
||||||
InventoryUpdate({
|
Rest.setUrl(scope.groups[i].related.inventory_source);
|
||||||
scope: scope,
|
Rest.get()
|
||||||
group_id: id,
|
.success( function(data, status, headers, config) {
|
||||||
url: scope.groups[i].related.update,
|
InventoryUpdate({
|
||||||
group_name: scope.groups[i].summary_fields.group.name,
|
scope: scope,
|
||||||
group_source: scope.groups[i].source
|
group_id: id,
|
||||||
});
|
url: data.related.update,
|
||||||
|
group_name: data.summary_fields.group.name,
|
||||||
|
group_source: data.source
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + scope.groups[i].related.inventory_source +
|
||||||
|
' POST returned status: ' + status });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,15 +369,24 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
var inventory_id = params.inventory_id;
|
var inventory_id = params.inventory_id;
|
||||||
var url = params.url;
|
var url = params.url;
|
||||||
|
var group_id = params.group_id;
|
||||||
|
var group_name = params.group_name;
|
||||||
|
var group_source = params.group_source;
|
||||||
|
|
||||||
if (scope.removeUpdateSubmitted) {
|
if (scope.removeUpdateSubmitted) {
|
||||||
scope.removeUpdateSubmitted();
|
scope.removeUpdateSubmitted();
|
||||||
}
|
}
|
||||||
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function() {
|
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function() {
|
||||||
// Refresh the project list after update request submitted
|
// Refresh the project list after update request submitted
|
||||||
//$location.path(GetBasePath('inventories') + inventory_id + '/groups'
|
Alert('Update Started', 'The request to start the inventory process was submitted. Monitor progress from the inventory summary screen. ' +
|
||||||
//InventorySummary({ scope: scope });
|
'The screen will refresh every 10 seconds, or refresh manually by clicking the <em>Refresh</em> button.', 'alert-info');
|
||||||
$location.url('/inventories/' + scope['inventory_id'] + '/groups/?status=updating');
|
var node = $('#inventory-node')
|
||||||
|
var selected = $('#tree-view').jstree('get_selected');
|
||||||
|
scope['inventorySummaryGroup'] = group_name;
|
||||||
|
selected.each(function(idx) {
|
||||||
|
$('#tree-view').jstree('deselect_node', $(this));
|
||||||
|
});
|
||||||
|
$('#tree-view').jstree('select_node', node);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removeInventorySubmit) {
|
if (scope.removeInventorySubmit) {
|
||||||
@@ -399,8 +408,8 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
if (data.can_update) {
|
if (data.can_update) {
|
||||||
var extra_html = "<div class=\"inventory-passwd-msg\">Starting inventory update for the <em>" + params.group_name +
|
var extra_html = "<div class=\"inventory-passwd-msg\">Starting inventory update for the <em>" + group_name +
|
||||||
"</em> group. Please provide the " + params.group_source + " credentials:</div>\n";
|
"</em> group. Please provide the " + group_source + " credentials:</div>\n";
|
||||||
scope.$emit('InventorySubmit', data.passwords_needed_to_update, extra_html);
|
scope.$emit('InventorySubmit', data.passwords_needed_to_update, extra_html);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
// searchSingleValue: true
|
// searchSingleValue: true
|
||||||
// searchType: 'boolean|int|etc.'
|
// searchType: 'boolean|int|etc.'
|
||||||
// searchValue: < value to match for boolean use 'true'|'false' >
|
// searchValue: < value to match for boolean use 'true'|'false' >
|
||||||
scope[iterator + "SearchType"] = list.fields[fld].searchType;
|
|
||||||
scope[iterator + 'InputDisable'] = true;
|
scope[iterator + 'InputDisable'] = true;
|
||||||
scope[iterator + "SearchValue"] = list.fields[fld].searchValue;
|
scope[iterator + "SearchValue"] = list.fields[fld].searchValue;
|
||||||
// For boolean type, SearchValue must be an object
|
// For boolean type, SearchValue must be an object
|
||||||
@@ -105,7 +104,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
else if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'false') {
|
else if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'false') {
|
||||||
scope[iterator + "SearchSelectValue"] = { value: 0 };
|
scope[iterator + "SearchSelectValue"] = { value: 0 };
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType == 'boolean') {
|
else {
|
||||||
scope[iterator + "SearchSelectValue"] = { value: list.fields[fld].searchValue };
|
scope[iterator + "SearchSelectValue"] = { value: list.fields[fld].searchValue };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
else if ( (list.fields[scope[iterator + 'SearchField']].searchType == 'select') &&
|
else if ( (list.fields[scope[iterator + 'SearchField']].searchType == 'select') &&
|
||||||
(scope[iterator + 'SearchSelectValue'].value == '' ||
|
(scope[iterator + 'SearchSelectValue'].value == '' ||
|
||||||
scope[iterator + 'SearchSelectValue'].value == null) ) {
|
scope[iterator + 'SearchSelectValue'].value == null) ) {
|
||||||
scope[iterator + 'SearchParams'] += '=';
|
scope[iterator + 'SearchParams'] += 'iexact=';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType'] + '=';
|
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType'] + '=';
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ angular.module('InventorySummaryDefinition', [])
|
|||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
label: 'Group',
|
label: 'Group',
|
||||||
ngBind: "group.summary_fields.group.name",
|
ngClick: "\{\{ 'GroupsEdit(' + group.id + ')' \}\}"
|
||||||
sourceModel: 'group',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: "\{\{ 'GroupsEdit(' + group.group + ')' \}\}"
|
|
||||||
},
|
},
|
||||||
hosts_with_active_failures: {
|
hosts_with_active_failures: {
|
||||||
label: 'Hosts with<br>Job Failures?',
|
label: 'Hosts with<br>Job Failures?',
|
||||||
@@ -37,52 +34,55 @@ angular.module('InventorySummaryDefinition', [])
|
|||||||
searchable: false,
|
searchable: false,
|
||||||
nosort: true
|
nosort: true
|
||||||
},
|
},
|
||||||
|
status: {
|
||||||
|
label: 'Update<br>Status',
|
||||||
|
ngClick: "viewUpdateStatus(\{\{ group.id \}\})",
|
||||||
|
searchType: 'select',
|
||||||
|
badgeIcon: "\{\{ 'icon-cloud-' + group.status_badge_class \}\}",
|
||||||
|
badgeToolTip: "\{\{ group.status_badge_tooltip \}\}",
|
||||||
|
awToolTip: "\{\{ group.status_badge_tooltip \}\}",
|
||||||
|
dataPlacement: 'top',
|
||||||
|
badgeTipPlacement: 'top',
|
||||||
|
badgePlacement: 'left',
|
||||||
|
searchOptions: [
|
||||||
|
{ name: "failed", value: "failed" },
|
||||||
|
{ name: "never", value: "never updated" },
|
||||||
|
{ name: "n/a", value: "none" },
|
||||||
|
{ name: "successful", value: "successful" },
|
||||||
|
{ name: "updating", value: "updating" }],
|
||||||
|
sourceModel: 'inventory_source',
|
||||||
|
sourceField: 'status'
|
||||||
|
},
|
||||||
|
last_updated: {
|
||||||
|
label: 'Last<br>Updated',
|
||||||
|
searchable: false,
|
||||||
|
nosort: true
|
||||||
|
},
|
||||||
|
source: {
|
||||||
|
label: 'Source',
|
||||||
|
searchType: 'select',
|
||||||
|
searchOptions: [
|
||||||
|
{ name: "ec2", value: "ec2" },
|
||||||
|
{ name: "none", value: "" },
|
||||||
|
{ name: "rackspace", value: "rackspace" }],
|
||||||
|
sourceModel: 'inventory_source',
|
||||||
|
sourceField: 'source'
|
||||||
|
},
|
||||||
has_active_failures: {
|
has_active_failures: {
|
||||||
label: 'Hosts have job failures?',
|
label: 'Hosts have job failures?',
|
||||||
searchSingleValue: true,
|
searchSingleValue: true,
|
||||||
searchType: 'boolean',
|
searchType: 'boolean',
|
||||||
searchValue: 'true',
|
searchValue: 'true',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
sourceModel: 'group',
|
|
||||||
sourceField: 'has_active_failures'
|
|
||||||
},
|
},
|
||||||
last_update_failed: {
|
last_update_failed: {
|
||||||
label: 'Update failed?',
|
label: 'Update failed?',
|
||||||
|
searchType: 'select',
|
||||||
searchSingleValue: true,
|
searchSingleValue: true,
|
||||||
searchType: 'boolean',
|
searchValue: 'failed',
|
||||||
searchValue: 'true',
|
searchOnly: true,
|
||||||
searchOnly: true
|
sourceModel: 'inventory_source',
|
||||||
},
|
sourceField: 'status'
|
||||||
status: {
|
|
||||||
label: 'Update<br>Status',
|
|
||||||
ngClick: "ShowUpdateStatus({ last_update: '{{ group.related.last_update }}', group_name: '{{ group.summary_fields.group.name }}' })",
|
|
||||||
searchType: 'select',
|
|
||||||
badgeIcon: 'icon-cloud',
|
|
||||||
badgeToolTip: "\{\{ group.status_badge_tooltip \}\}",
|
|
||||||
awToolTip: "\{\{ group.status_badge_tooltip \}\}",
|
|
||||||
dataPlacement: 'top',
|
|
||||||
badgeTipPlacement: 'top',
|
|
||||||
badgePlacement: 'left',
|
|
||||||
badgeClass: "\{\{ 'icon-cloud-' + group.status_badge_class \}\}",
|
|
||||||
searchOptions: [
|
|
||||||
{ name: "failed", value: "failed" },
|
|
||||||
{ name: "never", value: "never updated" },
|
|
||||||
{ name: "n/a", value: "none" },
|
|
||||||
{ name: "successful", value: "successful" },
|
|
||||||
{ name: "updating", value: "updating" }]
|
|
||||||
},
|
|
||||||
last_updated: {
|
|
||||||
label: 'Last<br>Updated',
|
|
||||||
searchable: false
|
|
||||||
},
|
|
||||||
source: {
|
|
||||||
label: 'Source',
|
|
||||||
searchType: 'select',
|
|
||||||
searchOptions: [
|
|
||||||
{ name: "Amazon EC2", value: "ec2" },
|
|
||||||
{ name: "Local Script", value: "file" },
|
|
||||||
{ name: "Manual", value: "" },
|
|
||||||
{ name: "Rackspace", value: "rackspace" }]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user