1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

AC-295 Fixed View License so that empty fields are not displayed. Now demo license info makes sense. Fixed links in nag messages and here to all point to store.ansibleworks.com

This commit is contained in:
chouseknecht 2013-07-30 12:52:46 -04:00
parent 7ff5d6f300
commit bc0db0312f
3 changed files with 157 additions and 51 deletions

View File

@ -201,6 +201,11 @@
font-size: 12px;
}
.note {
font-size: 12px;
padding-top: 15px;
}
legend {
font-size: medium;
font-weight: bold;

View File

@ -68,8 +68,8 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
status = 'alert-info';
hdr = 'AWX Demo';
msg = 'Thank you for trying AnsibleWorks AWX. You can use this edition to manage up to 10 hosts free. ' +
'Should you wish to acquire a license for additional servers, please visit ' +
'<a href="http://ansibleworks.com/ansibleworks-awx" target="_blank"><strong>ansibleworks.com/ansibleworks-awx</strong></a>, or ' +
'Should you wish to acquire a license for additional servers, please ' +
'<a href="http://store.ansibleworks.com" target="_blank"><strong>visit the AnsibleWorks online store</strong></a>, or ' +
'contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> for assistance.';
Alert(hdr, msg, status);
}
@ -78,7 +78,7 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
hdr = 'License Expired';
msg = 'Your AnsibleWorks AWX License has expired and is no longer compliant. ' +
'You can continue, but you will be unable to add any additional hosts. Please ' +
'visit <a href="http://ansibleworks.com/ansibleworks-awx" target="_blank"><strong>ansibleworks.com/ansibleworks-awx</strong></a> ' +
'<a href="http://store.ansibleworks.com" target="_blank"><strong>visit the AnsibleWorks online store</strong></a> ' +
'for license and renewal information, or contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> ' +
'for assistance.';
Alert(hdr, msg, status);
@ -87,8 +87,8 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
status = 'alert-info';
hdr = 'License Warning';
msg = 'Your AnsibleWorks AWX License has reached capacity for the number of managed ' +
'hosts allowed. You will not be able to add any additional hosts. To extend your license, please visit ' +
'<a href="http://ansibleworks.com/ansibleworks-awx" target="_blank"><strong>ansibleworks.com/ansibleworks-awx.</strong></a>, or ' +
'hosts allowed. You will not be able to add any additional hosts. To extend your license, please ' +
'<a href="http://store.ansibleworks.com" target="_blank"><strong>visit the AnsibleWorks online store</strong></a>, or ' +
'contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> for more information.';
Alert(hdr, msg, status, null, true);
}

View File

