From c77db691ebd98e1f19defc4b6e2c0e35204e61a5 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Thu, 13 Feb 2014 19:01:17 +0000 Subject: [PATCH] AC-725 Added tower version to app footer and license dialog. Refactored license dialog to use tabs rather than accordions. Fixed conflict between angular routes and TB tabs. --- awx/ui/static/js/app.js | 5 ++- .../static/js/controllers/Authentication.js | 6 ++-- awx/ui/static/js/forms/LicenseForm.js | 34 ++++++++++++------- awx/ui/static/js/helpers/Access.js | 10 +++--- awx/ui/static/less/ansible-ui.less | 7 +++- awx/ui/static/lib/ansible/AuthService.js | 15 ++++---- awx/ui/static/lib/ansible/form-generator.js | 4 ++- awx/ui/static/lib/ansible/license.js | 8 ++--- awx/ui/templates/ui/index.html | 23 +++++++------ 9 files changed, 66 insertions(+), 46 deletions(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 22de6ed5b7..22e3455789 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -446,8 +446,11 @@ angular.module('ansible', [ }; $rootScope.viewLicense = function () { - //$location.path('/license'); ViewLicense(); }; + $rootScope.toggleTab = function(e, tab, tabs) { + e.preventDefault(); + $('#' + tabs + ' #' + tab).tab('show'); + }; } ]); \ No newline at end of file diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js index 2ee4bd7f6b..b57a7e55c6 100644 --- a/awx/ui/static/js/controllers/Authentication.js +++ b/awx/ui/static/js/controllers/Authentication.js @@ -104,7 +104,7 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth $rootScope.user_is_superuser = data.results[0].is_superuser; Authorization.getLicense() .success(function (data) { - Authorization.setLicense(data.license_info); + Authorization.setLicense(data); if (lastPath()) { // Go back to most recent navigation path $location.path(lastPath()); @@ -114,12 +114,12 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth }) .error(function () { Wait('stop'); - Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus); + Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus); }); }) .error(function (data, status) { Wait('stop'); - Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus); + Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus); }); }) .error(function (data, status) { diff --git a/awx/ui/static/js/forms/LicenseForm.js b/awx/ui/static/js/forms/LicenseForm.js index cc0b3e6822..bfadbd41cf 100644 --- a/awx/ui/static/js/forms/LicenseForm.js +++ b/awx/ui/static/js/forms/LicenseForm.js @@ -13,7 +13,17 @@ angular.module('LicenseFormDefinition', []) name: 'license', well: false, - forceListeners: true, + + tabs: [{ + name: 'license', + label: 'License' + }, { + name: 'managed', + label: 'Managed Hosts' + },{ + name: 'contact', + label: 'Contact Info' + }], fields: { license_status: { @@ -21,64 +31,64 @@ angular.module('LicenseFormDefinition', []) control: "
" + "{{ license_status }}
", readonly: true, - section: 'License' + tab: 'license' }, license_key: { label: 'Key', type: 'textarea', 'class': 'modal-input-xlarge', readonly: true, - section: 'License' + tab: 'license' }, license_date: { label: 'Expires On', type: 'text', readonly: true, - section: 'License' + tab: 'license' }, time_remaining: { label: 'Time Left', type: 'text', readonly: true, - section: 'License' + tab: 'license' }, available_instances: { label: 'Available', type: 'text', readonly: true, - section: 'Managed Hosts' + tab: 'managed' }, current_instances: { label: 'Used', type: 'text', readonly: true, - section: 'Managed Hosts' + tab: 'managed' }, free_instances: { label: 'Remaining', type: 'text', readonly: true, - section: 'Managed Hosts', controlNGClass: 'free_instances_class', - labelNGClass: 'free_instances_class' + labelNGClass: 'free_instances_class', + tab: 'managed' }, company_name: { label: 'Company', type: 'text', readonly: true, - section: 'Contact Info' + tab: 'contact' }, contact_name: { label: 'Contact', type: 'text', readonly: true, - section: 'Contact Info' + tab: 'contact' }, contact_email: { label: 'Contact Email', type: 'text', readonly: true, - section: 'Contact Info' + tab: 'contact' } } }); \ No newline at end of file diff --git a/awx/ui/static/js/helpers/Access.js b/awx/ui/static/js/helpers/Access.js index 527e7dabaf..878f636eb7 100644 --- a/awx/ui/static/js/helpers/Access.js +++ b/awx/ui/static/js/helpers/Access.js @@ -48,13 +48,13 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies']) } ]) -.factory('CheckLicense', ['$rootScope', '$cookieStore', 'Alert', '$location', 'Authorization', - function ($rootScope, $cookieStore, Alert, $location, Authorization) { +.factory('CheckLicense', ['$rootScope', 'Store', 'Alert', '$location', 'Authorization', + function ($rootScope, Store, Alert, $location, Authorization) { return function () { // Check license status and alert the user, if needed var status = 'success', hdr, msg, - license = $cookieStore.get('license'), + license = Store('license'), purchase_msg = '

To purchase a license or extend an existing license ' + 'visit the Ansible online store, ' + 'or visit support.ansible.com for assistance.

'; @@ -62,9 +62,9 @@ angular.module('AccessHelper', ['RestServices', 'Utilities', 'ngCookies']) if (license && !Authorization.licenseTested()) { // This is our first time evaluating the license license.tested = true; - $cookieStore.remove('license'); - $cookieStore.put('license', license); + Store('license',license); //update with tested flag $rootScope.license_tested = true; + $rootScope.version = license.version; if (license.valid_key !== undefined && license.valid_key === false) { // The license is invalid. Stop the user from logging in. status = 'alert-danger'; diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 99df23631d..aab902398f 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -185,6 +185,11 @@ textarea { font-size: 16px; } +.license-version { + font-size: 18px; + color: @grey-txt; +} + .modal-dialog .ui-accordion .ui-accordion-content { overflow: hidden; } @@ -454,7 +459,7 @@ dd { } .copyright { - padding-top: 18px; + padding-top: 6px; font-weight: normal; text-align: center; } diff --git a/awx/ui/static/lib/ansible/AuthService.js b/awx/ui/static/lib/ansible/AuthService.js index cbf19b01da..b2522a0fac 100644 --- a/awx/ui/static/lib/ansible/AuthService.js +++ b/awx/ui/static/lib/ansible/AuthService.js @@ -11,8 +11,8 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) -.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', - function ($http, $rootScope, $location, $cookieStore, GetBasePath) { +.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store', + function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store) { return { setToken: function (token, expires) { // set the session cookie @@ -63,7 +63,6 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) $cookieStore.remove('token_expires'); $cookieStore.remove('current_user'); $cookieStore.remove('lastPath'); - $cookieStore.remove('license'); $cookieStore.put('userLoggedIn', false); $cookieStore.put('sessionExpired', false); $cookieStore.remove('lastPath', '/home'); @@ -86,9 +85,11 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) }); }, - setLicense: function (license) { + setLicense: function (data) { + var license = data.license_info; + license.version = data.version; license.tested = false; - $cookieStore.put('license', license); + Store('license', license); }, licenseTested: function () { @@ -96,7 +97,9 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) if ($rootScope.license_tested !== undefined) { result = $rootScope.license_tested; } else { - license = $cookieStore.get('license'); + // User may have hit browser refresh + license = Store('license'); + $rootScope.version = license.version; if (license && license.tested !== undefined) { result = license.tested; } else { diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 7fccc482e5..62efc86a82 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -1161,7 +1161,9 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) if (i === 0) { html += " class=\"active\""; } - html += ">" + tab.label + "\n"; + html += ">" + tab.label + "\n"; } html += "\n"; html += "
\n"; diff --git a/awx/ui/static/lib/ansible/license.js b/awx/ui/static/lib/ansible/license.js index 2942a490af..12c5caafbf 100644 --- a/awx/ui/static/lib/ansible/license.js +++ b/awx/ui/static/lib/ansible/license.js @@ -51,11 +51,7 @@ angular.module('License', ['RestServices', 'Utilities', 'FormGenerator', 'Prompt scope.formModalActionLabel = 'OK'; scope.formModalCancelShow = false; scope.formModalInfo = 'Purchase/Extend License'; - scope.formModalHeader = 'Tower License'; - - //$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none'); - //$('#form-modal').addClass('skinny-modal'); - + scope.formModalHeader = "Ansible Tower v." + data.version + ""; // Respond to license button scope.formModalInfoAction = function () { @@ -126,7 +122,7 @@ angular.module('License', ['RestServices', 'Utilities', 'FormGenerator', 'Prompt }) .error(function (data, status) { - ProcessErrors($rootScope, data, status, form, { hdr: 'Error!', + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve license. GET status: ' + status }); }); diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index f35d24f496..dcb4df03a3 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -164,15 +164,15 @@
@@ -374,7 +374,7 @@ target="_blank"> Contact Support