From 401317cf416b14fdd6cef8530b897341875f4610 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Wed, 24 Jul 2013 18:04:37 -0400 Subject: [PATCH] AC-232 License viewer completed. --- awx/ui/static/css/ansible-ui.css | 20 ++++++++ awx/ui/static/js/forms/License.js | 14 +++--- awx/ui/static/js/helpers/Lookup.js | 1 - awx/ui/static/lib/ansible/form-generator.js | 8 ++- awx/ui/static/lib/ansible/license.js | 54 ++++++++++++++++++--- awx/ui/templates/ui/index.html | 30 ++++++------ 6 files changed, 96 insertions(+), 31 deletions(-) diff --git a/awx/ui/static/css/ansible-ui.css b/awx/ui/static/css/ansible-ui.css index 1ca01ded47..454564b017 100644 --- a/awx/ui/static/css/ansible-ui.css +++ b/awx/ui/static/css/ansible-ui.css @@ -77,6 +77,10 @@ padding-left: 10px; } + .break { + word-wrap: break-word; + } + .login-alert { font-weight: normal; font-size: 14px; @@ -419,6 +423,22 @@ color: #5bb75b; } + .field-success { + color: #5bb75b; + } + + .field-success input { + border-color: #5bb75b; + } + + .field-failure { + color: #FF0000; + } + + .field-failure input { + border-color: #FF0000; + } + .job-changed, .license-warning, .license-demo { diff --git a/awx/ui/static/js/forms/License.js b/awx/ui/static/js/forms/License.js index 69f8353751..2d6e34df71 100644 --- a/awx/ui/static/js/forms/License.js +++ b/awx/ui/static/js/forms/License.js @@ -32,34 +32,36 @@ angular.module('LicenseFormDefinition', []) readonly: true }, license_date: { - label: 'Activated On', + label: 'Expires On', type: 'text', readonly: true, section: 'License' }, time_remaining: { - label: 'Days Left', + label: 'Time Left', type: 'text', readonly: true, section: 'License' }, available_instances: { - label: 'License Count', + label: 'Available', type: 'text', readonly: true, - section: 'Available Servers' + section: 'Managed Hosts' }, current_instances: { label: 'Used', type: 'text', readonly: true, - section: 'Available Servers' + section: 'Managed Hosts' }, free_instances: { label: 'Remaining', type: 'text', readonly: true, - section: 'Available Servers' + section: 'Managed Hosts', + controlNGClass: 'free_instances_class', + labelNGClass: 'free_instances_class' }, company_name: { label: 'Company', diff --git a/awx/ui/static/js/helpers/Lookup.js b/awx/ui/static/js/helpers/Lookup.js index 9e79a248e4..b287946d11 100644 --- a/awx/ui/static/js/helpers/Lookup.js +++ b/awx/ui/static/js/helpers/Lookup.js @@ -72,7 +72,6 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P } listScope['toggle_' + list.iterator] = function(id) { - console.log('here!'); for (var i=0; i < scope[list.name].length; i++) { if (listScope[list.name][i]['id'] == id) { listScope[list.name][i]['checked'] = '1'; diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index a1a225ce02..0462b14eb4 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -233,13 +233,17 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) html += (field.ngShow) ? this.attr(field,'ngShow') : ""; html += (field.ngHide) ? this.attr(field,'ngHide') : ""; html += ">\n"; - html += "' + "\n"; - html += "
\n"; + html += "
\n"; html += (field.clear || field.genMD5) ? "
\n" : ""; if (field.control === null || field.control === undefined || field.control) { html += "AWX licenses can be purchased, renewed or extended by visiting " + + "ansibleworks.com/ansibleworks-awx.

Would you like to visit the AWX licensing site now?

", + 'class': 'btn-primary', + action: function() { var href = $('#license-link').attr('href'); window.location = href; } + }); + } // Retrieve detail record and prepopulate the form Rest.setUrl(defaultUrl); @@ -39,7 +54,31 @@ angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', scope[fld] = data['license_info'][fld]; } } - var license = data['license_info'][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 (parseInt(scope['free_instances']) <= 0) { + scope['free_instances_class'] = 'field-failure'; + } + else { + scope['free_instances_class'] = 'field-success'; + } + + var license = data['license_info']; if (license['valid_key'] !== undefined && license['valid_key'] == false) { scope['license_status'] = 'Invalid'; scope['status_color'] = 'license-invalid'; @@ -53,13 +92,14 @@ angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', scope['status_color'] = 'license-expired'; } else if (license['free_instances'] !== undefined && parseInt(license['free_instances']) <= 0) { - scope['license_status'] = 'No available servers'; - scope['status_color'] = 'license-warning'; + scope['license_status'] = 'No available managed hosts'; + scope['status_color'] = 'license-invalid'; } else { scope['license_status'] = 'Valid'; scope['status_color'] = 'license-valid'; } + }) .error( function(data, status, headers, config) { ProcessErrors(scope, data, status, form, diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index bba138d684..a9deb72950 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -139,21 +139,6 @@
- - - + + +