@ -7,69 +7,170 @@
'use strict';
angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', 'FormGenerator', 'PromptDialog'])
.factory('ViewLicense', ['$location', 'LicenseForm', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
angular.module('License', ['RestServices', 'Utilities', 'FormGenerator', 'PromptDialog'])
.factory('ViewLicense', ['$location', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
'FormatDate', 'Prompt',
function($location, LicenseForm, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors, FormatDate, Prompt) {
function($location, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors, FormatDate, Prompt) {
return function() {
var defaultUrl=GetBasePath('config');
var generator = GenerateForm;
var form = LicenseForm;
var base = $location.path().replace(/^\//,'').split('/')[0];
// load the form
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
generator.reset();
scope.formModalAction = function() {
$('#form-modal').modal("hide");
}
scope.formModalActionLabel = 'OK';
scope.formModalCancelShow = false;
scope.formModalInfo = 'Purchase/Extend License';
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
$('#form-modal').addClass('skinny-modal');
scope.formModalHeader = 'AWX License';
var form = {
name: 'license',
well: false,
forceListeners: true,
'class': 'horizontal-narrow',
fields: {
license_status: {
label: 'Status',
type: 'custom',
control: '<div ng-class=\"status_color\" class=\"license-status\"><i class="icon-circle"></i> \{\{ license_status \}\}</div>',
readonly: true,
section: 'License'
},
license_key: {
label: 'Key',
type: 'textarea',
section: 'License',
'class': 'modal-input-xlarge',
readonly: true
},
license_date: {
label: 'Expires On',
type: 'text',
readonly: true,
section: 'License'
},
time_remaining: {
label: 'Time Left',
type: 'text',
readonly: true,
section: 'License'
},
available_instances: {
label: 'Available',
type: 'text',
readonly: true,
section: 'Managed Hosts'
},
current_instances: {
label: 'Used',
type: 'text',
readonly: true,
section: 'Managed Hosts'
},
free_instances: {
label: 'Remaining',
type: 'text',
readonly: true,
section: 'Managed Hosts',
controlNGClass: 'free_instances_class',
labelNGClass: 'free_instances_class'
},
company_name: {
label: 'Company',
type: 'text',
readonly: true,
section: 'Contact Info'
},
contact_name: {
label: 'Contact',
type: 'text',
readonly: true,
section: 'Contact Info'
},
contact_email: {
label: 'Contact Email',
type: 'text',
readonly: true,
section: 'Contact Info'
}
}
};
// Respond to View JSON button
scope.formModalInfoAction = function() {
Prompt({
hdr: 'AWX Licensing',
body: "<p class=\"break\">AWX licenses can be purchased, renewed or extended by visiting <a id=\"license-link\" " +
"target=\"_blank\" href=\"http://www.ansibleworks.com/ansibleworks-awx/\">" +
"ansibleworks.com/ansibleworks-awx</a>.</p><p>Would you like to visit the AWX licensing site now?</p>",
'class': 'btn-primary',
action: function() { var href = $('#license-link').attr('href'); window.location = href; }
});
var base = $location.path().replace(/^\//,'').split('/')[0];
function empty(x) {
var result = false;
if (x === null || x === undefined || x == '') {
result = true;
}
return result;
}
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl);
Rest.get()
.success( function(data, status, headers, config) {
for (var fld in form.fields) {
if (data['license_info'][fld]) {
scope[fld] = data['license_info'][fld];
if (fld != 'time_remaining' && fld != 'license_status') {
if (empty(data['license_info'][fld])) {
delete form.fields[fld];
}
}
}
var dt = new Date(parseInt(scope['license_date']));
if (dt.getFullYear() == '1970') {
// date was passed in seconds rather than milliseconds
dt = new Date(parseInt(scope['license_date']) * 1000);
scope['time_remaining'] = scope['time_remaining'] + '000';
}
scope['license_date'] = FormatDate(dt);
var days = parseInt(scope['time_remaining'] / 86400000);
var remainder = scope['time_remaining'] - (days * 86400000);
var hours = parseInt(remainder / 3600000);
remainder = remainder - (hours * 3600000);
var minutes = parseInt(remainder / 60000);
remainder = remainder - (minutes * 60000);
var seconds = parseInt(remainder / 1000);
scope['time_remaining'] = days + ' days ' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);
if (empty(data['license_info']['license_date'])) {
delete form.fields['license_date'];
delete form.fields['time_remaining'];
}
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
generator.reset();
scope.formModalAction = function() {
$('#form-modal').modal("hide");
}
scope.formModalActionLabel = 'OK';
scope.formModalCancelShow = false;
scope.formModalInfo = 'Purchase/Extend License';
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
$('#form-modal').addClass('skinny-modal');
scope.formModalHeader = 'AWX License';
// Respond to license button
scope.formModalInfoAction = function() {
Prompt({
hdr: 'AWX Licensing',
body: "<p>AWX licenses can be purchased or extended by visiting <a id=\"license-link\" " +
"href=\"http://store.ansibleworks.com\" target=\"_blank\">" +
"the AnsibleWorks online store</a>. Would you like to purchase or extend your license now?</p>",
'class': 'btn-primary',
action: function() {
var href = $('#license-link').attr('href');
window.open(href, 'storeWindow');
}
});
}
// Remove anything form the form that is empty
for (var fld in form.fields) {
if (data['license_info'][fld]) {
scope[fld] = data['license_info'][fld];
}
}
if (scope['license_date']) {
var dt = new Date(parseInt(scope['license_date']));
if (dt.getFullYear() == '1970') {
// date was passed in seconds rather than milliseconds
dt = new Date(parseInt(scope['license_date']) * 1000);
scope['time_remaining'] = scope['time_remaining'] + '000';
}
scope['license_date'] = FormatDate(dt);
var days = parseInt(scope['time_remaining'] / 86400000);
var remainder = scope['time_remaining'] - (days * 86400000);
var hours = parseInt(remainder / 3600000);
remainder = remainder - (hours * 3600000);
var minutes = parseInt(remainder / 60000);
remainder = remainder - (minutes * 60000);
var seconds = parseInt(remainder / 1000);
scope['time_remaining'] = days + ' days ' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);
}
if (parseInt(scope['free_instances']) <= 0) {
scope['free_instances_class'] = 'field-failure';