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
This commit is contained in:
Jared Tabor
2017-06-05 13:23:10 -07:00
parent 38ce6c7226
commit ff46e46b69
5 changed files with 56 additions and 36 deletions

View File

@@ -33,44 +33,32 @@ function (data, $scope, moment, $state, resourceData) {
} }
if(filter === "solvable"){ if(filter === "solvable"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.maintenance_actions.length > 0){ return (report.maintenance_actions.length > 0);
return report;
}
}); });
} }
if(filter === "not_solvable"){ if(filter === "not_solvable"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.maintenance_actions.length === 0){ return (report.maintenance_actions.length === 0);
return report;
}
}); });
} }
if(filter === "critical"){ if(filter === "critical"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.rule.severity === 'CRITICAL'){ return (report.rule.severity === 'CRITICAL');
return report;
}
}); });
} }
if(filter === "high"){ if(filter === "high"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.rule.severity === 'ERROR'){ return (report.rule.severity === 'ERROR');
return report;
}
}); });
} }
if(filter === "medium"){ if(filter === "medium"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.rule.severity === 'WARN'){ return (report.rule.severity === 'WARN');
return report;
}
}); });
} }
if(filter === "low"){ if(filter === "low"){
$scope.reports = _.filter($scope.reports_dataset.reports, function(report){ $scope.reports = _.filter($scope.reports_dataset.reports, function(report){
if(report.rule.severity === 'INFO'){ return (report.rule.severity === 'INFO');
return report;
}
}); });
} }
}; };

View File

