mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
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:
@@ -201,6 +201,11 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
font-size: 12px;
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
legend {
|
legend {
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
|
|||||||
status = 'alert-info';
|
status = 'alert-info';
|
||||||
hdr = 'AWX Demo';
|
hdr = 'AWX Demo';
|
||||||
msg = 'Thank you for trying AnsibleWorks AWX. You can use this edition to manage up to 10 hosts free. ' +
|
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 ' +
|
'Should you wish to acquire a license for additional servers, please ' +
|
||||||
'<a href="http://ansibleworks.com/ansibleworks-awx" target="_blank"><strong>ansibleworks.com/ansibleworks-awx</strong></a>, or ' +
|
'<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.';
|
'contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> for assistance.';
|
||||||
Alert(hdr, msg, status);
|
Alert(hdr, msg, status);
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
|
|||||||
hdr = 'License Expired';
|
hdr = 'License Expired';
|
||||||
msg = 'Your AnsibleWorks AWX License has expired and is no longer compliant. ' +
|
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 ' +
|
'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 license and renewal information, or contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> ' +
|
||||||
'for assistance.';
|
'for assistance.';
|
||||||
Alert(hdr, msg, status);
|
Alert(hdr, msg, status);
|
||||||
@@ -87,8 +87,8 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies'])
|
|||||||
status = 'alert-info';
|
status = 'alert-info';
|
||||||
hdr = 'License Warning';
|
hdr = 'License Warning';
|
||||||
msg = 'Your AnsibleWorks AWX License has reached capacity for the number of managed ' +
|
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 ' +
|
'hosts allowed. You will not be able to add any additional hosts. To extend your license, please ' +
|
||||||
'<a href="http://ansibleworks.com/ansibleworks-awx" target="_blank"><strong>ansibleworks.com/ansibleworks-awx.</strong></a>, or ' +
|
'<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.';
|
'contact <a href="mailto:info@ansibleworks.com"><strong>info@ansibleworks.com</strong></a> for more information.';
|
||||||
Alert(hdr, msg, status, null, true);
|
Alert(hdr, msg, status, null, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,69 +7,170 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', 'FormGenerator', 'PromptDialog'])
|
angular.module('License', ['RestServices', 'Utilities', 'FormGenerator', 'PromptDialog'])
|
||||||
.factory('ViewLicense', ['$location', 'LicenseForm', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
|
.factory('ViewLicense', ['$location', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
|
||||||
'FormatDate', 'Prompt',
|
'FormatDate', 'Prompt',
|
||||||
function($location, LicenseForm, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors, FormatDate, Prompt) {
|
function($location, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors, FormatDate, Prompt) {
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var defaultUrl=GetBasePath('config');
|
var defaultUrl=GetBasePath('config');
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm;
|
||||||
var form = LicenseForm;
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
|
|
||||||
// load the form
|
var form = {
|
||||||
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
|
name: 'license',
|
||||||
generator.reset();
|
well: false,
|
||||||
|
forceListeners: true,
|
||||||
scope.formModalAction = function() {
|
'class': 'horizontal-narrow',
|
||||||
$('#form-modal').modal("hide");
|
fields: {
|
||||||
}
|
license_status: {
|
||||||
|
label: 'Status',
|
||||||
scope.formModalActionLabel = 'OK';
|
type: 'custom',
|
||||||
scope.formModalCancelShow = false;
|
control: '<div ng-class=\"status_color\" class=\"license-status\"><i class="icon-circle"></i> \{\{ license_status \}\}</div>',
|
||||||
scope.formModalInfo = 'Purchase/Extend License';
|
readonly: true,
|
||||||
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
|
section: 'License'
|
||||||
$('#form-modal').addClass('skinny-modal');
|
},
|
||||||
scope.formModalHeader = 'AWX 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
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
scope.formModalInfoAction = function() {
|
|
||||||
Prompt({
|
|
||||||
hdr: 'AWX Licensing',
|
function empty(x) {
|
||||||
body: "<p class=\"break\">AWX licenses can be purchased, renewed or extended by visiting <a id=\"license-link\" " +
|
var result = false;
|
||||||
"target=\"_blank\" href=\"http://www.ansibleworks.com/ansibleworks-awx/\">" +
|
if (x === null || x === undefined || x == '') {
|
||||||
"ansibleworks.com/ansibleworks-awx</a>.</p><p>Would you like to visit the AWX licensing site now?</p>",
|
result = true;
|
||||||
'class': 'btn-primary',
|
|
||||||
action: function() { var href = $('#license-link').attr('href'); window.location = href; }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
if (data['license_info'][fld]) {
|
if (fld != 'time_remaining' && fld != 'license_status') {
|
||||||
scope[fld] = data['license_info'][fld];
|
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);
|
if (empty(data['license_info']['license_date'])) {
|
||||||
var remainder = scope['time_remaining'] - (days * 86400000);
|
delete form.fields['license_date'];
|
||||||
var hours = parseInt(remainder / 3600000);
|
delete form.fields['time_remaining'];
|
||||||
remainder = remainder - (hours * 3600000);
|
}
|
||||||
var minutes = parseInt(remainder / 60000);
|
|
||||||
remainder = remainder - (minutes * 60000);
|
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
|
||||||
var seconds = parseInt(remainder / 1000);
|
generator.reset();
|
||||||
scope['time_remaining'] = days + ' days ' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);
|
|
||||||
|
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) {
|
if (parseInt(scope['free_instances']) <= 0) {
|
||||||
scope['free_instances_class'] = 'field-failure';
|
scope['free_instances_class'] = 'field-failure';
|
||||||
|
|||||||
Reference in New Issue
Block a user