From ebd6973f6b8ccbeb78954b313c01e4ee7860f6e2 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 20 Nov 2013 03:45:31 +0000 Subject: [PATCH] AC-550 When user views inventory update status (by clicking on the status link) an alert at the top of the dialog will show when the error is caused by a license violation. --- awx/ui/static/js/forms/ActivityDetail.js | 2 +- awx/ui/static/js/forms/InventoryStatus.js | 17 +++++-- awx/ui/static/js/helpers/Groups.js | 48 ++++++++++-------- awx/ui/static/less/ansible-ui.less | 55 +++------------------ awx/ui/static/lib/ansible/Utilities.js | 6 +-- awx/ui/static/lib/ansible/form-generator.js | 7 ++- 6 files changed, 58 insertions(+), 77 deletions(-) diff --git a/awx/ui/static/js/forms/ActivityDetail.js b/awx/ui/static/js/forms/ActivityDetail.js index 7cce68036c..705ae61d9a 100644 --- a/awx/ui/static/js/forms/ActivityDetail.js +++ b/awx/ui/static/js/forms/ActivityDetail.js @@ -63,7 +63,7 @@ angular.module('ActivityDetailDefinition', []) }, changes: { label: 'Changes', - type: 'lgtextarea', + type: 'textarea', ngHide: "!changes || changes =='' || changes == 'null'", readonly: true } diff --git a/awx/ui/static/js/forms/InventoryStatus.js b/awx/ui/static/js/forms/InventoryStatus.js index 156577850f..0cf19ebdb3 100644 --- a/awx/ui/static/js/forms/InventoryStatus.js +++ b/awx/ui/static/js/forms/InventoryStatus.js @@ -16,29 +16,38 @@ angular.module('InventoryStatusDefinition', []) 'class': 'horizontal-narrow', fields: { + license_error: { + type: 'alertblock', + 'class': "alert-info", + alertTxt: "The invenvtory update process exceeded the available number of licensed hosts. " + + "View your license " + + "for more information.", + ngShow: 'license_error', + closeable: false + }, 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 9352ef1dc7..cd5534abd3 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -79,8 +79,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' } }]) - .factory('ViewUpdateStatus', [ 'Rest', 'ProcessErrors', 'GetBasePath', 'ShowUpdateStatus', 'Alert', - function(Rest, ProcessErrors, GetBasePath, ShowUpdateStatus, Alert) { + .factory('ViewUpdateStatus', [ 'Rest', 'ProcessErrors', 'GetBasePath', 'ShowUpdateStatus', 'Alert', 'Wait', + function(Rest, ProcessErrors, GetBasePath, ShowUpdateStatus, Alert, Wait) { return function(params) { var scope = params.scope; @@ -104,14 +104,19 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' 'clicking the Update button.', 'alert-info'); } else { + Wait('start'); Rest.setUrl(group.related.inventory_source); Rest.get() .success( function(data, status, headers, config) { var url = (data.related.current_update) ? data.related.current_update : data.related.last_update; - ShowUpdateStatus({ group_name: data.summary_fields.group.name, - last_update: url }); + ShowUpdateStatus({ + group_name: data.summary_fields.group.name, + last_update: url, + license_error: [ (data.summary_fields.last_update && data.summary_fields.last_update.license_error) ? true : false ] + }); }) .error( function(data, status, headers, config) { + Wait('stop'); ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source + ' POST returned status: ' + status }); @@ -1120,63 +1125,66 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' .factory('ShowUpdateStatus', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm', - 'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventoryStatusForm', + 'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventoryStatusForm', 'Wait', function($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors, GetBasePath, - FormatDate, InventoryStatusForm) { + FormatDate, InventoryStatusForm, Wait) { return function(params) { var group_name = params.group_name; var last_update = params.last_update; var generator = GenerateForm; var form = InventoryStatusForm; + var license_error = params.license_error var scope; if (last_update == undefined || last_update == null || last_update == ''){ + Wait('stop'); 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 ($rootScope.removeShowStatus) { + $rootScope.removeShowStatus(); + } + $rootScope.removeShowStatus = $rootScope.$on('showStatus', function(e, results) { + + }); + // Retrieve detail record and prepopulate the form Rest.setUrl(last_update); Rest.get() .success( function(data, status, headers, config) { - // load up the form + $('#form-modal').on('shown.bs.modal', function() { + Wait('stop'); + }); 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 (data[fld]) { if (fld == 'created') { - scope[fld] = FormatDate(new Date(results[fld])); + scope[fld] = FormatDate(new Date(data[fld])); } else { - scope[fld] = results[fld]; + scope[fld] = data[fld]; } } - //else { - // if (results.summary_fields.project[fld]) { - // scope[fld] = results.summary_fields.project[fld] - // } - //} } - + scope.license_error = license_error; 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) { + Wait('stop'); $('#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/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 16af6984ed..50a14a85c8 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -101,61 +101,22 @@ textarea { opacity: .4; } -.popover { - z-index: 2000; -} - /* TB tooltip overrides */ + + .popover { + z-index: 2000; + } + .tooltip { z-index: 1050; opacity: 1.0; } -/* - .tooltip-inner { - color: @tip-color; - background-color: @tip-background; - border-radius: 6px; - padding: 5px; + .alert { + margin-top: 15px; + margin-bottom: 15px; } - .tooltip.in { - opacity: 1.0; - } - - .tooltip.top .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.top-left .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.top-right .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.right .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.left .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.bottom .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.bottom-left .tooltip-arrow { - border-top-color: @tip-background; - } - - .tooltip.bottom-right .tooltip-arrow { - border-top-color: @tip-background; - } -*/ - hr { border-color: #e3e3e3; } diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js index 99d579d1f9..0e0e2687e6 100644 --- a/awx/ui/static/lib/ansible/Utilities.js +++ b/awx/ui/static/lib/ansible/Utilities.js @@ -356,7 +356,7 @@ angular.module('Utilities',['RestServices', 'Utilities']) }]) .factory('Wait', [ '$rootScope', function($rootScope) { - return function(directive) { + return function(directive, callback) { // Display a spinning icon in the center of the screen to freeze the // UI while waiting on async things to complete (i.e. API calls). // Wait('start' | 'stop'); @@ -375,11 +375,11 @@ angular.module('Utilities',['RestServices', 'Utilities']) $('.spinny').css({ top: y, left: x - }).fadeIn(400); + }).fadeIn(400, callback); } else { $rootScope.waiting = false; - $('.spinny, .overlay').fadeOut(1000); + $('.spinny, .overlay').fadeOut(500, callback); } } }]) diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 0a0c4f9d2c..5ca21ad428 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -437,10 +437,13 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) var html = ''; if (field.type == 'alertblock') { - html += "
×\n"; + html += (field.closeable == undefined || field.closeable == true) ? + "\n" : ""; html += field.alertTxt; html += "
\n"; }