@@ -1,38 +1,38 @@
<div class="InsightsLastCheck" <div class="InsightsLastCheck"
ng-show="isCheckingIn=false"> ng-show="isCheckingIn=false">
<i class="fa icon-job-failed InsightsIcon-warning"></i> <i class="fa icon-job-failed InsightsIcon-warning"></i>
This machine has not checked in with Insights in {{last_check_in}} hours <translate>This machine has not checked in with Insights in {{last_check_in}} hours</translate>
</div> </div>
<div class="InsightsNav"> <div class="InsightsNav">
<div class="InsightsNav-rightSide"> <div class="InsightsNav-rightSide">
<div class="InsightsNav-anchor" ng-click="filter('total')" <div class="InsightsNav-anchor" ng-click="filter('total')"
ng-class="{'is-currentFilter' : (currentFilter === 'total')}"> ng-class="{'is-currentFilter' : (currentFilter === 'total')}">
<div class="InsightsNav-badgeTitle">Total Issues</div> <div class="InsightsNav-badgeTitle"><translate>Total Issues</translate></div>
<span class="badge List-titleBadge InsightsNav-totalIssues">{{reports_dataset.reports.length}}</span> <span class="badge List-titleBadge InsightsNav-totalIssues">{{reports_dataset.reports.length}}</span>
</div> </div>
<div class="InsightsNav-anchor" ng-click="filter('critical')" <div class="InsightsNav-anchor" ng-click="filter('critical')"
ng-class="{'is-currentFilter' : (currentFilter === 'critical')}" ng-class="{'is-currentFilter' : (currentFilter === 'critical')}"
ng-show="critical_count>0"> ng-show="critical_count>0">
<div class="InsightsNav-badgeTitle">Critical</div> <div class="InsightsNav-badgeTitle"><translate>Critical</translate></div>
<span class="badge List-titleBadge InsightsNav-criticalIssues">{{critical_count}}</span> <span class="badge List-titleBadge InsightsNav-criticalIssues">{{critical_count}}</span>
</div> </div>
<div class="InsightsNav-anchor" ng-click="filter('high')" <div class="InsightsNav-anchor" ng-click="filter('high')"
ng-class="{'is-currentFilter' : (currentFilter === 'high')}" ng-class="{'is-currentFilter' : (currentFilter === 'high')}"
ng-show="high_count>0"> ng-show="high_count>0">
<div class="InsightsNav-badgeTitle">High</div> <div class="InsightsNav-badgeTitle"><translate>High</translate></div>
<span class="badge List-titleBadge InsightsNav-highIssues">{{high_count}}</span> <span class="badge List-titleBadge InsightsNav-highIssues">{{high_count}}</span>
</div> </div>
<div class="InsightsNav-anchor" ng-click="filter('medium')" <div class="InsightsNav-anchor" ng-click="filter('medium')"
ng-class="{'is-currentFilter' : (currentFilter === 'medium')}" ng-class="{'is-currentFilter' : (currentFilter === 'medium')}"
ng-show="med_count>0"> ng-show="med_count>0">
<div class="InsightsNav-badgeTitle">Medium</div> <div class="InsightsNav-badgeTitle"><translate>Medium</translate></div>
<span class="badge List-titleBadge InsightsNav-mediumIssues">{{med_count}}</span> <span class="badge List-titleBadge InsightsNav-mediumIssues">{{med_count}}</span>
</div> </div>
<div class="InsightsNav-anchor" ng-click="filter('low')" <div class="InsightsNav-anchor" ng-click="filter('low')"
ng-class="{'is-currentFilter' : (currentFilter === 'low')}" ng-class="{'is-currentFilter' : (currentFilter === 'low')}"
ng-show="low_count>0"> ng-show="low_count>0">
<div class="InsightsNav-badgeTitle">Low</div> <div class="InsightsNav-badgeTitle"><translate>Low</translate></div>
<span class="badge List-titleBadge InsightsNav-lowIssues">{{low_count}}</span> <span class="badge List-titleBadge InsightsNav-lowIssues">{{low_count}}</span>
</div> </div>
</div> </div>
@@ -41,13 +41,13 @@
<div class="InsightsNav-anchor" ng-click="filter('solvable')" <div class="InsightsNav-anchor" ng-click="filter('solvable')"
ng-class="{'is-currentFilter' : (currentFilter === 'solvable')}" ng-class="{'is-currentFilter' : (currentFilter === 'solvable')}"
ng-show="solvable_count>0"> ng-show="solvable_count>0">
<div class="InsightsNav-badgeTitle">Solvable With Playbook</div> <div class="InsightsNav-badgeTitle"><translate>Solvable With Playbook</translate></div>
<span class="badge List-titleBadge InsightsNav-solvableBadge">{{solvable_count}}</span> <span class="badge List-titleBadge InsightsNav-solvableBadge">{{solvable_count}}</span>
</div> </div>
<div class="InsightsNav-anchor" ng-click="filter('not_solvable')" <div class="InsightsNav-anchor" ng-click="filter('not_solvable')"
ng-class="{'is-currentFilter' : (currentFilter === 'not_solvable')}" ng-class="{'is-currentFilter' : (currentFilter === 'not_solvable')}"
ng-show="not_solvable_count>0"> ng-show="not_solvable_count>0">
<div class="InsightsNav-badgeTitle">Not Solvable With Playbook</div> <div class="InsightsNav-badgeTitle"><translate>Not Solvable With Playbook</translate></div>
<span class="badge List-titleBadge InsightsNav-solvableBadge">{{not_solvable_count}}</span> <span class="badge List-titleBadge InsightsNav-solvableBadge">{{not_solvable_count}}</span>
</div> </div>
</div> </div>
@@ -64,7 +64,7 @@
aw-tool-tip="Medium Risk" data-placement="top"> aw-tool-tip="Medium Risk" data-placement="top">
<img class="InsightsIcon" src="/static/assets/i_severity_low.svg" ng-show="report.rule.severity === 'INFO'" <img class="InsightsIcon" src="/static/assets/i_severity_low.svg" ng-show="report.rule.severity === 'INFO'"
aw-tool-tip="Low Risk" data-placement="top"> aw-tool-tip="Low Risk" data-placement="top">
<div class="InsightsRow-description">ISSUE: {{report.rule.description}}</div> <div class="InsightsRow-description"><translate>ISSUE: {{report.rule.description}}</translate></div>
<span class="Form-title--is_superuser">{{report.rule.category}}</span> <span class="Form-title--is_superuser">{{report.rule.category}}</span>
</div> </div>
<div class="InsightsRow-body">{{report.rule.summary}}</div> <div class="InsightsRow-body">{{report.rule.summary}}</div>

