diff --git a/awx/ui/client/legacy/styles/ansible-ui.less b/awx/ui/client/legacy/styles/ansible-ui.less index 708cc44496..a85621fd9b 100644 --- a/awx/ui/client/legacy/styles/ansible-ui.less +++ b/awx/ui/client/legacy/styles/ansible-ui.less @@ -1595,7 +1595,7 @@ tr td button i { padding: 20px 0; .alert { - padding: 10px; + padding: 0px; margin: 0; word-wrap: break-word; } diff --git a/awx/ui/client/src/license/license.block.less b/awx/ui/client/src/license/license.block.less index bc7008e7e6..f86d323ab8 100644 --- a/awx/ui/client/src/license/license.block.less +++ b/awx/ui/client/src/license/license.block.less @@ -183,10 +183,13 @@ overflow: hidden; } +.License-rhCredField { + margin-bottom: 10px; +} + .License-label { color: @field-label; font-weight: 400; - margin-top: 10px; } .License-action { @@ -198,3 +201,90 @@ .License-actionError { flex: 1; } + +.License-subSelectorModal { + height: 100%; + width: 100%; + position: fixed; + top: 0; + left: 0; + background: rgba(0, 0, 0, 0.3); + z-index: 1040; + display: flex; + align-items: center; + justify-content: center; +} + +.License-modal { + width: 750px; +} + +.License-modalBody { + border: 1px solid @b7grey; + max-height: 550px; + overflow: scroll; + border-radius: 4px; +} + +.License-modalRow { + display: flex; + padding: 10px; +} + +.License-modalRow:not(:last-of-type) { + border-bottom: 1px solid @b7grey; +} + +.License-modalRowRadio { + flex: 0 0 40px; + display: flex; + align-items: center; +} + +.License-trialTag { + font-weight: 100; + background-color: #ebebeb; + border-radius: 5px; + color: #606060; + font-size: 10px; + margin-right: 10px; + padding: 3px 9px; + line-height: 14px; + word-break: keep-all; + display: inline-flex; +} + +.License-introText { + margin-bottom: 10px; +} + +.License-getLicensesButton { + display: flex; + justify-content: flex-end; + margin-bottom: 20px; +} + +.License-checkboxLabel { + margin-left: 5px; + font-weight: normal; +} + +.License-modalRowDetails { + flex: 1; +} + +.License-modalRowDetailsLabel { + font-weight: normal; + width: 100%; +} + +.License-modalRowDetailsRow { + margin-bottom: 10px; +} + +.License-modalRowDetails--50 { + display: flex; + flex-basis: 50%; + align-items: center; + line-height: 21px; +} diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 318e28c864..3b1f3496ce 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -32,11 +32,9 @@ export default }; const reset = function() { - document.getElementById('License-form').reset(); $scope.newLicense.eula = undefined; - if (!$scope.licenseError) { - $scope.rhCreds = {}; - } + $scope.rhCreds = {}; + $scope.selectedLicense = {}; }; const initVars = (config) => { @@ -56,6 +54,7 @@ export default $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; + $scope.selectedLicense = {}; $scope.newLicense = { pendo: true, insights: true @@ -131,18 +130,60 @@ export default } }; + $scope.lookupLicenses = () => { + if ($scope.rhCreds.username && $scope.rhCreds.password) { + Wait('start'); + ConfigService.getSubscriptions($scope.rhCreds.username, $scope.rhCreds.password) + .then(({data}) => { + Wait('stop'); + if (data && data.length > 0) { + $scope.rhLicenses = data; + if ($scope.selectedLicense.fullLicense) { + $scope.selectedLicense.modalKey = $scope.selectedLicense.fullLicense.license_key; + } + $scope.showLicenseModal = true; + } else { + ProcessErrors($scope, data, status, null, { + hdr: i18n._('No Licenses Found'), + msg: i18n._('We were unable to locate licenses associated with this account') + }); + } + }) + .catch(({data, status}) => { + Wait('stop'); + ProcessErrors($scope, data, status, null, { + hdr: i18n._('Error Fetching Licenses') + }); + }); + } + }; + + $scope.confirmLicenseSelection = () => { + $scope.showLicenseModal = false; + $scope.selectedLicense.fullLicense = $scope.rhLicenses.find((license) => { + return license.license_key === $scope.selectedLicense.modalKey; + }); + $scope.selectedLicense.modalKey = undefined; + }; + + $scope.cancelLicenseLookup = () => { + $scope.showLicenseModal = false; + $scope.selectedLicense.modalKey = undefined; + }; + $scope.submit = function() { Wait('start'); - $scope.licenseError = false; let payload = {}; if ($scope.newLicense.file) { payload = $scope.newLicense.file; - } else if ($scope.rhCreds.username && $scope.rhCreds.password) { - payload = { - rh_password: $scope.rhCreds.password, - rh_username: $scope.rhCreds.username - }; + } else if ($scope.selectedLicense.fullLicense) { + payload = $scope.selectedLicense.fullLicense; + if ($scope.rhCreds.username && $scope.rhCreds.password) { + payload.rh_password = $scope.rhCreds.password; + payload.rh_username = $scope.rhCreds.username; + } } + CheckLicense.post(payload, $scope.newLicense.eula) .then((licenseInfo) => { reset(); @@ -179,9 +220,11 @@ export default }, 4000); } }); - }).catch((data) => { + }).catch(({data, status}) => { Wait('stop'); - $scope.licenseError = data.error; + ProcessErrors($scope, data, status, null, { + hdr: i18n._('Error Applying License') + }); }); }; }]; diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index 7b857ad506..924ec5c459 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -75,118 +75,193 @@