diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 0042de8cd9..9a2e38ccfd 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -233,6 +233,7 @@ var tower = angular.module('Tower', [ url: '/home', templateUrl: urlPrefix + 'partials/home.html', controller: Home, + params: {licenseMissing: null}, data: { activityStream: true }, @@ -789,6 +790,10 @@ var tower = angular.module('Tower', [ if (fromState.name === 'signIn'){ CheckLicense.notify(); } + + if(fromState.name === 'license' && toParams.hasOwnProperty('licenseMissing')){ + $rootScope.licenseMissing = toParams.licenseMissing; + } var list, id; // broadcast event change if editing crud object if ($location.$$path && $location.$$path.split("/")[3] && $location.$$path.split("/")[3] === "schedules") { diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 291ae0d0a7..61ab016946 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -6,9 +6,9 @@ export default ['Wait', '$state', '$scope', '$rootScope', '$location', 'GetBasePath', - 'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window', + 'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window', '$filter', function( Wait, $state, $scope, $rootScope, $location, GetBasePath, Rest, - ProcessErrors, CheckLicense, moment, $window){ + ProcessErrors, CheckLicense, moment, $window, $filter){ $scope.getKey = function(event){ // Mimic HTML5 spec, show filename $scope.fileName = event.target.files[0].name; @@ -40,33 +40,36 @@ export default $window.open('https://www.ansible.com/license', '_blank'); }; - $scope.newLicense = {}; - $scope.submit = function(){ - Wait('start'); - CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula) - .success(function(){ - reset(); - init(); - $scope.success = true; - // for animation purposes - var successTimeout = setTimeout(function(){ - $scope.success = false; - clearTimeout(successTimeout); - }, 4000); - if($rootScope.licenseMissing === true){ - $rootScope.licenseMissing = false; - $state.go('dashboard'); - } - else{ - $rootScope.licenseMissing = false; - } - }); - }; - var calcDaysRemaining = function(seconds){ - // calculate the number of days remaining on the license - var duration = moment.duration(seconds, 'seconds'); - return duration.days(); - }; + $scope.newLicense = {}; + $scope.submit = function(){ + Wait('start'); + CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula) + .success(function(){ + reset(); + init(); + if($rootScope.licenseMissing === true){ + $state.go('dashboard', { + licenseMissing: false + }); + } + else{ + $scope.success = true; + $rootScope.licenseMissing = false; + // for animation purposes + var successTimeout = setTimeout(function(){ + $scope.success = false; + clearTimeout(successTimeout); + }, 4000); + } + }); + }; + var calcDaysRemaining = function(seconds){ + // calculate the number of days remaining on the license + var duration = moment.duration(seconds, 'seconds').days(); + duration = (duration!==1) ? $filter('number')(duration, 0) + ' days' : $filter('number')(duration, 0) + ' day'; + return duration; + }; + var calcExpiresOn = function(days){ // calculate the expiration date of the license diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index fb1e88cbe1..f6d44b3b97 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -44,7 +44,7 @@