From b97fbe1905d94573ccbbc9261c1752edec7e116f Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Tue, 8 Oct 2013 02:00:10 +0000 Subject: [PATCH] AC-503 Cloud inventory process results now visible. --- awx/ui/static/js/app.js | 3 +- awx/ui/static/js/forms/InventoryStatus.js | 44 ++++++++++++ awx/ui/static/js/helpers/Groups.js | 78 +++++++++++++++++++++- awx/ui/static/js/lists/InventorySummary.js | 6 +- awx/ui/templates/ui/index.html | 1 + 5 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 awx/ui/static/js/forms/InventoryStatus.js diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 2d39e42b06..f06f387415 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -71,7 +71,8 @@ angular.module('ansible', [ 'License', 'HostGroupsFormDefinition', 'ObjectCountWidget', - 'JobsHelper' + 'JobsHelper', + 'InventoryStatusDefinition' ]) .config(['$routeProvider', function($routeProvider) { $routeProvider. diff --git a/awx/ui/static/js/forms/InventoryStatus.js b/awx/ui/static/js/forms/InventoryStatus.js new file mode 100644 index 0000000000..156577850f --- /dev/null +++ b/awx/ui/static/js/forms/InventoryStatus.js @@ -0,0 +1,44 @@ +/********************************************* + * Copyright (c) 2013 AnsibleWorks, Inc. + * + * InventoryStatus.js + * Form definition for Inventory Status -JSON view + * + * + */ +angular.module('InventoryStatusDefinition', []) + .value( + 'InventoryStatusForm', { + + name: 'inventory_update', + editTitle: 'Inventory Status', + well: false, + 'class': 'horizontal-narrow', + + fields: { + created: { + label: 'Created', + type: 'text', + readonly: true + }, + status: { + label: 'Status', + type: 'text', + readonly: true + }, + result_stdout: { + label: 'Std Out', + type: 'textarea', + ngShow: "result_stdout", + readonly: true, + rows: 15 + }, + result_traceback: { + label: 'Traceback', + type: 'textarea', + ngShow: "result_traceback", + readonly: true, + rows: 15 + } + } + }); //Form \ No newline at end of file diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index ef2d9ad606..29f66b8111 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -126,9 +126,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' .factory('InventoryStatus', [ '$rootScope', '$routeParams', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventorySummary', - 'GenerateList', 'ClearScope', 'SearchInit', 'PaginateInit', 'Refresh', 'InventoryUpdate', 'GroupsEdit', + 'GenerateList', 'ClearScope', 'SearchInit', 'PaginateInit', 'Refresh', 'InventoryUpdate', 'GroupsEdit', 'ShowUpdateStatus', function($rootScope, $routeParams, Rest, Alert, ProcessErrors, GetBasePath, FormatDate, InventorySummary, GenerateList, ClearScope, SearchInit, - PaginateInit, Refresh, InventoryUpdate, GroupsEdit) { + PaginateInit, Refresh, InventoryUpdate, GroupsEdit, ShowUpdateStatus) { return function(params) { //Build a summary of a given inventory @@ -214,11 +214,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' for (var opt in list.fields['status'].searchOptions) { if (list.fields['status'].searchOptions[opt].value == $routeParams['status']) { scope[list.iterator + 'SearchSelectValue'] = list.fields['status'].searchOptions[opt]; + break; } } } scope.search(list.iterator); + + scope.ShowUpdateStatus = ShowUpdateStatus; // Click on group name scope.GroupsEdit = function(group_id) { @@ -810,7 +813,76 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' show: true }); } - }]); + }]) + + + .factory('ShowUpdateStatus', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm', + 'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventoryStatusForm', + function($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors, GetBasePath, + FormatDate, InventoryStatusForm) { + return function(params) { + + var group_name = params.group_name; + var last_update = params.last_update; + var generator = GenerateForm; + var form = InventoryStatusForm; + var scope; + + if (last_update == undefined || last_update == null || last_update == ''){ + 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 { + // Retrieve detail record and prepopulate the form + Rest.setUrl(last_update); + Rest.get() + .success( function(data, status, headers, config) { + // load up the form + scope = generator.inject(form, { mode: 'edit', modal: true, related: false}); + generator.reset(); + var results = data; + for (var fld in form.fields) { + if (results[fld]) { + if (fld == 'created') { + scope[fld] = FormatDate(new Date(results[fld])); + } + else { + scope[fld] = results[fld]; + } + } + //else { + // if (results.summary_fields.project[fld]) { + // scope[fld] = results.summary_fields.project[fld] + // } + //} + } + + scope.formModalAction = function() { + $('#form-modal').modal("hide"); + } + + scope.formModalActionLabel = 'OK'; + scope.formModalCancelShow = false; + scope.formModalInfo = false; + scope.formModalHeader = group_name + ' - Inventory Update'; + + $('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none'); + $('#form-modal').addClass('skinny-modal'); + + if (!scope.$$phase) { + scope.$digest(); + } + }) + .error( function(data, status, headers, config) { + $('#form-modal').modal("hide"); + ProcessErrors(scope, data, status, null, + { hdr: 'Error!', msg: 'Failed to retrieve last update: ' + last_update + '. GET status: ' + status }); + }); + } + } + }]); + + diff --git a/awx/ui/static/js/lists/InventorySummary.js b/awx/ui/static/js/lists/InventorySummary.js index 4e83cc4ac3..44903f0ec9 100644 --- a/awx/ui/static/js/lists/InventorySummary.js +++ b/awx/ui/static/js/lists/InventorySummary.js @@ -55,9 +55,13 @@ angular.module('InventorySummaryDefinition', []) }, status: { label: 'Update
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 \}\}", + badgeToolTip: "\{\{ group.status_badge_tooltip \}\}", + awToolTip: "\{\{ group.status_badge_tooltip \}\}", + dataPlacement: 'top', + badgeTipPlacement: 'top', badgePlacement: 'left', badgeClass: "\{\{ 'icon-cloud-' + group.status_badge_class \}\}", searchOptions: [ diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index a827d6f823..f5cfa4f9ae 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -70,6 +70,7 @@ +