diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 53a6a7746f..291ae0d0a7 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -5,91 +5,91 @@ *************************************************/ export default - ['Wait', '$state', '$scope', '$rootScope', '$location', 'GetBasePath', - 'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window', - function( Wait, $state, $scope, $rootScope, $location, GetBasePath, Rest, - ProcessErrors, CheckLicense, moment, $window){ - $scope.getKey = function(event){ - // Mimic HTML5 spec, show filename - $scope.fileName = event.target.files[0].name; - // Grab the key from the raw license file - var raw = new FileReader(); - // readAsFoo runs async - raw.onload = function(){ - try { - $scope.newLicense.file = JSON.parse(raw.result); - } - catch(err) { - ProcessErrors($rootScope, null, null, null, {msg: 'Invalid file format. Please upload valid JSON.'}); - } - }; - try { - raw.readAsText(event.target.files[0]); - } - catch(err) { - ProcessErrors($rootScope, null, null, null, {msg: 'Invalid file format. Please upload valid JSON.'}); - } - }; - // HTML5 spec doesn't provide a way to customize file input css - // So we hide the default input, show our own, and simulate clicks to the hidden input - $scope.fakeClick = function(){ - $('#License-file').click(); - }; + ['Wait', '$state', '$scope', '$rootScope', '$location', 'GetBasePath', + 'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window', + function( Wait, $state, $scope, $rootScope, $location, GetBasePath, Rest, + ProcessErrors, CheckLicense, moment, $window){ + $scope.getKey = function(event){ + // Mimic HTML5 spec, show filename + $scope.fileName = event.target.files[0].name; + // Grab the key from the raw license file + var raw = new FileReader(); + // readAsFoo runs async + raw.onload = function(){ + try { + $scope.newLicense.file = JSON.parse(raw.result); + } + catch(err) { + ProcessErrors($rootScope, null, null, null, {msg: 'Invalid file format. Please upload valid JSON.'}); + } + }; + try { + raw.readAsText(event.target.files[0]); + } + catch(err) { + ProcessErrors($rootScope, null, null, null, {msg: 'Invalid file format. Please upload valid JSON.'}); + } + }; + // HTML5 spec doesn't provide a way to customize file input css + // So we hide the default input, show our own, and simulate clicks to the hidden input + $scope.fakeClick = function(){ + $('#License-file').click(); + }; - $scope.downloadLicense = function(){ + $scope.downloadLicense = function(){ $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(ms){ - // calculate the number of days remaining on the license - var duration = moment.duration(ms); - return duration.days(); - }; + $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(); + }; - var calcExpiresOn = function(days){ - // calculate the expiration date of the license - return moment().add(days, 'days').calendar(); - }; - var init = function(){ - $scope.fileName = "No file selected."; - $scope.title = $rootScope.licenseMissing ? "Tower License" : "License Management"; - Wait('start'); - CheckLicense.get() - .then(function(res){ - $scope.license = res.data; - $scope.license.version = res.data.version.split('-')[0]; - $scope.time = {}; - $scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining); - $scope.time.expiresOn = calcExpiresOn($scope.time.remaining); - $scope.valid = CheckLicense.valid($scope.license.license_info); - Wait('stop'); - }); - }; - var reset = function(){ - document.getElementById('License-form').reset(); - }; - init(); - } - ]; + var calcExpiresOn = function(days){ + // calculate the expiration date of the license + return moment().add(days, 'days').calendar(); + }; + var init = function(){ + $scope.fileName = "No file selected."; + $scope.title = $rootScope.licenseMissing ? "Tower License" : "License Management"; + Wait('start'); + CheckLicense.get() + .then(function(res){ + $scope.license = res.data; + $scope.license.version = res.data.version.split('-')[0]; + $scope.time = {}; + $scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining); + $scope.time.expiresOn = calcExpiresOn($scope.time.remaining); + $scope.valid = CheckLicense.valid($scope.license.license_info); + Wait('stop'); + }); + }; + var reset = function(){ + document.getElementById('License-form').reset(); + }; + init(); + } + ]; diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index f666b2a9ce..fb1e88cbe1 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -118,8 +118,8 @@
- Save successful! + Save successful!