mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
Add rh username and pass to license form
This commit is contained in:
parent
846e67ee6a
commit
900fcbf87e
@ -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) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
});
|
||||
};
|
||||
}];
|
||||
|
||||
@ -94,19 +94,44 @@
|
||||
2
|
||||
</span>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<form id="License-form" name="uploadlicense">
|
||||
<div class="License-subTitleText">
|
||||
<span class="Form-requiredAsterisk">*</span>
|
||||
<translate>License File</translate>
|
||||
<translate>License</translate>
|
||||
</div>
|
||||
<div class="input-group License-file--container">
|
||||
<span class="btn btn-primary" ng-click="fakeClick()" ng-disabled="!user_is_superuser" 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 class="License-file--left">
|
||||
<div class="d-block w-100">
|
||||
<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 class="License-subTitleText">
|
||||
<span class="Form-requiredAsterisk">*</span>
|
||||
@ -142,8 +167,9 @@
|
||||
</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="licenseError == true" class="License-redText License-submit--failure pull-right" translate>Invalid License - Save unsuccessful</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user