mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 06:58:06 -03:30
Moves initial system settings rest call out to resolve
This commit is contained in:
parent
608567795d
commit
113622c05e
@ -201,7 +201,7 @@ class ApiV2SubscriptionView(APIView):
|
||||
getattr(getattr(exc, 'response', None), 'status_code', None) == 401
|
||||
):
|
||||
msg = _("The provided credentials are invalid (HTTP 401).")
|
||||
if isinstance(exc, ValueError) and exc.args:
|
||||
if isinstance(exc, (ValueError, OSError)) and exc.args:
|
||||
msg = exc.args[0]
|
||||
logger.exception(smart_text(u"Invalid license submitted."),
|
||||
extra=dict(actor=request.user.username))
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
import {N_} from "../i18n";
|
||||
|
||||
export default
|
||||
['Wait', '$state', '$scope', '$rootScope', 'ProcessErrors', 'CheckLicense', 'moment', 'Rest', '$timeout',
|
||||
'$window', 'ConfigService', 'pendoService', 'insightsEnablementService', 'i18n', 'config', 'GetBasePath',
|
||||
function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, Rest, $timeout,
|
||||
$window, ConfigService, pendoService, insightsEnablementService, i18n, config, GetBasePath) {
|
||||
['Wait', '$state', '$scope', '$rootScope', 'ProcessErrors', 'CheckLicense', 'moment', '$timeout', 'Rest',
|
||||
'$window', 'ConfigService', 'pendoService', 'insightsEnablementService', 'i18n', 'config', 'rhCreds', 'GetBasePath',
|
||||
function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, $timeout, Rest,
|
||||
$window, ConfigService, pendoService, insightsEnablementService, i18n, config, rhCreds, GetBasePath) {
|
||||
|
||||
const calcDaysRemaining = function(seconds) {
|
||||
// calculate the number of days remaining on the license
|
||||
@ -61,9 +61,18 @@ export default
|
||||
};
|
||||
|
||||
$scope.rhCreds = {};
|
||||
|
||||
if (rhCreds.REDHAT_USERNAME && rhCreds.REDHAT_USERNAME !== "") {
|
||||
$scope.rhCreds.username = rhCreds.REDHAT_USERNAME;
|
||||
}
|
||||
|
||||
if (rhCreds.REDHAT_PASSWORD && rhCreds.REDHAT_PASSWORD !== "") {
|
||||
$scope.rhCreds.password = rhCreds.REDHAT_PASSWORD;
|
||||
$scope.showPlaceholderPassword = true;
|
||||
}
|
||||
};
|
||||
|
||||
const init = (config) => {
|
||||
const updateRHCreds = (config) => {
|
||||
Rest.setUrl(`${GetBasePath('settings')}system/`);
|
||||
Rest.get()
|
||||
.then(({data}) => {
|
||||
@ -82,7 +91,7 @@ export default
|
||||
});
|
||||
};
|
||||
|
||||
init(config);
|
||||
initVars(config);
|
||||
|
||||
$scope.getKey = function(event) {
|
||||
// Mimic HTML5 spec, show filename
|
||||
@ -210,7 +219,7 @@ export default
|
||||
licenseMissing: false
|
||||
});
|
||||
} else {
|
||||
init(config);
|
||||
updateRHCreds(config);
|
||||
$scope.success = true;
|
||||
$rootScope.licenseMissing = false;
|
||||
// for animation purposes
|
||||
|
||||
@ -42,6 +42,24 @@ export default {
|
||||
return config;
|
||||
});
|
||||
}
|
||||
]
|
||||
],
|
||||
rhCreds: ['Rest', 'GetBasePath', function(Rest, GetBasePath) {
|
||||
Rest.setUrl(`${GetBasePath('settings')}system/`);
|
||||
return Rest.get()
|
||||
.then(({data}) => {
|
||||
const rhCreds = {};
|
||||
if (data.REDHAT_USERNAME && data.REDHAT_USERNAME !== "") {
|
||||
rhCreds.REDHAT_USERNAME = data.REDHAT_USERNAME;
|
||||
}
|
||||
|
||||
if (data.REDHAT_PASSWORD && data.REDHAT_PASSWORD !== "") {
|
||||
rhCreds.REDHAT_PASSWORD = data.REDHAT_PASSWORD;
|
||||
}
|
||||
|
||||
return rhCreds;
|
||||
}).catch(() => {
|
||||
return {};
|
||||
});
|
||||
}]
|
||||
},
|
||||
};
|
||||
|
||||
@ -6,7 +6,8 @@ describe('Controller: LicenseController', () => {
|
||||
LicenseController,
|
||||
ConfigService,
|
||||
ProcessErrors,
|
||||
config;
|
||||
config,
|
||||
rhCreds;
|
||||
|
||||
beforeEach(angular.mock.module('awApp'));
|
||||
beforeEach(angular.mock.module('license', ($provide) => {
|
||||
@ -22,23 +23,31 @@ describe('Controller: LicenseController', () => {
|
||||
version: '3.1.0-devel'
|
||||
};
|
||||
|
||||
rhCreds = {
|
||||
password: '$encrypted$',
|
||||
username: 'foo',
|
||||
}
|
||||
|
||||
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
||||
|
||||
$provide.value('ConfigService', ConfigService);
|
||||
$provide.value('ProcessErrors', ProcessErrors);
|
||||
$provide.value('config', config);
|
||||
$provide.value('rhCreds', rhCreds);
|
||||
}));
|
||||
|
||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_) => {
|
||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_, _rhCreds_) => {
|
||||
scope = $rootScope.$new();
|
||||
ConfigService = _ConfigService_;
|
||||
ProcessErrors = _ProcessErrors_;
|
||||
config = _config_;
|
||||
rhCreds = _rhCreds_;
|
||||
LicenseController = $controller('licenseController', {
|
||||
$scope: scope,
|
||||
ConfigService: ConfigService,
|
||||
ProcessErrors: ProcessErrors,
|
||||
config: config
|
||||
config: config,
|
||||
rhCreds: rhCreds
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user