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

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.

This commit is contained in:
Chris Houseknecht 2013-11-20 03:45:31 +00:00
parent 059047ab77
commit ebd6973f6b
6 changed files with 58 additions and 77 deletions

View File

@ -63,7 +63,7 @@ angular.module('ActivityDetailDefinition', [])
},
changes: {
label: 'Changes',
type: 'lgtextarea',
type: 'textarea',
ngHide: "!changes || changes =='' || changes == 'null'",
readonly: true
}

View File

@ -16,6 +16,15 @@ 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. " +
"<strong><a ng-click=\"viewLicense()\" href=\"\">View your license</a></strong> " +
"for more information.",
ngShow: 'license_error',
closeable: false
},
created: {
label: 'Created',
type: 'text',

View File

@ -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 + '<span class="subtitle"> - Inventory Update</span>';
$('#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 });

View File

@ -101,61 +101,22 @@ textarea {
opacity: .4;
}
/* TB tooltip overrides */
.popover {
z-index: 2000;
}
/* TB tooltip overrides */
.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;
}

View File

@ -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);
}
}
}])

View File

@ -437,10 +437,13 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities'])
var html = '';
if (field.type == 'alertblock') {
html += "<div class=\"alert alert-dismissable " + field['class'] + "\" ";
html += "<div class=\"alert ";
html += (field.closeable == undefined || field.closeable == true) ? "alert-dismissable " : "";
html += field['class'] + "\" ";
html += (field.ngShow) ? this.attr(field, 'ngShow') : "";
html += ">\n";
html += "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n";
html += (field.closeable == undefined || field.closeable == true) ?
"<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n" : "";
html += field.alertTxt;
html += "</div>\n";
}