diff --git a/awx/ui/client/src/inventories/insights/insights.controller.js b/awx/ui/client/src/inventories/insights/insights.controller.js index 69cc50e7ed..786df445a1 100644 --- a/awx/ui/client/src/inventories/insights/insights.controller.js +++ b/awx/ui/client/src/inventories/insights/insights.controller.js @@ -33,44 +33,32 @@ function (data, $scope, moment, $state, resourceData) { } if(filter === "solvable"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.maintenance_actions.length > 0){ - return report; - } + return (report.maintenance_actions.length > 0); }); } if(filter === "not_solvable"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.maintenance_actions.length === 0){ - return report; - } + return (report.maintenance_actions.length === 0); }); } if(filter === "critical"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.rule.severity === 'CRITICAL'){ - return report; - } + return (report.rule.severity === 'CRITICAL'); }); } if(filter === "high"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.rule.severity === 'ERROR'){ - return report; - } + return (report.rule.severity === 'ERROR'); }); } if(filter === "medium"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.rule.severity === 'WARN'){ - return report; - } + return (report.rule.severity === 'WARN'); }); } if(filter === "low"){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){ - if(report.rule.severity === 'INFO'){ - return report; - } + return (report.rule.severity === 'INFO'); }); } }; diff --git a/awx/ui/client/src/inventories/insights/insights.partial.html b/awx/ui/client/src/inventories/insights/insights.partial.html index c161c49fea..d0c98ae65e 100644 --- a/awx/ui/client/src/inventories/insights/insights.partial.html +++ b/awx/ui/client/src/inventories/insights/insights.partial.html @@ -1,38 +1,38 @@
' + i18n._('URL popover text'); + $scope.urlPopover = '
' + i18n._('URL popover text') + '
'; } } @@ -162,10 +163,15 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm', $state.go('projects'); }; $scope.lookupCredential = function(){ - let credType = ($scope.scm_type.value === "insights") ? 13 : 2; //insights cred type is 13, SCM is 2 + // Perform a lookup on the credential_type. Git, Mercurial, and Subversion + // all use SCM as their credential type. + let credType = _.filter(CredentialTypes, function(credType){ + return ($scope.scm_type.value !== "insights" && credType.kind === "scm" || + $scope.scm_type.value === "insights" && credType.kind === "insights"); + }); $state.go('.credential', { credential_search: { - credential_type: credType, + credential_type: credType[0].id, page_size: '5', page: '1' } diff --git a/awx/ui/client/src/projects/edit/projects-edit.controller.js b/awx/ui/client/src/projects/edit/projects-edit.controller.js index ea5b9f9cd3..be0890de12 100644 --- a/awx/ui/client/src/projects/edit/projects-edit.controller.js +++ b/awx/ui/client/src/projects/edit/projects-edit.controller.js @@ -8,11 +8,11 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest', 'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt', 'ClearScope', 'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty', 'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification', - 'i18n', + 'i18n', 'CredentialTypes', function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert, ProcessErrors, GenerateForm, Prompt, ClearScope, GetBasePath, GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate, - $state, CreateSelect2, ToggleNotification, i18n) { + $state, CreateSelect2, ToggleNotification, i18n, CredentialTypes) { ClearScope('htmlTemplate'); @@ -290,10 +290,15 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest', }; $scope.lookupCredential = function(){ - let credType = ($scope.scm_type.value === "insights") ? 13 : 2; //insights cred type is 13, SCM is 2 + // Perform a lookup on the credential_type. Git, Mercurial, and Subversion + // all use SCM as their credential type. + let credType = _.filter(CredentialTypes, function(credType){ + return ($scope.scm_type.value !== "insights" && credType.kind === "scm" || + $scope.scm_type.value === "insights" && credType.kind === "insights"); + }); $state.go('.credential', { credential_search: { - credential_type: credType, + credential_type: credType[0].id, page_size: '5', page: '1' } diff --git a/awx/ui/client/src/projects/main.js b/awx/ui/client/src/projects/main.js index 1b76213cd3..52fa7270b6 100644 --- a/awx/ui/client/src/projects/main.js +++ b/awx/ui/client/src/projects/main.js @@ -28,7 +28,24 @@ angular.module('Projects', [revisions.name]) .config(['$stateProvider', 'stateDefinitionsProvider', function($stateProvider, stateDefinitionsProvider) { let stateDefinitions = stateDefinitionsProvider.$get(); - + var projectResolve = { + CredentialTypes: ['Rest', '$stateParams', 'GetBasePath', 'ProcessErrors', + (Rest, $stateParams, GetBasePath, ProcessErrors) => { + var path = GetBasePath('credential_types'); + Rest.setUrl(path); + return Rest.get() + .then(function(data) { + return (data.data.results); + }).catch(function(response) { + ProcessErrors(null, response.data, response.status, null, { + hdr: 'Error!', + msg: 'Failed to get credential tpyes. GET returned status: ' + + response.status + }); + }); + } + ] + }; // lazily generate a tree of substates which will replace this node in ui-router's stateRegistry // see: stateDefinition.factory for usage documentation $stateProvider.state({ @@ -55,6 +72,10 @@ angular.module('Projects', [revisions.name]) }, ncyBreadcrumb: { label: N_('PROJECTS') + }, + resolve: { + add: projectResolve, + edit: projectResolve } }) });