diff --git a/awx/ui/client/legacy-styles/ansible-ui.less b/awx/ui/client/legacy-styles/ansible-ui.less index ec58ca474f..22b188eacc 100644 --- a/awx/ui/client/legacy-styles/ansible-ui.less +++ b/awx/ui/client/legacy-styles/ansible-ui.less @@ -99,7 +99,9 @@ a:focus { color: @blue-dark; text-decoration: none; } - +.btn{ + text-transform: uppercase; +} /* Old style TB default button with grey background */ .btn-grey { color: #333; diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 43ad6627fb..a570f0df38 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -1,11 +1,9 @@ /************************************************* - * Copyright (c) 2015 Ansible, Inc. + * Copyright (c) 2016 Ansible, Inc. * * All Rights Reserved *************************************************/ - - var urlPrefix; if ($basePath) { @@ -34,6 +32,7 @@ import managementJobs from './management-jobs/main'; import jobDetail from './job-detail/main'; // modules +import license from './license/main'; import setupMenu from './setup-menu/main'; import mainMenu from './main-menu/main'; import breadCrumb from './bread-crumb/main'; @@ -46,7 +45,6 @@ import login from './login/main'; import activityStream from './activity-stream/main'; import standardOut from './standard-out/main'; import {JobTemplatesList, JobTemplatesAdd, JobTemplatesEdit} from './controllers/JobTemplates'; -import {LicenseController} from './controllers/License'; import {ScheduleEditController} from './controllers/Schedules'; import {ProjectsList, ProjectsAdd, ProjectsEdit} from './controllers/Projects'; import {OrganizationsList, OrganizationsAdd, OrganizationsEdit} from './controllers/Organizations'; @@ -79,6 +77,7 @@ var tower = angular.module('Tower', [ // 'ngAnimate', 'ngSanitize', 'ngCookies', + license.name, RestServices.name, browserData.name, systemTracking.name, @@ -99,7 +98,6 @@ var tower = angular.module('Tower', [ standardOut.name, 'templates', 'Utilities', - 'LicenseHelper', 'OrganizationFormDefinition', 'UserFormDefinition', 'FormGenerator', @@ -858,21 +856,6 @@ var tower = angular.module('Tower', [ } }). - state('license', { - url: '/license', - templateUrl: urlPrefix + 'partials/license.html', - controller: LicenseController, - ncyBreadcrumb: { - parent: 'setup', - label: 'LICENSE' - }, - resolve: { - features: ['FeaturesService', function(FeaturesService) { - return FeaturesService.get(); - }] - } - }). - state('sockets', { url: '/sockets', templateUrl: urlPrefix + 'partials/sockets.html', @@ -1042,7 +1025,6 @@ var tower = angular.module('Tower', [ $rootScope.$on("$stateChangeStart", function (event, next, nextParams, prev) { - // this line removes the query params attached to a route if(prev && prev.$$route && prev.$$route.name === 'systemTracking'){ @@ -1082,15 +1064,15 @@ var tower = angular.module('Tower', [ if ($rootScope.current_user === undefined || $rootScope.current_user === null) { Authorization.restoreUserInfo(); //user must have hit browser refresh } - if (next && next.$$route && (!/^\/(login|logout)/.test(next.$$route.originalPath))) { - // if not headed to /login or /logout, then check the license - CheckLicense.test(); - } } activateTab(); }); $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { + // catch license expiration notifications immediately after user logs in, redirect + if (fromState.name == 'signIn'){ + CheckLicense.notify(); + } // broadcast event change if editing crud object if ($location.$$path && $location.$$path.split("/")[3] && $location.$$path.split("/")[3] === "schedules") { var list = $location.$$path.split("/")[3]; diff --git a/awx/ui/client/src/controllers/License.js b/awx/ui/client/src/controllers/License.js deleted file mode 100644 index 6bca4f5121..0000000000 --- a/awx/ui/client/src/controllers/License.js +++ /dev/null @@ -1,189 +0,0 @@ -/************************************ - * Copyright (c) 2015 Ansible, Inc. - * - * - * Organizations.js - * - * Controller functions for Organization model. - * - */ -/** - * @ngdoc function - * @name controllers.function:Organizations - * @description This controller's for the Organizations page -*/ - - -export function LicenseController(ClearScope, $location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, - GetBasePath, ProcessErrors, FormatDate, Prompt, Empty, LicenseForm, IsAdmin, CreateDialog, CheckLicense, - TextareaResize, $scope, Wait) { - - ClearScope(); - - $scope.getDefaultHTML = function(license_info) { - var fld, html, - self = this, - generator = GenerateForm; - - self.form = angular.copy(LicenseForm); - - for (fld in self.form.fields) { - if (fld !== 'time_remaining' && fld !== 'license_status' && fld !== 'tower_version') { - if (Empty(license_info[fld])) { - delete self.form.fields[fld]; - } - } - } - - if (!IsAdmin()) { - delete self.form.fields.license_key; - } - - if (license_info.is_aws || Empty(license_info.license_date)) { - delete self.form.fields.license_date; - delete self.form.fields.time_remaining; - } - - html = generator.buildHTML(self.form, { mode: 'edit', showButtons: false }); - return html; - }; - - $scope.loadDefaultScope = function(license_info, version) { - var fld, dt, days, license, - self = this; - - for (fld in self.form.fields) { - if (!Empty(license_info[fld])) { - $scope[fld] = license_info[fld]; - } - } - - $scope.tower_version = version; - - if ($scope.license_date) { - dt = new Date(parseInt($scope.license_date, 10) * 1000); // expects license_date in seconds - $scope.license_date = FormatDate(dt); - $scope.time_remaining = parseInt($scope.time_remaining,10) * 1000; - if ($scope.time_remaining < 0) { - days = 0; - } else { - days = Math.floor($scope.time_remaining / 86400000); - } - $scope.time_remaining = (days!==1) ? $filter('number')(days, 0) + ' days' : $filter('number')(days, 0) + ' day'; // '1 day' and '0 days/2 days' or more - } - - if (parseInt($scope.free_instances) <= 0) { - $scope.free_instances_class = 'field-failure'; - } else { - $scope.free_instances_class = 'field-success'; - } - - license = license_info; - 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) { - $scope.license_status = 'License Expired'; - $scope.status_color = 'license-expired'; - } else if (license.date_warning !== undefined && license.date_warning) { - $scope.license_status = 'License Expiring Soon'; - $scope.status_color = 'license-warning'; - } else if (license.free_instances !== undefined && parseInt(license.free_instances) <= 0) { - $scope.license_status = 'No Available Managed Hosts'; - $scope.status_color = 'license-invalid'; - } else { - $scope.license_status = 'Valid License'; - $scope.status_color = 'license-valid'; - } - }; - - $scope.setLicense = function(license_info, version) { - this.license = license_info; - this.version = version; - }; - - $scope.getLicense = function(){ - return this.license; - }; - - $scope.submitLicenseKey = function() { - CheckLicense.postLicense($scope.license_json, $scope); - }; - - if ($scope.removeLicenseDataReady) { - $scope.removeLicenseDataReady(); - } - $scope.removeLicenseDataReady = $scope.$on('LicenseDataReady', function(e, data) { - var html, version, eula, h; - version = data.version.replace(/-.*$/,''); - $scope.setLicense(data.license_info, version); - html = $scope.getDefaultHTML(data.license_info); - $scope.loadDefaultScope(data.license_info, version); - eula = (data.eula) ? data.eula : "" ; - - e = angular.element(document.getElementById('license-modal-dialog')); - e.empty().html(html); - - $scope.parseType = 'json'; - $scope.license_json = JSON.stringify($scope.license, null, ' '); - $scope.eula = eula; - $scope.eula_agreement = false; - - - h = CheckLicense.getHTML($scope.getLicense(),true).body; - $('#license-modal-dialog #license_tabs').append("
The Ansible Tower license is invalid.
"; - } - else if (this.getRemainingDays(license.time_remaining) <= 0) { - title = "License Expired"; - html = "Thank you for using Ansible Tower. The Ansible Tower license has expired
"; - if (parseInt(license.grace_period_remaining,10) > 86400) { - // trial licenses don't get a grace period - if (license.trial) { - html += "Don't worry — your existing history and content has not been affected, but playbooks will no longer run and new hosts cannot be added. " + - "If you are ready to upgrade, " + contact_us + " or visit " + pricing + " to see all of your license options. Thanks!
"; - } else { - html += "Don't worry — your existing history and content has not been affected, but in " + this.getRemainingDays(license.grace_period_remaining) + " days playbooks will no longer " + - "run and new hosts cannot be added. If you are ready to upgrade, " + contact_us + " " + - "or visit ansible.com/pricing to see all of your license options. Thanks!
"; - } - } else { - html += "Don’t worry — your existing history and content has not been affected, but playbooks will no longer run and new hosts cannot be added. If you are ready to renew or upgrade, contact us " + - "at " + renew + ". Thanks!
"; - } - } - else if (this.getRemainingDays(license.time_remaining) < 15) { - // Warning: license expiring in less than 15 days - title = "License Warning"; - html = "Thank you for using Ansible Tower. The Ansible Tower license " + - "has " + this.getRemainingDays(license.time_remaining) + " days remaining.
"; - // trial licenses don't get a grace period - if (license.trial) { - html += "After this license expires, playbooks will no longer run and hosts cannot be added. If you are ready to upgrade, " + contact_us + " or visit " + pricing + " to see all of your license options. Thanks!
"; - } else { - html += "After this license expires, playbooks will no longer run and hosts cannot be added. If you are ready to renew or upgrade, contact us at " + renew + ". Thanks!
"; - } - - // If there is exactly one day remaining, change "days remaining" - // to "day remaining". - html = html.replace('has 1 days remaining', 'has 1 day remaining'); - } - 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 new hosts can be added. Existing " + - "playbooks can still be run against hosts already in inventory.
" + - "If you are ready to upgrade, contact us at " + renew + ". Thanks!
"; - - } else { - // license is valid. the following text is displayed in the license viewer - title = "Update License"; - html = "The Ansible Tower license is valid.
" + - "If you are ready to upgrade, contact us at " + renew + ". Thanks!
"; - license_is_valid = true; - } - } else { - // No license - title = "Add Your License"; - html = "Now that you’ve successfully installed or upgraded Ansible Tower, the next step is to add a license file. " + - "If you don’t have a license file yet, " + license_link + " to see all of our free and paid license options.
" + - "Get a Free Tower Trial License
"; - } - - if (IsAdmin()) { - html += "Copy and paste the contents of your license in the field below, agree to the End User License Agreement, and click Submit.
"; - } else { - html += "A system administrator can install the new license by choosing View License on the Account Menu and clicking on the Update License tab.
"; - } - - html += "If you are ready to upgrade, please contact us by clicking the button below
+ +Copy and paste the contents of your license in the field below, agree to the End User License Agreement, and click submit.
+ +