mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 14:09:28 -02:30
Add rh username and pass to license form
This commit is contained in:
@@ -5,29 +5,29 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$state', '$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors',
|
['$state', '$rootScope', 'Rest', 'GetBasePath',
|
||||||
'ConfigService',
|
'ConfigService', '$q',
|
||||||
function($state, $rootScope, Rest, GetBasePath, ProcessErrors,
|
function($state, $rootScope, Rest, GetBasePath,
|
||||||
ConfigService){
|
ConfigService, $q){
|
||||||
return {
|
return {
|
||||||
get: function() {
|
get: function() {
|
||||||
var config = ConfigService.get();
|
var config = ConfigService.get();
|
||||||
return config.license_info;
|
return config.license_info;
|
||||||
},
|
},
|
||||||
|
|
||||||
post: function(license, eula){
|
post: function(payload, eula){
|
||||||
var defaultUrl = GetBasePath('config');
|
var defaultUrl = GetBasePath('config');
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
var data = license;
|
var data = payload;
|
||||||
data.eula_accepted = eula;
|
data.eula_accepted = eula;
|
||||||
|
|
||||||
return Rest.post(JSON.stringify(data))
|
return Rest.post(JSON.stringify(data))
|
||||||
.then((response) =>{
|
.then((response) =>{
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
.catch(({res, status}) => {
|
.catch(() => {
|
||||||
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',
|
return $q.reject();
|
||||||
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
valid: function(license) {
|
valid: function(license) {
|
||||||
|
|||||||
@@ -26,6 +26,21 @@
|
|||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
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 {
|
.License-submit--success.ng-hide-add, .License-submit--success.ng-hide-remove {
|
||||||
transition: all ease-in-out 0.5s;
|
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;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.License-file--container {
|
.License-file--container {
|
||||||
|
display: flex;
|
||||||
input[type=file] {
|
input[type=file] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -148,3 +165,21 @@
|
|||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
font-weight: bold;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export default
|
|||||||
|
|
||||||
const reset = function() {
|
const reset = function() {
|
||||||
document.getElementById('License-form').reset();
|
document.getElementById('License-form').reset();
|
||||||
|
$scope.rhPassword = null;
|
||||||
|
$scope.rhUsername = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = function(config) {
|
const init = function(config) {
|
||||||
@@ -87,7 +89,7 @@ export default
|
|||||||
// HTML5 spec doesn't provide a way to customize file input css
|
// 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
|
// So we hide the default input, show our own, and simulate clicks to the hidden input
|
||||||
$scope.fakeClick = function() {
|
$scope.fakeClick = function() {
|
||||||
if($scope.user_is_superuser) {
|
if($scope.user_is_superuser && (!$scope.rhUsername || $scope.rhUsername === '') && (!$scope.rhPassword || $scope.rhPassword === '')) {
|
||||||
$('#License-file').click();
|
$('#License-file').click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -96,44 +98,58 @@ export default
|
|||||||
$window.open('https://www.ansible.com/license', '_blank');
|
$window.open('https://www.ansible.com/license', '_blank');
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submit = function() {
|
$scope.submit = function() {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula)
|
$scope.licenseError = false;
|
||||||
.then((licenseInfo) => {
|
let payload = {};
|
||||||
reset();
|
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.delete();
|
||||||
ConfigService.getConfig(licenseInfo)
|
ConfigService.getConfig(licenseInfo)
|
||||||
.then(function(config) {
|
.then(function(config) {
|
||||||
|
|
||||||
if ($rootScope.licenseMissing === true) {
|
if ($rootScope.licenseMissing === true) {
|
||||||
if ($scope.newLicense.pendo) {
|
if ($scope.newLicense.pendo) {
|
||||||
pendoService.updatePendoTrackingState('detailed');
|
pendoService.updatePendoTrackingState('detailed');
|
||||||
pendoService.issuePendoIdentity();
|
pendoService.issuePendoIdentity();
|
||||||
} else {
|
} else {
|
||||||
pendoService.updatePendoTrackingState('off');
|
pendoService.updatePendoTrackingState('off');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.newLicense.insights) {
|
if ($scope.newLicense.insights) {
|
||||||
insightsEnablementService.updateInsightsTrackingState(true);
|
insightsEnablementService.updateInsightsTrackingState(true);
|
||||||
} else {
|
} else {
|
||||||
insightsEnablementService.updateInsightsTrackingState(false);
|
insightsEnablementService.updateInsightsTrackingState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$state.go('dashboard', {
|
$state.go('dashboard', {
|
||||||
licenseMissing: false
|
licenseMissing: false
|
||||||
});
|
|
||||||
} else {
|
|
||||||
init(config);
|
|
||||||
$scope.success = true;
|
|
||||||
$rootScope.licenseMissing = false;
|
|
||||||
// for animation purposes
|
|
||||||
const successTimeout = setTimeout(function() {
|
|
||||||
$scope.success = false;
|
|
||||||
clearTimeout(successTimeout);
|
|
||||||
}, 4000);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} 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;
|
||||||
|
});
|
||||||
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -94,19 +94,44 @@
|
|||||||
2
|
2
|
||||||
</span>
|
</span>
|
||||||
<span class="License-helperText">
|
<span class="License-helperText">
|
||||||
<translate>Choose your license file, agree to the End User License Agreement, and click submit.</translate>
|
<translate>Choose your license file or provide your Red Hat subscription credentials, agree to the End User License Agreement, and click submit.</translate>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="License-form" name="uploadlicense">
|
<form id="License-form" name="uploadlicense">
|
||||||
<div class="License-subTitleText">
|
<div class="License-subTitleText">
|
||||||
<span class="Form-requiredAsterisk">*</span>
|
<span class="Form-requiredAsterisk">*</span>
|
||||||
<translate>License File</translate>
|
<translate>License</translate>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group License-file--container">
|
<div class="input-group License-file--container">
|
||||||
<span class="btn btn-primary" ng-click="fakeClick()" ng-disabled="!user_is_superuser" translate>Browse</span>
|
<div class="License-file--left">
|
||||||
<span class="License-fileName" ng-class="{'License-helperText' : fileName == 'No file selected.'}">{{fileName|translate}}</span>
|
<div class="d-block w-100">
|
||||||
<input id="License-file" class="form-control" type="file" file-on-change="getKey"/>
|
<div class="License-helperText License-licenseStepHelp" translate>Upload a license file</div>
|
||||||
|
<div class="License-filePicker">
|
||||||
|
<span class="btn btn-primary" ng-click="fakeClick()" ng-disabled="!user_is_superuser || (rhUsername && rhUsername.length > 0) || (rhPassword && rhPassword.length > 0)" translate>Browse</span>
|
||||||
|
<span class="License-fileName" ng-class="{'License-helperText' : fileName == 'No file selected.'}">{{fileName|translate}}</span>
|
||||||
|
<input id="License-file" class="form-control" type="file" file-on-change="getKey"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="License-file--middle License-helperText" translate>
|
||||||
|
<div class="License-separator"></div>
|
||||||
|
<div translate>OR</div>
|
||||||
|
<div class="License-separator"></div>
|
||||||
|
</div>
|
||||||
|
<div class="License-file--right">
|
||||||
|
<div class="d-block w-100">
|
||||||
|
<div class="License-helperText License-licenseStepHelp" translate>Provide your Red Hat subscription credentials</div>
|
||||||
|
<div>
|
||||||
|
<label class="LoginModal-label d-block" translate>USERNAME</label>
|
||||||
|
<input class="w-100" type="text" ng-model="rhUsername" ng-disabled="newLicense.file" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="LoginModal-label d-block" translate>PASSWORD</label>
|
||||||
|
<input class="w-100" type="password" ng-model="rhPassword" ng-disabled="newLicense.file" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="License-subTitleText">
|
<div class="License-subTitleText">
|
||||||
<span class="Form-requiredAsterisk">*</span>
|
<span class="Form-requiredAsterisk">*</span>
|
||||||
@@ -142,8 +167,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="newLicense.file.license_key == null || newLicense.eula == null || !user_is_superuser" translate>Submit</button>
|
<button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="(!newLicense.file && (!rhUsername || !rhPassword)) || (newLicense.file && newLicense.file.license_key == null) || newLicense.eula == null || !user_is_superuser" translate>Submit</button>
|
||||||
<span ng-show="success == true" class="License-greenText License-submit--success pull-right" translate>Save successful!</span>
|
<span ng-show="success == true" class="License-greenText License-submit--success pull-right" translate>Save successful!</span>
|
||||||
|
<span ng-show="licenseError == true" class="License-redText License-submit--failure pull-right" translate>Invalid License - Save unsuccessful</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user