From 0db0972eb15c814630fd3f9dee7235e6613605bd Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Thu, 7 Aug 2014 18:02:18 -0400 Subject: [PATCH] License Started making language revisions per 8/7 status meeting notes. --- awx/ui/static/js/helpers/License.js | 46 +++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/awx/ui/static/js/helpers/License.js b/awx/ui/static/js/helpers/License.js index f0834a6426..f66349b3d6 100644 --- a/awx/ui/static/js/helpers/License.js +++ b/awx/ui/static/js/helpers/License.js @@ -49,54 +49,65 @@ function($rootScope, $compile, CreateDialog, Store, LicenseUpdateForm, GenerateF }, getHTML: function(license, includeFormButton) { - var title, html, result = {}; + + var title, html, result = {}, license_is_valid=false; + if (license && typeof license === 'object' && Object.keys(license).length > 0 && license.valid_key !== undefined) { // we have a license if (!license.valid_key) { title = "Invalid License"; - html = "

The Ansible Tower license is invalid. Please visit " + - "ansible.com/license to obtain a valid license key."; + html = "

The Ansible Tower license is invalid.

"; } else if (this.getRemainingDays(license.time_remaining) <= 0) { if (parseInt(license.grace_period_remaining,10) > 86400) { title = "License Expired"; html = "

Thank you for using Ansible Tower. The Ansible Tower license " + - "has expired. You will no longer be able to add managed hosts or run playbooks after " + this.getRemainingDays(license.grace_period_remaining) + " days

" + - "

Please visit ansible.com/license to purchse a valid license."; + "has expired. You will no longer be able to add managed hosts or run playbooks after " + this.getRemainingDays(license.grace_period_remaining) + " days

"; } else { title = "License Expired"; html = "

Thank you for using Ansible Tower. The Ansible Tower license " + "has expired, and the 30 day grace period has been exceeded. To continue using Tower to run playbooks and add managed hosts a " + - "valid license key is required.

Please visit ansible.com/license to purchse a license."; + "valid license key is required.

"; } } else if (this.getRemainingDays(license.time_remaining) < 15) { title = "License Warning"; html = "

Thank you for using Ansible Tower. The Ansible Tower license " + - "has " + this.getRemainingDays(license.time_remaining) + " days remaining. Once the license expires you will no longer be able to add managed hosts or run playbooks.

" + - "

Extend your Ansible Tower license by visiting ansible.com/license."; + "has " + this.getRemainingDays(license.time_remaining) + " days remaining. Once the license expires you will no longer be able to add managed hosts or run playbooks.

"; } else if (license.free_instances <= 0) { title = "Host Count Exceeded"; html = "

The Ansible Tower license has reached capacity for the number of " + - "managed hosts allowed. No additional hosts can be added.

To extend the Ansible Tower license please visit " + - "ansible.com/license."; + "managed hosts allowed. No additional hosts can be added.

"; } else { // license is valid. the following text is displayed in the license viewer title = "Update License"; // not actually used - html = "

The Ansible Tower license is valid. To extend or renew the license " + - "visit ansible.com/license."; + html = "

The Ansible Tower license is valid.

"; + license_is_valid = true; } } else { // No license title = "License Required"; html = "

Thank you for trying Ansible Tower. Without a valid license you will not be able to add managed hosts or " + - "run playbooks. A FREE trial license is available for various infrastructure sizes, as well as free unlimited use for up to ten nodes.

" + - "

Visit ansible.com/license to obtain a license key."; + "run playbooks. A FREE trial license is available for various infrastructure sizes, as well as free unlimited use for up to ten nodes.

"; } if (IsAdmin()) { - html += " Copy and paste the license key in the field below and click the Submit button."; + if (license_is_valid) { + html += "

If you need to update or extend the Ansible Tower license, please visit ansible.com/license. " + + "Copy and paste the new license key in the field below and click the Submit button.

"; + } else { + html += "

Please visit ansible.com/license to obtain a valid license key. " + + "Copy and paste the license key in the field below and click the Submit button."; + } + } else { + if (license_is_valid) { + html += "

If you need to update or extend the Ansible Tower license, please visit ansible.com/license. A system administrator " + + "can install the new license by choosing View License on the Account Menu and clicking on the Update License tab."; + } else { + html += "

Please visit ansible.com/license to obtain a valid license key. A system administrator " + + "can install the new license by choosing View License on the Account Menu and clicking on the Update License tab."; + } } html += "

"; @@ -436,7 +447,10 @@ function ($location, $rootScope, $compile, GenerateForm, Rest, Alert, GetBasePat } license = license_info; - if (!license.valid_key) { + if (license.valid_key === undefined) { + scope.license_status = 'Missing License Key'; + scope.status_color = 'license-invalid'; + } else if (!license.valid_key) { scope.license_status = 'Invalid License Key'; scope.status_color = 'license-invalid'; } else if (license.date_expired !== undefined && license.date_expired) {