View File

@@ -7,9 +7,10 @@
export default ['$scope', '$location', '$stateParams', 'GenerateForm', export default ['$scope', '$location', '$stateParams', 'GenerateForm',
'ProjectsForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'ProjectsForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath',
'GetProjectPath', 'GetChoices', 'Wait', '$state', 'CreateSelect2', 'i18n', 'GetProjectPath', 'GetChoices', 'Wait', '$state', 'CreateSelect2', 'i18n',
'CredentialTypes',
function($scope, $location, $stateParams, GenerateForm, ProjectsForm, Rest, function($scope, $location, $stateParams, GenerateForm, ProjectsForm, Rest,
Alert, ProcessErrors, GetBasePath, GetProjectPath, GetChoices, Wait, $state, Alert, ProcessErrors, GetBasePath, GetProjectPath, GetChoices, Wait, $state,
CreateSelect2, i18n) { CreateSelect2, i18n, CredentialTypes) {
var form = ProjectsForm(), var form = ProjectsForm(),
base = $location.path().replace(/^\//, '').split('/')[0], base = $location.path().replace(/^\//, '').split('/')[0],
@@ -153,7 +154,7 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
break; break;
default: default:
$scope.credentialLabel = "SCM Credential"; $scope.credentialLabel = "SCM Credential";
$scope.urlPopover = '<p> ' + i18n._('URL popover text'); $scope.urlPopover = '<p> ' + i18n._('URL popover text') + '</p>';
} }
} }
@@ -162,10 +163,15 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
$state.go('projects'); $state.go('projects');
}; };
$scope.lookupCredential = function(){ $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', { $state.go('.credential', {
credential_search: { credential_search: {
credential_type: credType, credential_type: credType[0].id,
page_size: '5', page_size: '5',
page: '1' page: '1'
} }

View File

@@ -8,11 +8,11 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt', 'ClearScope', 'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt', 'ClearScope',
'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty', 'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty',
'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification', 'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification',
'i18n', 'i18n', 'CredentialTypes',
function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert, function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert,
ProcessErrors, GenerateForm, Prompt, ClearScope, GetBasePath, ProcessErrors, GenerateForm, Prompt, ClearScope, GetBasePath,
GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate, GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate,
$state, CreateSelect2, ToggleNotification, i18n) { $state, CreateSelect2, ToggleNotification, i18n, CredentialTypes) {
ClearScope('htmlTemplate'); ClearScope('htmlTemplate');
@@ -290,10 +290,15 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
}; };
$scope.lookupCredential = function(){ $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', { $state.go('.credential', {
credential_search: { credential_search: {
credential_type: credType, credential_type: credType[0].id,
page_size: '5', page_size: '5',
page: '1' page: '1'
} }

View File

@@ -28,7 +28,24 @@ angular.module('Projects', [revisions.name])
.config(['$stateProvider', 'stateDefinitionsProvider', .config(['$stateProvider', 'stateDefinitionsProvider',
function($stateProvider, stateDefinitionsProvider) { function($stateProvider, stateDefinitionsProvider) {
let stateDefinitions = stateDefinitionsProvider.$get(); 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 // lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation // see: stateDefinition.factory for usage documentation
$stateProvider.state({ $stateProvider.state({
@@ -55,6 +72,10 @@ angular.module('Projects', [revisions.name])
}, },
ncyBreadcrumb: { ncyBreadcrumb: {
label: N_('PROJECTS') label: N_('PROJECTS')
},
resolve: {
add: projectResolve,
edit: projectResolve
} }
}) })
}); });