diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 2cd07a5300..c49c4165e1 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -9,10 +9,10 @@ import {N_} from "../i18n"; export default ['Wait', '$state', '$scope', '$rootScope', 'ProcessErrors', 'CheckLicense', 'moment','$window', - 'ConfigService', 'FeaturesService', 'pendoService', 'i18n', + 'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config', function( Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, $window, ConfigService, - FeaturesService, pendoService, i18n){ + FeaturesService, pendoService, i18n, config){ var calcDaysRemaining = function(seconds){ // calculate the number of days remaining on the license @@ -38,18 +38,13 @@ export default // license/license.partial.html compares fileName $scope.fileName = N_("No file selected."); $scope.title = $rootScope.licenseMissing ? ("Tower " + i18n._("License")) : i18n._("License Management"); - Wait('start'); - ConfigService.delete(); - ConfigService.getConfig().then(function(config){ - $scope.license = config; - $scope.license.version = config.version.split('-')[0]; - $scope.time = {}; - $scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining); - $scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date); - $scope.valid = CheckLicense.valid($scope.license.license_info); - $scope.compliant = $scope.license.license_info.compliant; - Wait('stop'); - }); + $scope.license = config; + $scope.license.version = config.version.split('-')[0]; + $scope.time = {}; + $scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining); + $scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date); + $scope.valid = CheckLicense.valid($scope.license.license_info); + $scope.compliant = $scope.license.license_info.compliant; }; init(); diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index b8d434f7ce..82abcf3ba3 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -98,7 +98,7 @@ -
+
License File
Browse diff --git a/awx/ui/client/src/license/license.route.js b/awx/ui/client/src/license/license.route.js index 78ab6e4348..cd09b28ad5 100644 --- a/awx/ui/client/src/license/license.route.js +++ b/awx/ui/client/src/license/license.route.js @@ -24,6 +24,15 @@ export default { return CheckLicense.notify(); } - }] + }], + config: ['ConfigService', 'CheckLicense', '$rootScope', + function(ConfigService, CheckLicense, $rootScope) { + ConfigService.delete(); + return ConfigService.getConfig() + .then(function(config){ + $rootScope.licenseMissing = (CheckLicense.valid(config.license_info) === false) ? true : false; + return config; + }); + }] }, }; diff --git a/awx/ui/tests/spec/license/license.controller-test.js b/awx/ui/tests/spec/license/license.controller-test.js index 060fcd5b58..d2bde80536 100644 --- a/awx/ui/tests/spec/license/license.controller-test.js +++ b/awx/ui/tests/spec/license/license.controller-test.js @@ -5,7 +5,8 @@ describe('Controller: LicenseController', () => { let scope, LicenseController, ConfigService, - ProcessErrors; + ProcessErrors, + config; beforeEach(angular.mock.module('Tower')); beforeEach(angular.mock.module('license', ($provide) => { @@ -14,40 +15,33 @@ describe('Controller: LicenseController', () => { 'delete' ]); - ConfigService.getConfig.and.returnValue({ - then: function(callback){ - return callback({ - license_info: { - time_remaining: 1234567 // seconds - }, - version: '3.1.0-devel' - }); - } - }); + config = { + license_info: { + time_remaining: 1234567 // seconds + }, + version: '3.1.0-devel' + }; ProcessErrors = jasmine.createSpy('ProcessErrors'); $provide.value('ConfigService', ConfigService); $provide.value('ProcessErrors', ProcessErrors); + $provide.value('config', config); })); - beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_) => { + beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_) => { scope = $rootScope.$new(); ConfigService = _ConfigService_; ProcessErrors = _ProcessErrors_; + config = _config_; LicenseController = $controller('licenseController', { $scope: scope, ConfigService: ConfigService, - ProcessErrors: ProcessErrors + ProcessErrors: ProcessErrors, + config: config }); })); - // Suites - it('should GET a config object on initialization', ()=>{ - expect(ConfigService.delete).toHaveBeenCalled(); - expect(ConfigService.getConfig).toHaveBeenCalled(); - }); - xit('should show correct expiration date', ()=>{ let date = new Date(), options = {