Use ConfigService to get version for doc links

This commit is contained in:
gconsidine
2017-08-01 13:40:53 -04:00
parent 214b72bb8d
commit 384637fce8

View File

@@ -1,17 +1,22 @@
export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', 'SmartSearchService', 'i18n', 'ConfigModel', export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', 'SmartSearchService', 'i18n', 'ConfigService',
function($stateParams, $scope, $state, GetBasePath, qs, SmartSearchService, i18n, ConfigModel) { function($stateParams, $scope, $state, GetBasePath, qs, SmartSearchService, i18n, configService) {
let path, let path,
defaults, defaults,
queryset, queryset,
stateChangeSuccessListener, stateChangeSuccessListener;
configModel = new ConfigModel();
configModel.request('get') configService.getConfig()
.then(() => init()); .then(config => init(config));
function init() { function init(config) {
let version = configModel.getTruncatedVersion() || 'latest'; let version;
try {
version = config.version.split('-')[0];
} catch (err) {
version = 'latest';
}
$scope.documentationLink = `http://docs.ansible.com/ansible-tower/${version}/html/userguide/search_sort.html`; $scope.documentationLink = `http://docs.ansible.com/ansible-tower/${version}/html/userguide/search_sort.html`;