From ff46e46b69b310c2736e36a4ef0fc8af4206f751 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 5 Jun 2017 13:23:10 -0700 Subject: [PATCH] submitting changes after PR feedback adding translate directive to partial, performing a lookup on credential_types for the credential on the project page, and some other small changes --- .../insights/insights.controller.js | 24 +++++-------------- .../insights/insights.partial.html | 18 +++++++------- .../projects/add/projects-add.controller.js | 14 +++++++---- .../projects/edit/projects-edit.controller.js | 13 ++++++---- awx/ui/client/src/projects/main.js | 23 +++++++++++++++++- 5 files changed, 56 insertions(+), 36 deletions(-) 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 @@
- This machine has not checked in with Insights in {{last_check_in}} hours + This machine has not checked in with Insights in {{last_check_in}} hours
-
Total Issues
+
Total Issues
{{reports_dataset.reports.length}}
-
Critical
+
Critical
{{critical_count}}
-
High
+
High
{{high_count}}
-
Medium
+
Medium
{{med_count}}
-
Low
+
Low
{{low_count}}
@@ -41,13 +41,13 @@
-
Solvable With Playbook
+
Solvable With Playbook
{{solvable_count}}
-
Not Solvable With Playbook
+
Not Solvable With Playbook
{{not_solvable_count}}
@@ -64,7 +64,7 @@ aw-tool-tip="Medium Risk" data-placement="top"> -
ISSUE: {{report.rule.description}}
+
ISSUE: {{report.rule.description}}
{{report.rule.category}}
{{report.rule.summary}}
diff --git a/awx/ui/client/src/projects/add/projects-add.controller.js b/awx/ui/client/src/projects/add/projects-add.controller.js index 7f2e4c7abc..a458e1c51e 100644 --- a/awx/ui/client/src/projects/add/projects-add.controller.js +++ b/awx/ui/client/src/projects/add/projects-add.controller.js @@ -7,9 +7,10 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm', 'ProjectsForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'GetProjectPath', 'GetChoices', 'Wait', '$state', 'CreateSelect2', 'i18n', + 'CredentialTypes', function($scope, $location, $stateParams, GenerateForm, ProjectsForm, Rest, Alert, ProcessErrors, GetBasePath, GetProjectPath, GetChoices, Wait, $state, - CreateSelect2, i18n) { + CreateSelect2, i18n, CredentialTypes) { var form = ProjectsForm(), base = $location.path().replace(/^\//, '').split('/')[0], @@ -153,7 +154,7 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm', break; default: $scope.credentialLabel = "SCM Credential"; - $scope.urlPopover = '

' + 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 } }) });