mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 05:01:09 -02:30
Event viewer
Fixed name collision between EventViewer and LogViewer, which caused things to now show up on the log viewer dialog.
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
||||||
|
|
||||||
.factory('EventViewer', ['$compile', 'CreateDialog', 'GetEvent', 'Wait', 'AddTable', 'GetBasePath', 'LookUpName', 'Empty', 'AddPreFormattedText',
|
.factory('EventViewer', ['$compile', 'CreateDialog', 'GetEvent', 'Wait', 'EventAddTable', 'GetBasePath', 'LookUpName', 'Empty', 'EventAddPreFormattedText',
|
||||||
function($compile, CreateDialog, GetEvent, Wait, AddTable, GetBasePath, LookUpName, Empty, AddPreFormattedText) {
|
function($compile, CreateDialog, GetEvent, Wait, EventAddTable, GetBasePath, LookUpName, Empty, EventAddPreFormattedText) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var parent_scope = params.scope,
|
var parent_scope = params.scope,
|
||||||
url = params.url,
|
url = params.url,
|
||||||
@@ -39,11 +39,11 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
$('#eventview-tabs li:eq(2)').hide();
|
$('#eventview-tabs li:eq(2)').hide();
|
||||||
$('#eventview-tabs li:eq(3)').hide();
|
$('#eventview-tabs li:eq(3)').hide();
|
||||||
|
|
||||||
AddTable({ scope: scope, id: 'status-form-container', event: data });
|
EventAddTable({ scope: scope, id: 'status-form-container', event: data });
|
||||||
|
|
||||||
if (data.stdout) {
|
if (data.stdout) {
|
||||||
$('#eventview-tabs li:eq(1)').show();
|
$('#eventview-tabs li:eq(1)').show();
|
||||||
AddPreFormattedText({
|
EventAddPreFormattedText({
|
||||||
id: 'stdout-form-container',
|
id: 'stdout-form-container',
|
||||||
val: data.stdout
|
val: data.stdout
|
||||||
});
|
});
|
||||||
@@ -51,7 +51,7 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
|
|
||||||
if (data.stderr) {
|
if (data.stderr) {
|
||||||
$('#eventview-tabs li:eq(2)').show();
|
$('#eventview-tabs li:eq(2)').show();
|
||||||
AddPreFormattedText({
|
EventAddPreFormattedText({
|
||||||
id: 'stderr-form-container',
|
id: 'stderr-form-container',
|
||||||
val: data.stderr
|
val: data.stderr
|
||||||
});
|
});
|
||||||
@@ -59,7 +59,7 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
|
|
||||||
if (data.traceback) {
|
if (data.traceback) {
|
||||||
$('#eventview-tabs li:eq(3)').show();
|
$('#eventview-tabs li:eq(3)').show();
|
||||||
AddPreFormattedText({
|
EventAddPreFormattedText({
|
||||||
id: 'traceback-form-container',
|
id: 'traceback-form-container',
|
||||||
val: data.traceback
|
val: data.traceback
|
||||||
});
|
});
|
||||||
@@ -160,33 +160,7 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('LookUpName', ['Rest', 'ProcessErrors', 'Empty', function(Rest, ProcessErrors, Empty) {
|
.factory('EventAddTable', ['$compile', '$filter', 'Empty', function($compile, $filter, Empty) {
|
||||||
return function(params) {
|
|
||||||
var url = params.url,
|
|
||||||
scope_var = params.scope_var,
|
|
||||||
scope = params.scope;
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.get()
|
|
||||||
.success(function(data) {
|
|
||||||
if (scope_var === 'inventory_source') {
|
|
||||||
scope[scope_var + '_name'] = data.summary_fields.group.name;
|
|
||||||
}
|
|
||||||
else if (!Empty(data.name)) {
|
|
||||||
scope[scope_var + '_name'] = data.name;
|
|
||||||
}
|
|
||||||
if (!Empty(data.group)) {
|
|
||||||
// Used for inventory_source
|
|
||||||
scope.group = data.group;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error(function(data, status) {
|
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to retrieve ' + url + '. GET returned: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
.factory('AddTable', ['$compile', '$filter', 'Empty', function($compile, $filter, Empty) {
|
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
id = params.id,
|
id = params.id,
|
||||||
@@ -274,7 +248,7 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('AddTextarea', [ function() {
|
.factory('EventAddTextarea', [ function() {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var container_id = params.container_id,
|
var container_id = params.container_id,
|
||||||
val = params.val,
|
val = params.val,
|
||||||
@@ -287,7 +261,7 @@ angular.module('EventViewerHelper', ['ModalDialog', 'Utilities'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('AddPreFormattedText', [function() {
|
.factory('EventAddPreFormattedText', [function() {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var id = params.id,
|
var id = params.id,
|
||||||
val = params.val,
|
val = params.val,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
scope = parent_scope.$new(true),
|
scope = parent_scope.$new(true),
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
pieces;
|
pieces;
|
||||||
|
|
||||||
if (scope.removeModalReady) {
|
if (scope.removeModalReady) {
|
||||||
scope.removeModalReady();
|
scope.removeModalReady();
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,6 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
}
|
}
|
||||||
scope.removeJobReady = scope.$on('JobReady', function(e, data) {
|
scope.removeJobReady = scope.$on('JobReady', function(e, data) {
|
||||||
var key, resizeText, elem;
|
var key, resizeText, elem;
|
||||||
|
|
||||||
$('#status-form-container').empty();
|
$('#status-form-container').empty();
|
||||||
$('#options-form-container').empty();
|
$('#options-form-container').empty();
|
||||||
$('#stdout-form-container').empty();
|
$('#stdout-form-container').empty();
|
||||||
@@ -45,7 +44,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
$('#logview-tabs li:eq(2)').hide();
|
$('#logview-tabs li:eq(2)').hide();
|
||||||
$('#logview-tabs li:eq(4)').hide();
|
$('#logview-tabs li:eq(4)').hide();
|
||||||
$('#logview-tabs li:eq(5)').hide();
|
$('#logview-tabs li:eq(5)').hide();
|
||||||
|
|
||||||
// Make sure subsequenct scope references don't bubble up to the parent
|
// Make sure subsequenct scope references don't bubble up to the parent
|
||||||
for (key in LogViewerStatusForm.fields) {
|
for (key in LogViewerStatusForm.fields) {
|
||||||
scope[key] = '';
|
scope[key] = '';
|
||||||
@@ -59,7 +58,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
}
|
}
|
||||||
scope.created_by = '';
|
scope.created_by = '';
|
||||||
scope.job_template = '';
|
scope.job_template = '';
|
||||||
|
|
||||||
if (data.related.created_by) {
|
if (data.related.created_by) {
|
||||||
pieces = data.related.created_by.replace(/^\//,'').replace(/\/$/,'').split('/');
|
pieces = data.related.created_by.replace(/^\//,'').replace(/\/$/,'').split('/');
|
||||||
scope.created_by = parseInt(pieces[pieces.length - 1],10);
|
scope.created_by = parseInt(pieces[pieces.length - 1],10);
|
||||||
@@ -69,7 +68,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
url: GetBasePath('users') + scope.created_by + '/'
|
url: GetBasePath('users') + scope.created_by + '/'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// For jobs link the name to the job parent
|
// For jobs link the name to the job parent
|
||||||
if (base === 'jobs') {
|
if (base === 'jobs') {
|
||||||
if (data.type === 'job') {
|
if (data.type === 'job') {
|
||||||
@@ -90,7 +89,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
|
|
||||||
AddTable({ scope: scope, form: LogViewerStatusForm, id: 'status-form-container', getIcon: getIcon });
|
AddTable({ scope: scope, form: LogViewerStatusForm, id: 'status-form-container', getIcon: getIcon });
|
||||||
AddTable({ scope: scope, form: LogViewerOptionsForm, id: 'options-form-container', getIcon: getIcon });
|
AddTable({ scope: scope, form: LogViewerOptionsForm, id: 'options-form-container', getIcon: getIcon });
|
||||||
|
|
||||||
if (data.result_stdout) {
|
if (data.result_stdout) {
|
||||||
$('#logview-tabs li:eq(1)').show();
|
$('#logview-tabs li:eq(1)').show();
|
||||||
AddPreFormattedText({
|
AddPreFormattedText({
|
||||||
@@ -98,7 +97,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
val: data.result_stdout
|
val: data.result_stdout
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.result_traceback) {
|
if (data.result_traceback) {
|
||||||
$('#logview-tabs li:eq(2)').show();
|
$('#logview-tabs li:eq(2)').show();
|
||||||
AddPreFormattedText({
|
AddPreFormattedText({
|
||||||
@@ -106,14 +105,14 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
val: data.result_traceback
|
val: data.result_traceback
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (data.job_env) {
|
/*if (data.job_env) {
|
||||||
EnvTable({
|
EnvTable({
|
||||||
id: 'env-form-container',
|
id: 'env-form-container',
|
||||||
vars: data.job_env
|
vars: data.job_env
|
||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (data.extra_vars) {
|
if (data.extra_vars) {
|
||||||
$('#logview-tabs li:eq(4)').show();
|
$('#logview-tabs li:eq(4)').show();
|
||||||
AddTextarea({
|
AddTextarea({
|
||||||
@@ -122,7 +121,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
val: ParseVariableString(data.extra_vars)
|
val: ParseVariableString(data.extra_vars)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.source_vars) {
|
if (data.source_vars) {
|
||||||
$('#logview-tabs li:eq(5)').show();
|
$('#logview-tabs li:eq(5)').show();
|
||||||
AddTextarea({
|
AddTextarea({
|
||||||
@@ -131,7 +130,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
val: ParseVariableString(data.source_vars)
|
val: ParseVariableString(data.source_vars)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Empty(scope.source)) {
|
if (!Empty(scope.source)) {
|
||||||
if (scope.removeChoicesReady) {
|
if (scope.removeChoicesReady) {
|
||||||
scope.removeChoicesReady();
|
scope.removeChoicesReady();
|
||||||
@@ -295,7 +294,6 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
{ "variable": "job_template", "url": "/#/job_templates/" },
|
{ "variable": "job_template", "url": "/#/job_templates/" },
|
||||||
{ "variable": "created_by", "url": "/#/users/" }
|
{ "variable": "created_by", "url": "/#/users/" }
|
||||||
];
|
];
|
||||||
|
|
||||||
html = "<table class=\"table logviewer-status\">\n";
|
html = "<table class=\"table logviewer-status\">\n";
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (!Empty(scope[fld])) {
|
if (!Empty(scope[fld])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user