mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 18:07:33 -02:30
Host events
added check in host event call to make sure an empty data set is not returend from the API
This commit is contained in:
@@ -273,7 +273,8 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities', 'EventsViewerFo
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('GetEvent', ['Wait', 'Rest', 'ProcessErrors', function(Wait, Rest, ProcessErrors) {
|
.factory('GetEvent', ['Wait', 'Rest', 'ProcessErrors',
|
||||||
|
function(Wait, Rest, ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var url = params.url,
|
var url = params.url,
|
||||||
scope = params.scope,
|
scope = params.scope,
|
||||||
@@ -295,70 +296,79 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities', 'EventsViewerFo
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success( function(data) {
|
||||||
scope.next_event_set = data.next;
|
|
||||||
scope.prev_event_set = data.previous;
|
if(jQuery.isEmptyObject(data)) {
|
||||||
data.results.forEach(function(event) {
|
Wait('stop');
|
||||||
var msg, key, event_data = {};
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
if (event.event_data.res) {
|
msg: 'Failed to get event ' + url + '. ' });
|
||||||
if (typeof event.event_data.res !== 'object') {
|
|
||||||
// turn event_data.res into an object
|
|
||||||
msg = event.event_data.res;
|
|
||||||
event.event_data.res = {};
|
|
||||||
event.event_data.res.msg = msg;
|
|
||||||
}
|
|
||||||
for (key in event.event_data) {
|
|
||||||
if (key !== "res") {
|
|
||||||
event.event_data.res[key] = event.event_data[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.event_data.res.ansible_facts) {
|
|
||||||
// don't show fact gathering results
|
|
||||||
event.event_data.res.task = "Gathering Facts";
|
|
||||||
delete event.event_data.res.ansible_facts;
|
|
||||||
}
|
|
||||||
event.event_data.res.status = getStatus(event);
|
|
||||||
event_data = event.event_data.res;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.event_data.status = getStatus(event);
|
|
||||||
event_data = event.event_data;
|
|
||||||
}
|
|
||||||
// convert results to stdout
|
|
||||||
if (event_data.results && typeof event_data.results === "object" && Array.isArray(event_data.results)) {
|
|
||||||
event_data.stdout = "";
|
|
||||||
event_data.results.forEach(function(row) {
|
|
||||||
event_data.stdout += row + "\n";
|
|
||||||
});
|
|
||||||
delete event_data.results;
|
|
||||||
}
|
|
||||||
if (event_data.invocation) {
|
|
||||||
for (key in event_data.invocation) {
|
|
||||||
event_data[key] = event_data.invocation[key];
|
|
||||||
}
|
|
||||||
delete event_data.invocation;
|
|
||||||
}
|
|
||||||
event_data.play = event.play;
|
|
||||||
if (event.task) {
|
|
||||||
event_data.task = event.task;
|
|
||||||
}
|
|
||||||
event_data.created = event.created;
|
|
||||||
event_data.role = event.role;
|
|
||||||
event_data.host_id = event.host;
|
|
||||||
event_data.host_name = event.host_name;
|
|
||||||
if (event_data.host) {
|
|
||||||
delete event_data.host;
|
|
||||||
}
|
|
||||||
event_data.id = event.id;
|
|
||||||
event_data.parent = event.parent;
|
|
||||||
event_data.event = (event.event_display) ? event.event_display : event.event;
|
|
||||||
results.push(event_data);
|
|
||||||
});
|
|
||||||
if (show_event) {
|
|
||||||
scope.$emit('ShowNextEvent', results, show_event);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope.$emit('EventReady', results);
|
scope.next_event_set = data.next;
|
||||||
}
|
scope.prev_event_set = data.previous;
|
||||||
|
data.results.forEach(function(event) {
|
||||||
|
var msg, key, event_data = {};
|
||||||
|
if (event.event_data.res) {
|
||||||
|
if (typeof event.event_data.res !== 'object') {
|
||||||
|
// turn event_data.res into an object
|
||||||
|
msg = event.event_data.res;
|
||||||
|
event.event_data.res = {};
|
||||||
|
event.event_data.res.msg = msg;
|
||||||
|
}
|
||||||
|
for (key in event.event_data) {
|
||||||
|
if (key !== "res") {
|
||||||
|
event.event_data.res[key] = event.event_data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.event_data.res.ansible_facts) {
|
||||||
|
// don't show fact gathering results
|
||||||
|
event.event_data.res.task = "Gathering Facts";
|
||||||
|
delete event.event_data.res.ansible_facts;
|
||||||
|
}
|
||||||
|
event.event_data.res.status = getStatus(event);
|
||||||
|
event_data = event.event_data.res;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.event_data.status = getStatus(event);
|
||||||
|
event_data = event.event_data;
|
||||||
|
}
|
||||||
|
// convert results to stdout
|
||||||
|
if (event_data.results && typeof event_data.results === "object" && Array.isArray(event_data.results)) {
|
||||||
|
event_data.stdout = "";
|
||||||
|
event_data.results.forEach(function(row) {
|
||||||
|
event_data.stdout += row + "\n";
|
||||||
|
});
|
||||||
|
delete event_data.results;
|
||||||
|
}
|
||||||
|
if (event_data.invocation) {
|
||||||
|
for (key in event_data.invocation) {
|
||||||
|
event_data[key] = event_data.invocation[key];
|
||||||
|
}
|
||||||
|
delete event_data.invocation;
|
||||||
|
}
|
||||||
|
event_data.play = event.play;
|
||||||
|
if (event.task) {
|
||||||
|
event_data.task = event.task;
|
||||||
|
}
|
||||||
|
event_data.created = event.created;
|
||||||
|
event_data.role = event.role;
|
||||||
|
event_data.host_id = event.host;
|
||||||
|
event_data.host_name = event.host_name;
|
||||||
|
if (event_data.host) {
|
||||||
|
delete event_data.host;
|
||||||
|
}
|
||||||
|
event_data.id = event.id;
|
||||||
|
event_data.parent = event.parent;
|
||||||
|
event_data.event = (event.event_display) ? event.event_display : event.event;
|
||||||
|
results.push(event_data);
|
||||||
|
});
|
||||||
|
if (show_event) {
|
||||||
|
scope.$emit('ShowNextEvent', results, show_event);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('EventReady', results);
|
||||||
|
}
|
||||||
|
} //else statement
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
|||||||
@@ -517,11 +517,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
if(question.type === 'integer'){
|
if(question.type === 'integer'){
|
||||||
min = (!Empty(question.min)) ? Number(question.min) : "";
|
min = (!Empty(question.min)) ? Number(question.min) : "";
|
||||||
max = (!Empty(question.max)) ? Number(question.max) : "" ;
|
max = (!Empty(question.max)) ? Number(question.max) : "" ;
|
||||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class="form-control" name="'+question.variable+'" ng-min="'+min+'" ng-max="'+max+'" integer>'+
|
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class="form-control" name="'+question.variable+'" ng-required="'+question.required+'" integer />'+
|
||||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && ' +
|
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && job_launch_form.'+question.variable+'.$error.required">A value is required!</div>'+
|
||||||
'job_launch_form.'+question.variable+'.$error.required\">A value is required!</div>'+
|
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$dirty && (job_launch_form.'+question.variable+'.$error.number || job_launch_form.'+question.variable+'.$error.integer)" >This is not valid integer!</div>'+
|
||||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>'+
|
|
||||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.number || job_launch_form.'+question.variable+'.$error.integer">This is not valid integer!</div>'+
|
|
||||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -530,10 +528,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
min = (!Empty(question.min)) ? question.min : "";
|
min = (!Empty(question.min)) ? question.min : "";
|
||||||
max = (!Empty(question.max)) ? question.max : "" ;
|
max = (!Empty(question.max)) ? question.max : "" ;
|
||||||
defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_float)) ? question.default_float : "" ;
|
defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_float)) ? question.default_float : "" ;
|
||||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class=" form-control" name="'+question.variable+'" ng-min="'+min+'" ng-max="'+max+'" smart-float>'+
|
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class=" form-control" name="'+question.variable+'" ng-required="'+question.variable+'" smart-float />'+
|
||||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.number || job_launch_form.'+question.variable+'.$error.float">This is not valid float!</div>'+
|
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.number || job_launch_form.'+question.variable+'.$error.float">This is not valid float!</div>'+
|
||||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||||
// '<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$dirty || job_launch_form.'+question.variable+'.$error.required"> A value is required!</div>';
|
|
||||||
}
|
}
|
||||||
html+='</div>';
|
html+='</div>';
|
||||||
if(question.index === scope.survey_questions.length-1){
|
if(question.index === scope.survey_questions.length-1){
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
|
// scope: true,
|
||||||
link: function (scope, elem, attr, ctrl) {
|
link: function (scope, elem, attr, ctrl) {
|
||||||
scope.$watch(attr.ngMin, function () {
|
scope.$watch(attr.ngMin, function () {
|
||||||
ctrl.$setViewValue(ctrl.$viewValue);
|
ctrl.$setViewValue(ctrl.$viewValue);
|
||||||
@@ -162,7 +163,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ctrl.$parsers.push(minValidator);
|
ctrl.$parsers.push(minValidator);
|
||||||
ctrl.$formatters.push(minValidator);
|
ctrl.$formatters.push(minValidator);
|
||||||
}
|
}
|
||||||
@@ -173,6 +173,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
|
// scope: true,
|
||||||
link: function (scope, elem, attr, ctrl) {
|
link: function (scope, elem, attr, ctrl) {
|
||||||
scope.$watch(attr.ngMax, function () {
|
scope.$watch(attr.ngMax, function () {
|
||||||
ctrl.$setViewValue(ctrl.$viewValue);
|
ctrl.$setViewValue(ctrl.$viewValue);
|
||||||
@@ -187,7 +188,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ctrl.$parsers.push(maxValidator);
|
ctrl.$parsers.push(maxValidator);
|
||||||
ctrl.$formatters.push(maxValidator);
|
ctrl.$formatters.push(maxValidator);
|
||||||
}
|
}
|
||||||
@@ -196,14 +196,19 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
|
|
||||||
|
|
||||||
.directive('smartFloat', function() {
|
.directive('smartFloat', function() {
|
||||||
var FLOAT_REGEXP = /^\-?\d+((\.|\,)\d+)?$/;
|
var FLOAT_REGEXP_1 = /^\$?\d+(.\d{3})*(\,\d*)?$/, //Numbers like: 1.123,56
|
||||||
|
FLOAT_REGEXP_2 = /^\$?\d+(,\d{3})*(\.\d*)?$/; //Numbers like: 1,123.56
|
||||||
return {
|
return {
|
||||||
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function (scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift(function(viewValue) {
|
ctrl.$parsers.unshift(function (viewValue) {
|
||||||
if (FLOAT_REGEXP.test(viewValue)) {
|
if (FLOAT_REGEXP_1.test(Number(viewValue))) {
|
||||||
ctrl.$setValidity('float', true);
|
ctrl.$setValidity('float', true);
|
||||||
return parseFloat(viewValue.replace(',', '.'));
|
return parseFloat(viewValue.replace('.', '').replace(',', '.'));
|
||||||
|
} else if (FLOAT_REGEXP_2.test(Number(viewValue))) {
|
||||||
|
ctrl.$setValidity('float', true);
|
||||||
|
return parseFloat(viewValue.replace(',', ''));
|
||||||
} else {
|
} else {
|
||||||
ctrl.$setValidity('float', false);
|
ctrl.$setValidity('float', false);
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -211,6 +216,21 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// var FLOAT_REGEXP = /^\-?\d+((\.|\,)\d+)?$/;
|
||||||
|
// return {
|
||||||
|
// require: 'ngModel',
|
||||||
|
// link: function(scope, elm, attrs, ctrl) {
|
||||||
|
// ctrl.$parsers.unshift(function(viewValue) {
|
||||||
|
// if (FLOAT_REGEXP.test(viewValue)) {
|
||||||
|
// ctrl.$setValidity('float', true);
|
||||||
|
// return parseFloat(viewValue.replace(',', '.'));
|
||||||
|
// } else {
|
||||||
|
// ctrl.$setValidity('float', false);
|
||||||
|
// return undefined;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
})
|
})
|
||||||
|
|
||||||
// integer Validate that input is of type integer. Taken from Angular developer
|
// integer Validate that input is of type integer. Taken from Angular developer
|
||||||
@@ -221,6 +241,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
// override/interfere with this directive.
|
// override/interfere with this directive.
|
||||||
.directive('integer', function() {
|
.directive('integer', function() {
|
||||||
return {
|
return {
|
||||||
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift(function(viewValue) {
|
ctrl.$parsers.unshift(function(viewValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user