diff --git a/awx/ui/client/src/license/checkLicense.factory.js b/awx/ui/client/src/license/checkLicense.factory.js index 04a658fa82..d5cbc0ed44 100644 --- a/awx/ui/client/src/license/checkLicense.factory.js +++ b/awx/ui/client/src/license/checkLicense.factory.js @@ -5,29 +5,29 @@ *************************************************/ export default - ['$state', '$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', - 'ConfigService', - function($state, $rootScope, Rest, GetBasePath, ProcessErrors, - ConfigService){ + ['$state', '$rootScope', 'Rest', 'GetBasePath', + 'ConfigService', '$q', + function($state, $rootScope, Rest, GetBasePath, + ConfigService, $q){ return { get: function() { var config = ConfigService.get(); return config.license_info; }, - post: function(license, eula){ + post: function(payload, eula){ var defaultUrl = GetBasePath('config'); Rest.setUrl(defaultUrl); - var data = license; + var data = payload; data.eula_accepted = eula; + return Rest.post(JSON.stringify(data)) .then((response) =>{ return response.data; }) - .catch(({res, status}) => { - ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', - msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status}); - }); + .catch(() => { + return $q.reject(); + }); }, valid: function(license) { diff --git a/awx/ui/client/src/license/license.block.less b/awx/ui/client/src/license/license.block.less index 08a6c624a6..f274b903a9 100644 --- a/awx/ui/client/src/license/license.block.less +++ b/awx/ui/client/src/license/license.block.less @@ -26,6 +26,21 @@ display: block; width: 100%; } +.License-file--left { + display: flex; + flex:1; + overflow: hidden; +} +.License-file--middle { + display: flex; + flex: 0 0 auto; + padding: 0px 20px; + flex-direction: column; +} +.License-file--right { + display: flex; + flex:1; +} .License-submit--success.ng-hide-add, .License-submit--success.ng-hide-remove { transition: all ease-in-out 0.5s; } @@ -109,10 +124,12 @@ } } -.License-submit--success{ +.License-submit--success, .License-submit--failure{ + line-height: 33px; margin: 0; } .License-file--container { + display: flex; input[type=file] { display: none; } @@ -148,3 +165,21 @@ padding: 10px 0; font-weight: bold; } + +.License-separator { + display: flex; + flex: 1; + background: linear-gradient(#d7d7d7, #d7d7d7) no-repeat center/2px 100%; +} + +.License-licenseStepHelp { + font-size: 12px; + font-style: italic; + margin-bottom: 10px; +} + +.License-filePicker { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index ac80686a4f..7809a664f2 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -34,6 +34,8 @@ export default const reset = function() { document.getElementById('License-form').reset(); + $scope.rhPassword = null; + $scope.rhUsername = null; }; const init = function(config) { @@ -87,7 +89,7 @@ export default // 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() { - if($scope.user_is_superuser) { + if($scope.user_is_superuser && (!$scope.rhUsername || $scope.rhUsername === '') && (!$scope.rhPassword || $scope.rhPassword === '')) { $('#License-file').click(); } }; @@ -96,44 +98,58 @@ export default $window.open('https://www.ansible.com/license', '_blank'); }; - $scope.submit = function() { - Wait('start'); - CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula) - .then((licenseInfo) => { - reset(); + $scope.submit = function() { + Wait('start'); + $scope.licenseError = false; + let payload = {}; + if ($scope.newLicense.file) { + payload = $scope.newLicense.file; + } else if ($scope.rhUsername && $scope.rhPassword) { + payload = { + rh_password: $scope.rhPassword, + rh_username: $scope.rhUsername + }; + } + CheckLicense.post(payload, $scope.newLicense.eula) + .then((licenseInfo) => { + reset(); - ConfigService.delete(); - ConfigService.getConfig(licenseInfo) - .then(function(config) { + ConfigService.delete(); + ConfigService.getConfig(licenseInfo) + .then(function(config) { - if ($rootScope.licenseMissing === true) { - if ($scope.newLicense.pendo) { - pendoService.updatePendoTrackingState('detailed'); - pendoService.issuePendoIdentity(); - } else { - pendoService.updatePendoTrackingState('off'); - } + if ($rootScope.licenseMissing === true) { + if ($scope.newLicense.pendo) { + pendoService.updatePendoTrackingState('detailed'); + pendoService.issuePendoIdentity(); + } else { + pendoService.updatePendoTrackingState('off'); + } - if ($scope.newLicense.insights) { - insightsEnablementService.updateInsightsTrackingState(true); - } else { - insightsEnablementService.updateInsightsTrackingState(false); - } + if ($scope.newLicense.insights) { + insightsEnablementService.updateInsightsTrackingState(true); + } else { + insightsEnablementService.updateInsightsTrackingState(false); + } - $state.go('dashboard', { - licenseMissing: false - }); - } else { - init(config); - $scope.success = true; - $rootScope.licenseMissing = false; - // for animation purposes - const successTimeout = setTimeout(function() { - $scope.success = false; - clearTimeout(successTimeout); - }, 4000); - } + $state.go('dashboard', { + licenseMissing: false }); + } else { + init(config); + $scope.success = true; + $rootScope.licenseMissing = false; + // for animation purposes + const successTimeout = setTimeout(function() { + $scope.success = false; + clearTimeout(successTimeout); + }, 4000); + } }); - }; + }).catch(() => { + Wait('stop'); + reset(); + $scope.licenseError = true; + }); + }; }]; diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index 96b44b6bb9..7c3e5e6e4d 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -94,19 +94,44 @@ 2 - Choose your license file, agree to the End User License Agreement, and click submit. + Choose your license file or provide your Red Hat subscription credentials, agree to the End User License Agreement, and click submit.
* - License File + License
- Browse - {{fileName|translate}} - +
+
+
Upload a license file
+
+ Browse + {{fileName|translate}} + +
+
+
+
+
+
OR
+
+
+
+
+
Provide your Red Hat subscription credentials
+
+ + +
+
+ + +
+
+
* @@ -142,8 +167,9 @@
- + Save successful! + Invalid License - Save unsuccessful