Merge pull request #480 from jlmitch5/fix_failure_update_reason

Fix failure update reason
This commit is contained in:
jlmitch5
2015-10-23 08:24:58 -07:00
11 changed files with 87 additions and 41 deletions

View File

@@ -13,7 +13,7 @@
export function JobDetailController ($location, $rootScope, $filter, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest, export function JobDetailController ($location, $rootScope, $filter, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, DrawGraph, LoadHostSummary, ReloadHostSummaryList, JobIsFinished, SetTaskStyles, DigestEvent, ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, DrawGraph, LoadHostSummary, ReloadHostSummaryList, JobIsFinished, SetTaskStyles, DigestEvent,
UpdateDOM, EventViewer, DeleteJob, PlaybookRun, HostEventsViewer, LoadPlays, LoadTasks, LoadHosts, HostsEdit, ParseVariableString, GetChoices) { UpdateDOM, EventViewer, DeleteJob, PlaybookRun, HostEventsViewer, LoadPlays, LoadTasks, LoadHosts, HostsEdit, ParseVariableString, GetChoices, fieldChoices, fieldLabels) {
ClearScope(); ClearScope();
@@ -27,11 +27,33 @@ export function JobDetailController ($location, $rootScope, $filter, $scope, $co
scope.plays = []; scope.plays = [];
scope.previousTaskFailed = false;
scope.$watch('job_status', function(job_status) { scope.$watch('job_status', function(job_status) {
if (job_status && job_status.explanation && job_status.explanation.split(":")[0] === "Previous Task Failed") { if (job_status && job_status.explanation && job_status.explanation.split(":")[0] === "Previous Task Failed") {
scope.previousTaskFailed = true;
var taskObj = JSON.parse(job_status.explanation.substring(job_status.explanation.split(":")[0].length + 1)); var taskObj = JSON.parse(job_status.explanation.substring(job_status.explanation.split(":")[0].length + 1));
job_status.explanation = job_status.explanation.split(":")[0] + ". "; // return a promise from the options request with the permission type choices (including adhoc) as a param
job_status.explanation += "<code>" + taskObj.task_type + "-" + taskObj.task_id + " failed for " + taskObj.task_name + "</code>" var fieldChoice = fieldChoices({
scope: $scope,
url: 'api/v1/unified_jobs/',
field: 'type'
});
// manipulate the choices from the options request to be set on
// scope and be usable by the list form
fieldChoice.then(function (choices) {
choices =
fieldLabels({
choices: choices
});
scope.explanation_fail_type = choices[taskObj.job_type];
scope.explanation_fail_name = taskObj.job_name;
scope.explanation_fail_id = taskObj.job_id;
scope.task_detail = scope.explanation_fail_type + " failed for " + scope.explanation_fail_name + " with id " + scope.explanation_fail_id + ".";
});
} else {
scope.previousTaskFailed = false;
} }
}, true); }, true);
@@ -1415,5 +1437,5 @@ export function JobDetailController ($location, $rootScope, $filter, $scope, $co
JobDetailController.$inject = [ '$location', '$rootScope', '$filter', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath', JobDetailController.$inject = [ '$location', '$rootScope', '$filter', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'DrawGraph', 'LoadHostSummary', 'ReloadHostSummaryList', 'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'DrawGraph', 'LoadHostSummary', 'ReloadHostSummaryList',
'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun', 'HostEventsViewer', 'LoadPlays', 'LoadTasks', 'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun', 'HostEventsViewer', 'LoadPlays', 'LoadTasks',
'LoadHosts', 'HostsEdit', 'ParseVariableString', 'GetChoices' 'LoadHosts', 'HostsEdit', 'ParseVariableString', 'GetChoices', 'fieldChoices', 'fieldLabels'
]; ];

View File

@@ -176,7 +176,7 @@ TeamsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors, export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
OrganizationList, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) { OrganizationList, Wait, Stream, fieldChoices, fieldLabels, permissionsSearchSelect) {
ClearScope(); ClearScope();
@@ -192,16 +192,17 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
$scope.permission_search_select = []; $scope.permission_search_select = [];
// return a promise from the options request with the permission type choices (including adhoc) as a param // return a promise from the options request with the permission type choices (including adhoc) as a param
var permissionsChoice = permissionsChoices({ var permissionsChoice = fieldChoices({
scope: $scope, scope: $scope,
url: 'api/v1/' + base + '/' + id + '/permissions/' url: 'api/v1/' + base + '/' + id + '/permissions/',
field: 'permission_type'
}); });
// manipulate the choices from the options request to be set on // manipulate the choices from the options request to be set on
// scope and be usable by the list form // scope and be usable by the list form
permissionsChoice.then(function (choices) { permissionsChoice.then(function (choices) {
choices = choices =
permissionsLabel({ fieldLabels({
choices: choices choices: choices
}); });
_.map(choices, function(n, key) { _.map(choices, function(n, key) {
@@ -431,5 +432,5 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm', TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect' 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'fieldChoices', 'fieldLabels', 'permissionsSearchSelect'
]; ];

View File

@@ -208,7 +208,7 @@ UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert, export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) { Prompt, CheckAccess, ResetForm, Wait, Stream, fieldChoices, fieldLabels, permissionsSearchSelect) {
ClearScope(); ClearScope();
@@ -224,16 +224,17 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
$scope.permission_search_select = []; $scope.permission_search_select = [];
// return a promise from the options request with the permission type choices (including adhoc) as a param // return a promise from the options request with the permission type choices (including adhoc) as a param
var permissionsChoice = permissionsChoices({ var permissionsChoice = fieldChoices({
scope: $scope, scope: $scope,
url: 'api/v1/' + base + '/' + id + '/permissions/' url: 'api/v1/' + base + '/' + id + '/permissions/',
field: 'permission_type'
}); });
// manipulate the choices from the options request to be set on // manipulate the choices from the options request to be set on
// scope and be usable by the list form // scope and be usable by the list form
permissionsChoice.then(function (choices) { permissionsChoice.then(function (choices) {
choices = choices =
permissionsLabel({ fieldLabels({
choices: choices choices: choices
}); });
_.map(choices, function(n, key) { _.map(choices, function(n, key) {
@@ -519,5 +520,5 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm', UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect' 'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'fieldChoices', 'fieldLabels', 'permissionsSearchSelect'
]; ];

View File

@@ -34,7 +34,22 @@
<div class="form-group" ng-show="job_status.explanation"> <div class="form-group" ng-show="job_status.explanation">
<label class="col-lg-2 col-md-12 col-sm-12 col-xs-12">Explanation</label> <label class="col-lg-2 col-md-12 col-sm-12 col-xs-12">Explanation</label>
<div class="col-lg-10 col-md-12 col-sm-12 col-xs-12 job_status_explanation" ng-bind-html="job_status.explanation"></div> <div class="col-lg-10 col-md-12 col-sm-12 col-xs-12 job_status_explanation"
ng-show="!previousTaskFailed" ng-bind-html="job_status.explanation"></div>
<div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 job_status_explanation"
ng-show="previousTaskFailed">Previous Task Failed
<a
href=""
aw-pop-over="{{ task_detail }}"
aw-pop-over-watch="task_detail"
data-placement="right"
data-container="body" class="help-link" over-title="Failure Detail"
title=""
tabindex="-1">
<i class="fa fa-question-circle">
</i>
</a>
</div>
</div> </div>
<div class="form-group" ng-show="job_status.traceback"> <div class="form-group" ng-show="job_status.traceback">

View File

@@ -10,8 +10,8 @@
* @description This controller for permissions add * @description This controller for permissions add
*/ */
export default export default
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel', ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'fieldChoices', 'fieldLabels',
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) { function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, fieldChoices, fieldLabels) {
ClearScope(); ClearScope();
@@ -22,13 +22,14 @@ export default
base = $location.path().replace(/^\//, '').split('/')[0], base = $location.path().replace(/^\//, '').split('/')[0],
master = {}; master = {};
var permissionsChoice = permissionsChoices({ var permissionsChoice = fieldChoices({
scope: $scope, scope: $scope,
url: 'api/v1/' + base + '/' + id + '/permissions/' url: 'api/v1/' + base + '/' + id + '/permissions/',
field: 'permission_type'
}); });
permissionsChoice.then(function (choices) { permissionsChoice.then(function (choices) {
return permissionsLabel({ return fieldLabels({
choices: choices choices: choices
}); });
}).then(function (choices) { }).then(function (choices) {

View File

@@ -10,8 +10,8 @@
* @description This controller for permissions edit * @description This controller for permissions edit
*/ */
export default export default
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel', ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'fieldChoices', 'fieldLabels',
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) { function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, fieldChoices, fieldLabels) {
ClearScope(); ClearScope();
@@ -25,13 +25,14 @@ export default
$scope.permission_label = {}; $scope.permission_label = {};
var permissionsChoice = permissionsChoices({ var permissionsChoice = fieldChoices({
scope: $scope, scope: $scope,
url: 'api/v1/' + base + '/' + base_id + '/permissions/' url: 'api/v1/' + base + '/' + base_id + '/permissions/',
field: 'permission_type'
}); });
permissionsChoice.then(function (choices) { permissionsChoice.then(function (choices) {
return permissionsLabel({ return fieldLabels({
choices: choices choices: choices
}); });
}).then(function (choices) { }).then(function (choices) {

View File

@@ -12,8 +12,8 @@
export default export default
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect', ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'fieldChoices', 'fieldLabels', 'permissionsSearchSelect',
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsChoices, permissionsLabel, permissionsSearchSelect) { function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, fieldChoices, fieldLabels, permissionsSearchSelect) {
ClearScope(); ClearScope();
@@ -27,16 +27,17 @@ export default
$scope.permission_search_select = []; $scope.permission_search_select = [];
// return a promise from the options request with the permission type choices (including adhoc) as a param // return a promise from the options request with the permission type choices (including adhoc) as a param
var permissionsChoice = permissionsChoices({ var permissionsChoice = fieldChoices({
scope: $scope, scope: $scope,
url: 'api/v1/' + base + '/' + base_id + '/permissions/' url: 'api/v1/' + base + '/' + base_id + '/permissions/',
field: 'permission_type'
}); });
// manipulate the choices from the options request to be set on // manipulate the choices from the options request to be set on
// scope and be usable by the list form // scope and be usable by the list form
permissionsChoice.then(function (choices) { permissionsChoice.then(function (choices) {
choices = choices =
permissionsLabel({ fieldLabels({
choices: choices choices: choices
}); });
_.map(choices, function(n, key) { _.map(choices, function(n, key) {

View File

@@ -12,8 +12,6 @@ import list from './shared/permissions.list';
import form from './shared/permissions.form'; import form from './shared/permissions.form';
import permissionsCategoryChange from './shared/category-change.factory'; import permissionsCategoryChange from './shared/category-change.factory';
import permissionsChoices from './shared/get-choices.factory';
import permissionsLabel from './shared/get-labels.factory';
import permissionsSearchSelect from './shared/get-search-select.factory'; import permissionsSearchSelect from './shared/get-search-select.factory';
export default export default
@@ -25,6 +23,4 @@ export default
.factory('permissionsList', list) .factory('permissionsList', list)
.factory('permissionsForm', form) .factory('permissionsForm', form)
.factory('permissionsCategoryChange', permissionsCategoryChange) .factory('permissionsCategoryChange', permissionsCategoryChange)
.factory('permissionsChoices', permissionsChoices)
.factory('permissionsLabel', permissionsLabel)
.factory('permissionsSearchSelect', permissionsSearchSelect); .factory('permissionsSearchSelect', permissionsSearchSelect);

View File

@@ -16,24 +16,28 @@
['Rest', 'ProcessErrors', function(Rest, ProcessErrors) { ['Rest', 'ProcessErrors', function(Rest, ProcessErrors) {
return function (params) { return function (params) {
var scope = params.scope, var scope = params.scope,
url = params.url; url = params.url,
field = params.field;
// Auto populate the field if there is only one result // Auto populate the field if there is only one result
Rest.setUrl(url); Rest.setUrl(url);
return Rest.options() return Rest.options()
.then(function (data) { .then(function (data) {
data = data.data; data = data.data;
var choices = data.actions.GET.permission_type.choices; var choices = data.actions.GET[field].choices;
// manually add the adhoc label to the choices object // manually add the adhoc label to the choices object if
choices.push(["adhoc", // the permission_type field
data.actions.GET.run_ad_hoc_commands.help_text]); if (field === "permission_type") {
choices.push(["adhoc",
data.actions.GET.run_ad_hoc_commands.help_text]);
}
return choices; return choices;
}) })
.catch(function (data, status) { .catch(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get permission type labels. Options requrest returned status: ' + status }); msg: 'Failed to get ' + field + ' labels. Options requrest returned status: ' + status });
}); });
}; };
}]; }];

View File

@@ -6,6 +6,8 @@
import restServicesFactory from './restServices.factory'; import restServicesFactory from './restServices.factory';
import interceptors from './interceptors.service'; import interceptors from './interceptors.service';
import fieldChoices from './get-choices.factory';
import fieldLabels from './get-labels.factory';
export default export default
angular.module('RestServices', []) angular.module('RestServices', [])
@@ -13,4 +15,6 @@ export default
$httpProvider.interceptors.push('RestInterceptor'); $httpProvider.interceptors.push('RestInterceptor');
}]) }])
.factory('Rest', restServicesFactory) .factory('Rest', restServicesFactory)
.service('RestInterceptor', interceptors); .service('RestInterceptor', interceptors)
.factory('fieldChoices', fieldChoices)
.factory('fieldLabels', fieldLabels);