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 @@
{{title}}
-
Welcome to Ansible Tower! Please complete the steps below to acquire a license.
-
- - 1 - - - Please click the button below to visit Ansible's website to get a Tower license key. - -
- - - -
- - 2 - - - Choose your license file or provide your Red Hat customer credentials, agree to the End User License Agreement, and click submit. - -
- -
-
- * - License -
-
-
-
-
Upload a license file
-
- Browse - {{fileName|translate}} - -
+
Welcome to Ansible Tower! Please complete the steps below to acquire a license.
+
+
+
+
+ + 1 + + + Please click the button below to visit Ansible's website to get a Tower license key. +
-
-
-
-
OR
-
-
-
-
-
Provide your Red Hat customer credentials
-
- - -
-
- -
- - - - -
-
- -
-
+ + + +
+ + 2 + + + Choose your license file, agree to the End User License Agreement, and click submit. + +
+
+ * + License +
+
Upload a license file
+
+ Browse + {{fileName|translate}} +
-
- * - End User License Agreement +
+
+
OR
+
-
{{ license.eula }}
-
+
+
+
+ + Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM. + +
+
+ + +
+
+ +
+ + + + +
+
+ +
+
+
+ GET LICENSES +
+
+
+ Selected +
+ {{selectedLicense.fullLicense.subscription_name}} +
+
+
+
+
+ * + End User License Agreement +
+
{{ license.eula }}
+
+
+ +
+
+
+ Tracking and Analytics +
+
+ + + By default, Tower collects and transmits analytics data on Tower usage to Red Hat. There are two categories of data collected by Tower. For more information, see this Tower documentation page. Uncheck the following boxes to disable this feature. + +
- -
-
-
- Tracking and Analytics -
-
- - - By default, Tower collects and transmits analytics data on Tower usage to Red Hat. There are two categories of data collected by Tower. For more information, see this Tower documentation page. Uncheck the following boxes to disable this feature. - -
-
+
-
- - Automation analytics: This data is used to enhance future releases of the Tower Software and to provide Automation Insights to Tower subscribers. -
+ User analytics: This data is used to enhance future releases of the Tower Software and help streamline customer experience and success. + +
+
+
-
-
- Save successful! - Save unsuccessful - {{licenseError}} -
-
- -
+
+
+
+ Save successful!
- +
+ +
+
+
+ +
diff --git a/awx/ui/client/src/shared/Utilities.js b/awx/ui/client/src/shared/Utilities.js index 8c3a2b9d7b..c731a54bba 100644 --- a/awx/ui/client/src/shared/Utilities.js +++ b/awx/ui/client/src/shared/Utilities.js @@ -238,9 +238,9 @@ angular.module('Utilities', ['RestServices', 'Utilities']) msg = ""; _.forOwn(data, function(value, key) { if (Array.isArray(data[key])) { - msg += `${key}: ${data[key][0]}`; + msg += `${key.toUpperCase()}: ${data[key][0]}`; } else { - msg += `${key} : ${value} `; + msg += `${key.toUpperCase()}: ${value} `; } }); Alert(defaultMsg.hdr, msg); diff --git a/awx/ui/client/src/shared/config/config.service.js b/awx/ui/client/src/shared/config/config.service.js index 910e89c9e4..8432303f8e 100644 --- a/awx/ui/client/src/shared/config/config.service.js +++ b/awx/ui/client/src/shared/config/config.service.js @@ -58,6 +58,11 @@ export default deferred.reject('Config not found.'); } return deferred.promise; + }, + + getSubscriptions: function(username, password) { + Rest.setUrl(`${GetBasePath('config')}subscriptions`); + return Rest.post({ rh_username: username, rh_password: password} ); } }; }