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